This commit is contained in:
j 2017-02-15 17:44:59 +00:00
parent a5dfc438d3
commit 2b0f2d7b99
7 changed files with 309 additions and 343 deletions

View file

@ -121,10 +121,6 @@ pandora.ui.home = function() {
var folder = pandora.getListData().folder, var folder = pandora.getListData().folder,
value = $findInput.value(); value = $findInput.value();
folder && pandora.$ui.folderList[folder].options({selected: []}); folder && pandora.$ui.folderList[folder].options({selected: []});
if (pandora.user.ui.section == 'items') {
pandora.$ui.findSelect.value('*');
pandora.$ui.findInput.value(value);
}
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set({ pandora.UI.set({
page: '', page: '',
@ -136,6 +132,8 @@ pandora.ui.home = function() {
}, },
section: 'items' section: 'items'
}); });
pandora.$ui.findSelect && pandora.$ui.findSelect.value('*');
pandora.$ui.findInput && pandora.$ui.findInput.value(value);
} }
}) })
.appendTo(that), .appendTo(that),

View file

@ -160,10 +160,6 @@ pandora.ui.home = function() {
var folder = pandora.getListData().folder, var folder = pandora.getListData().folder,
value = $findInput.value(); value = $findInput.value();
folder && pandora.$ui.folderList[folder].options({selected: []}); folder && pandora.$ui.folderList[folder].options({selected: []});
if (pandora.user.ui.section == 'items') {
pandora.$ui.findSelect.value('*');
pandora.$ui.findInput.value(value);
}
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set({ pandora.UI.set({
page: '', page: '',
@ -175,6 +171,8 @@ pandora.ui.home = function() {
}, },
section: 'items' section: 'items'
}); });
pandora.$ui.findSelect && pandora.$ui.findSelect.value('*');
pandora.$ui.findInput && pandora.$ui.findInput.value(value);
} }
}) })
.appendTo($box), .appendTo($box),

View file

