This commit is contained in:
j 2011-09-29 13:31:07 +02:00
commit 219a5bbf32
21 changed files with 294 additions and 446 deletions

View file

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

View file

@ -96,9 +96,7 @@ def parseConditions(conditions, operator, user):
conn.append(q) conn.append(q)
pass pass
else: else:
if condition.get('value', '') != '' or \ conn.append(parseCondition(condition, user))
condition.get('operator', '') == '=':
conn.append(parseCondition(condition, user))
if conn: if conn:
q = conn[0] q = conn[0]
for c in conn[1:]: for c in conn[1:]:

View file

@ -46,9 +46,7 @@ def parseConditions(conditions, operator, user):
conn.append(q) conn.append(q)
pass pass
else: else:
if condition.get('value', '') != '' or \ conn.append(parseCondition(condition, user))
condition.get('operator', '') == '=':
conn.append(parseCondition(condition, user))
if conn: if conn:
q = conn[0] q = conn[0]
for c in conn[1:]: for c in conn[1:]:

View file

@ -98,7 +98,8 @@ def parseCondition(condition):
elif key_type == 'list': elif key_type == 'list':
q = Q(itemId=False) q = Q(itemId=False)
l = v.split(":") 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])) lqs = list(List.objects.filter(name=l[1], user__username=l[0]))
if len(lqs) == 1: if len(lqs) == 1:
l = lqs[0] l = lqs[0]
@ -165,9 +166,7 @@ def parseConditions(conditions, operator):
conn.append(q) conn.append(q)
pass pass
else: else:
if condition.get('value', '') != '' or \ conn.append(parseCondition(condition))
condition.get('operator', '') == '=':
conn.append(parseCondition(condition))
if conn: if conn:
q = conn[0] q = conn[0]
for c in conn[1:]: for c in conn[1:]:

View file

@ -9,16 +9,8 @@ import models
def parseCondition(condition, user): def parseCondition(condition, user):
''' '''
condition: {
value: "war"
}
or
condition: {
key: "year",
value: "1970-1980,
operator: "!="
}
''' '''
print condition, user
k = condition.get('key', 'name') k = condition.get('key', 'name')
k = { k = {
'user': 'user__username', 'user': 'user__username',
@ -29,15 +21,16 @@ def parseCondition(condition, user):
v = condition['value'] v = condition['value']
op = condition.get('operator') op = condition.get('operator')
if not op: if not op:
op = '' op = '='
if op.startswith('!'): if op.startswith('!'):
op = op[1:] op = op[1:]
exclude = True exclude = True
else: else:
exclude = False exclude = False
if k == 'id': if k == 'id':
v = v.split(':') v = v.split(":")
if len(v) == 2: if len(v) >= 2:
v = (v[0], ":".join(v[1:]))
q = Q(user__username=v[0], name=v[1]) q = Q(user__username=v[0], name=v[1])
else: else:
q = Q(id__in=[]) q = Q(id__in=[])
@ -53,7 +46,6 @@ def parseCondition(condition, user):
'^': '__istartswith', '^': '__istartswith',
'$': '__iendswith', '$': '__iendswith',
}.get(op, '__icontains')) }.get(op, '__icontains'))
key = str(key) key = str(key)
if exclude: if exclude:
q = ~Q(**{key: v}) q = ~Q(**{key: v})
@ -89,9 +81,7 @@ def parseConditions(conditions, operator, user):
conn.append(q) conn.append(q)
pass pass
else: else:
if condition.get('value', '') != '' or \ conn.append(parseCondition(condition, user))
condition.get('operator', '') == '=':
conn.append(parseCondition(condition, user))
if conn: if conn:
q = conn[0] q = conn[0]
for c in conn[1:]: for c in conn[1:]:
@ -142,4 +132,4 @@ class ListManager(Manager):
qs = qs.filter(Q(status='public') | Q(status='featured')) qs = qs.filter(Q(status='public') | Q(status='featured'))
else: else:
qs = qs.filter(Q(status='public') | Q(status='featured') | Q(user=user)) 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 from item.models import Item
def get_list_or_404_json(id): 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) return get_object_or_404_json(models.List, user__username=username, name=listname)
def _order_query(qs, sort): def _order_query(qs, sort):
@ -94,7 +96,6 @@ def findLists(request):
else: else:
qs = _order_query(query['qs'], query['sort']) qs = _order_query(query['qs'], query['sort'])
#range
response = json_response() response = json_response()
if 'keys' in data: if 'keys' in data:
qs = qs[query['range'][0]:query['range'][1]] qs = qs[query['range'][0]:query['range'][1]]

