hook up url controller to ui controller

This commit is contained in:
rolux 2011-09-26 19:17:39 +00:00
parent 56c156d3f6
commit 4da5a6ca84
11 changed files with 44 additions and 81 deletions

View file

@ -549,6 +549,7 @@
"columnWidth": {} "columnWidth": {}
} }
}, },
"editIcon": false,
"find": {"conditions": [], "operator": "&"}, "find": {"conditions": [], "operator": "&"},
"groups": [ "groups": [
{"id": "director", "sort": [{"key": "items", "operator": "-"}]}, {"id": "director", "sort": [{"key": "items", "operator": "-"}]},

View file

@ -90,7 +90,7 @@ Ox.load({
pandora.site.listSettings = {}; pandora.site.listSettings = {};
Ox.map(pandora.site.user.ui, function(val, key) { Ox.map(pandora.site.user.ui, function(val, key) {
if (/^list[A-Z]/.test(key)) { if (/^list[A-Z]/.test(key)) {
pandora.site.listSettings[key] = key[0].toLowerCase() + key.substr(1); pandora.site.listSettings[key] = key[4].toLowerCase() + key.substr(5);
} }
}); });
if (Ox.isEmpty(pandora.user.ui.lists)) { if (Ox.isEmpty(pandora.user.ui.lists)) {
@ -98,7 +98,7 @@ Ox.load({
Ox.forEach(pandora.site.listSettings, function(listSetting, setting) { Ox.forEach(pandora.site.listSettings, function(listSetting, setting) {
listSettings[listSetting] = pandora.site.user.ui[setting]; listSettings[listSetting] = pandora.site.user.ui[setting];
}); });
pandora.UI.set('lists|', listSettings); pandora.UI.set('lists.', listSettings);
} }
Ox.extend(pandora.user, { Ox.extend(pandora.user, {

View file

@ -20,12 +20,21 @@ pandora.UI = (function() {
self.previousUI = Ox.clone(pandora.user.ui, true); self.previousUI = Ox.clone(pandora.user.ui, true);
Ox.forEach(obj, function(val, key) { Ox.forEach(obj, function(val, key) {
var listSettings = pandora.site.listSettings var listSettings = pandora.site.listSettings
if (key == 'list' && !pandora.user.ui.lists[val]) { if (key == 'list') {
// add default list settings if (!pandora.user.ui.lists[val]) {
obj['lists.' + that.encode(val)] = {}; obj['lists.' + that.encode(val)] = {};
}
Ox.forEach(listSettings, function(listSetting, setting) { Ox.forEach(listSettings, function(listSetting, setting) {
obj['lists.' + that.encode(val)][listSetting] = pandora.site.user.ui[setting]; if (!pandora.user.ui.lists[val]) {
// add default list settings and copy to settings
obj['lists.' + that.encode(val)][listSetting] = pandora.site.user.ui[setting];
obj[setting] = pandora.site.user.ui[setting];
} else {
// copy list settings to setting
obj[setting] = pandora.user.ui.lists[val][listSetting];
}
}); });
Ox.forEach()
} else if (Object.keys(listSettings).indexOf(key) > -1) { } else if (Object.keys(listSettings).indexOf(key) > -1) {
// add list setting // add list setting
obj['lists.' + that.encode(pandora.user.ui.list) + '.' + listSettings[key]] = val; obj['lists.' + that.encode(pandora.user.ui.list) + '.' + listSettings[key]] = val;
@ -52,9 +61,12 @@ pandora.UI = (function() {
} else { } else {
ui[keys[i]] = val; ui[keys[i]] = val;
} }
// set[key] = val; if (key[0] != '_') {
// fixme: remove later // don't send private keys
set[key.replace(/\./g, '|')] = val; // set[key] = val;
// fixme: remove later
set[key.replace(/\./g, '|')] = val;
}
} }
}); });
if (Ox.len(set)) { if (Ox.len(set)) {

View file

@ -555,6 +555,12 @@ pandora.URL = (function() {
views: views views: views
}); });
['item', 'itemSort', 'itemView', 'list', 'listSort', 'listView'].forEach(function(event) {
pandora.UI.bind(event, function() {
that.push();
});
});
return that; return that;
}; };
@ -586,7 +592,7 @@ pandora.URL = (function() {
var state = getState(); var state = getState();
Ox.print('&&&&&&&', state) Ox.print('&&&&&&&', state)
self.URL.push(state); self.URL.push(state);
setState(state); //setState(state);
} }
return that; return that;
}; };

View file

@ -32,6 +32,9 @@ pandora.ui.contentPanel = function() {
listView: function() { listView: function() {
that.replaceElement(1, pandora.$ui.list = pandora.ui.list()); that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
}, },
item: function() {
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());
} }

View file

@ -127,7 +127,7 @@ pandora.ui.home = function() {
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
pandora.URL.push(); //pandora.URL.push();
that.fadeOutScreen(); that.fadeOutScreen();
} }
}) })

