').css({
- border: 'dotted 1px rgb(0, 0, 0)', // FIXME: make themes
- borderRadius: '32px',
- height: '128px',
- margin: '8px',
- width: '128px'
- }).appendTo($item);
- }
- var $container = $('
').css({
- margin: '10px 12px 8px 0'
- }).appendTo($item);
- var title = data.title ? (
- (
- data.type == 'custom' ? ''
- : Ox._('Featured ' + Ox.toTitleCase(data.type) + ': ')
- ) + data.title
- ) : '';
- $title = Ox.EditableContent({
- editable: data.type == 'custom',
- placeholder: '
' + Ox._('Title') + '',
- value: title
- }).css({
- fontSize: '13px',
- fontWeight: 'bold'
- }).bindEvent({
- submit: function(data_) {
- editItem(data.id, 'title', data_.value);
- //fixme: update list
- }
- }).appendTo($container);
- $text = Ox.EditableContent({
- editable: data.type == 'custom',
- placeholder: '
' + Ox._('Text') + '',
- type: 'textarea',
- value: data.text || ''
- }).css({
- margin: '0 12px 0 0'
- }).bindEvent({
- submit: function(data_) {
- editItem(data.id, 'text', data_.value);
- }
- }).appendTo($item);
+ margin: '16px'
+ })
+ );
}
function renderList(items, selected) {
@@ -329,9 +341,20 @@ pandora.ui.homeDialog = function() {
width: 224
},
{
- id: 'active',
- format: function(value) {
- return value ? $('
').attr({
+ id: 'text',
+ visible: false,
+ width: 0
+ },
+ {
+ id: 'link',
+ visible: false,
+ width: 0
+ },
+ {
+ id: 'complete',
+ format: function(value, data) {
+ console.log('##', data);
+ return pandora.isCompleteHomeItem(data) ? $('
').attr({
src: Ox.UI.getImageURL('symbolCheck')
}).css({
width: '10px',
@@ -352,8 +375,16 @@ pandora.ui.homeDialog = function() {
})
.bindEvent({
select: function(data) {
+ var item = Ox.getObjectById($list.options('items'), data.ids[0]),
+ status = $list == $activeList ? 'active' : 'inactive';
+
if (data.ids.length) {
- var item = Ox.getObjectById(items, data.ids[0])
+ (
+ status == 'active' ? $inactiveList : $activeList
+ ).options({selected: []});
+ }
+ updateMenu(status, data.ids.length);
+ if (item || $activeList.options('selected').length + $inactiveList.options('selected').length == 0) {
renderItem(item);
renderForm(item);
}
@@ -378,6 +409,12 @@ pandora.ui.homeDialog = function() {
return $list;
}
+ function updateMenu(status, value) {
+ (
+ status == 'active' ? $activeMenu : $inactiveMenu
+ )[value ? 'enableItem' : 'disableItem']('deleteitem');
+ }
+
return that;
};
diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js
index 104873da2..f03e68350 100644
--- a/static/js/mainMenu.js
+++ b/static/js/mainMenu.js
@@ -221,18 +221,18 @@ pandora.ui.mainMenu = function() {
getSortMenu(),
getFindMenu(),
{ id: 'dataMenu', title: Ox._('Data'), items: [
- { id: 'documents', title: Ox._('Manage Documents...'), disabled: !pandora.site.capabilities.canManageDocuments[pandora.user.level] },
- { id: 'entities', title: Ox._('Manage Entities...'), disabled: !pandora.site.entities.length || !pandora.site.capabilities.canManageEntities[pandora.user.level] },
- {},
+ !Ox.isEmpty(pandora.site.capabilities.canManageHome)
+ ? [{ id: 'managehome', title: Ox._('Manage Home...'), disabled: !pandora.site.capabilities.canManageHome[pandora.user.level] }] : [],
+ pandora.site.entities.length
+ ? [{ id: 'entities', title: Ox._('Manage Entities...'), disabled: !pandora.site.entities.length || !pandora.site.capabilities.canManageEntities[pandora.user.level] }] : [],
+ (!Ox.isEmpty(pandora.site.capabilities.canManageHome) || pandora.site.entities.length)
+ ? [{}] : [],
{ id: 'titles', title: Ox._('Manage Titles...'), disabled: !pandora.site.capabilities.canManageTitlesAndNames[pandora.user.level] },
{ id: 'names', title: Ox._('Manage Names...'), disabled: !pandora.site.capabilities.canManageTitlesAndNames[pandora.user.level] },
{},
{ id: 'places', title: Ox._('Manage Places...'), disabled: !pandora.site.capabilities.canManagePlacesAndEvents[pandora.user.level] },
{ id: 'events', title: Ox._('Manage Events...'), disabled: !pandora.site.capabilities.canManagePlacesAndEvents[pandora.user.level] },
{},
- Ox.isEmpty(pandora.site.capabilities.canManageHome) ? [] : [
- { id: 'managehome', title: Ox._('Manage Home...'), disabled: !pandora.site.capabilities.canManageHome[pandora.user.level] }
- ],
{ id: 'users', title: Ox._('Manage Users...'), disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] },
{ id: 'statistics', title: Ox._('Statistics...'), disabled: !pandora.site.capabilities.canManageUsers[pandora.user.level] },
{},
@@ -609,8 +609,6 @@ pandora.ui.mainMenu = function() {
pandora.$ui.filters.clearFilters();
} else if (data.id == 'findsimilar') {
pandora.$ui.similarClipsDialog = pandora.ui.similarClipsDialog().open();
- } else if (data.id == 'documents') {
- pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open();
} else if (data.id == 'entities') {
pandora.$ui.entitiesDialog = pandora.ui.entitiesDialog().open();
} else if (data.id == 'titles') {
diff --git a/static/js/utils.js b/static/js/utils.js
index 5e278b07a..225cf5046 100644
--- a/static/js/utils.js
+++ b/static/js/utils.js
@@ -357,7 +357,10 @@ pandora.changeFolderItemStatus = function(id, status, callback) {
pandora.api['edit' + folderItem]({
id: id,
status: status
- }, callback);
+ }, function(result) {
+ Ox.Request.clearCache('find' + folderItem);
+ callback(result);
+ });
}
};
@@ -365,20 +368,8 @@ pandora.clickLink = function(e, selectEmbed) {
var match = e.target.id.match(/^embed(\d+)$/);
if (match) {
(selectEmbed || pandora.$ui.textPanel.selectEmbed)(parseInt(match[1]));
- } else if (
- e.target.hostname == document.location.hostname
- && !Ox.startsWith(e.target.pathname, '/static')
- && (
- window.self == window.top
- || pandora.isEmbeddableView(e.target.href)
- )
- ) {
- if (pandora.$ui.home && e.target.pathname != '/home') {
- pandora.$ui.home.fadeOutScreen();
- }
- pandora.URL.push(e.target.pathname, true);
} else {
- pandora.openLink(e.target.href);
+ pandora.openURL(e.target.href);
}
};
@@ -2390,6 +2381,7 @@ pandora.hasPlacesLayer = function() {
});
};
+
pandora.isClipView = function(view, item) {
if (pandora.user.ui.section == 'items') {
if (arguments.length == 0) {
@@ -2404,6 +2396,10 @@ pandora.isClipView = function(view, item) {
).indexOf(view) > -1;
};
+pandora.isCompleteHomeItem = function(data) {
+ return data.image && data.title && data.text && data.link;
+};
+
pandora.isEmbeddableView = function(url) {
// FIXME: actually return true for embeddable views
return false;
@@ -2504,6 +2500,26 @@ pandora.openLink = function(url) {
}
};
+pandora.openURL = function(url) {
+ var a = document.createElement('a');
+ a.href = url;
+ if (
+ a.hostname == document.location.hostname
+ && !Ox.startsWith(a.pathname, '/static')
+ && (
+ window.self == window.top
+ || pandora.isEmbeddableView(a.href)
+ )
+ ) {
+ pandora.URL.push(a.pathname, true);
+ if (pandora.$ui.home && a.pathname != '/home') {
+ pandora.$ui.home.fadeOutScreen();
+ }
+ } else {
+ pandora.openLink(a.href);
+ }
+};
+
pandora.signin = function(data) {
// fixme: this is still voodoo
pandora.user = Ox.extend(data.user, {
@@ -2622,6 +2638,90 @@ pandora.renameList = function(oldId, newId, newName, folder) {
}
};
+pandora.renderHomeItem = function(options) {
+ var data = options.data,
+ editItem = options.editItem,
+ isEditable = editItem && data.type == 'custom';
+
+ var $item = Ox.Element().addClass('OxTextPage').css({
+ clear: 'both'
+ });
+ var $title, $text;
+ if (!data) {
+ return $item;
+ }
+ if (data.image && data.image.length) {
+ var $image = Ox.Element({
+ element: '
',
+ tooltip: Ox._('View {0}', [data.title]),
+ }).attr({
+ src: data.image
+ }).css({
+ borderRadius: '32px',
+ float: 'left',
+ height: '128px',
+ marginBottom: '16px',
+ width: '128px',
+ cursor: 'pointer'
+ }).on({
+ click: function() {
+ pandora.openURL(data.link);
+ }
+ }).appendTo($item)
+ } else {
+ var $placeholder = $('
').css({
+ border: 'dotted 1px rgb(0, 0, 0)', // FIXME: make themes
+ borderRadius: '32px',
+ float: 'left',
+ height: '128px',
+ marginBottom: '16px',
+ width: '128px',
+ }).appendTo($item);
+ }
+ var $container = $('
').css({
+ marginLeft: '144px'
+ }).appendTo($item);
+ var title = data.title ? (
+ (
+ data.type == 'custom' ? '' : Ox._(Ox.toTitleCase(data.type) + ': ')
+ ) + data.title
+ ) : '';
+ $title = Ox.EditableContent({
+ editable: isEditable,
+ placeholder: '' + Ox._('Title') + '',
+ value: title
+ }).css({
+ cursor: 'pointer',
+ fontSize: '13px',
+ fontWeight: 'bold'
+ }).bindEvent({
+ anyclick: function() {
+ if (!isEditable) {
+ pandora.openURL(data.link);
+ }
+ },
+ submit: function(data_) {
+ editItem(data.id, 'title', data_.value);
+ }
+ }).appendTo($container);
+ $text = Ox.EditableContent({
+ clickLink: pandora.clickLink,
+ editable: isEditable,
+ placeholder: '' + Ox._('Text') + '',
+ type: 'textarea',
+ value: data.text || ''
+ }).css({
+ marginTop: '6px',
+ paddingBottom: '16px',
+ textAlign: 'justify'
+ }).bindEvent({
+ submit: function(data_) {
+ editItem(data.id, 'text', data_.value);
+ }
+ }).appendTo($container);
+ return $item;
+};
+
pandora.resizeFilters = function(width) {
pandora.user.ui.filterSizes = pandora.getFilterSizes();
pandora.$ui.browser && pandora.$ui.browser