url controller updates, refactoring

This commit is contained in:
rolux 2011-09-28 17:32:03 +00:00
parent 4a8954332a
commit 1d894fc934
18 changed files with 287 additions and 427 deletions

View file

@ -3,7 +3,8 @@
"canPlayClips": {"guest": 1, "member": 2, "staff": 3, "admin": 4},
"canPlayVideo": {"guest": 0, "member": 1, "staff": 3, "admin": 4},
"canSeeItem": {"guest": 2, "member": 2, "staff": 3, "admin": 4},
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4}
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4},
"canSeeExtraItemViews": {"guest": false, "member": false, "staff": true, "admin": true}
},
"clipKeys": [
{"id": "clip:text", "title": "Text", "type": "string"},
@ -438,12 +439,12 @@
},
"itemViews": [
{"id": "info", "title": "Info"},
{"id": "statistics", "title": "Statistics"},
{"id": "clips", "title": "Clips"},
{"id": "video", "title": "Video"},
{"id": "timeline", "title": "Timeline"},
{"id": "map", "title": "Map"},
{"id": "calendar", "title": "Calendar"},
{"id": "data", "title": "Data"},
{"id": "files", "title": "Files"}
],
"layers": [
@ -527,9 +528,9 @@
{"id": "favorites", "title": "Favorites", "public": true, "items": []},
{"id": "most_popular", "title": "Most Popular", "query": {}},
{"id": "recently_viewed", "title": "Recently Viewed", "query": {}},
{"id": "1960s", "title": "1960s", "query": {"conditions": [{"key": "year", "value": "196", "operator": "^"}], "operator": ""}},
{"id": "movies_with_full_video", "title": "Movies with Full Video", "query": {"conditions": [{"key": "canPlayVideo", "value": true, "operator": ""}], "operator": ""}},
{"id": "movies_with_full_video", "title": "Movies with Clips", "query": {"conditions": [{"key": "canPlayClips", "value": true, "operator": ""}], "operator": ""}}
{"id": "1960s", "title": "1960s", "query": {"conditions": [{"key": "year", "value": "196", "operator": "^"}], "operator": "&"}},
{"id": "movies_with_full_video", "title": "Movies with Full Video", "query": {"conditions": [{"key": "canPlayVideo", "value": true, "operator": ""}], "operator": "&"}},
{"id": "movies_with_full_video", "title": "Movies with Clips", "query": {"conditions": [{"key": "canPlayClips", "value": true, "operator": ""}], "operator": "&"}}
],
"favorite": [
{"id": "rlx:watchme", "title": "rlx: watchme", "public": true, "items": [0, 1, 2, 3, 4]}

View file

@ -98,7 +98,8 @@ def parseCondition(condition):
elif key_type == 'list':
q = Q(itemId=False)
l = v.split(":")
if len(l) == 2:
if len(l) >= 2:
l = (l[0], ":".join(l[1:]))
lqs = list(List.objects.filter(name=l[1], user__username=l[0]))
if len(lqs) == 1:
l = lqs[0]

View file

@ -9,15 +9,6 @@ import models
def parseCondition(condition, user):
'''
condition: {
value: "war"
}
or
condition: {
key: "year",
value: "1970-1980,
operator: "!="
}
'''
k = condition.get('key', 'name')
k = {
@ -36,8 +27,9 @@ def parseCondition(condition, user):
else:
exclude = False
if k == 'id':
v = v.split(':')
if len(v) == 2:
v = v.split(":")
if len(v) >= 2:
v = (v[0], ":".join(v[1:]))
q = Q(user__username=v[0], name=v[1])
else:
q = Q(id__in=[])
@ -142,4 +134,4 @@ class ListManager(Manager):
qs = qs.filter(Q(status='public') | Q(status='featured'))
else:
qs = qs.filter(Q(status='public') | Q(status='featured') | Q(user=user))
return qs
return qs.distinct()

View file

@ -13,7 +13,9 @@ from item import utils
from item.models import Item
def get_list_or_404_json(id):
username, listname = id.split(':')
id = id.split(':')
username = id[0]
listname = ":".join(id[1:])
return get_object_or_404_json(models.List, user__username=username, name=listname)
def _order_query(qs, sort):
@ -94,7 +96,7 @@ def findLists(request):
else:
qs = _order_query(query['qs'], query['sort'])
#range
qs = qs.distinct()
response = json_response()
if 'keys' in data:
qs = qs[query['range'][0]:query['range'][1]]

View file

@ -129,10 +129,6 @@ Ox.load({
pandora.user.ui.theme = 'classic';
}
window.onpopstate = function(event) {
//pandora.URL.update();
};
// set up url controller
pandora.URL.init().parse(function() {

View file

@ -17,12 +17,20 @@ pandora.UI = (function() {
// sets pandora.user.ui.key to val
// key foo.bar.baz sets pandora.user.ui.foo.bar.baz
// val null removes a key
that.set = function(/*{key: val} or key, val*/) {
that.set = function(/* {key: val}[, flag] or key, val[, flag] */) {
var add = {},
args = Ox.makeObject(arguments),
args,
doNotTriggerEvents,
listSettings = pandora.site.listSettings,
set = {},
trigger = {};
if (Ox.isObject(arguments[0])) {
args = arguments[0];
triggerEvents = Ox.isUndefined(arguments[1]) ? true : arguments[1];
} else {
args = Ox.makeObject([arguments[0], arguments[1]]);
triggerEvents = Ox.isUndefined(arguments[2]) ? true : arguments[1];
}
Ox.print('UI SET', args)
self.previousUI = Ox.clone(pandora.user.ui, true);
Ox.forEach(args, function(val, key) {
@ -37,7 +45,7 @@ pandora.UI = (function() {
pandora.user.ui._findState = pandora.getFindState(val);
if (list != self.previousUI._list) {
if (!pandora.user.ui.lists[list]) {
add['lists.' +that.encode(list)] = {};
add['lists.' + that.encode(list)] = {};
}
Ox.forEach(listSettings, function(listSetting, setting) {
if (!pandora.user.ui.lists[list]) {
@ -73,7 +81,7 @@ pandora.UI = (function() {
)] = {'in': 0, out: 0, position: 0};
}
});
[add, args].forEach(function(obj, isArg) {
[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;
@ -87,23 +95,29 @@ pandora.UI = (function() {
ui[keys[0]] = val;
}
set[key] = val;
if (isArg) {
if (!isAdd) {
trigger[key] = val;
}
}
});
});
Ox.len(set) && pandora.api.setUI(set);
Ox.forEach(trigger, function(val, key) {
triggerEvents && Ox.forEach(trigger, function(val, key) {
Ox.forEach(pandora.$ui, function(element) {
// fixme: send previousVal as second parameter
element.ox && element.triggerEvent('pandora_' + key.toLowerCase(), {
value: val,
previousValue: self.previousUI[key]
});
});
});
Ox.len(trigger) && pandora.URL.push();
/*
if (!pandora.$ui.appPanel) {
pandora.URL.replace();
} else if (Ox.len(trigger)) {
pandora.URL.push();
}
*/
pandora.URL.update(Object.keys(trigger));
};
return that;

View file

@ -4,120 +4,87 @@ pandora.URL = (function() {
var self = {}, that = {};
/*
function foundItem() {
pandora.UI.set(Ox.extend({
section: 'items',
item: item,
itemView: view
}, ['video', 'timeline'].indexOf(view) > -1 ? {
videoView: view
} : {}));
if (time) {
points = time[0].split(',');
if (
points.length == 2
&& (points = Ox.flatten([points[0], points[1].split('-')]))[2] == ''
) {
pandora.api.get({
id: item,
keys: ['duration']
}, function(result) {
points[2] = result.data.duration.toString();
foundTime();
});
} else {
foundTime();
}
} else {
if (!pandora.user.ui.videoPoints[item]) {
pandora.UI.set('videoPoints|' + item, {
'in': 0, out: 0, position: 0
});
}
foundTime();
function getState(keys) {
Ox.print('KEYS', keys)
var state = {};
/*
if (keys.indexOf('type') > -1) {
state.type = pandora.user.ui.section == 'items'
? pandora.site.itemsSection
: pandora.user.ui.section;
}
function foundTime() {
if (time) {
// fixme: this is duplicated, see Ox.VideoPlayer() parsePositionInput()
points = points.map(function(point, i) {
var parts = point.split(':').reverse();
while (parts.length > 3) {
parts.pop();
}
return parts.reduce(function(prev, curr, i) {
return prev + (parseFloat(curr) || 0) * Math.pow(60, i);
}, 0);
});
pandora.UI.set('videoPoints|' + item, {
'in': points.length == 1 ? 0 : points[points.length - 2],
out: points.length == 1 ? 0 : points[points.length - 1],
position: points[0],
});
points = points.map(function(point) {
return point == -1 ? '' : Ox.formatDuration(point, 3).replace(/\.000$/, '');
});
split[split.length - 1] = points[0] + (
points.length == 1 ? '' : ',' + points[1] + '-' + points[2]
*/
state.type = pandora.site.itemsSection;
if (!keys || keys.indexOf('item') > -1) {
state.item = pandora.user.ui.item;
}
if (!keys || keys.indexOf('listView') > -1 || keys.indexOf('itemView') > -1) {
if (!pandora.user.ui.item) {
state.view = pandora.user.ui.listView;
} else {
state.item = pandora.user.ui.item;
state.view = pandora.user.ui.itemView;
}
}
if (!keys || keys.filter(function(key) {
return /^videoPoints/.test(key);
}).length) {
var videoPoints = pandora.user.ui.videoPoints;
state.item = pandora.user.ui.item;
state.view = pandora.user.ui.itemView;
state.span = [];
if (
pandora.user.ui.item
&& ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1
&& videoPoints[pandora.user.ui.item]
) {
videoPoints = videoPoints[pandora.user.ui.item];
state.span = Ox.merge(
videoPoints.position
? videoPoints.position
: [],
videoPoints['in'] || videoPoints.out
? [videoPoints['in'], videoPoints.out]
: []
);
}
pandora.URL.replace(split.join('/'));
// on page load, we have to check if the item is in the previously selected list
// if it is not, the movie browser has to be reloaded
if (pandora.user.ui.list) {
pandora.user.ui.query = {
conditions: [{key: 'list', value: pandora.user.ui.list, operator: ''}],
operator: '&'
};
pandora.api.find({
query: pandora.user.ui.query,
positions: [pandora.user.ui.item],
sort: [{key: 'id', operator: ''}]
}, function(result) {
if (Ox.isUndefined(result.data.positions[pandora.user.ui.item])) {
pandora.UI.set({list: ''});
pandora.user.ui.query = {conditions:[], operator: '&'};
}
callback();
});
} else {
callback();
}
}
}
*/
function getState() {
return {
type: pandora.user.ui.section == 'items'
? pandora.site.itemsSection
: pandora.user.ui.section,
item: pandora.user.ui.item,
view: !pandora.user.ui.item
? pandora.user.ui.listView
: pandora.user.ui.itemView,
sort: !pandora.user.ui.item
? pandora.user.ui.listSort
: pandora.isClipView(pandora.user.ui.itemView)
? pandora.user.ui.itemSort : [],
find: !pandora.user.ui.item
? pandora.user.ui.find
: ''
};
if (!keys || keys.indexOf('listSort') > -1 || keys.indexOf('itemSort') > -1) {
if (!pandora.user.ui.item) {
state.view = pandora.user.ui.listView;
state.sort = pandora.user.ui.listSort;
} else {
state.item = pandora.user.ui.item;
state.view = pandora.user.ui.itemView;
state.sort = pandora.user.ui.itemSort;
}
/*
: pandora.isClipView(pandora.user.ui.itemView)
? pandora.user.ui.itemSort : [],
*/
}
if (!state.item) {
state.find = pandora.user.ui.find;
}
Ox.print('STATE .................... ->', state)
return state;
}
function setState(state) {
Ox.print('STATE:', state)
var previousUI = pandora.UI.getPrevious();
// var previousUI = Ox.clone(pandora.user.ui);
function setState(state, callback) {
Ox.print('SET STATE:', state)
var find, previousUI = pandora.UI.getPrevious();
Ox.Request.cancel();
$('video').each(function() {
$(this).trigger('stop');
});
pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find);
pandora.user.ui._findState = pandora.getFindState(pandora.user.ui.find);
if (Ox.isEmpty(state)) {
if (pandora.user.ui.showHome) {
pandora.$ui.home = pandora.ui.home().showScreen();
/*
@ -127,12 +94,17 @@ pandora.URL = (function() {
);
*/
} else {
/*
pandora.UI.set({
section: 'items',
item: ''
});
}
*/
}
callback && callback();
} else if (state.page) {
if (state.page == 'home') {
//pandora.$ui.home = pandora.ui.home().showScreen();
pandora.$ui.home = pandora.ui.home().fadeInScreen();
@ -159,6 +131,8 @@ pandora.URL = (function() {
} else if (state.page == 'api') {
document.location.href = '/api/';
}
callback && callback();
} else {
var set = {
@ -168,11 +142,21 @@ pandora.URL = (function() {
};
if (state.view) {
set[!pandora.user.ui.item ? 'listView' : 'itemView'] = state.view;
set[!state.item ? 'listView' : 'itemView'] = state.view;
}
if (state.span) {
if (['video', 'timeline'].indexOf(state.view) > -1) {
set['videoPoints.' + state.item] = {
position: state.span[0],
'in': state.span[1] || 0,
out: state.span[2] || 0
}
}
}
if (state.sort) {
set[!pandora.user.ui.item ? 'listSort' : 'itemSort'] = state.sort;
set[!state.item ? 'listSort' : 'itemSort'] = state.sort;
}
///*
@ -185,174 +169,33 @@ pandora.URL = (function() {
pandora.user.ui._findState = pandora.getFindState(find);
}
//*/
if (['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) {
if (state.span) {
set['videoPoints.' + pandora.user.ui.item] = {
position: state.span[0],
'in': state.span[1] || 0,
out: state.span[2] || 0
if (!pandora.$ui.appPanel && state.item && pandora.user.ui.find) {
// on page load, if item is set and there is or was a query,
// we have to check if the item actually matches the query,
// and otherwise reset find
pandora.api.find({
query: pandora.user.ui.find,
positions: [state.item],
sort: [{key: 'id', operator: ''}]
}, function(result) {
if (Ox.isUndefined(result.data.positions[state.item])) {
set.find = pandora.site.user.ui.find
}
} else if (!pandora.user.ui.videoPoints[pandora.user.ui.item]) {
set['videoPoints.' + pandora.user.ui.item] = {
position: 0,
'in': 0,
out: 0
}
}
}
pandora.UI.set(set);
/*
if (!pandora.$ui.appPanel) {
return;
}
if (pandora.user.ui.section != previousUI.section) {
// new section
pandora.$ui.appPanel.replaceElement(1, pandora.$ui.mainPanel = pandora.ui.mainPanel());
} else if (!pandora.user.ui.item && !previousUI.item) {
// list to list
Ox.print('pUI', previousUI);
var isClipView = pandora.isClipView(),
list = pandora.user.ui.lists[pandora.user.ui.list],
previousList = previousUI.lists[previousUI.list],
wasClipView = pandora.isClipView(previousList.view);
if (pandora.user.ui.list != previousUI.list) {
pandora.$ui.findElement.replaceWith(pandora.$ui.findElement = pandora.ui.findElement());
}
if (list.view != previousList.view) {
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + list.view);
pandora.$ui.viewSelect.options({value: list.view});
if (isClipView != wasClipView) {
pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu());
pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect());
if (isClipView && !wasClipView) {
pandora.UI.set('lists.' + pandora.user.ui.list + '.selected', []);
}
}
}
if (!Ox.isEqual(list.sort, previousList.sort)) {
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + list.sort[0].key);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + ((
list.sort[0].operator || pandora.getSortOperator(list.sort[0].key)
) == '+' ? 'ascending' : 'descending'));
pandora.$ui.sortSelect.options({value: list.sort[0].key});
}
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
if (Ox.isEqual(pandora.user.ui.find, previousUI.find)) {
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
} else {
pandora.user.ui._groupsState.forEach(function(data, i) {
if (!Ox.isEqual(data.find, previousUI._groupsState[i].find)) {
pandora.$ui.groups[i].reloadList();
}
});
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
//pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
// fixme: should list selection and deselection happen here?
// (home and menu may cause a list switch)
} else if (!pandora.user.ui.item || !previousUI.item) {
// list to item or item to list
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
pandora.UI.set(set);
callback && callback();
});
} else {
// item to item
if (pandora.user.ui.item != previousUI.item) {
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
}
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.item());
pandora.UI.set(set);
callback && callback();
}
if (
previousUI.item
&& ['video', 'timeline'].indexOf(previousUI.itemView) > -1
) {
var $item = pandora.$ui[
previousUI.itemView == 'video' ? 'player' : 'editor'
];
$item && pandora.UI.set(
'videoPoints.' + previousUI.item + '.position',
$item.options('position')
);
}
*/
}
pandora.user.ui.showHome = false;
}
function updateUI() {
// remove later
var previousUI = pandora.UI.getPrevious();
Ox.Request.cancel();
$('video').each(function() {
$(this).trigger('stop');
});
pandora.URL.parse(function() {
if (pandora.user.ui.section != previousUI.section) {
pandora.$ui.appPanel.replaceElement(1, pandora.$ui.mainPanel = pandora.ui.mainPanel());
} else if (!pandora.user.ui.item && !previousUI.item) {
// list to list
var isClipView = pandora.isClipView(),
list = pandora.user.ui.lists[pandora.user.ui.list],
previousList = previousUI.lists[previousUI.list],
wasClipView = pandora.isClipView(previousList.view);
if (list.view != previousList.view) {
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + list.view);
pandora.$ui.viewSelect.options({value: list.view});
if (isClipView != wasClipView) {
pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu());
pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect());
if (isClipView && !wasClipView) {
pandora.UI.set('lists.' + pandora.user.ui.list + '.selected', []);
}
}
}
if (!Ox.isEqual(list.sort, previousList.sort)) {
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + list.sort[0].key);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + ((
list.sort[0].operator || pandora.getSortOperator(list.sort[0].key)
) == '+' ? 'ascending' : 'descending'));
pandora.$ui.sortSelect.options({value: list.sort[0].key});
}
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
if (Ox.isEqual(pandora.user.ui.find, previousUI.find)) {
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list());
} else {
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
// fixme: should list selection and deselection happen here?
// (home and menu may cause a list switch)
} else if (!pandora.user.ui.item || !previousUI.item) {
// list to item or item to list
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
} else {
// item to item
if (pandora.user.ui.item != previousUI.item) {
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
}
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.item());
}
if (
previousUI.item &&
['video', 'timeline'].indexOf(previousUI.itemView) > -1
) {
var $item = pandora.$ui[
previousUI.itemView == 'video' ? 'player' : 'editor'
];
$item && pandora.UI.set(
'videoPoints.' + previousUI.item + '.position',
$item.options('position')
);
}
});
}
that.init = function() {
var itemsSection = pandora.site.itemsSection,
@ -400,7 +243,7 @@ pandora.URL = (function() {
// itemSort[0].key is the default sort key
[Ox.getObjectById(pandora.site.clipKeys, pandora.user.ui.itemSort[0].key)],
Ox.map(pandora.site.clipKeys, function(key) {
return key.id == pandora.user.ui.itemSort ? null : key;
return key.id == pandora.user.ui.itemSort[0].key ? null : key;
})
);
}
@ -436,6 +279,21 @@ pandora.URL = (function() {
views: views
});
///*
window.onhashchange = function() {
that.parse();
};
window.onpopstate = function(e) {
self.isPopState = true;
if (!Ox.isEmpty(e.state)) {
Ox.print('E.STATE', e.state)
setState(e.state);
} else {
that.parse();
}
};
//*/
return that;
};
@ -446,8 +304,7 @@ pandora.URL = (function() {
document.location.href = decodeURI(document.location.pathname.substr(4));
} else {
self.URL.parse(function(state) {
setState(state);
callback();
setState(state, callback);
});
}
return that;
@ -460,14 +317,11 @@ pandora.URL = (function() {
// pushes a new URL (as string or from state)
that.push = function(url) {
Ox.print('push', arguments[0])
if (url) {
self.URL.push(url, setState);
self.URL.push(null, '', url, setState);
} else {
var state = getState();
Ox.print('&&&&&&&', state)
self.URL.push(state);
//setState(state);
alert('DO YOU REALLY WANT TO CALL PUSH WITHOUT URL?')
//self.URL.push(getState());
}
return that;
};
@ -475,77 +329,32 @@ pandora.URL = (function() {
// replaces the current URL (as string or from state)
that.replace = function(url) {
if (url) {
self.URL.replace(url, setState)
self.URL.replace(null, '', url, setState)
} else {
self.URL.replace(getState());
}
return that;
};
that.update = function(keys) {
var action;
if (self.isPopState) {
self.isPopState = false;
} else {
if (
!pandora.$ui.appPanel
|| keys.every(function(key) {
return /^videoPoints/.test(key);
})
) {
action = 'replace'
} else {
action = 'push'
}
self.URL[action](getState(), 'title', getState(keys));
}
};
return that;
/*
parse: function(callback) {
var pathname = document.location.pathname.substr(1),
search = document.location.search.substr(1);
if (/\/$/.test(pathname)) {
pathname = pathname.substr(0, pathname.length - 1);
}
Ox.forEach(regexps, function(fn, re) {
re = new RegExp(re);
if (re.test(pathname)) {
Ox.print('URL re ' + re);
fn(pathname, search, function() {
pandora.Query.updateGroups();
pandora.user.ui.showHome = false;
callback();
});
return false;
}
});
},
push: function(title, url) {
if (arguments.length == 1) { // fixme: remove later
url = title;
}
if (url[0] != '/') {
url = '/' + url;
}
saveURL();
history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url);
},
pushPrevious: function() {
history.pushState({}, '', previousURL);
},
set: function(title, url) {
if (arguments.length == 1) { // fixme: remove later
url = title;
}
if (url[0] != '/') {
url = '/' + url;
}
history.pushState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url);
updateURL();
},
replace: function(title, url) {
if (arguments.length == 1) { // fixme: remove later
url = title;
}
if (url[0] != '/') {
url = '/' + url;
}
saveURL();
history.replaceState({}, pandora.site.site.name + (title ? ' - ' + title : ''), url);
},
update: function() {
this.set(pandora.Query.toString());
}
*/
}());

View file

@ -284,7 +284,10 @@ pandora.getFoldersHeight = function() {
pandora.getFoldersWidth = function() {
var width = pandora.user.ui.sidebarSize;
// fixme: don't use height(), look up in splitpanels
if (pandora.getFoldersHeight() > pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height()) {
if (
/*pandora.$ui.appPanel
&&*/ pandora.getFoldersHeight() > pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height()
) {
width -= Ox.UI.SCROLLBAR_SIZE;
}
return width;
@ -319,7 +322,7 @@ pandora.getItemByIdOrTitle = function(str, callback) {
} else {
pandora.api.find({
query: {
conditions: [{key: 'title', value: str, operator: ''}], // fixme: operator will be "="
conditions: [{key: 'title', value: str, operator: '='}],
operator: '&'
},
sort: [{key: 'votes', operator: ''}], // fixme: not all systems have "votes"
@ -356,9 +359,11 @@ pandora.getListData = function() {
return false;
}
});
data = pandora.$ui.folderList[folder].value(pandora.user.ui._list);
data.editable = data.user == pandora.user.username && data.type == 'static';
data.folder = folder;
if (folder) {
data = pandora.$ui.folderList[folder].value(pandora.user.ui._list);
data.editable = data.user == pandora.user.username && data.type == 'static';
data.folder = folder;
}
}
return data;
};
@ -558,7 +563,7 @@ pandora.selectList = function() {
pandora.api.findLists({
keys: ['status', 'user'],
query: {
conditions: [{key: 'id', value: pandora.user.ui._list, operator: '='}],
conditions: [{key: 'id', value: pandora.user.ui._list, operator: '=='}],
operator: ''
},
range: [0, 1]

View file

@ -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 = {};

View file

@ -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);
}

View file

@ -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, {

View file

@ -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

View file

@ -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);
}
});
}

View file

@ -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();
}
}
})

View file

@ -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,

View file

@ -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);

View file

@ -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: '='}

View file

@ -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
})