View file

@ -18,14 +18,13 @@ pandora.ui.infoView = function(data) {
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = pandora.user.ui.icons == 'posters' ? 0 : iconSize / 8, borderRadius = pandora.user.ui.icons == 'posters' ? 0 : iconSize / 8,
edit = false,
that = Ox.Element(), that = Ox.Element(),
uid = Ox.uid(), uid = Ox.uid(),
$list, $list,
$info = $('<div>') $info = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
left: pandora.user.level == 'admin' ? -listWidth + 'px' : 0, left: pandora.user.level == 'admin' && !pandora.user.ui.editPoster ? -listWidth + 'px' : 0,
top: 0, top: 0,
right: 0, right: 0,
}) })
@ -328,16 +327,15 @@ pandora.ui.infoView = function(data) {
$icon.bindEvent({ $icon.bindEvent({
doubleclick: function() { doubleclick: function() {
if (!edit) { pandora.UI.set('editPoster', !pandora.user.ui.editPoster);
if (pandora.user.ui.editPoster) {
$info.animate({ $info.animate({
left: 0 left: 0
}, 250); }, 250);
edit = true;
} else { } else {
$info.animate({ $info.animate({
left: -listWidth + 'px' left: -listWidth + 'px'
}, 250); }, 250);
edit = false;
} }
} }
}); });
@ -367,7 +365,6 @@ pandora.ui.infoView = function(data) {
id: data.id, id: data.id,
keys: [pandora.user.ui.icons == 'posters' ? 'posters' : 'frames'] keys: [pandora.user.ui.icons == 'posters' ? 'posters' : 'frames']
}, 0, function(result) { }, 0, function(result) {
Ox.print('RESULT', result.data)
var images = result.data[pandora.user.ui.icons == 'posters' ? 'posters' : 'frames'], var images = result.data[pandora.user.ui.icons == 'posters' ? 'posters' : 'frames'],
selectedImage = images.filter(function(image) { selectedImage = images.filter(function(image) {
return image.selected; return image.selected;

View file

@ -80,54 +80,6 @@ pandora.ui.item = function() {
} }
}); });
} else if (pandora.user.ui.itemView == 'clips') {
var ratio = result.data.stream.aspectRatio;
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({
fixedRatio: ratio,
item: function(data, sort, size) {
size = size || 128;
var width = ratio > 1 ? size : Math.round(size * ratio),
height = ratio > 1 ? Math.round(size / ratio) : size,
url = '/' + pandora.user.ui.item + '/' + height + 'p' + data['in'] + '.jpg';
return {
height: height,
id: data['id'],
info: Ox.formatDuration(data['in'], 'short') + ' - ' + Ox.formatDuration(data['out'], 'short'),
title: data.value,
url: url,
width: width
};
},
items: function(data, callback) {
pandora.api.findAnnotations(Ox.extend(data, {
itemQuery: {
conditions:[{
key: 'id',
value: pandora.user.ui.item,
operator: '='
}]
}
}), callback);
},
keys: ['id', 'value', 'in', 'out'],
size: 128,
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
unique: 'id'
}).bindEvent({
open: function(data) {
var id = data.ids[0],
item = pandora.user.ui.item,
points = {
'in': pandora.$ui.clips.value(id, 'in'),
out: pandora.$ui.clips.value(id, 'out')
};
pandora.UI.set('videoPoints|' + item, Ox.extend(points, {
position: points['in']
}));
pandora.URL.set(item + '/timeline');
}
}));
} else if (pandora.user.ui.itemView == 'info') { } else if (pandora.user.ui.itemView == 'info') {
//Ox.print('result.data', result.data) //Ox.print('result.data', result.data)
if (pandora.user.level == 'admin' && false) { if (pandora.user.level == 'admin' && false) {
@ -196,7 +148,6 @@ pandora.ui.item = function() {
} else if (pandora.user.ui.itemView == 'clips') { } else if (pandora.user.ui.itemView == 'clips') {
var ratio = result.data.videoRatio; var ratio = result.data.videoRatio;
Ox.print('RATIO', ratio)
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({ pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({
fixedRatio: ratio, fixedRatio: ratio,
item: function(data, sort, size) { item: function(data, sort, size) {
@ -214,7 +165,6 @@ pandora.ui.item = function() {
}; };
}, },
items: function(data, callback) { items: function(data, callback) {
Ox.print('DATA', data)
pandora.api.findAnnotations(Ox.extend(data, { pandora.api.findAnnotations(Ox.extend(data, {
itemQuery: { itemQuery: {
conditions:[{ conditions:[{
@ -241,7 +191,7 @@ pandora.ui.item = function() {
})); }));
pandora.UI.set({ pandora.UI.set({
itemView: pandora.user.ui.videoView itemView: pandora.user.ui.videoView
}) });
}, },
// fixme: duplicated // fixme: duplicated
openpreview: function(data) { openpreview: function(data) {

View file

@ -507,7 +507,7 @@ pandora.ui.list = function() {
}); });
pandora.api.findEvents({ pandora.api.findEvents({
itemQuery: pandora.user.ui.query, itemQuery: pandora.user.ui.find,
keys: ['id', 'name', 'start', 'end'], keys: ['id', 'name', 'start', 'end'],
query: {} query: {}
}, function(result) { }, function(result) {
@ -675,10 +675,6 @@ pandora.ui.list = function() {
} }
that.display = function() { // fixme: used?
pandora.$ui.rightPanel.replaceElement(1, pandora.$ui.contentPanel = pandora.ui.contentPanel());
};
pandora.UI.bind({ pandora.UI.bind({
listSort: function(value) { listSort: function(value) {
that.options({sort: value}); that.options({sort: value});

View file

@ -70,7 +70,7 @@ pandora.ui.mainMenu = function() {
]}, ]},
{}, {},
{ id: 'openmovie', title: ['Open ' + pandora.site.itemName.singular, 'Open ' + pandora.site.itemName.plural], items: [ { id: 'openmovie', title: ['Open ' + pandora.site.itemName.singular, 'Open ' + pandora.site.itemName.plural], items: [
{ group: 'movieview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) { { group: 'itemview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) {
return Ox.extend({ return Ox.extend({
checked: ui.itemView == view.id, checked: ui.itemView == view.id,
}, view); }, view);
@ -151,13 +151,8 @@ pandora.ui.mainMenu = function() {
var value = data.checked[0] ? data.checked[0].id : null; var value = data.checked[0] ? data.checked[0].id : null;
if (data.id == 'find') { if (data.id == 'find') {
pandora.$ui.findSelect.options({value: value}); pandora.$ui.findSelect.options({value: value});
} else if (data.id == 'movieview') { } else if (data.id == 'itemview') {
var id = document.location.pathname.split('/')[1]; pandora.UI.set({itemView: value});
// fixme: what's this?
if (value == 'info')
url(id + '/info');
else
url(id);
} else if (Ox.startsWith(data.id, 'ordergroup')) { } else if (Ox.startsWith(data.id, 'ordergroup')) {
var groups = Ox.clone(pandora.user.ui.groups), var groups = Ox.clone(pandora.user.ui.groups),
id = data.id.replace('ordergroup', ''), id = data.id.replace('ordergroup', ''),

View file

@ -58,6 +58,9 @@ pandora.ui.rightPanel = function() {
}); });
} }
pandora.UI.bind({ pandora.UI.bind({
list: function() {
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());