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": {}
}
},
"editIcon": false,
"find": {"conditions": [], "operator": "&"},
"groups": [
{"id": "director", "sort": [{"key": "items", "operator": "-"}]},

View file

@ -90,7 +90,7 @@ Ox.load({
pandora.site.listSettings = {};
Ox.map(pandora.site.user.ui, function(val, 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)) {
@ -98,7 +98,7 @@ Ox.load({
Ox.forEach(pandora.site.listSettings, function(listSetting, setting) {
listSettings[listSetting] = pandora.site.user.ui[setting];
});
pandora.UI.set('lists|', listSettings);
pandora.UI.set('lists.', listSettings);
}
Ox.extend(pandora.user, {

View file

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

View file

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

View file

@ -32,6 +32,9 @@ pandora.ui.contentPanel = function() {
listView: function() {
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
},
item: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
},
itemView: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
}

View file

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

View file

@ -18,14 +18,13 @@ pandora.ui.infoView = function(data) {
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = pandora.user.ui.icons == 'posters' ? 0 : iconSize / 8,
edit = false,
that = Ox.Element(),
uid = Ox.uid(),
$list,
$info = $('<div>')
.css({
position: 'absolute',
left: pandora.user.level == 'admin' ? -listWidth + 'px' : 0,
left: pandora.user.level == 'admin' && !pandora.user.ui.editPoster ? -listWidth + 'px' : 0,
top: 0,
right: 0,
})
@ -328,16 +327,15 @@ pandora.ui.infoView = function(data) {
$icon.bindEvent({
doubleclick: function() {
if (!edit) {
pandora.UI.set('editPoster', !pandora.user.ui.editPoster);
if (pandora.user.ui.editPoster) {
$info.animate({
left: 0
}, 250);
edit = true;
} else {
$info.animate({
left: -listWidth + 'px'
}, 250);
edit = false;
}
}
});
@ -367,7 +365,6 @@ pandora.ui.infoView = function(data) {
id: data.id,
keys: [pandora.user.ui.icons == 'posters' ? 'posters' : 'frames']
}, 0, function(result) {
Ox.print('RESULT', result.data)
var images = result.data[pandora.user.ui.icons == 'posters' ? 'posters' : 'frames'],
selectedImage = images.filter(function(image) {
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') {
//Ox.print('result.data', result.data)
if (pandora.user.level == 'admin' && false) {
@ -196,7 +148,6 @@ pandora.ui.item = function() {
} else if (pandora.user.ui.itemView == 'clips') {
var ratio = result.data.videoRatio;
Ox.print('RATIO', ratio)
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({
fixedRatio: ratio,
item: function(data, sort, size) {
@ -214,7 +165,6 @@ pandora.ui.item = function() {
};
},
items: function(data, callback) {
Ox.print('DATA', data)
pandora.api.findAnnotations(Ox.extend(data, {
itemQuery: {
conditions:[{
@ -241,7 +191,7 @@ pandora.ui.item = function() {
}));
pandora.UI.set({
itemView: pandora.user.ui.videoView
})
});
},
// fixme: duplicated
openpreview: function(data) {

View file

@ -507,7 +507,7 @@ pandora.ui.list = function() {
});
pandora.api.findEvents({
itemQuery: pandora.user.ui.query,
itemQuery: pandora.user.ui.find,
keys: ['id', 'name', 'start', 'end'],
query: {}
}, 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({
listSort: function(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: [
{ 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({
checked: ui.itemView == view.id,
}, view);
@ -151,13 +151,8 @@ pandora.ui.mainMenu = function() {
var value = data.checked[0] ? data.checked[0].id : null;
if (data.id == 'find') {
pandora.$ui.findSelect.options({value: value});
} else if (data.id == 'movieview') {
var id = document.location.pathname.split('/')[1];
// fixme: what's this?
if (value == 'info')
url(id + '/info');
else
url(id);
} else if (data.id == 'itemview') {
pandora.UI.set({itemView: value});
} else if (Ox.startsWith(data.id, 'ordergroup')) {
var groups = Ox.clone(pandora.user.ui.groups),
id = data.id.replace('ordergroup', ''),

View file

@ -58,6 +58,9 @@ pandora.ui.rightPanel = function() {
});
}
pandora.UI.bind({
list: function() {
that.replaceElement(1, pandora.$ui.contentPanel = pandora.ui.contentPanel());
},
itemView: function(value) {
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('itemView'))) {
that.replaceElement(0, pandora.$ui.toolbar = pandora.ui.toolbar());