user ox.ui events for pandora ui events

This commit is contained in:
rolux 2011-09-28 01:30:13 +02:00
parent 1f2bfe2f76
commit 76442b5f34
14 changed files with 119 additions and 145 deletions

View file

@ -5,15 +5,12 @@ pandora.UI = (function() {
self.previousUI = {}; self.previousUI = {};
that.bind = function() {
Ox.Event.bind.apply(null, arguments);
};
that.encode = function(val) { that.encode = function(val) {
return val.replace(/\./g, '\\.'); return val.replace(/\./g, '\\.');
}; };
that.getPrevious = function(key) { that.getPrevious = function(key) {
// fixme: probably unneeded by now
return !key ? self.previousUI : self.previousUI[key]; return !key ? self.previousUI : self.previousUI[key];
}; };
@ -93,11 +90,6 @@ pandora.UI = (function() {
}); });
}); });
Ox.len(set) && pandora.api.setUI(set); Ox.len(set) && pandora.api.setUI(set);
Ox.forEach(trigger, function(val, key) {
// fixme: send previousVal as second parameter
Ox.Event.trigger(key, val);
});
Ox.forEach(trigger, function(val, key) { Ox.forEach(trigger, function(val, key) {
Ox.forEach(pandora.$ui, function(element) { Ox.forEach(pandora.$ui, function(element) {
// fixme: send previousVal as second parameter // fixme: send previousVal as second parameter
@ -107,6 +99,7 @@ pandora.UI = (function() {
}); });
}); });
}); });
Ox.len(trigger) && Ox.URL.push();
}; };
return that; return that;

View file

@ -436,12 +436,6 @@ pandora.URL = (function() {
views: views views: views
}); });
['find', 'item', 'itemSort', 'itemView', 'list', 'listSort', 'listView'].forEach(function(event) {
pandora.UI.bind(event, function() {
that.push();
});
});
return that; return that;
}; };

View file

@ -90,20 +90,18 @@ pandora.ui.browser = function() {
pandora.$ui.editor.gainFocus(); pandora.$ui.editor.gainFocus();
} }
} }
} },
}); pandora_icons: function(data) {
pandora.enableDragAndDrop(that, false);
pandora.UI.bind({
icons: function(value) {
that.options({ that.options({
borderRadius: value == 'posters' ? 0 : 8, borderRadius: data.value == 'posters' ? 0 : 8,
defaultRatio: value == 'posters' ? 5/8 : 1 defaultRatio: data.value == 'posters' ? 5/8 : 1
}).reloadList(true); }).reloadList(true);
}, },
showSitePoster: function() { pandora_showsiteposter: function() {
pandora.user.ui.icons == 'poster' && that.reloadList(true); pandora.user.ui.icons == 'poster' && that.reloadList(true);
} }
}); });
pandora.enableDragAndDrop(that, false);
} }
return that; return that;
}; };

View file

@ -1,46 +1,46 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.contentPanel = function() { pandora.ui.contentPanel = function() {
var that = Ox.SplitPanel({ var that = Ox.SplitPanel({
elements: !pandora.user.ui.item ? [ elements: !pandora.user.ui.item ? [
{ {
collapsed: !pandora.user.ui.showGroups, collapsed: !pandora.user.ui.showGroups,
collapsible: true, collapsible: true,
element: pandora.$ui.browser = pandora.ui.browser(), element: pandora.$ui.browser = pandora.ui.browser(),
resizable: true, resizable: true,
resize: [96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256], resize: [96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256],
size: pandora.user.ui.groupsSize, size: pandora.user.ui.groupsSize,
tooltip: 'groups' tooltip: 'groups'
},
{
element: pandora.$ui.list = pandora.ui.list()
}
] : [
{
collapsed: !pandora.user.ui.showMovies,
collapsible: true,
element: pandora.$ui.browser = pandora.ui.browser(),
size: 112 + Ox.UI.SCROLLBAR_SIZE,
tooltip: pandora.site.itemName.plural.toLowerCase()
},
{
element: pandora.$ui.item = pandora.ui.item()
}
],
orientation: 'vertical'
})
.bindEvent({
pandora_listview: function() {
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
}, },
{ pandora_item: function(data) {
element: pandora.$ui.list = pandora.ui.list() if (data.value && data.previousValue) {
} that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
] : [ }
{
collapsed: !pandora.user.ui.showMovies,
collapsible: true,
element: pandora.$ui.browser = pandora.ui.browser(),
size: 112 + Ox.UI.SCROLLBAR_SIZE,
tooltip: pandora.site.itemName.plural.toLowerCase()
}, },
{ pandora_itemview: function() {
element: pandora.$ui.item = pandora.ui.item()
}
],
orientation: 'vertical'
});
pandora.UI.bind({
listView: function() {
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
},
item: function(value) {
if (value && pandora.UI.getPrevious('item')) {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
} }
}, });
itemView: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
}
});
return that; return that;
}; };

View file

@ -235,7 +235,7 @@ pandora.ui.folders = function() {
that.append($folder); that.append($folder);
}); });
pandora.resizeFolders(); pandora.resizeFolders();
pandora.selectList(); //fixme: doesn't work //pandora.selectList();
} }
} }
}) })

View file

@ -515,9 +515,9 @@ pandora.ui.infoView = function(data) {
$data.css({height: height + 'px'}); $data.css({height: height + 'px'});
}; };
pandora.UI.bind({ that.bindEvent({
icons: that.reload, pandora_icons: that.reload,
showSitePoster: function() { pandora_showsiteposter: function() {
pandora.user.ui.icons == 'poster' && that.reload(); pandora.user.ui.icons == 'poster' && that.reload();
} }
}); });

View file

@ -250,13 +250,11 @@ pandora.ui.item = function() {
} else { } else {
$('.OxSelectedVideo').removeClass('OxSelectedVideo'); $('.OxSelectedVideo').removeClass('OxSelectedVideo');
} }
},
pandora_itemsort: function(data) {
pandora.$ui.clips.options({sort: data.value});
} }
})); }));
pandora.UI.bind({
itemSort: function(value) {
pandora.$ui.clips.options({sort: value});
}
});
} else if (pandora.user.ui.itemView == 'video') { } else if (pandora.user.ui.itemView == 'video') {
// fixme: duplicated // fixme: duplicated

View file

@ -675,20 +675,20 @@ pandora.ui.list = function() {
} }
pandora.UI.bind({ that.bindEvent({
listSort: function(value) { pandora_listsort: function(data) {
that.options({sort: value}); that.options({sort: data.value});
} }
}); });
if (pandora.user.ui.listView == 'grid') { if (pandora.user.ui.listView == 'grid') {
pandora.UI.bind({ that.bindEvent({
icons: function(value) { pandora_icons: function(data) {
that.options({ that.options({
borderRadius: value == 'posters' ? 0 : 16, borderRadius: data.value == 'posters' ? 0 : 16,
defaultRatio: value == 'posters' ? 5/8 : 1 defaultRatio: data.value == 'posters' ? 5/8 : 1
}).reloadList(true); }).reloadList(true);
}, },
showSitePoster: function() { pandora_showsiteposter: function() {
pandora.user.ui.icons == 'poster' && that.reloadList(true); pandora.user.ui.icons == 'poster' && that.reloadList(true);
} }
}); });

View file

@ -1,45 +1,45 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.mainPanel = function() { pandora.ui.mainPanel = function() {
var that = Ox.SplitPanel({ var that = Ox.SplitPanel({
elements: [ elements: [
{ {
collapsible: true, collapsible: true,
collapsed: !pandora.user.ui.showSidebar, collapsed: !pandora.user.ui.showSidebar,
element: pandora.$ui.leftPanel = pandora.ui.leftPanel(), element: pandora.$ui.leftPanel = pandora.ui.leftPanel(),
resizable: true, resizable: true,
resize: [192, 256, 320, 384], resize: [192, 256, 320, 384],
size: pandora.user.ui.sidebarSize, size: pandora.user.ui.sidebarSize,
tooltip: 'lists' tooltip: 'lists'
},
{
element: pandora.$ui.rightPanel = pandora.ui.rightPanel()
}
],
orientation: 'horizontal'
})
.bindEvent({
pandora_find: function() {
var previousUI = pandora.UI.getPrevious();
if (pandora.user.ui._list == previousUI._list) {
pandora.$ui.list.reloadList();
pandora.user.ui._groupsState.forEach(function(data, i) {
if (!Ox.isEqual(data.selected, previousUI._groupsState[i].selected)) {
pandora.$ui.groups[i].options({selected: data.selected});
}
if (!Ox.isEqual(data.find, previousUI._groupsState[i].find)) {
pandora.$ui.groups[i].reloadList();
}
});
} else {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
}, },
{ pandora_item: function(data) {
element: pandora.$ui.rightPanel = pandora.ui.rightPanel() if (!data.value || !data.previousValue) {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
} }
], });
orientation: 'horizontal'
});
pandora.UI.bind({
find: function() {
var previousUI = pandora.UI.getPrevious();
if (pandora.user.ui._list == previousUI._list) {
pandora.$ui.list.reloadList();
pandora.user.ui._groupsState.forEach(function(data, i) {
if (!Ox.isEqual(data.selected, previousUI._groupsState[i].selected)) {
pandora.$ui.groups[i].options({selected: data.selected});
}
if (!Ox.isEqual(data.find, previousUI._groupsState[i].find)) {
pandora.$ui.groups[i].reloadList();
}
});
} else {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
},
item: function(value) {
if (!value || !pandora.UI.getPrevious('item')) {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
}
}
});
return that; return that;
}; };

View file

@ -229,6 +229,11 @@ pandora.ui.mainMenu = function() {
} else if (data.id == 'clearcache') { } else if (data.id == 'clearcache') {
Ox.Request.clearCache(); Ox.Request.clearCache();
} }
},
pandora_listView: function(data) {
if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
that.replaceMenu('sortMenu', getSortMenu());
}
} }
}); });
@ -350,14 +355,6 @@ pandora.ui.mainMenu = function() {
}); });
}); });
pandora.UI.bind({
listView: function(value) {
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('listView'))) {
that.replaceMenu('sortMenu', getSortMenu());
}
}
});
return that; return that;
}; };

View file

@ -20,15 +20,13 @@ pandora.ui.orderButton = function() {
}] }]
}); });
that.options({title: getTitle()}); that.options({title: getTitle()});
},
pandora_listsort: function() {
that.options({title: getTitle()});
} }
}); });
function getTitle() { function getTitle() {
return pandora.user.ui.listSort[0].operator == '+' ? 'up' : 'down'; return pandora.user.ui.listSort[0].operator == '+' ? 'up' : 'down';
} }
pandora.UI.bind({
listSort: function() {
that.options({title: getTitle()});
}
});
return that; return that;
} }

View file

@ -54,16 +54,14 @@ pandora.ui.rightPanel = function() {
pandora.$ui.editor.options({width: data.size}); pandora.$ui.editor.options({width: data.size});
} }
} }
},
pandora_itemview: function(data) {
if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
that.replaceElement(0, pandora.$ui.toolbar = pandora.ui.toolbar());
}
} }
}); });
} }
pandora.UI.bind({
itemView: function(value) {
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('itemView'))) {
that.replaceElement(0, pandora.$ui.toolbar = pandora.ui.toolbar());
}
}
})
return that; return that;
}; };

View file

@ -25,9 +25,9 @@ pandora.ui.toolbar = function() {
that.append( that.append(
pandora.$ui.findElement = pandora.ui.findElement() pandora.$ui.findElement = pandora.ui.findElement()
); );
pandora.UI.bind({ that.bindEvent({
listView: function(value) { pandora_listview: function(data) {
if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('listView'))) { if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
pandora.$ui.sortSelect.replaceWith( pandora.$ui.sortSelect.replaceWith(
pandora.$ui.sortSelect = pandora.ui.sortSelect() pandora.$ui.sortSelect = pandora.ui.sortSelect()
); );

View file

@ -19,16 +19,14 @@ pandora.ui.viewSelect = function() {
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
pandora.UI.set(viewKey, data.selected[0].id); pandora.UI.set(viewKey, data.selected[0].id);
},
pandora_listview: function(data) {
that.selectItem(data.value);
},
pandora_itemview: function(data) {
that.selectItem(data.value);
} }
}); });
pandora.UI.bind({
listView: function(value) {
that.selectItem(value);
},
itemView: function(value) {
that.selectItem(value);
}
});
return that; return that;
}; };