refactoring (intermediate state)
This commit is contained in:
parent
164961e562
commit
1f2bfe2f76
16 changed files with 206 additions and 169 deletions
|
@ -39,7 +39,7 @@ class UserProfile(models.Model):
|
||||||
for key in new:
|
for key in new:
|
||||||
if isinstance(new[key], dict) and key in ui:
|
if isinstance(new[key], dict) and key in ui:
|
||||||
ui[key] = updateUI(ui[key], new[key])
|
ui[key] = updateUI(ui[key], new[key])
|
||||||
else:
|
elif isinstance(ui, dict):
|
||||||
ui[key] = new[key]
|
ui[key] = new[key]
|
||||||
return ui
|
return ui
|
||||||
ui = updateUI(ui, self.ui)
|
ui = updateUI(ui, self.ui)
|
||||||
|
|
|
@ -566,7 +566,7 @@ def setUI(request):
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
profile = request.user.get_profile()
|
profile = request.user.get_profile()
|
||||||
for key in data:
|
for key in data:
|
||||||
keys = key.split('|')
|
keys = re.sub('([^\\\\])\.', '\\1\n', key).split('\n')
|
||||||
value = data[key]
|
value = data[key]
|
||||||
p = profile.ui
|
p = profile.ui
|
||||||
while len(keys)>1:
|
while len(keys)>1:
|
||||||
|
|
|
@ -21,81 +21,92 @@ pandora.UI = (function() {
|
||||||
// key foo.bar.baz sets pandora.user.ui.foo.bar.baz
|
// key foo.bar.baz sets pandora.user.ui.foo.bar.baz
|
||||||
// val null removes a key
|
// val null removes a key
|
||||||
that.set = function(/*{key: val} or key, val*/) {
|
that.set = function(/*{key: val} or key, val*/) {
|
||||||
var obj = Ox.makeObject(arguments),
|
var add = {},
|
||||||
|
args = Ox.makeObject(arguments),
|
||||||
|
listSettings = pandora.site.listSettings,
|
||||||
set = {},
|
set = {},
|
||||||
trigger = {};
|
trigger = {};
|
||||||
|
Ox.print('UI SET', args)
|
||||||
self.previousUI = Ox.clone(pandora.user.ui, true);
|
self.previousUI = Ox.clone(pandora.user.ui, true);
|
||||||
Ox.forEach(obj, function(val, key) {
|
Ox.forEach(args, function(val, key) {
|
||||||
});
|
|
||||||
Ox.forEach(obj, function(val, key) {
|
|
||||||
var i = 0,
|
|
||||||
keys = key.split('.'),
|
|
||||||
listSettings = pandora.site.listSettings,
|
|
||||||
ui = pandora.user.ui;
|
|
||||||
while (i < keys.length - 1) {
|
|
||||||
ui = ui[keys[i]];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (!Ox.isEqual(ui[keys[i]], val)) {
|
|
||||||
if (val === null) {
|
|
||||||
delete ui[keys[i]]
|
|
||||||
} else {
|
|
||||||
ui[keys[i]] = val;
|
|
||||||
}
|
|
||||||
if (key[0] != '_') {
|
|
||||||
// don't save or trigger events for private keys
|
|
||||||
// set[key] = val;
|
|
||||||
set[key] = val;
|
|
||||||
trigger[key] = val;
|
|
||||||
}
|
|
||||||
if (key == 'find') {
|
if (key == 'find') {
|
||||||
// the challenge here is that find may change list,
|
// the challenge here is that find may change list,
|
||||||
// and list may then change listSort and listView,
|
// and list may then change listSort and listView,
|
||||||
// which we don't want to trigger, since find triggers
|
// which we don't want to trigger, since find triggers
|
||||||
var list = pandora.getListsState()
|
var list = pandora.getListsState(val);
|
||||||
|
add['item'] = '';
|
||||||
pandora.user.ui._list = list;
|
pandora.user.ui._list = list;
|
||||||
pandora.user.ui._groupsState = pandora.getGroupsState();
|
pandora.user.ui._groupsState = pandora.getGroupsState(val);
|
||||||
pandora.user.ui._findState = pandora.getFindState();
|
pandora.user.ui._findState = pandora.getFindState(val);
|
||||||
if (list != self.previousUI.list) {
|
if (list != self.previousUI._list) {
|
||||||
if (!pandora.user.ui.lists[list]) {
|
if (!pandora.user.ui.lists[list]) {
|
||||||
set['lists.' + that.encode(list)] = {};
|
add['lists.' + list] = {};
|
||||||
}
|
}
|
||||||
Ox.forEach(listSettings, function(listSetting, setting) {
|
Ox.forEach(listSettings, function(listSetting, setting) {
|
||||||
if (!pandora.user.ui.lists[list]) {
|
if (!pandora.user.ui.lists[list]) {
|
||||||
// add default list settings and copy to settings
|
// add default list setting and copy to settings
|
||||||
set['lists.' + that.encode(list)][listSetting] = pandora.site.user.ui[setting];
|
add['lists.' + list][listSetting] = pandora.site.user.ui[setting];
|
||||||
set[setting] = pandora.site.user.ui[setting];
|
add[setting] = pandora.site.user.ui[setting];
|
||||||
} else {
|
} else {
|
||||||
// copy list settings to setting
|
// copy lists setting to settings
|
||||||
set[setting] = pandora.user.ui.lists[list][listSetting];
|
add[setting] = pandora.user.ui.lists[list][listSetting]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (Object.keys(listSettings).indexOf(key) > -1) {
|
} else if (Object.keys(listSettings).indexOf(key) > -1) {
|
||||||
// copy setting to list setting
|
// copy setting to list setting
|
||||||
set['lists.' + that.encode(pandora.user.ui.list) + '.' + listSettings[key]] = val;
|
add['lists.' + that.encode(pandora.user.ui._list || '') + '.' + listSettings[key]] = val;
|
||||||
|
} else if (key == 'item' && val) {
|
||||||
|
// when switching to an item, update list selection
|
||||||
|
add['listSelection'] = [val];
|
||||||
|
add['lists.' + that.encode(pandora.user.ui._list || '') + '.selection'] = [val];
|
||||||
} else if (
|
} else if (
|
||||||
key == 'itemView'
|
key == 'itemView'
|
||||||
&& ['video', 'timeline'].indexOf(val) > -1
|
&& ['video', 'timeline'].indexOf(val) > -1
|
||||||
&& !pandora.user.ui.videoPoints[pandora.user.ui.item]
|
&& !pandora.user.ui.videoPoints[pandora.user.ui.item]
|
||||||
) {
|
) {
|
||||||
// add default videoPoints
|
// add default videoPoints
|
||||||
set['videoPoints.' + pandora.user.ui.item] = {'in': 0, out: 0, position: 0};
|
add['videoPoints.' + pandora.user.ui.item] = {'in': 0, out: 0, position: 0};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
[args, add].forEach(function(obj, isAdd) {
|
||||||
|
Ox.forEach(obj, function(val, key) {
|
||||||
|
var keys = key.replace(/([^\\])\./g, '$1\n').split('\n'),
|
||||||
|
ui = pandora.user.ui;
|
||||||
|
while (keys.length > 1) {
|
||||||
|
ui = ui[keys.shift()];
|
||||||
|
}
|
||||||
|
if (!Ox.isEqual(ui[keys[0]], val)) {
|
||||||
|
if (val === null) {
|
||||||
|
delete ui[keys[0]]
|
||||||
|
} else {
|
||||||
|
ui[keys[0]] = val;
|
||||||
|
}
|
||||||
|
// don't save or trigger events for private keys
|
||||||
|
//if (key[0] != '_') {
|
||||||
|
//}
|
||||||
|
set[key] = val;
|
||||||
|
if (!isAdd) {
|
||||||
|
trigger[key] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
Ox.len(set) && pandora.api.setUI(set);
|
||||||
Ox.forEach(trigger, function(val, key) {
|
Ox.forEach(trigger, function(val, key) {
|
||||||
|
// fixme: send previousVal as second parameter
|
||||||
Ox.Event.trigger(key, val);
|
Ox.Event.trigger(key, val);
|
||||||
});
|
});
|
||||||
// fixme: swap later, once the backend accepts dots
|
|
||||||
// Ox.len(set) && pandora.api.setUI(set);
|
Ox.forEach(trigger, function(val, key) {
|
||||||
if (Ox.len(set)) {
|
Ox.forEach(pandora.$ui, function(element) {
|
||||||
var set_ = {};
|
// fixme: send previousVal as second parameter
|
||||||
Ox.forEach(set, function(val, key) {
|
element.ox && element.triggerEvent('pandora_' + key.toLowerCase(), {
|
||||||
set_[key.replace(/\./g, '|')] = val;
|
value: val,
|
||||||
|
previousValue: self.previousUI[key]
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
pandora.api.setUI(set_);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
|
@ -115,8 +115,8 @@ pandora.URL = (function() {
|
||||||
$('video').each(function() {
|
$('video').each(function() {
|
||||||
$(this).trigger('stop');
|
$(this).trigger('stop');
|
||||||
});
|
});
|
||||||
pandora.user.ui._groupsState = pandora.getGroupsState();
|
pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find);
|
||||||
pandora.user.ui._findState = pandora.getFindState();
|
pandora.user.ui._findState = pandora.getFindState(pandora.user.ui.find);
|
||||||
if (Ox.isEmpty(state)) {
|
if (Ox.isEmpty(state)) {
|
||||||
if (pandora.user.ui.showHome) {
|
if (pandora.user.ui.showHome) {
|
||||||
pandora.$ui.home = pandora.ui.home().showScreen();
|
pandora.$ui.home = pandora.ui.home().showScreen();
|
||||||
|
@ -160,51 +160,50 @@ pandora.URL = (function() {
|
||||||
document.location.href = '/api/';
|
document.location.href = '/api/';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pandora.UI.set({
|
|
||||||
|
var set = {
|
||||||
section: state.type == pandora.site.itemsSection ? 'items' : state.type,
|
section: state.type == pandora.site.itemsSection ? 'items' : state.type,
|
||||||
item: state.item,
|
item: state.item,
|
||||||
});
|
//find: state.find
|
||||||
|
};
|
||||||
state.find && pandora.UI.set({
|
|
||||||
find: state.find,
|
|
||||||
list: pandora.getListsState(state.find)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (state.view) {
|
if (state.view) {
|
||||||
pandora.UI.set(
|
set[!pandora.user.ui.item ? 'listView' : 'itemView'] = state.view;
|
||||||
!pandora.user.ui.item
|
|
||||||
? 'listView'
|
|
||||||
: 'itemView',
|
|
||||||
state.view
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora.user.ui._groupsState = pandora.getGroupsState();
|
if (state.sort) {
|
||||||
Ox.print('_groupsState =', pandora.user.ui._groupsState);
|
set[!pandora.user.ui.item ? 'listSort' : 'itemSort'] = state.sort;
|
||||||
pandora.user.ui._findState = pandora.getFindState();
|
}
|
||||||
|
|
||||||
|
///*
|
||||||
|
if (state.find) {
|
||||||
|
set.find = state.find;
|
||||||
|
} else {
|
||||||
|
var find = pandora.user.ui.find;
|
||||||
|
pandora.user.ui._list = pandora.getListsState(find)
|
||||||
|
pandora.user.ui._groupsState = pandora.getGroupsState(find);
|
||||||
|
pandora.user.ui._findState = pandora.getFindState(find);
|
||||||
|
}
|
||||||
|
//*/
|
||||||
|
|
||||||
if (['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) {
|
if (['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) {
|
||||||
if (state.span) {
|
if (state.span) {
|
||||||
pandora.UI.set('videoPoints.' + pandora.user.ui.item, {
|
set['videoPoints.' + pandora.user.ui.item] = {
|
||||||
position: state.span[0],
|
position: state.span[0],
|
||||||
'in': state.span[1] || 0,
|
'in': state.span[1] || 0,
|
||||||
out: state.span[2] || 0
|
out: state.span[2] || 0
|
||||||
});
|
}
|
||||||
} else if (!pandora.user.ui.videoPoints[pandora.user.ui.item]) {
|
} else if (!pandora.user.ui.videoPoints[pandora.user.ui.item]) {
|
||||||
pandora.UI.set('videoPoints.' + pandora.user.ui.item, {
|
set['videoPoints.' + pandora.user.ui.item] = {
|
||||||
position: 0,
|
position: 0,
|
||||||
'in': 0,
|
'in': 0,
|
||||||
out: 0
|
out: 0
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.sort && pandora.UI.set(
|
|
||||||
!pandora.user.ui.item
|
pandora.UI.set(set);
|
||||||
? 'lists.' + pandora.user.ui.list + '.sort'
|
|
||||||
: 'itemSort',
|
|
||||||
state.sort
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (!pandora.$ui.appPanel) {
|
if (!pandora.$ui.appPanel) {
|
||||||
|
@ -382,9 +381,14 @@ pandora.URL = (function() {
|
||||||
sortKeys[itemsSection] = {list: {}, item: {}};
|
sortKeys[itemsSection] = {list: {}, item: {}};
|
||||||
views[itemsSection].list.forEach(function(view) {
|
views[itemsSection].list.forEach(function(view) {
|
||||||
sortKeys[itemsSection].list[view] = Ox.merge(
|
sortKeys[itemsSection].list[view] = Ox.merge(
|
||||||
pandora.isClipView(view) ? Ox.clone(pandora.site.clipKeys) : [],
|
|
||||||
// listSort[0].key is the default sort key
|
// listSort[0].key is the default sort key
|
||||||
[Ox.getObjectById(pandora.site.sortKeys, pandora.user.ui.listSort[0].key)],
|
Ox.getObjectById(pandora.site.sortKeys, pandora.user.ui.listSort[0].key)
|
||||||
|
|| pandora.isClipView(view)
|
||||||
|
&& Ox.getObjectById(pandora.site.clipKeys, pandora.user.ui.listSort[0].key)
|
||||||
|
|| [],
|
||||||
|
pandora.isClipView(view) ? Ox.map(pandora.site.clipKeys, function(key) {
|
||||||
|
return key.id == pandora.user.ui.listSort[0].key ? null : key;
|
||||||
|
}) : [],
|
||||||
Ox.map(pandora.site.sortKeys, function(key) {
|
Ox.map(pandora.site.sortKeys, function(key) {
|
||||||
return key.id == pandora.user.ui.listSort[0].key ? null : key;
|
return key.id == pandora.user.ui.listSort[0].key ? null : key;
|
||||||
})
|
})
|
||||||
|
|
|
@ -349,22 +349,17 @@ pandora.getItemByIdOrTitle = function(str, callback) {
|
||||||
|
|
||||||
pandora.getListData = function() {
|
pandora.getListData = function() {
|
||||||
var data = {}, folder;
|
var data = {}, folder;
|
||||||
if (pandora.user.ui.list) {
|
if (pandora.user.ui._list) {
|
||||||
Ox.forEach(pandora.$ui.folderList, function(list, key) {
|
Ox.forEach(pandora.$ui.folderList, function(list, key) {
|
||||||
if (list.options('selected').length) {
|
if (list.options('selected').length) {
|
||||||
folder = key;
|
folder = key;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// the one case where folder is undefinded is when on page load
|
data = pandora.$ui.folderList[folder].value(pandora.user.ui._list);
|
||||||
// the folderLists call getListData to determine which list is selected
|
|
||||||
if (folder) {
|
|
||||||
//Ox.print('gLD f', folder)
|
|
||||||
data = pandora.$ui.folderList[folder].value(pandora.user.ui.list);
|
|
||||||
data.editable = data.user == pandora.user.username && data.type == 'static';
|
data.editable = data.user == pandora.user.username && data.type == 'static';
|
||||||
data.folder = folder;
|
data.folder = folder;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -559,12 +554,11 @@ pandora.resizeFolders = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.selectList = function() {
|
pandora.selectList = function() {
|
||||||
// fixme: can this be removed?
|
if (pandora.user.ui._list) {
|
||||||
if (pandora.user.ui.list) {
|
|
||||||
pandora.api.findLists({
|
pandora.api.findLists({
|
||||||
keys: ['status', 'user'],
|
keys: ['status', 'user'],
|
||||||
query: {
|
query: {
|
||||||
conditions: [{key: 'id', value: pandora.user.ui.list, operator: '='}],
|
conditions: [{key: 'id', value: pandora.user.ui._list, operator: '='}],
|
||||||
operator: ''
|
operator: ''
|
||||||
},
|
},
|
||||||
range: [0, 1]
|
range: [0, 1]
|
||||||
|
@ -576,7 +570,7 @@ pandora.selectList = function() {
|
||||||
list.user == pandora.user.username ? 'personal' : 'favorite'
|
list.user == pandora.user.username ? 'personal' : 'favorite'
|
||||||
);
|
);
|
||||||
pandora.$ui.folderList[folder]
|
pandora.$ui.folderList[folder]
|
||||||
.options('selected', [pandora.user.ui.list])
|
.options('selected', [pandora.user.ui._list])
|
||||||
.gainFocus();
|
.gainFocus();
|
||||||
} else {
|
} else {
|
||||||
pandora.user.ui.list = '';
|
pandora.user.ui.list = '';
|
||||||
|
@ -612,19 +606,16 @@ pandora.selectList = function() {
|
||||||
return indices.length == 1 ? indices[0] : -1;
|
return indices.length == 1 ? indices[0] : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora.getFindState = function() {
|
pandora.getFindState = function(find) {
|
||||||
// The find element is populated if exactly one condition in an & query
|
// The find element is populated if exactly one condition in an & query
|
||||||
// has a findKey as key and "=" as operator (and all other conditions
|
// has a findKey as key and "=" as operator (and all other conditions
|
||||||
// are either list or groups), or if all conditions in an | query have
|
// are either list or groups), or if all conditions in an | query have
|
||||||
// the same group id as key and "==" as operator
|
// the same group id as key and "==" as operator
|
||||||
var conditions,
|
var conditions, indices, state = {index: -1, key: '*', value: ''};
|
||||||
find = pandora.user.ui.find,
|
|
||||||
indices,
|
|
||||||
state = {index: -1, key: '*', value: ''};
|
|
||||||
if (find.operator == '&') {
|
if (find.operator == '&') {
|
||||||
// number of conditions that are not list or groups
|
// number of conditions that are not list or groups
|
||||||
conditions = find.conditions.length
|
conditions = find.conditions.length
|
||||||
- !!pandora.user.ui.list
|
- !!pandora.user.ui._list
|
||||||
- pandora.user.ui._groupsState.filter(function(group) {
|
- pandora.user.ui._groupsState.filter(function(group) {
|
||||||
return group.index > -1;
|
return group.index > -1;
|
||||||
}).length;
|
}).length;
|
||||||
|
@ -658,10 +649,9 @@ pandora.selectList = function() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora.getGroupsState = function() {
|
pandora.getGroupsState = function(find) {
|
||||||
// A group is selected if exactly one condition in an & query or every
|
// A group is selected if exactly one condition in an & query or every
|
||||||
// condition in an | query has the group id as key and "==" as operator
|
// condition in an | query has the group id as key and "==" as operator
|
||||||
var find = pandora.user.ui.find;
|
|
||||||
return pandora.user.ui.groups.map(function(group) {
|
return pandora.user.ui.groups.map(function(group) {
|
||||||
// FIXME: cant index be an empty array, instead of -1?
|
// FIXME: cant index be an empty array, instead of -1?
|
||||||
var key = group.id,
|
var key = group.id,
|
||||||
|
@ -691,8 +681,10 @@ pandora.selectList = function() {
|
||||||
} else {
|
} else {
|
||||||
// one condition in an & query matches this group
|
// one condition in an & query matches this group
|
||||||
state.find.conditions.splice(state.index, 1);
|
state.find.conditions.splice(state.index, 1);
|
||||||
if (state.find.conditions.length == 1) {
|
if (
|
||||||
if (state.find.conditions[0].conditions) {
|
state.find.conditions.length == 1
|
||||||
|
&& state.find.conditions[0].conditions
|
||||||
|
) {
|
||||||
// unwrap single remaining bracketed query
|
// unwrap single remaining bracketed query
|
||||||
state.find = {
|
state.find = {
|
||||||
conditions: state.find.conditions[0].conditions,
|
conditions: state.find.conditions[0].conditions,
|
||||||
|
@ -701,15 +693,14 @@ pandora.selectList = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return state;
|
return state;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pandora.getListsState = function() {
|
pandora.getListsState = function(find) {
|
||||||
// A list is selected if exactly one condition in an & query has "list"
|
// A list is selected if exactly one condition in an & query has "list"
|
||||||
// as key and "==" as operator
|
// as key and "==" as operator
|
||||||
var find = pandora.user.ui.find, index, state = '';
|
var index, state = '';
|
||||||
if (find.operator == '&') {
|
if (find.operator == '&') {
|
||||||
index = oneCondition(find.conditions, 'list', '==');
|
index = oneCondition(find.conditions, 'list', '==');
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ pandora.ui.backButton = function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
pandora.UI.set({item: null});
|
pandora.UI.set({item: ''});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return that;
|
return that;
|
||||||
|
|
|
@ -80,7 +80,6 @@ pandora.ui.browser = function() {
|
||||||
},
|
},
|
||||||
select: function(data) {
|
select: function(data) {
|
||||||
pandora.UI.set({
|
pandora.UI.set({
|
||||||
'listSelection': data.ids,
|
|
||||||
'item': data.ids[0]
|
'item': data.ids[0]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,7 +33,9 @@ pandora.ui.contentPanel = function() {
|
||||||
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
||||||
},
|
},
|
||||||
item: function(value) {
|
item: function(value) {
|
||||||
value && that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
if (value && pandora.UI.getPrevious('item')) {
|
||||||
|
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
itemView: function() {
|
itemView: function() {
|
||||||
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
||||||
|
|
|
@ -241,7 +241,7 @@ pandora.ui.folderList = function(id) {
|
||||||
max: 1,
|
max: 1,
|
||||||
min: 0,
|
min: 0,
|
||||||
pageLength: 1000,
|
pageLength: 1000,
|
||||||
selected: pandora.getListData().folder == id ? [pandora.user.ui.list] : [],
|
//selected: pandora.getListData().folder == id ? [pandora.user.ui._list] : [],
|
||||||
sort: [{key: 'position', operator: '+'}],
|
sort: [{key: 'position', operator: '+'}],
|
||||||
sortable: id != 'featured' || pandora.user.level == 'admin'
|
sortable: id != 'featured' || pandora.user.level == 'admin'
|
||||||
})
|
})
|
||||||
|
|
|
@ -113,17 +113,32 @@ pandora.ui.group = function(id) {
|
||||||
// nothing selected
|
// nothing selected
|
||||||
find.conditions.splice(index, 1);
|
find.conditions.splice(index, 1);
|
||||||
if (find.conditions.length == 1) {
|
if (find.conditions.length == 1) {
|
||||||
|
if (find.conditions[0].conditions) {
|
||||||
|
// unwrap single remaining bracketed query
|
||||||
|
find = {
|
||||||
|
conditions: find.conditions[0].conditions,
|
||||||
|
operator: '|'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
find.operator = '&';
|
find.operator = '&';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (conditions.length == 1) {
|
} else if (conditions.length == 1) {
|
||||||
// one item selected
|
// one item selected
|
||||||
find.conditions[index] = conditions[0];
|
find.conditions[index] = conditions[0];
|
||||||
} else {
|
} else {
|
||||||
// multiple items selected
|
// multiple items selected
|
||||||
find.conditions[index].conditions = conditions;
|
if (pandora.user.ui.find.conditions.length == 1) {
|
||||||
find.conditions[index].operator = '|';
|
find = {
|
||||||
delete find.conditions[index].key;
|
conditions: conditions,
|
||||||
delete find.conditions[index].value;
|
operator: '|'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
find.conditions[index] = {
|
||||||
|
conditions: conditions,
|
||||||
|
operator: '|'
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -18,6 +18,22 @@ pandora.ui.mainPanel = function() {
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
});
|
});
|
||||||
pandora.UI.bind({
|
pandora.UI.bind({
|
||||||
|
find: function() {
|
||||||
|
var previousUI = pandora.UI.getPrevious();
|
||||||
|
if (pandora.user.ui._list == previousUI._list) {
|
||||||
|
pandora.$ui.list.reloadList();
|
||||||
|
pandora.user.ui._groupsState.forEach(function(data, i) {
|
||||||
|
if (!Ox.isEqual(data.selected, previousUI._groupsState[i].selected)) {
|
||||||
|
pandora.$ui.groups[i].options({selected: data.selected});
|
||||||
|
}
|
||||||
|
if (!Ox.isEqual(data.find, previousUI._groupsState[i].find)) {
|
||||||
|
pandora.$ui.groups[i].reloadList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
||||||
|
}
|
||||||
|
},
|
||||||
item: function(value) {
|
item: function(value) {
|
||||||
if (!value || !pandora.UI.getPrevious('item')) {
|
if (!value || !pandora.UI.getPrevious('item')) {
|
||||||
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
|
||||||
|
|
|
@ -272,10 +272,11 @@ pandora.ui.mainMenu = function() {
|
||||||
return { id: 'sortMenu', title: 'Sort', items: [
|
return { id: 'sortMenu', title: 'Sort', items: [
|
||||||
{ id: 'sortmovies', title: 'Sort ' + (isClipView ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
|
{ id: 'sortmovies', title: 'Sort ' + (isClipView ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [
|
||||||
{ group: 'sortmovies', min: 1, max: 1, items: Ox.merge(isClipView ? Ox.merge(pandora.site.clipKeys.map(function(key) {
|
{ group: 'sortmovies', min: 1, max: 1, items: Ox.merge(isClipView ? Ox.merge(pandora.site.clipKeys.map(function(key) {
|
||||||
return Ox.extend({
|
return Ox.extend(Ox.clone(key), {
|
||||||
checked: ui.listSort[0].key == key.id
|
checked: ui.listSort[0].key == key.id,
|
||||||
}, key);
|
title: 'Clip ' + key.title
|
||||||
}), {}) : [], pandora.site.sortKeys.map(function(key) {
|
});
|
||||||
|
}), /*{}*/[]) : [], pandora.site.sortKeys.map(function(key) {
|
||||||
return Ox.extend({
|
return Ox.extend({
|
||||||
checked: ui.listSort[0].key == key.id
|
checked: ui.listSort[0].key == key.id
|
||||||
}, key);
|
}, key);
|
||||||
|
@ -349,6 +350,15 @@ pandora.ui.mainMenu = function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pandora.UI.bind({
|
||||||
|
listView: function(value) {
|
||||||
|
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('listView'))) {
|
||||||
|
that.replaceMenu('sortMenu', getSortMenu());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ pandora.ui.orderButton = function() {
|
||||||
key: pandora.user.ui.listSort[0].key,
|
key: pandora.user.ui.listSort[0].key,
|
||||||
operator: pandora.user.ui.listSort[0].operator == '+' ? '-' : '+'
|
operator: pandora.user.ui.listSort[0].operator == '+' ? '-' : '+'
|
||||||
}]
|
}]
|
||||||
})
|
});
|
||||||
that.options({title: getTitle()});
|
that.options({title: getTitle()});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,22 +58,6 @@ pandora.ui.rightPanel = function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
pandora.UI.bind({
|
pandora.UI.bind({
|
||||||
find: function() {
|
|
||||||
var previousUI = pandora.UI.getPrevious();
|
|
||||||
if (pandora.user.ui.list == previousUI.list) {
|
|
||||||
pandora.$ui.list.reloadList();
|
|
||||||
pandora.user.ui._groupsState.forEach(function(data, i) {
|
|
||||||
if (!Ox.isEqual(data.selected, previousUI._groupsState[i].selected)) {
|
|
||||||
pandora.$ui.groups[i].options({selected: data.selected});
|
|
||||||
}
|
|
||||||
if (!Ox.isEqual(data.find, previousUI._groupsState[i].find)) {
|
|
||||||
pandora.$ui.groups[i].reloadList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
that.replaceElement(1, pandora.$ui.contentPanel = pandora.ui.contentPanel());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
itemView: function(value) {
|
itemView: function(value) {
|
||||||
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('itemView'))) {
|
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('itemView'))) {
|
||||||
that.replaceElement(0, pandora.$ui.toolbar = pandora.ui.toolbar());
|
that.replaceElement(0, pandora.$ui.toolbar = pandora.ui.toolbar());
|
||||||
|
|
|
@ -10,7 +10,7 @@ pandora.ui.sortSelect = function() {
|
||||||
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
|
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
!pandora.user.ui.item && items.push({});
|
//!pandora.user.ui.item && items.push({});
|
||||||
}
|
}
|
||||||
if (!pandora.user.ui.item) {
|
if (!pandora.user.ui.item) {
|
||||||
items = Ox.merge(items, pandora.site.sortKeys.map(function(key) {
|
items = Ox.merge(items, pandora.site.sortKeys.map(function(key) {
|
||||||
|
@ -32,19 +32,15 @@ pandora.ui.sortSelect = function() {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
pandora.UI.set(sortKey, [{key: data.selected[0].id, operator: ''}]);
|
pandora.UI.set(sortKey, [{key: data.selected[0].id, operator: ''}]);
|
||||||
|
},
|
||||||
|
pandora_listsort: function(data) {
|
||||||
|
that.selectItem(data.value[0].key);
|
||||||
|
},
|
||||||
|
pandora_itemsort: function(value) {
|
||||||
|
that.selectItem(data.value[0].key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pandora.UI.bind({
|
|
||||||
listSort: function(value) {
|
|
||||||
that.selectItem(value[0].key);
|
|
||||||
},
|
|
||||||
item: function(value) {
|
|
||||||
|
|
||||||
},
|
|
||||||
itemSort: function(value) {
|
|
||||||
that.selectItem(value[0].key);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,15 @@ pandora.ui.toolbar = function() {
|
||||||
that.append(
|
that.append(
|
||||||
pandora.$ui.findElement = pandora.ui.findElement()
|
pandora.$ui.findElement = pandora.ui.findElement()
|
||||||
);
|
);
|
||||||
|
pandora.UI.bind({
|
||||||
|
listView: function(value) {
|
||||||
|
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('listView'))) {
|
||||||
|
pandora.$ui.sortSelect.replaceWith(
|
||||||
|
pandora.$ui.sortSelect = pandora.ui.sortSelect()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue