diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index 8b8f8094..da88b056 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -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; diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 5c4f9850..06c3174b 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -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; }; diff --git a/static/js/pandora/ui/browser.js b/static/js/pandora/ui/browser.js index 324b327e..a35f756f 100644 --- a/static/js/pandora/ui/browser.js +++ b/static/js/pandora/ui/browser.js @@ -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; }; diff --git a/static/js/pandora/ui/contentPanel.js b/static/js/pandora/ui/contentPanel.js index aa8bae7d..62cd6d20 100644 --- a/static/js/pandora/ui/contentPanel.js +++ b/static/js/pandora/ui/contentPanel.js @@ -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; }; diff --git a/static/js/pandora/ui/folders.js b/static/js/pandora/ui/folders.js index cc5c88d4..07ca0ab5 100644 --- a/static/js/pandora/ui/folders.js +++ b/static/js/pandora/ui/folders.js @@ -235,7 +235,7 @@ pandora.ui.folders = function() { that.append($folder); }); pandora.resizeFolders(); - pandora.selectList(); //fixme: doesn't work + //pandora.selectList(); } } }) diff --git a/static/js/pandora/ui/infoView.js b/static/js/pandora/ui/infoView.js index b0cb498a..80f9b8b5 100644 --- a/static/js/pandora/ui/infoView.js +++ b/static/js/pandora/ui/infoView.js @@ -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(); } }); diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 6b495645..6729629b 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -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 diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 43246430..0865027d 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -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); } }); diff --git a/static/js/pandora/ui/mainPanel.js b/static/js/pandora/ui/mainPanel.js index bd8934d5..f0f745fe 100644 --- a/static/js/pandora/ui/mainPanel.js +++ b/static/js/pandora/ui/mainPanel.js @@ -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; }; diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 5f4eb71a..33ce2a89 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -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; }; diff --git a/static/js/pandora/ui/orderButton.js b/static/js/pandora/ui/orderButton.js index 451b3ba1..ad71b017 100644 --- a/static/js/pandora/ui/orderButton.js +++ b/static/js/pandora/ui/orderButton.js @@ -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; } \ No newline at end of file diff --git a/static/js/pandora/ui/rightPanel.js b/static/js/pandora/ui/rightPanel.js index e0e67b92..fea39f55 100644 --- a/static/js/pandora/ui/rightPanel.js +++ b/static/js/pandora/ui/rightPanel.js @@ -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; }; diff --git a/static/js/pandora/ui/toolbar.js b/static/js/pandora/ui/toolbar.js index 6f31e003..11784250 100644 --- a/static/js/pandora/ui/toolbar.js +++ b/static/js/pandora/ui/toolbar.js @@ -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() ); diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index 801c7ae7..26410194 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -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; };