forked from 0x2620/pandora
use pandora.hasCapability
This commit is contained in:
parent
4a69de4a05
commit
db2d37e2bb
32 changed files with 49 additions and 53 deletions
|
@ -45,7 +45,7 @@ pandora.ui.addItemDialog = function(options) {
|
|||
{
|
||||
id: 'import',
|
||||
title: Ox._('Import Video Files'),
|
||||
disabled: !pandora.site.capabilities.canImportItems[pandora.user.level],
|
||||
disabled: !pandora.hasCapability('canImportItems'),
|
||||
selected: selected == 'import'
|
||||
}
|
||||
]
|
||||
|
|
|
@ -213,7 +213,7 @@ pandora.ui.clipList = function(videoRatio) {
|
|||
pandora.api.get({id: item, keys: ['durations', 'rightslevel', 'streams']}, function(result) {
|
||||
var points = [that.value(id, 'in'), that.value(id, 'out')],
|
||||
$player = Ox.VideoPlayer({
|
||||
censored: pandora.site.capabilities.canPlayClips[pandora.user.level] < result.data.rightslevel
|
||||
censored: pandora.hasCapability('canPlayClips') < result.data.rightslevel
|
||||
? [{'in': 0, out: points[1] - points[0]}]
|
||||
: [],
|
||||
censoredIcon: pandora.site.cantPlay.icon,
|
||||
|
|
|
@ -29,7 +29,7 @@ pandora.ui.collection = function() {
|
|||
unique: 'id',
|
||||
columns: pandora.site.documentSortKeys.filter(function(key) {
|
||||
return !key.capability
|
||||
|| pandora.site.capabilities[key.capability][pandora.user.level];
|
||||
|| pandora.hasCapability(key.capability);
|
||||
}).map(function(key) {
|
||||
var position = ui.collectionColumns.indexOf(key.id);
|
||||
return {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
pandora.ui.documentInfoView = function(data) {
|
||||
|
||||
var ui = pandora.user.ui,
|
||||
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level] || data.editable,
|
||||
canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level],
|
||||
canEdit = pandora.hasCapability('canEditMetadata') || data.editable,
|
||||
canRemove = pandora.hasCapability('canRemoveItems'),
|
||||
css = {
|
||||
marginTop: '4px',
|
||||
textAlign: 'justify'
|
||||
|
@ -485,7 +485,7 @@ pandora.ui.documentInfoView = function(data) {
|
|||
.appendTo($line);
|
||||
}
|
||||
capabilities.forEach(function(capability) {
|
||||
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel,
|
||||
var hasCapability = pandora.hasCapability(capability.name, userLevel) >= rightsLevel,
|
||||
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
|
||||
Ox.Button({
|
||||
tooltip: (canEdit ? Ox.toTitleCase(userLevel) : 'You') + ' '
|
||||
|
|
|
@ -10,7 +10,7 @@ pandora.ui.documentsDialog = function() {
|
|||
// FIXME: user may not have the manage entites capability
|
||||
$switchButton = Ox.Button({
|
||||
disabled: !pandora.site.entities.length
|
||||
|| !pandora.site.capabilities.canManageEntities[pandora.user.level],
|
||||
|| !pandora.hasCapability('canManageEntities'),
|
||||
title: Ox._('Manage Entities...')
|
||||
})
|
||||
.bindEvent({
|
||||
|
|
|
@ -576,7 +576,7 @@ pandora.ui.documentsPanel = function(options) {
|
|||
var $name, $description, $input,
|
||||
item = $list.value($list.options('selected')[0]),
|
||||
editable = item.user == pandora.user.username
|
||||
|| pandora.site.capabilities.canEditDocuments[pandora.user.level]
|
||||
|| pandora.hasCapability('canEditDocuments')
|
||||
|| options.editable,
|
||||
labelWidth = 80,
|
||||
width = ui.documentSize - 16 - Ox.UI.SCROLLBAR_SIZE;
|
||||
|
|
|
@ -413,7 +413,7 @@ pandora.ui.editPanel = function(isEmbed) {
|
|||
var $content = Ox.Element()
|
||||
.css({padding: '16px'})
|
||||
.appendTo(that),
|
||||
isEditable = pandora.site.capabilities.canEditSitePages[pandora.user.level];
|
||||
isEditable = pandora.hasCapability('canEditSitePages');
|
||||
Ox.EditableContent({
|
||||
editable: false,
|
||||
value: Ox._('{0} Edits', [pandora.site.site.name]),
|
||||
|
|
|
@ -20,9 +20,9 @@ pandora.ui.editor = function(data) {
|
|||
clickLink: pandora.clickLink,
|
||||
cuts: data.cuts || [],
|
||||
duration: data.duration,
|
||||
enableDownload: pandora.site.capabilities.canDownloadVideo[pandora.user.level] >= data.rightslevel || data.editable,
|
||||
enableExport: pandora.site.capabilities.canExportAnnotations[pandora.user.level] || data.editable,
|
||||
enableImport: pandora.site.capabilities.canImportAnnotations[pandora.user.level] || data.editable,
|
||||
enableDownload: pandora.hasCapability('canDownloadVideo') >= data.rightslevel || data.editable,
|
||||
enableExport: pandora.hasCapability('canExportAnnotations') || data.editable,
|
||||
enableImport: pandora.hasCapability('canImportAnnotations') || data.editable,
|
||||
enableSetPosterFrame: !pandora.site.media.importFrames && data.editable,
|
||||
enableSubtitles: ui.videoSubtitles,
|
||||
find: ui.itemFind,
|
||||
|
|
|
@ -190,8 +190,8 @@ Ox.load('UI', {
|
|||
});
|
||||
|
||||
function getVideoOptions(data) {
|
||||
var canPlayClips = data.editable || pandora.site.capabilities.canPlayClips[pandora.user.level] >= data.rightslevel,
|
||||
canPlayVideo = data.editable || pandora.site.capabilities.canPlayVideo[pandora.user.level] >= data.rightslevel,
|
||||
var canPlayClips = data.editable || pandora.hasCapability('canPlayClips') >= data.rightslevel,
|
||||
canPlayVideo = data.editable || pandora.hasCapability('canPlayVideo') >= data.rightslevel,
|
||||
options = {},
|
||||
subtitlesLayer = pandora.site.layers.filter(function(layer) {
|
||||
return layer.isSubtitles;
|
||||
|
@ -226,7 +226,7 @@ Ox.load('UI', {
|
|||
annotation.duration = Math.abs(annotation.out - annotation['in']);
|
||||
annotation.editable = annotation.editable
|
||||
|| annotation.user == pandora.user.username
|
||||
|| pandora.site.capabilities['canEditAnnotations'][pandora.user.level];
|
||||
|| pandora.hasCapability('canEditAnnotations');
|
||||
return annotation;
|
||||
})
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ pandora.ui.entityDialog = function() {
|
|||
.css({overflowY: 'auto'}),
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: (pandora.site.capabilities.canManageEntities[pandora.user.level] ? [
|
||||
buttons: (pandora.hasCapability('canManageEntities') ? [
|
||||
Ox.Button({
|
||||
id: 'edit',
|
||||
title: Ox._('Edit Entity...')
|
||||
|
|
|
@ -38,7 +38,7 @@ pandora.ui.errorDialog = function(data) {
|
|||
setTimeout(function() {
|
||||
if ($('.OxErrorDialog').length == 0 && !pandora.isUnloading) {
|
||||
showLogsButton = error == 'error'
|
||||
&& pandora.site.capabilities.canSeeDebugMenu[pandora.user.level]
|
||||
&& pandora.hasCapability('canSeeDebugMenu')
|
||||
that = pandora.ui.iconDialog({
|
||||
buttons: (showLogsButton ? [
|
||||
Ox.Button({
|
||||
|
|
|
@ -35,7 +35,7 @@ pandora.ui.findElement = function() {
|
|||
items: [].concat(
|
||||
pandora.site.findKeys.filter(function(key, i) {
|
||||
return (!key.capability
|
||||
|| pandora.site.capabilities[key.capability][pandora.user.level])
|
||||
|| pandora.hasCapability(key.capability))
|
||||
&& !key.advanced;
|
||||
}).map(function(key) {
|
||||
return {
|
||||
|
|
|
@ -7,7 +7,7 @@ pandora.ui.folderList = function(id, section) {
|
|||
i = Ox.getIndexById(pandora.site.sectionFolders[section], id),
|
||||
folderItems = pandora.getFolderItems(section),
|
||||
folderItem = folderItems.slice(0, -1),
|
||||
canEditFeatured = pandora.site.capabilities['canEditFeatured' + folderItems][pandora.user.level],
|
||||
canEditFeatured = pandora.hasCapability('canEditFeatured' + folderItems),
|
||||
$placeholder,
|
||||
that;
|
||||
var columns, items;
|
||||
|
|
|
@ -18,7 +18,7 @@ pandora.ui.folders = function(section) {
|
|||
}[section]] || '').split(':')[0] == pandora.user.username,
|
||||
folderItems = pandora.getFolderItems(section),
|
||||
folderItem = folderItems.slice(0, -1),
|
||||
canEditFeatured = pandora.site.capabilities['canEditFeatured' + folderItems][pandora.user.level],
|
||||
canEditFeatured = pandora.hasCapability('canEditFeatured' + folderItems),
|
||||
initCounter = 0,
|
||||
loadCounter = 0;
|
||||
pandora.$ui.allItems = pandora.ui.allItems(section).appendTo(that);
|
||||
|
|
|
@ -21,7 +21,7 @@ pandora.ui.groupsDialog = function(options) {
|
|||
width: 584 + Ox.UI.SCROLLBAR_SIZE
|
||||
}),
|
||||
|
||||
canManageGroups = pandora.site.capabilities.canManageUsers[pandora.user.level],
|
||||
canManageGroups = pandora.hasCapability('canManageUsers'),
|
||||
isItem = options.type == 'item',
|
||||
|
||||
$content,
|
||||
|
|
|
@ -215,7 +215,7 @@ pandora.ui.listInfo = function() {
|
|||
: pandora.user.ui.section == 'documents'
|
||||
? pandora.user.ui._collection
|
||||
: ui[folderItem.toLowerCase()],
|
||||
canEditFeaturedLists = pandora.site.capabilities['canEditFeatured' + folderItems][pandora.user.level],
|
||||
canEditFeaturedLists = pandora.hasCapability('canEditFeatured' + folderItems),
|
||||
that = Ox.Element().css({padding: '16px', textAlign: 'center'}),
|
||||
$icon = Ox.Element('<img>')
|
||||
.attr({
|
||||
|
|
|
@ -6,8 +6,8 @@ pandora.ui.infoView = function(data) {
|
|||
// when collapsing the movies browser, the info view should become a split panel
|
||||
|
||||
var ui = pandora.user.ui,
|
||||
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level],
|
||||
canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level],
|
||||
canEdit = pandora.hasCapability('canEditMetadata'),
|
||||
canRemove = pandora.hasCapability('canRemoveItems'),
|
||||
canSeeAllMetadata = pandora.user.level != 'guest',
|
||||
css = {
|
||||
marginTop: '4px',
|
||||
|
@ -859,7 +859,7 @@ pandora.ui.infoView = function(data) {
|
|||
.appendTo($line);
|
||||
}
|
||||
capabilities.forEach(function(capability) {
|
||||
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel,
|
||||
var hasCapability = pandora.hasCapability(capability.name, userLevel) >= rightsLevel,
|
||||
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
|
||||
Ox.Button({
|
||||
tooltip: (canEdit ? Ox.toTitleCase(userLevel) : 'You') + ' '
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
pandora.ui.infoView = function(data) {
|
||||
|
||||
var ui = pandora.user.ui,
|
||||
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level],
|
||||
canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level],
|
||||
canEdit = pandora.hasCapability('canEditMetadata'),
|
||||
canRemove = pandora.hasCapability('canRemoveItems'),
|
||||
canSeeAllMetadata = pandora.user.level != 'guest',
|
||||
css = {
|
||||
marginTop: '4px',
|
||||
|
@ -65,7 +65,7 @@ pandora.ui.infoView = function(data) {
|
|||
{
|
||||
id: 'upload',
|
||||
title: Ox._('Upload Video...'),
|
||||
disabled: !pandora.site.capabilities.canAddItems[pandora.user.level]
|
||||
disabled: !pandora.hasCapability('canAddItems')
|
||||
},
|
||||
{},
|
||||
{
|
||||
|
@ -904,7 +904,7 @@ pandora.ui.infoView = function(data) {
|
|||
.appendTo($line);
|
||||
}
|
||||
capabilities.forEach(function(capability) {
|
||||
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel,
|
||||
var hasCapability = pandora.hasCapability(capability.name, userLevel) >= rightsLevel,
|
||||
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
|
||||
Ox.Button({
|
||||
tooltip: Ox._('{0} '
|
||||
|
|
|
@ -4,8 +4,8 @@ pandora.ui.infoView = function(data) {
|
|||
|
||||
var ui = pandora.user.ui,
|
||||
descriptions = [],
|
||||
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level] || data.editable,
|
||||
canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level],
|
||||
canEdit = pandora.hasCapability('canEditMetadata') || data.editable,
|
||||
canRemove = pandora.hasCapability('canRemoveItems'),
|
||||
css = {
|
||||
marginTop: '4px',
|
||||
textAlign: 'justify'
|
||||
|
@ -495,7 +495,7 @@ pandora.ui.infoView = function(data) {
|
|||
.appendTo($line);
|
||||
}
|
||||
capabilities.forEach(function(capability) {
|
||||
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel,
|
||||
var hasCapability = pandora.hasCapability(capability.name, userLevel) >= rightsLevel,
|
||||
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
|
||||
Ox.Button({
|
||||
tooltip: (canEdit ? Ox.toTitleCase(userLevel) : 'You') + ' '
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
pandora.ui.infoView = function(data) {
|
||||
|
||||
var ui = pandora.user.ui,
|
||||
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level] || data.editable,
|
||||
canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level] || data.editable,
|
||||
canEdit = pandora.hasCapability('canEditMetadata') || data.editable,
|
||||
canRemove = pandora.hasCapability('canRemoveItems') || data.editable,
|
||||
css = {
|
||||
marginTop: '4px',
|
||||
textAlign: 'justify'
|
||||
|
@ -665,7 +665,7 @@ pandora.ui.infoView = function(data) {
|
|||
.appendTo($line);
|
||||
}
|
||||
capabilities.forEach(function(capability) {
|
||||
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel,
|
||||
var hasCapability = pandora.hasCapability(capability.name, userLevel) >= rightsLevel,
|
||||
$element = Ox.Theme.formatColorLevel(hasCapability, ['', '']);
|
||||
Ox.Button({
|
||||
tooltip: Ox._('{0} '
|
||||
|
|
|
@ -13,7 +13,7 @@ pandora.ui.item = function() {
|
|||
pandora.api.get({
|
||||
id: pandora.user.ui.item,
|
||||
keys: isVideoView ? Ox.unique(pandora.VIDEO_OPTIONS_KEYS.concat(pandora.site.itemTitleKeys)) : []
|
||||
}, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) {
|
||||
}, pandora.user.ui.itemView == 'info' && pandora.hasCapability('canEditMetadata') ? 0 : -1, function(result) {
|
||||
|
||||
if (pandora.user.ui.item != item) {
|
||||
return;
|
||||
|
|
|
@ -100,7 +100,7 @@ pandora.ui.itemClips = function(options) {
|
|||
result.data.durations, points
|
||||
),
|
||||
$player = Ox.VideoPlayer({
|
||||
censored: pandora.site.capabilities.canPlayClips[pandora.user.level] < result.data.rightslevel
|
||||
censored: pandora.hasCapability('canPlayClips') < result.data.rightslevel
|
||||
? [{'in': partsAndPoints.points[0], out: partsAndPoints.points[1]}]
|
||||
: [],
|
||||
enableMouse: true,
|
||||
|
|
|
@ -55,7 +55,7 @@ pandora.ui.list = function() {
|
|||
width: 16
|
||||
}], pandora.site.sortKeys.filter(function(key) {
|
||||
return !key.capability
|
||||
|| pandora.site.capabilities[key.capability][pandora.user.level];
|
||||
|| pandora.hasCapability(key.capability);
|
||||
}).map(function(key) {
|
||||
var position = ui.listColumns.indexOf(key.id);
|
||||
return {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
pandora.ui.mediaView = function(options) {
|
||||
|
||||
var canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level] || options.editable,
|
||||
var canRemove = pandora.hasCapability('canRemoveItems') || options.editable,
|
||||
self = {},
|
||||
keys = ['title', 'director', 'year', 'id'],
|
||||
listKeys = keys.filter(function(key) {
|
||||
|
|
|
@ -122,7 +122,7 @@ pandora.ui.navigationView = function(type, videoRatio) {
|
|||
|
||||
that.replaceElement(0,
|
||||
$element = Ox.Map({
|
||||
// clickable: pandora.site.capabilities.canClickMap[pandora.user.level],
|
||||
// clickable: pandora.hasCapability('canClickMap'),
|
||||
find: ui.mapFind,
|
||||
// 20 px menu + 24 px toolbar + 1px resizbar + 16px statusbar (if !item)
|
||||
height: isEmbed ? window.innerHeight - 40
|
||||
|
|
|
@ -12,7 +12,7 @@ pandora.ui.news = function(width, height) {
|
|||
backgroundColor = Ox.Theme() == 'oxlight' ? 'rgb(224, 224, 224)'
|
||||
: Ox.Theme() == 'oxmedium' ? 'rgb(128, 128, 128)'
|
||||
: 'rgb(32, 32, 32)',
|
||||
isEditable = pandora.site.capabilities.canEditSitePages[pandora.user.level],
|
||||
isEditable = pandora.hasCapability('canEditSitePages'),
|
||||
items = [],
|
||||
$text;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ pandora.ui.player = function(data) {
|
|||
clickLink: pandora.clickLink,
|
||||
cuts: data.cuts || [],
|
||||
duration: data.duration,
|
||||
enableDownload: pandora.site.capabilities.canDownloadVideo[pandora.user.level] >= data.rightslevel,
|
||||
enableDownload: pandora.hasCapability('canDownloadVideo') >= data.rightslevel,
|
||||
enableSubtitles: ui.videoSubtitles,
|
||||
find: ui.itemFind,
|
||||
getLargeTimelineURL: function(type, i) {
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
pandora.ui.siteDialog = function(section) {
|
||||
|
||||
var canSeeVersion = pandora.site.capabilities.canSeeSoftwareVersion[pandora.user.level],
|
||||
var canSeeVersion = pandora.hasCapability('canSeeSoftwareVersion'),
|
||||
dialogHeight = Math.round((window.innerHeight - 48) * 0.75),
|
||||
dialogWidth = Math.round(window.innerWidth * 0.75),
|
||||
isEditable = pandora.site.capabilities.canEditSitePages[pandora.user.level],
|
||||
isEditable = pandora.hasCapability('canEditSitePages'),
|
||||
tabs = Ox.clone(pandora.site.sitePages, true).map(function(page) {
|
||||
page.title = Ox._(page.title);
|
||||
return page;
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
pandora.ui.siteDialog = function(section) {
|
||||
|
||||
var canSeeVersion = pandora.site.capabilities.canSeeSoftwareVersion[pandora.user.level],
|
||||
var canSeeVersion = pandora.hasCapability('canSeeSoftwareVersion'),
|
||||
dialogHeight = Math.round((window.innerHeight - 48) * 0.75),
|
||||
dialogWidth = Math.round(window.innerWidth * 0.75),
|
||||
isEditable = pandora.site.capabilities.canEditSitePages[pandora.user.level],
|
||||
isEditable = pandora.hasCapability('canEditSitePages'),
|
||||
tabs = Ox.clone(pandora.site.sitePages, true).map(function(page) {
|
||||
page.title = Ox._(page.title);
|
||||
return page;
|
||||
|
|
|
@ -149,9 +149,7 @@ pandora.ui.tasksDialog = function(options) {
|
|||
],
|
||||
width: 128
|
||||
}).css({
|
||||
display: pandora.site.capabilities.canSeeAllTasks[
|
||||
pandora.user.level
|
||||
] ? 'block' : 'none',
|
||||
display: pandora.hasCapability('canSeeAllTasks') ? 'block' : 'none',
|
||||
margin: '8px 4px 4px 4px'
|
||||
}).bindEvent({
|
||||
change: function(data) {
|
||||
|
|
|
@ -9,9 +9,7 @@ pandora.ui.uploadVideoDialog = function(data) {
|
|||
$.browser.version < '35' || Firefogg().version >= 334
|
||||
),
|
||||
infoContent = Ox._('Please select the video file that you want to upload.'),
|
||||
itemView = pandora.site.capabilities.canSeeExtraItemViews[
|
||||
pandora.user.level
|
||||
] ? 'media' : 'info',
|
||||
itemView = pandora.hasCapability('canSeeExtraItemViews') ? 'media' : 'info',
|
||||
selectFile,
|
||||
$actionButton,
|
||||
$closeButton,
|
||||
|
|
|
@ -14,7 +14,7 @@ pandora.ui.viewSelect = function() {
|
|||
that;
|
||||
if (
|
||||
viewKey == 'itemView'
|
||||
&& pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level]
|
||||
&& pandora.hasCapability('canSeeExtraItemViews')
|
||||
) {
|
||||
items = items.concat([
|
||||
{},
|
||||
|
|
Loading…
Reference in a new issue