View file

@ -92,9 +92,7 @@ def parseConditions(conditions, operator, user):
conn.append(q) conn.append(q)
pass pass
else: else:
if condition.get('value', '') != '' or \ conn.append(parseCondition(condition, user))
condition.get('operator', '') == '=':
conn.append(parseCondition(condition, user))
if conn: if conn:
q = conn[0] q = conn[0]
for c in conn[1:]: for c in conn[1:]:

View file

@ -47,9 +47,7 @@ def parseConditions(conditions, operator, user):
conn.append(q) conn.append(q)
pass pass
else: else:
if condition.get('value', '') != '' or \ conn.append(parseCondition(condition, user))
condition.get('operator', '') == '=':
conn.append(parseCondition(condition, user))
if conn: if conn:
q = conn[0] q = conn[0]
for c in conn[1:]: for c in conn[1:]:

View file

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

View file

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

View file

@ -4,120 +4,87 @@ pandora.URL = (function() {
var self = {}, that = {}; var self = {}, that = {};
/* function getState(keys) {
function foundItem() { Ox.print('KEYS', keys)
pandora.UI.set(Ox.extend({ var state = {};
section: 'items', /*
item: item, if (keys.indexOf('type') > -1) {
itemView: view state.type = pandora.user.ui.section == 'items'
}, ['video', 'timeline'].indexOf(view) > -1 ? { ? pandora.site.itemsSection
videoView: view : pandora.user.ui.section;
} : {}));
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 foundTime() { */
if (time) { state.type = pandora.site.itemsSection;
// fixme: this is duplicated, see Ox.VideoPlayer() parsePositionInput() if (!keys || keys.indexOf('item') > -1) {
points = points.map(function(point, i) { state.item = pandora.user.ui.item;
var parts = point.split(':').reverse(); }
while (parts.length > 3) { if (!keys || keys.indexOf('listView') > -1 || keys.indexOf('itemView') > -1) {
parts.pop(); if (!pandora.user.ui.item) {
} state.view = pandora.user.ui.listView;
return parts.reduce(function(prev, curr, i) { } else {
return prev + (parseFloat(curr) || 0) * Math.pow(60, i); state.item = pandora.user.ui.item;
}, 0); state.view = pandora.user.ui.itemView;
}); }
pandora.UI.set('videoPoints|' + item, { }
'in': points.length == 1 ? 0 : points[points.length - 2], if (!keys || keys.filter(function(key) {
out: points.length == 1 ? 0 : points[points.length - 1], return /^videoPoints/.test(key);
position: points[0], }).length) {
}); var videoPoints = pandora.user.ui.videoPoints;
points = points.map(function(point) { state.item = pandora.user.ui.item;
return point == -1 ? '' : Ox.formatDuration(point, 3).replace(/\.000$/, ''); state.view = pandora.user.ui.itemView;
}); state.span = [];
split[split.length - 1] = points[0] + ( if (
points.length == 1 ? '' : ',' + points[1] + '-' + points[2] 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();
}
} }
} 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;
function getState() { } else {
return { state.item = pandora.user.ui.item;
type: pandora.user.ui.section == 'items' state.view = pandora.user.ui.itemView;
? pandora.site.itemsSection state.sort = pandora.user.ui.itemSort;
: pandora.user.ui.section, }
item: pandora.user.ui.item, /*
view: !pandora.user.ui.item : pandora.isClipView(pandora.user.ui.itemView)
? pandora.user.ui.listView ? pandora.user.ui.itemSort : [],
: pandora.user.ui.itemView, */
sort: !pandora.user.ui.item }
? pandora.user.ui.listSort if (!state.item) {
: pandora.isClipView(pandora.user.ui.itemView) state.find = pandora.user.ui.find;
? pandora.user.ui.itemSort : [], }
find: !pandora.user.ui.item Ox.print('STATE .................... ->', state)
? pandora.user.ui.find return state;
: ''
};
} }
function setState(state) { function setState(state, callback) {
Ox.print('STATE:', state)
var previousUI = pandora.UI.getPrevious(); Ox.print('SET STATE:', state)
// var previousUI = Ox.clone(pandora.user.ui); var find, previousUI = pandora.UI.getPrevious();
Ox.Request.cancel(); Ox.Request.cancel();
$('video').each(function() { $('video').each(function() {
$(this).trigger('stop'); $(this).trigger('stop');
}); });
pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find); pandora.user.ui._groupsState = pandora.getGroupsState(pandora.user.ui.find);
pandora.user.ui._findState = pandora.getFindState(pandora.user.ui.find); 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();
/* /*
@ -127,12 +94,17 @@ pandora.URL = (function() {
); );
*/ */
} else { } else {
/*
pandora.UI.set({ pandora.UI.set({
section: 'items', section: 'items',
item: '' item: ''
}); });
*/
} }
callback && callback();
} else if (state.page) { } else if (state.page) {
if (state.page == 'home') { if (state.page == 'home') {
//pandora.$ui.home = pandora.ui.home().showScreen(); //pandora.$ui.home = pandora.ui.home().showScreen();
pandora.$ui.home = pandora.ui.home().fadeInScreen(); pandora.$ui.home = pandora.ui.home().fadeInScreen();
@ -159,6 +131,8 @@ pandora.URL = (function() {
} else if (state.page == 'api') { } else if (state.page == 'api') {
document.location.href = '/api/'; document.location.href = '/api/';
} }
callback && callback();
} else { } else {
var set = { var set = {
@ -168,11 +142,21 @@ pandora.URL = (function() {
}; };
if (state.view) { 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) { if (state.sort) {
set[!pandora.user.ui.item ? 'listSort' : 'itemSort'] = state.sort; set[!state.item ? 'listSort' : 'itemSort'] = state.sort;
} }
///* ///*
@ -186,173 +170,32 @@ pandora.URL = (function() {
} }
//*/ //*/
if (['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) { if (!pandora.$ui.appPanel && state.item && pandora.user.ui.find) {
if (state.span) { // on page load, if item is set and there is or was a query,
set['videoPoints.' + pandora.user.ui.item] = { // we have to check if the item actually matches the query,
position: state.span[0], // and otherwise reset find
'in': state.span[1] || 0, pandora.api.find({
out: state.span[2] || 0 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]) { pandora.UI.set(set);
set['videoPoints.' + pandora.user.ui.item] = { callback && callback();
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());
} else { } else {
// item to item pandora.UI.set(set);
if (pandora.user.ui.item != previousUI.item) { callback && callback();
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')
);
}
*/
} }
pandora.user.ui.showHome = false; 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() { that.init = function() {
var itemsSection = pandora.site.itemsSection, var itemsSection = pandora.site.itemsSection,
@ -400,7 +243,7 @@ pandora.URL = (function() {
// itemSort[0].key is the default sort key // itemSort[0].key is the default sort key
[Ox.getObjectById(pandora.site.clipKeys, pandora.user.ui.itemSort[0].key)], [Ox.getObjectById(pandora.site.clipKeys, pandora.user.ui.itemSort[0].key)],
Ox.map(pandora.site.clipKeys, function(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 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; return that;
}; };
@ -446,8 +304,7 @@ pandora.URL = (function() {
document.location.href = decodeURI(document.location.pathname.substr(4)); document.location.href = decodeURI(document.location.pathname.substr(4));
} else { } else {
self.URL.parse(function(state) { self.URL.parse(function(state) {
setState(state); setState(state, callback);
callback();
}); });
} }
return that; return that;
@ -460,14 +317,11 @@ pandora.URL = (function() {
// pushes a new URL (as string or from state) // pushes a new URL (as string or from state)
that.push = function(url) { that.push = function(url) {
Ox.print('push', arguments[0])
if (url) { if (url) {
self.URL.push(url, setState); self.URL.push(null, '', url, setState);
} else { } else {
var state = getState(); alert('DO YOU REALLY WANT TO CALL PUSH WITHOUT URL?')
Ox.print('&&&&&&&', state) //self.URL.push(getState());
self.URL.push(state);
//setState(state);
} }
return that; return that;
}; };
@ -475,77 +329,32 @@ pandora.URL = (function() {
// replaces the current URL (as string or from state) // replaces the current URL (as string or from state)
that.replace = function(url) { that.replace = function(url) {
if (url) { if (url) {
self.URL.replace(url, setState) self.URL.replace(null, '', url, setState)
} else { } else {
self.URL.replace(getState()); self.URL.replace(getState());
} }
return that; 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; 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() { pandora.getFoldersWidth = function() {
var width = pandora.user.ui.sidebarSize; var width = pandora.user.ui.sidebarSize;
// fixme: don't use height(), look up in splitpanels // 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; width -= Ox.UI.SCROLLBAR_SIZE;
} }
return width; return width;
@ -319,7 +322,7 @@ pandora.getItemByIdOrTitle = function(str, callback) {
} else { } else {
pandora.api.find({ pandora.api.find({
query: { query: {
conditions: [{key: 'title', value: str, operator: ''}], // fixme: operator will be "=" conditions: [{key: 'title', value: str, operator: '='}],
operator: '&' operator: '&'
}, },
sort: [{key: 'votes', operator: ''}], // fixme: not all systems have "votes" sort: [{key: 'votes', operator: ''}], // fixme: not all systems have "votes"
@ -356,9 +359,11 @@ pandora.getListData = function() {
return false; return false;
} }
}); });
data = pandora.$ui.folderList[folder].value(pandora.user.ui._list); if (folder) {
data.editable = data.user == pandora.user.username && data.type == 'static'; data = pandora.$ui.folderList[folder].value(pandora.user.ui._list);
data.folder = folder; data.editable = data.user == pandora.user.username && data.type == 'static';
data.folder = folder;
}
} }
return data; return data;
}; };
@ -558,7 +563,7 @@ pandora.selectList = function() {
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]

View file

@ -97,6 +97,9 @@ pandora.ui.browser = function() {
defaultRatio: data.value == 'posters' ? 5/8 : 1 defaultRatio: data.value == 'posters' ? 5/8 : 1
}).reloadList(true); }).reloadList(true);
}, },
pandora_item: function(data) {
that.options({selected: [data.value]});
},
pandora_showsiteposter: function() { pandora_showsiteposter: function() {
pandora.user.ui.icons == 'posters' && that.reloadList(true); pandora.user.ui.icons == 'posters' && that.reloadList(true);
} }

View file

@ -50,10 +50,10 @@ pandora.ui.folderBrowserBar = function(id) {
items: function(data, callback) { items: function(data, callback) {
var query = id == 'favorite' ? {conditions: [ var query = id == 'favorite' ? {conditions: [
{key: 'status', value: 'public', operator: '='}, {key: 'status', value: 'public', operator: '='},
{key: 'user', value: pandora.user.username, operator: '!'}, {key: 'user', value: pandora.user.username, operator: '!=='},
{key: key, value: value, operator: ''} {key: key, value: value, operator: ''}
], operator: '&'} : {conditions: [ ], operator: '&'} : {conditions: [
{key: 'status', value: 'private', operator: '!'}, {key: 'status', value: 'private', operator: '!='},
{key: key, value: value, operator: ''} {key: key, value: value, operator: ''}
], operator: '&'}; ], operator: '&'};
return pandora.api.findLists(Ox.extend(data, { return pandora.api.findLists(Ox.extend(data, {

View file

@ -117,9 +117,9 @@ pandora.ui.folderBrowserList = function(id) {
items: function(data, callback) { items: function(data, callback) {
var query = id == 'favorite' ? {conditions: [ var query = id == 'favorite' ? {conditions: [
{key: 'status', value: 'public', operator: '='}, {key: 'status', value: 'public', operator: '='},
{key: 'user', value: pandora.user.username, operator: '!'} {key: 'user', value: pandora.user.username, operator: '!=='}
], operator: '&'} : {conditions: [ ], operator: '&'} : {conditions: [
{key: 'status', value: 'private', operator: '!'} {key: 'status', value: 'private', operator: '!='}
], operator: ''}; ], operator: ''};
return pandora.api.findLists(Ox.extend(data, { return pandora.api.findLists(Ox.extend(data, {
query: query query: query

View file

@ -119,17 +119,17 @@ pandora.ui.folderList = function(id) {
var query; var query;
if (id == 'personal') { if (id == 'personal') {
query = {conditions: [ query = {conditions: [
{key: 'user', value: pandora.user.username, operator: '='}, {key: 'user', value: pandora.user.username, operator: '=='},
{key: 'status', value: 'featured', operator: '!'} {key: 'status', value: 'featured', operator: '!='}
], operator: '&'}; ], operator: '&'};
} else if (id == 'favorite') { } else if (id == 'favorite') {
query = {conditions: [ query = {conditions: [
{key: 'subscribed', value: true, operator: '='}, {key: 'subscribed', value: true, operator: '='},
{key: 'status', value: 'featured', operator: '!'}, {key: 'status', value: 'featured', operator: '!='},
], operator: '&'}; ], operator: '&'};
} else if (id == 'featured') { } else if (id == 'featured') {
query = {conditions: [ query = {conditions: [
{key: 'status', value: 'featured', operator: '='} {key: 'status', value: 'featured', operator: '='} // fixme: '==' performs better
], operator: '&'}; ], operator: '&'};
} }
return pandora.api.findLists(Ox.extend(data, { return pandora.api.findLists(Ox.extend(data, {
@ -263,8 +263,12 @@ pandora.ui.folderList = function(id) {
type: event.keys == '' ? 'static' : 'smart' type: event.keys == '' ? 'static' : 'smart'
}, function(result) { }, function(result) {
var id = result.data.id; var id = result.data.id;
pandora.UI.set('lists.' + id, pandora.site.user.ui.lists['']); // fixme: necessary? pandora.UI.set({
pandora.URL.set('?find=list:' + id) find: {
conditions: [{key: 'list', value: id, operator: '=='}],
operator: '&'
}
});
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
that.reloadList().bindEventOnce({ that.reloadList().bindEventOnce({
load: function(data) { load: function(data) {
@ -313,19 +317,47 @@ pandora.ui.folderList = function(id) {
} }
}, },
'delete': function(data) { 'delete': function(data) {
// fixme: add a confirmation dialog
//var $list = pandora.$ui.folderList[id];
pandora.URL.set('?find=');
that.options({selected: []});
if (id == 'personal') { if (id == 'personal') {
pandora.api.removeList({ var $dialog = Ox.Dialog({
id: data.ids[0] buttons: [
}, function(result) { Ox.Button({
pandora.UI.set('lists.' + data.ids[0], null); id: 'cancel',
Ox.Request.clearCache(); // fixme: remove title: 'Cancel'
that.reloadList(); }).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') { } else if (id == 'favorite') {
that.options({selected: []});
pandora.api.unsubscribeFromList({ pandora.api.unsubscribeFromList({
id: data.ids[0] id: data.ids[0]
}, function(result) { }, function(result) {
@ -333,6 +365,7 @@ pandora.ui.folderList = function(id) {
that.reloadList(); that.reloadList();
}); });
} else if (id == 'featured' && pandora.user.level == 'admin') { } else if (id == 'featured' && pandora.user.level == 'admin') {
that.options({selected: []});
pandora.api.editList({ pandora.api.editList({
id: data.ids[0], id: data.ids[0],
status: 'public' status: 'public'
@ -392,11 +425,15 @@ pandora.ui.folderList = function(id) {
data_ = {id: data.id}; data_ = {id: data.id};
data_[data.key] = data.value; data_[data.key] = data.value;
pandora.api.editList(data_, function(result) { pandora.api.editList(data_, function(result) {
// fixme: we may want slashes in list names
if (result.data.id != data.id) { if (result.data.id != data.id) {
pandora.$ui.folderList[id].value(data.id, 'name', result.data.name); pandora.$ui.folderList[id].value(data.id, 'name', result.data.name);
pandora.$ui.folderList[id].value(data.id, 'id', result.data.id); 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' type: data.id == 'new' ? 'static' : 'smart'
}, function(result) { }, function(result) {
var id = result.data.id; var id = result.data.id;
pandora.UI.set('lists.' + id, pandora.site.user.ui.lists['']); // fixme: necessary? pandora.UI.set({
pandora.URL.set('?find=list:' + id) find: {
conditions: [{key: 'list', value: id, operator: '=='}],
operator: '&'
}
});
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({ $list.reloadList().bindEventOnce({
load: function(data) { load: function(data) {
@ -235,7 +239,7 @@ pandora.ui.folders = function() {
that.append($folder); that.append($folder);
}); });
pandora.resizeFolders(); 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') { } else if (pandora.user.ui.itemView == 'clips') {
var ratio = result.data.videoRatio; var ratio = result.data.videoRatio;
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({ pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({
@ -266,7 +257,7 @@ pandora.ui.item = function() {
if (data.ids.length) { if (data.ids.length) {
var id = data.ids[0], var id = data.ids[0],
item = id.split('/')[0], width, height, 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'); $video = $('.OxItem.OxSelected > .OxIcon > .OxVideoPlayer');
if ($img.length) { if ($img.length) {
var width = ratio > 1 ? 128 : Math.round(128 * ratio), var width = ratio > 1 ? 128 : Math.round(128 * ratio),
@ -587,6 +578,14 @@ pandora.ui.item = function() {
} else if (pandora.user.ui.itemView == 'calendar') { } else if (pandora.user.ui.itemView == 'calendar') {
pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('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') { } else if (pandora.user.ui.itemView == 'files') {
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.contentPanel.replaceElement(1,

View file

@ -130,17 +130,12 @@ pandora.ui.list = function() {
}, },
sort: function(data) { sort: function(data) {
Ox.print('---- SORT ----', 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({ pandora.UI.set({
listSort: [{key: data.key, operator: data.operator}] listSort: [{key: data.key, operator: data.operator}]
}); });
pandora.URL.push();
} }
}); });
} else if (view == 'grid') { } else if (view == 'grid') {
//alert(JSON.stringify(pandora.user.ui.lists[pandora.user.ui.list].selected))
that = Ox.IconList({ that = Ox.IconList({
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16, borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16,
defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1, defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1,
@ -164,7 +159,6 @@ pandora.ui.list = function() {
}; };
}, },
items: function(data, callback) { items: function(data, callback) {
//Ox.print('data, pandora.Query.toObject', data, pandora.Query.toObject())
pandora.api.find(Ox.extend(data, { pandora.api.find(Ox.extend(data, {
query: pandora.user.ui.find query: pandora.user.ui.find
}), callback); }), callback);

View file

@ -330,12 +330,12 @@ pandora.ui.mainMenu = function() {
queries = { queries = {
// fixme: duplicated // fixme: duplicated
personal: {conditions: [ personal: {conditions: [
{key: 'user', value: pandora.user.username, operator: '='}, {key: 'user', value: pandora.user.username, operator: '=='},
{key: 'status', value: 'featured', operator: '!'} {key: 'status', value: 'featured', operator: '!='}
], operator: '&'}, ], operator: '&'},
favorite: {conditions: [ favorite: {conditions: [
{key: 'subscribed', value: true, operator: '='}, {key: 'subscribed', value: true, operator: '='},
{key: 'status', value: 'featured', operator: '!'}, {key: 'status', value: 'featured', operator: '!='},
], operator: '&'}, ], operator: '&'},
featured: {conditions: [ featured: {conditions: [
{key: 'status', value: 'featured', operator: '='} {key: 'status', value: 'featured', operator: '='}

View file

@ -4,11 +4,15 @@ pandora.ui.viewSelect = function() {
var viewKey = !pandora.user.ui.item ? 'listView' : 'itemView', var viewKey = !pandora.user.ui.item ? 'listView' : 'itemView',
that = Ox.Select({ that = Ox.Select({
id: 'viewSelect', id: 'viewSelect',
items: pandora.site[viewKey + 's'].map(function(view) { items: Ox.map(pandora.site[viewKey + 's'], function(view) {
return Ox.extend(Ox.clone(view), { return viewKey == 'listView'
checked: view.id == pandora.user.ui[viewKey], || ['data', 'files'].indexOf(view.id) == -1
title: 'View ' + view.title || 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 width: !pandora.user.ui.item ? 144 : 128
}) })