url controller updates, refactoring
This commit is contained in:
parent
4a8954332a
commit
1d894fc934
18 changed files with 287 additions and 427 deletions
|
|
@ -147,7 +147,6 @@ pandora.ui.accountForm = function(action, value) {
|
|||
}
|
||||
});
|
||||
} else if (action == 'reset') {
|
||||
Ox.print('DATA???', data)
|
||||
var usernameOrEmail = data.usernameOrEmail,
|
||||
key = usernameOrEmail[0];
|
||||
data = {};
|
||||
|
|
|
|||
|
|
@ -97,6 +97,9 @@ pandora.ui.browser = function() {
|
|||
defaultRatio: data.value == 'posters' ? 5/8 : 1
|
||||
}).reloadList(true);
|
||||
},
|
||||
pandora_item: function(data) {
|
||||
that.options({selected: [data.value]});
|
||||
},
|
||||
pandora_showsiteposter: function() {
|
||||
pandora.user.ui.icons == 'posters' && that.reloadList(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ pandora.ui.folderBrowserBar = function(id) {
|
|||
items: function(data, callback) {
|
||||
var query = id == 'favorite' ? {conditions: [
|
||||
{key: 'status', value: 'public', operator: '='},
|
||||
{key: 'user', value: pandora.user.username, operator: '!'},
|
||||
{key: 'user', value: pandora.user.username, operator: '!=='},
|
||||
{key: key, value: value, operator: ''}
|
||||
], operator: '&'} : {conditions: [
|
||||
{key: 'status', value: 'private', operator: '!'},
|
||||
{key: 'status', value: 'private', operator: '!='},
|
||||
{key: key, value: value, operator: ''}
|
||||
], operator: '&'};
|
||||
return pandora.api.findLists(Ox.extend(data, {
|
||||
|
|
|
|||
|
|
@ -117,9 +117,9 @@ pandora.ui.folderBrowserList = function(id) {
|
|||
items: function(data, callback) {
|
||||
var query = id == 'favorite' ? {conditions: [
|
||||
{key: 'status', value: 'public', operator: '='},
|
||||
{key: 'user', value: pandora.user.username, operator: '!'}
|
||||
{key: 'user', value: pandora.user.username, operator: '!=='}
|
||||
], operator: '&'} : {conditions: [
|
||||
{key: 'status', value: 'private', operator: '!'}
|
||||
{key: 'status', value: 'private', operator: '!='}
|
||||
], operator: ''};
|
||||
return pandora.api.findLists(Ox.extend(data, {
|
||||
query: query
|
||||
|
|
|
|||
|
|
@ -119,17 +119,17 @@ pandora.ui.folderList = function(id) {
|
|||
var query;
|
||||
if (id == 'personal') {
|
||||
query = {conditions: [
|
||||
{key: 'user', value: pandora.user.username, operator: '='},
|
||||
{key: 'status', value: 'featured', operator: '!'}
|
||||
{key: 'user', value: pandora.user.username, operator: '=='},
|
||||
{key: 'status', value: 'featured', operator: '!='}
|
||||
], operator: '&'};
|
||||
} else if (id == 'favorite') {
|
||||
query = {conditions: [
|
||||
{key: 'subscribed', value: true, operator: '='},
|
||||
{key: 'status', value: 'featured', operator: '!'},
|
||||
{key: 'status', value: 'featured', operator: '!='},
|
||||
], operator: '&'};
|
||||
} else if (id == 'featured') {
|
||||
query = {conditions: [
|
||||
{key: 'status', value: 'featured', operator: '='}
|
||||
{key: 'status', value: 'featured', operator: '='} // fixme: '==' performs better
|
||||
], operator: '&'};
|
||||
}
|
||||
return pandora.api.findLists(Ox.extend(data, {
|
||||
|
|
@ -263,8 +263,12 @@ pandora.ui.folderList = function(id) {
|
|||
type: event.keys == '' ? 'static' : 'smart'
|
||||
}, function(result) {
|
||||
var id = result.data.id;
|
||||
pandora.UI.set('lists.' + id, pandora.site.user.ui.lists['']); // fixme: necessary?
|
||||
pandora.URL.set('?find=list:' + id)
|
||||
pandora.UI.set({
|
||||
find: {
|
||||
conditions: [{key: 'list', value: id, operator: '=='}],
|
||||
operator: '&'
|
||||
}
|
||||
});
|
||||
Ox.Request.clearCache(); // fixme: remove
|
||||
that.reloadList().bindEventOnce({
|
||||
load: function(data) {
|
||||
|
|
@ -313,19 +317,47 @@ pandora.ui.folderList = function(id) {
|
|||
}
|
||||
},
|
||||
'delete': function(data) {
|
||||
// fixme: add a confirmation dialog
|
||||
//var $list = pandora.$ui.folderList[id];
|
||||
pandora.URL.set('?find=');
|
||||
that.options({selected: []});
|
||||
if (id == 'personal') {
|
||||
pandora.api.removeList({
|
||||
id: data.ids[0]
|
||||
}, function(result) {
|
||||
pandora.UI.set('lists.' + data.ids[0], null);
|
||||
Ox.Request.clearCache(); // fixme: remove
|
||||
that.reloadList();
|
||||
});
|
||||
var $dialog = Ox.Dialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
id: 'cancel',
|
||||
title: 'Cancel'
|
||||
}).bindEvent({
|
||||
click: function() {
|
||||
$dialog.close();
|
||||
}
|
||||
}),
|
||||
Ox.Button({
|
||||
id: 'delete',
|
||||
title: 'Delete'
|
||||
}).bindEvent({
|
||||
click: function() {
|
||||
$dialog.close();
|
||||
that.options({selected: []});
|
||||
pandora.api.removeList({
|
||||
id: data.ids[0]
|
||||
}, function(result) {
|
||||
pandora.UI.set('lists.' + data.ids[0], null);
|
||||
pandora.UI.set({
|
||||
find: pandora.site.user.ui.find
|
||||
});
|
||||
Ox.Request.clearCache(); // fixme: remove
|
||||
that.reloadList();
|
||||
});
|
||||
}
|
||||
})
|
||||
],
|
||||
content: $('<div>')
|
||||
.css({margin: '16px'})
|
||||
.html('Do you want to delete the list ' + data.ids[0] + '?'),
|
||||
height: 128,
|
||||
keys: {enter: 'delete', escape: 'cancel'},
|
||||
title: 'Delete List',
|
||||
width: 304
|
||||
}).open();
|
||||
} else if (id == 'favorite') {
|
||||
that.options({selected: []});
|
||||
pandora.api.unsubscribeFromList({
|
||||
id: data.ids[0]
|
||||
}, function(result) {
|
||||
|
|
@ -333,6 +365,7 @@ pandora.ui.folderList = function(id) {
|
|||
that.reloadList();
|
||||
});
|
||||
} else if (id == 'featured' && pandora.user.level == 'admin') {
|
||||
that.options({selected: []});
|
||||
pandora.api.editList({
|
||||
id: data.ids[0],
|
||||
status: 'public'
|
||||
|
|
@ -392,11 +425,15 @@ pandora.ui.folderList = function(id) {
|
|||
data_ = {id: data.id};
|
||||
data_[data.key] = data.value;
|
||||
pandora.api.editList(data_, function(result) {
|
||||
// fixme: we may want slashes in list names
|
||||
if (result.data.id != data.id) {
|
||||
pandora.$ui.folderList[id].value(data.id, 'name', result.data.name);
|
||||
pandora.$ui.folderList[id].value(data.id, 'id', result.data.id);
|
||||
pandora.URL.set('?find=list:' + result.data.id);
|
||||
pandora.UI.set({
|
||||
find: {
|
||||
conditions: [{key: 'list', value: result.data.id, operator: '=='}],
|
||||
operator: '&'
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,8 +50,12 @@ pandora.ui.folders = function() {
|
|||
type: data.id == 'new' ? 'static' : 'smart'
|
||||
}, function(result) {
|
||||
var id = result.data.id;
|
||||
pandora.UI.set('lists.' + id, pandora.site.user.ui.lists['']); // fixme: necessary?
|
||||
pandora.URL.set('?find=list:' + id)
|
||||
pandora.UI.set({
|
||||
find: {
|
||||
conditions: [{key: 'list', value: id, operator: '=='}],
|
||||
operator: '&'
|
||||
}
|
||||
});
|
||||
Ox.Request.clearCache(); // fixme: remove
|
||||
$list.reloadList().bindEventOnce({
|
||||
load: function(data) {
|
||||
|
|
@ -235,7 +239,7 @@ pandora.ui.folders = function() {
|
|||
that.append($folder);
|
||||
});
|
||||
pandora.resizeFolders();
|
||||
//pandora.selectList();
|
||||
pandora.selectList();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -196,15 +196,6 @@ pandora.ui.item = function() {
|
|||
);
|
||||
}
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'statistics') {
|
||||
var stats = Ox.Container();
|
||||
Ox.TreeList({
|
||||
data: result.data,
|
||||
width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE
|
||||
}).appendTo(stats);
|
||||
|
||||
pandora.$ui.contentPanel.replaceElement(1, stats);
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'clips') {
|
||||
var ratio = result.data.videoRatio;
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({
|
||||
|
|
@ -266,7 +257,7 @@ pandora.ui.item = function() {
|
|||
if (data.ids.length) {
|
||||
var id = data.ids[0],
|
||||
item = id.split('/')[0], width, height,
|
||||
$img = $('.OxItem.OxSelected > .OxIcon > img'),
|
||||
$img = pandora.$ui.clips.find('.OxItem.OxSelected > .OxIcon > img'),
|
||||
$video = $('.OxItem.OxSelected > .OxIcon > .OxVideoPlayer');
|
||||
if ($img.length) {
|
||||
var width = ratio > 1 ? 128 : Math.round(128 * ratio),
|
||||
|
|
@ -587,6 +578,14 @@ pandora.ui.item = function() {
|
|||
} else if (pandora.user.ui.itemView == 'calendar') {
|
||||
pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('Calendar'));
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'data') {
|
||||
var stats = Ox.Container();
|
||||
Ox.TreeList({
|
||||
data: result.data,
|
||||
width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE
|
||||
}).appendTo(stats);
|
||||
|
||||
pandora.$ui.contentPanel.replaceElement(1, stats);
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'files') {
|
||||
pandora.$ui.contentPanel.replaceElement(1,
|
||||
|
|
|
|||
|
|
@ -130,17 +130,12 @@ pandora.ui.list = function() {
|
|||
},
|
||||
sort: function(data) {
|
||||
Ox.print('---- SORT ----', data)
|
||||
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + data.key);
|
||||
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (data.operator == '+' ? 'ascending' : 'descending'));
|
||||
pandora.$ui.sortSelect.selectItem(data.key);
|
||||
pandora.UI.set({
|
||||
listSort: [{key: data.key, operator: data.operator}]
|
||||
});
|
||||
pandora.URL.push();
|
||||
}
|
||||
});
|
||||
} else if (view == 'grid') {
|
||||
//alert(JSON.stringify(pandora.user.ui.lists[pandora.user.ui.list].selected))
|
||||
that = Ox.IconList({
|
||||
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16,
|
||||
defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1,
|
||||
|
|
@ -164,7 +159,6 @@ pandora.ui.list = function() {
|
|||
};
|
||||
},
|
||||
items: function(data, callback) {
|
||||
//Ox.print('data, pandora.Query.toObject', data, pandora.Query.toObject())
|
||||
pandora.api.find(Ox.extend(data, {
|
||||
query: pandora.user.ui.find
|
||||
}), callback);
|
||||
|
|
|
|||
|
|
@ -330,12 +330,12 @@ pandora.ui.mainMenu = function() {
|
|||
queries = {
|
||||
// fixme: duplicated
|
||||
personal: {conditions: [
|
||||
{key: 'user', value: pandora.user.username, operator: '='},
|
||||
{key: 'status', value: 'featured', operator: '!'}
|
||||
{key: 'user', value: pandora.user.username, operator: '=='},
|
||||
{key: 'status', value: 'featured', operator: '!='}
|
||||
], operator: '&'},
|
||||
favorite: {conditions: [
|
||||
{key: 'subscribed', value: true, operator: '='},
|
||||
{key: 'status', value: 'featured', operator: '!'},
|
||||
{key: 'status', value: 'featured', operator: '!='},
|
||||
], operator: '&'},
|
||||
featured: {conditions: [
|
||||
{key: 'status', value: 'featured', operator: '='}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@ pandora.ui.viewSelect = function() {
|
|||
var viewKey = !pandora.user.ui.item ? 'listView' : 'itemView',
|
||||
that = Ox.Select({
|
||||
id: 'viewSelect',
|
||||
items: pandora.site[viewKey + 's'].map(function(view) {
|
||||
return Ox.extend(Ox.clone(view), {
|
||||
checked: view.id == pandora.user.ui[viewKey],
|
||||
title: 'View ' + view.title
|
||||
});
|
||||
items: Ox.map(pandora.site[viewKey + 's'], function(view) {
|
||||
return viewKey == 'listView'
|
||||
|| ['data', 'files'].indexOf(view.id) == -1
|
||||
|| pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level]
|
||||
? Ox.extend(Ox.clone(view), {
|
||||
checked: view.id == pandora.user.ui[viewKey],
|
||||
title: 'View ' + view.title
|
||||
})
|
||||
: null;
|
||||
}),
|
||||
width: !pandora.user.ui.item ? 144 : 128
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue