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

View file

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

View file

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

View file

@ -1,46 +1,46 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.contentPanel = function() {
var that = Ox.SplitPanel({
elements: !pandora.user.ui.item ? [
{
collapsed: !pandora.user.ui.showGroups,
collapsible: true,
element: pandora.$ui.browser = pandora.ui.browser(),
resizable: true,
resize: [96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256],
size: pandora.user.ui.groupsSize,
tooltip: 'groups'
elements: !pandora.user.ui.item ? [
{
collapsed: !pandora.user.ui.showGroups,
collapsible: true,
element: pandora.$ui.browser = pandora.ui.browser(),
resizable: true,
resize: [96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256],
size: pandora.user.ui.groupsSize,
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());
},
{
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()
pandora_item: function(data) {
if (data.value && data.previousValue) {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
}
},
{
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')) {
pandora_itemview: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
}
},
itemView: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
}
});
});
return that;
};

View file

@ -235,7 +235,7 @@ pandora.ui.folders = function() {
that.append($folder);
});
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'});
};
pandora.UI.bind({
icons: that.reload,
showSitePoster: function() {
that.bindEvent({
pandora_icons: that.reload,
pandora_showsiteposter: function() {
pandora.user.ui.icons == 'poster' && that.reload();
}
});

View file

@ -250,13 +250,11 @@ pandora.ui.item = function() {
} else {
$('.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') {
// fixme: duplicated

View file

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

View file

@ -1,45 +1,45 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.mainPanel = function() {
var that = Ox.SplitPanel({
elements: [
{
collapsible: true,
collapsed: !pandora.user.ui.showSidebar,
element: pandora.$ui.leftPanel = pandora.ui.leftPanel(),
resizable: true,
resize: [192, 256, 320, 384],
size: pandora.user.ui.sidebarSize,
tooltip: 'lists'
elements: [
{
collapsible: true,
collapsed: !pandora.user.ui.showSidebar,
element: pandora.$ui.leftPanel = pandora.ui.leftPanel(),
resizable: true,
resize: [192, 256, 320, 384],
size: pandora.user.ui.sidebarSize,
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());
}
},
{
element: pandora.$ui.rightPanel = pandora.ui.rightPanel()
pandora_item: function(data) {
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;
};

View file

@ -229,6 +229,11 @@ pandora.ui.mainMenu = function() {
} else if (data.id == '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;
};

View file

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

View file

@ -54,16 +54,14 @@ pandora.ui.rightPanel = function() {
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;
};

View file

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

View file

@ -19,16 +19,14 @@ pandora.ui.viewSelect = function() {
.bindEvent({
change: function(data) {
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;
};