@ -112,10 +112,6 @@ pandora.ui.home = function() {
var folder = pandora.getListData().folder, var folder = pandora.getListData().folder,
value = $findInput.value(); value = $findInput.value();
folder && pandora.$ui.folderList[folder].options({selected: []}); folder && pandora.$ui.folderList[folder].options({selected: []});
if (pandora.user.ui.section == 'items') {
pandora.$ui.findSelect.value('*');
pandora.$ui.findInput.value(value);
}
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set({ pandora.UI.set({
page: '', page: '',
@ -127,6 +123,8 @@ pandora.ui.home = function() {
}, },
section: 'items' section: 'items'
}); });
pandora.$ui.findSelect && pandora.$ui.findSelect.value('*');
pandora.$ui.findInput && pandora.$ui.findInput.value(value);
} }
}) })
.appendTo(that), .appendTo(that),
@ -153,6 +151,7 @@ pandora.ui.home = function() {
} }
}) })
.appendTo(that), .appendTo(that),
$signupButton = Ox.Button({ $signupButton = Ox.Button({
title: Ox._('Sign Up'), title: Ox._('Sign Up'),
width: 74 width: 74

View file

@ -132,10 +132,6 @@ pandora.ui.home = function() {
var folder = pandora.getListData().folder, var folder = pandora.getListData().folder,
value = $findInput.value(); value = $findInput.value();
folder && pandora.$ui.folderList[folder].options({selected: []}); folder && pandora.$ui.folderList[folder].options({selected: []});
if (pandora.user.ui.section == 'items') {
pandora.$ui.findSelect.value('*');
pandora.$ui.findInput.value(value);
}
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set({ pandora.UI.set({
page: '', page: '',
@ -147,6 +143,8 @@ pandora.ui.home = function() {
}, },
section: 'items' section: 'items'
}); });
pandora.$ui.findSelect && pandora.$ui.findSelect.value('*');
pandora.$ui.findInput && pandora.$ui.findInput.value(value);
} }
}) })
.appendTo($box), .appendTo($box),
@ -175,18 +173,17 @@ pandora.ui.home = function() {
}) })
.appendTo($box), .appendTo($box),
$footer = Ox.Element().css({
clear: 'both',
height: '64px',
paddingTop: '12px'
}),
$signupButton = Ox.Button({ $signupButton = Ox.Button({
title: Ox._('Sign Up'), title: Ox._('Sign Up'),
width: 122 width: 122
}) })
.css({ .css({
position: 'absolute',
left: 0,
top: '144px',
right: '390px',
bottom: 0,
margin: '0 auto 0 auto',
opacity: 0
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
@ -200,13 +197,7 @@ pandora.ui.home = function() {
width: 122 width: 122
}) })
.css({ .css({
position: 'absolute', marginLeft: '8px',
left: 0,
top: '144px',
right: '130px',
bottom: 0,
margin: '0 auto 0 auto',
opacity: 0
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
@ -220,13 +211,6 @@ pandora.ui.home = function() {
width: 252 width: 252
}) })
.css({ .css({
position: 'absolute',
left: 0,
top: '144px',
right: '260px',
bottom: 0,
margin: '0 auto 0 auto',
opacity: 0
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
@ -240,205 +224,57 @@ pandora.ui.home = function() {
width: 252 width: 252
}) })
.css({ .css({
position: 'absolute', marginLeft: '8px'
left: '260px',
top: '144px',
right: 0,
bottom: 0,
margin: '0 auto 0 auto',
opacity: 0
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
pandora.UI.set({page: 'about'}); pandora.UI.set({page: 'about'});
that.fadeOutScreen(); that.fadeOutScreen();
} }
}) }),
.appendTo($box),
$features = $('<div>') $features = $('<div>')
.attr({id: 'lists'}) .attr({id: 'lists'})
.css({ .css({
position: 'absolute', position: 'absolute',
left: 0, left: 0,
top: '184px', top: '152px',
right: 0, right: 0,
bottom: 0, bottom: 0,
width: '560px', width: '512px',
margin: '0 auto 0 auto', margin: '0 auto 0 auto',
opacity: 0 opacity: 0
}) })
.appendTo($box); .appendTo($box);
if (pandora.user.level == 'guest') { if (pandora.user.level == 'guest') {
$signupButton.appendTo($box); $signupButton.appendTo($footer);
$signinButton.appendTo($box); $signinButton.appendTo($footer);
} else { } else {
$preferencesButton.appendTo($box); $preferencesButton.appendTo($footer);
} }
$aboutButton.appendTo($footer);
function showFeatures() { function showFeatures() {
var $space,
featured = {},
find = {
query: {
conditions: [{key: 'status', value: 'featured', operator: '=='}],
operator: '&'
},
keys: ['description', 'modified', 'name', 'user'],
sort: [{key: 'position', operator: '+'}]
},
items, lists, edits, texts;
pandora.api.getHomeItems({active: true}, function(result) { pandora.api.getHomeItems({active: true}, function(result) {
items = result.data.items; var items = result.data.items.filter(pandora.isCompleteHomeItem),
lists = 1; $texts;
edits = 1;
texts = 1;
show();
});
function show() {
var counter = 0, max = 8, mouse = false, position = 0, selected = 0,
color = Ox.Theme() == 'oxlight' ? 'rgb(0, 0, 0)'
: Ox.Theme() == 'oxmedium' ? 'rgb(0, 0, 0)'
: 'rgb(255, 255, 255)',
$label, $texts,
$featuresBox, $featuresContainer, $featuresContent,
$featureBox = [], $featureIcon = [],
$previousButton, $nextButton;
if (items.length) {
$features.empty(); $features.empty();
if (items.length) {
$texts = Ox.Element().appendTo($features); $texts = Ox.Element().appendTo($features);
var top = 24;
items.forEach(function(item) { items.forEach(function(item) {
var $text, $icon; var $item = pandora.renderHomeItem({
$icon = Ox.Element({ data: item
element: '<img>', }).appendTo($texts);
tooltip: getTooltip(item) });
}) } else {
.attr({ $features.css({
src: item.image top: '132px'
}) });
.css({
left: 0,
right: '390px',
width: '122px',
height: '122px',
borderRadius: '32px',
marginRight: '8px',
cursor: 'pointer',
float: 'left'
})
.bindEvent({
anyclick: function() {
openItem(item);
} }
}); $features.append($footer);
$text = Ox.Label({
//width: 386 + 122
})
.addClass('OxSelectable')
.css({
//position: 'absolute',
left: '24px',
//top: top + 'px',
right: 0,
height: 'auto',
padding: '8px 8px 8px 8px',
borderRadius: '32px',
marginBottom: '16px',
overflowY: 'auto',
lineHeight: '14px',
textOverflow: 'ellipsis',
whiteSpace: 'normal'
})
.append($icon)
.append(
Ox.Element().css({
//padding: '8px',
}).html(getHTML(item))
)
.appendTo($texts);
pandora.createLinks($text);
top += 130;
});
$features.animate({opacity: 1}, 250); $features.animate({opacity: 1}, 250);
}
function getHTML(item) {
return '<b>' + Ox.encodeHTMLEntities(item.title) + '</b><br><br>' + item.text;
}
function getTooltip(item) {
return Ox._('View {0}', [Ox._(Ox.toTitleCase(item.title))])
}
function openItem(item) {
that.fadeOutScreen();
if (item.type == 'custom') {
pandora.URL.push(item.link);
} else {
pandora.UI.set(Ox.extend({
section: item.type == 'list' ? 'items' : item.type + 's',
page: ''
}, item.type == 'list' ? {
find: {
conditions: [{
key: 'list',
value: item.contentid,
operator: '=='
}],
operator: '&'
}
} : item.type == 'collection' ? {
findDocuments: {
conditions: [{
key: 'collection',
value: item.contentid,
operator: '=='
}],
operator: '&'
}
} : item.type == 'edit' ? {
edit: item.contentid
} : {
}));
}
}
function scrollToPosition(i, animate) {
if (i >= 0 && i <= items.length - max && i != position) {
position = i;
$featuresContent.stop().animate({
left: (position * -65) + 'px'
}, animate ? 250 : 0, function() {
if (position == 0) {
$previousButton.removeClass('visible').stop().animate({
opacity: 0
}, 250, function() {
$previousButton.hide();
}); });
} else {
$previousButton.addClass('visible');
}
if (position == items.length - max) {
$nextButton.removeClass('visible').stop().animate({
opacity: 0
}, 250, function() {
$nextButton.hide();
});
} else {
$nextButton.addClass('visible');
}
if (mouse) {
$featuresBox.trigger('mouseenter');
}
});
}
}
}
} }
that.fadeInScreen = function() { that.fadeInScreen = function() {

View file

@ -8,11 +8,13 @@ pandora.ui.homeDialog = function() {
var $folders = $('<div>').css({overflowX: 'hidden', overflowY: 'auto'}); var $folders = $('<div>').css({overflowX: 'hidden', overflowY: 'auto'});
var $item = $('<div>').addClass('OxTextPage'); var $activeList, $inactiveList, $activeMenu, $inactiveMenu;
var $item = $('<div>').addClass('OxTextPage').css({overflow: 'auto'});
var $form = $('<div>'); var $form = $('<div>');
var $title, $text, $typeSelect, $imageInput, $linkInput, $nameInput; var $statusSelect, $typeSelect, $imageInput, $linkInput, $nameInput;
var $dialogPanel = Ox.SplitPanel({ var $dialogPanel = Ox.SplitPanel({
elements: [ elements: [
@ -36,10 +38,10 @@ pandora.ui.homeDialog = function() {
], ],
closeButton: true, closeButton: true,
content: $dialogPanel, content: $dialogPanel,
height: 256, //576, height: Math.round((window.innerHeight - 48) * 0.9),
removeOnClose: true, removeOnClose: true,
title: Ox._('Manage Home Screen'), title: Ox._('Manage Home Screen'),
width: 1050 // 256 + 17 + 512 + 17 + 256 width: 1058 // 256 + 17 + 512 + 17 + 256
}); });
pandora.api.getHomeItems({}, function(result) { pandora.api.getHomeItems({}, function(result) {
@ -55,46 +57,63 @@ pandora.ui.homeDialog = function() {
}); });
}); });
function editItem(id, key, value) { function addItem(active, callback) {
var title = $title.value(); pandora.api.addHomeItem({
var text = $text.value(); active: active,
var type = $typeSelect.value(); }, function(response) {
if (type == 'custom') { items.push(response.data);
var image = $imageInput.value(); var selected = response.data.id;
var link = $linkInput.value(); renderFolders(items, selected);
} else { var item = Ox.getObjectById(items, selected);
var name = $nameInput.value(); renderItem(item);
title = true; renderForm(item);
text = true; callback && callback();
});
}
function deleteItem(id, callback) {
pandora.api.removeHomeItem({
id: id
}, function() {
items = items.filter(function(item) {
return item.id != id;
});
var selected = items[0].id;
renderFolders(items, selected);
var item = Ox.getObjectById(items, selected);
renderItem(item);
renderForm(item);
callback && callback();
});
}
function editItem(id, key, value, callback) {
if (key == 'name') {
key = 'contentid'; key = 'contentid';
} }
if ( var data = Ox.extend({id: id}, key, value);
!title || !text if (key == 'type') {
|| (type == 'custom' && (!image || !link)) Ox.extend(data, {'contentid': ''});
|| (type != 'custom' && !name)
) {
return;
}
Ox.print('id', id, 'k', key, 'v', value);
var data = {id: id};
data[key] = value;
if (key == 'contentid') {
data.type = type;
} }
pandora.api.editHomeItem(data, function(result) { pandora.api.editHomeItem(data, function(result) {
Ox.Request.clearCache(); // FIXME: too much? Ox.Request.clearCache('Home');
items.some(function(item) { var item = Ox.getObjectById(items, id);
if (item.id == id) { Ox.unique(Object.keys(item).concat(Object.keys(result.data))).forEach(function(key) {
item[key] = value; item[key] = result.data[key] || '';
if (key == 'contentid') {
item.image = result.data.image;
item.text = result.data.text;
item.title = result.data.title;
renderItem(item);
}
return true;
};
}); });
renderFolders(items, item.id);
/*
console.log('1', item)
console.log('2', (item.status == 'active' ? $activeList : $inactiveList).value(id));
(item.status == 'active' ? $activeList : $inactiveList).value(id, {
image: item.image,
title: item.title,
text: item.text,
link: item.link
});
*/
renderItem(item);
renderForm(item);
callback && callback();
}); });
} }
@ -112,9 +131,9 @@ pandora.ui.homeDialog = function() {
}, },
range: [0, 1000] range: [0, 1000]
}, function(result) { }, function(result) {
autocompleteData[value] = result.data.items.map(function(item) { autocompleteData[value] = [''].concat(result.data.items.map(function(item) {
return item.id; return item.id;
}); }));
callback(); callback();
}); });
}, },
@ -122,14 +141,14 @@ pandora.ui.homeDialog = function() {
); );
} }
function renderFolder(type, items, selected) { function renderFolder(status, items, selected) {
var extras = [ var extras = [
Ox.MenuButton({ Ox.MenuButton({
items: [ items: [
{id: 'newitem', title: Ox._( {id: 'newitem', title: Ox._(
'New ' + (type == 'active' ? 'Active' : 'Inactive') + ' Item' 'New ' + (status == 'active' ? 'Active' : 'Inactive') + ' Item'
)}, )},
{id: 'deleteitem', title: Ox._('Delete Selected Item')} {id: 'deleteitem', title: Ox._('Delete Selected Item'), disabled: !selected}
], ],
title: 'edit', title: 'edit',
tooltip: Ox._('Manage Items'), tooltip: Ox._('Manage Items'),
@ -137,18 +156,26 @@ pandora.ui.homeDialog = function() {
}).bindEvent({ }).bindEvent({
click: function(data) { click: function(data) {
if (data.id == 'newitem') { if (data.id == 'newitem') {
// ... addItem(status == 'active');
} else if (data.id == 'deleteitem') { } else if (data.id == 'deleteitem') {
// ... var id = (
} status == 'active' ? $activeList : $inactiveList
).options('selected')[0];
id && deleteItem(id);
} }
},
}) })
]; ];
if (status == 'active') {
$activeMenu = extras[0];
} else {
$inactiveMenu = extras[0];
}
var $folder = Ox.CollapsePanel({ var $folder = Ox.CollapsePanel({
collapsed: false, collapsed: false,
extras: extras, extras: extras,
size: 16, size: 16,
title: Ox._((type == 'active' ? 'Active' : 'Inactive') + ' Items') title: Ox._((status == 'active' ? 'Active' : 'Inactive') + ' Items')
}).bindEvent({ }).bindEvent({
toggle: function(data) { toggle: function(data) {
data.collapsed && $list.loseFocus(); data.collapsed && $list.loseFocus();
@ -159,31 +186,63 @@ pandora.ui.homeDialog = function() {
padding: '1px 4px', padding: '1px 4px',
}).html(Ox._('No items')).hide().appendTo($folder.$content) }).html(Ox._('No items')).hide().appendTo($folder.$content)
var $list = renderList(items.filter(function(item) { var $list = renderList(items.filter(function(item) {
return item.active == (type == 'active'); return item.active == (status == 'active');
}), selected).bindEventOnce({ }), selected).bindEventOnce({
init: function(data) { init: function(data) {
updateMenu(status, $list.options('selected').length);
$placeholder[data.items ? 'hide' : 'show'](); $placeholder[data.items ? 'hide' : 'show']();
$folder.$content.css({ $folder.$content.css({
height: (data.items || 1) * 16 + 'px' height: (data.items || 1) * 16 + 'px'
}); });
} }
}).bindEvent({
add: function(event) {
addItem(status == 'active');
},
'delete': function(data) {
data.ids.length && deleteItem(data.ids[0]);
}
}).appendTo($folder.$content); }).appendTo($folder.$content);
if (status == 'active') {
$activeList = $list;
} else {
$inactiveList = $list;
}
return $folder; return $folder;
} }
function renderFolders(items, selected) { function renderFolders(items, selected) {
$folders.empty(); $folders.empty();
['active', 'inactive'].forEach(function(type) { ['active', 'inactive'].forEach(function(status) {
var $folder = renderFolder(type, items, selected).appendTo($folders); var $folder = renderFolder(status, items, selected).appendTo($folders);
}); });
} }
function renderForm(data, focus) { function renderForm(data, focus) {
$form.empty(); $form.empty();
if (!data) {
return;
}
$statusSelect = Ox.Select({
items: [
{id: 'active', title: Ox._('Active')},
{id: 'inactive', title: Ox._('Inactive')}
],
label: Ox._('Status'),
labelWidth: 80,
value: data.active ? 'active' : 'inactive',
width: 240
}).css({
margin: '8px'
}).bindEvent({
change: function(data_) {
editItem(data.id, 'active', data_.value == 'active');
}
}).appendTo($form);
$typeSelect = Ox.Select({ $typeSelect = Ox.Select({
items: [ items: [
{id: 'custom', title: Ox._('Custom')}, {id: 'custom', title: Ox._('Custom')},
{},
{id: 'list', title: Ox._('List')}, {id: 'list', title: Ox._('List')},
{id: 'edit', title: Ox._('Edit')}, {id: 'edit', title: Ox._('Edit')},
{id: 'collection', title: Ox._('Collection')} {id: 'collection', title: Ox._('Collection')}
@ -196,9 +255,9 @@ pandora.ui.homeDialog = function() {
margin: '8px' margin: '8px'
}).bindEvent({ }).bindEvent({
change: function(data_) { change: function(data_) {
var item = {id: data.id, type: data_.value}; editItem(data.id, 'type', data_.value, function() {
renderItem(item); (data.type == 'custom' ? $imageInput : $nameInput).focusInput();
renderForm(item, true); });
} }
}).appendTo($form); }).appendTo($form);
if (data.type == 'custom') { if (data.type == 'custom') {
@ -229,6 +288,8 @@ pandora.ui.homeDialog = function() {
} else { } else {
$nameInput = Ox.Input({ $nameInput = Ox.Input({
autocomplete: autocompleteData[data.type], autocomplete: autocompleteData[data.type],
autocompleteReplace: true,
autocompleteReplaceCorrect: true,
autocompleteSelect: true, autocompleteSelect: true,
autocompleteSelectMaxWidth: 256, autocompleteSelectMaxWidth: 256,
label: Ox._('Name'), label: Ox._('Name'),
@ -243,66 +304,17 @@ pandora.ui.homeDialog = function() {
} }
}).appendTo($form); }).appendTo($form);
} }
if (focus) {
(data.type == 'custom' ? $imageInput : $nameInput).focusInput();
}
} }
function renderItem(data) { function renderItem(data) {
$item.empty(); $item.empty().append(
if (data.image) { pandora.renderHomeItem({
var $image = $('<img>').attr({ data: data,
src: data.image editItem: editItem
}).css({ }).css({
borderRadius: '32px', margin: '16px'
float: 'left', })
height: '128px', );
margin: '12px',
width: '128px'
}).appendTo($item)
} else {
var $placeholder = $('<div>').css({
border: 'dotted 1px rgb(0, 0, 0)', // FIXME: make themes
borderRadius: '32px',
height: '128px',
margin: '8px',
width: '128px'
}).appendTo($item);
}
var $container = $('<div>').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: '<span class="OxLight">' + Ox._('Title') + '</span>',
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: '<span class="OxLight">' + Ox._('Text') + '</span>',
type: 'textarea',
value: data.text || ''
}).css({
margin: '0 12px 0 0'
}).bindEvent({
submit: function(data_) {
editItem(data.id, 'text', data_.value);
}
}).appendTo($item);
} }
function renderList(items, selected) { function renderList(items, selected) {
@ -329,9 +341,20 @@ pandora.ui.homeDialog = function() {
width: 224 width: 224
}, },
{ {
id: 'active', id: 'text',
format: function(value) { visible: false,
return value ? $('<img>').attr({ width: 0
},
{
id: 'link',
visible: false,
width: 0
},
{
id: 'complete',
format: function(value, data) {
console.log('##', data);
return pandora.isCompleteHomeItem(data) ? $('<img>').attr({
src: Ox.UI.getImageURL('symbolCheck') src: Ox.UI.getImageURL('symbolCheck')
}).css({ }).css({
width: '10px', width: '10px',
@ -352,8 +375,16 @@ pandora.ui.homeDialog = function() {
}) })
.bindEvent({ .bindEvent({
select: function(data) { select: function(data) {
var item = Ox.getObjectById($list.options('items'), data.ids[0]),
status = $list == $activeList ? 'active' : 'inactive';
if (data.ids.length) { 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); renderItem(item);
renderForm(item); renderForm(item);
} }
@ -378,6 +409,12 @@ pandora.ui.homeDialog = function() {
return $list; return $list;
} }
function updateMenu(status, value) {
(
status == 'active' ? $activeMenu : $inactiveMenu
)[value ? 'enableItem' : 'disableItem']('deleteitem');
}
return that; return that;
}; };

View file

@ -221,18 +221,18 @@ pandora.ui.mainMenu = function() {
getSortMenu(), getSortMenu(),
getFindMenu(), getFindMenu(),
{ id: 'dataMenu', title: Ox._('Data'), items: [ { id: 'dataMenu', title: Ox._('Data'), items: [
{ id: 'documents', title: Ox._('Manage Documents...'), disabled: !pandora.site.capabilities.canManageDocuments[pandora.user.level] }, !Ox.isEmpty(pandora.site.capabilities.canManageHome)
{ id: 'entities', title: Ox._('Manage Entities...'), disabled: !pandora.site.entities.length || !pandora.site.capabilities.canManageEntities[pandora.user.level] }, ? [{ 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: '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: '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: '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] }, { 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: '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] }, { 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(); pandora.$ui.filters.clearFilters();
} else if (data.id == 'findsimilar') { } else if (data.id == 'findsimilar') {
pandora.$ui.similarClipsDialog = pandora.ui.similarClipsDialog().open(); pandora.$ui.similarClipsDialog = pandora.ui.similarClipsDialog().open();
} else if (data.id == 'documents') {
pandora.$ui.documentsDialog = pandora.ui.documentsDialog().open();
} else if (data.id == 'entities') { } else if (data.id == 'entities') {
pandora.$ui.entitiesDialog = pandora.ui.entitiesDialog().open(); pandora.$ui.entitiesDialog = pandora.ui.entitiesDialog().open();
} else if (data.id == 'titles') { } else if (data.id == 'titles') {

View file

@ -357,7 +357,10 @@ pandora.changeFolderItemStatus = function(id, status, callback) {
pandora.api['edit' + folderItem]({ pandora.api['edit' + folderItem]({
id: id, id: id,
status: status 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+)$/); var match = e.target.id.match(/^embed(\d+)$/);
if (match) { if (match) {
(selectEmbed || pandora.$ui.textPanel.selectEmbed)(parseInt(match[1])); (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 { } else {
pandora.openLink(e.target.href); pandora.openURL(e.target.href);
} }
}; };
@ -2390,6 +2381,7 @@ pandora.hasPlacesLayer = function() {
}); });
}; };
pandora.isClipView = function(view, item) { pandora.isClipView = function(view, item) {
if (pandora.user.ui.section == 'items') { if (pandora.user.ui.section == 'items') {
if (arguments.length == 0) { if (arguments.length == 0) {
@ -2404,6 +2396,10 @@ pandora.isClipView = function(view, item) {
).indexOf(view) > -1; ).indexOf(view) > -1;
}; };
pandora.isCompleteHomeItem = function(data) {
return data.image && data.title && data.text && data.link;
};
pandora.isEmbeddableView = function(url) { pandora.isEmbeddableView = function(url) {
// FIXME: actually return true for embeddable views // FIXME: actually return true for embeddable views
return false; 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) { pandora.signin = function(data) {
// fixme: this is still voodoo // fixme: this is still voodoo
pandora.user = Ox.extend(data.user, { 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: '<img>',
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 = $('<div>').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 = $('<div>').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: '<span class="OxLight">' + Ox._('Title') + '</span>',
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: '<span class="OxLight">' + Ox._('Text') + '</span>',
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.resizeFilters = function(width) {
pandora.user.ui.filterSizes = pandora.getFilterSizes(); pandora.user.ui.filterSizes = pandora.getFilterSizes();
pandora.$ui.browser && pandora.$ui.browser pandora.$ui.browser && pandora.$ui.browser