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

@ -27,17 +27,17 @@ pandora.ui.contentPanel = function() {
} }
], ],
orientation: 'vertical' orientation: 'vertical'
}); })
pandora.UI.bind({ .bindEvent({
listView: function() { pandora_listview: function() {
that.replaceElement(1, pandora.$ui.list = pandora.ui.list()); that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
}, },
item: function(value) { pandora_item: function(data) {
if (value && pandora.UI.getPrevious('item')) { if (data.value && data.previousValue) {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
} }
}, },
itemView: function() { pandora_itemview: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
} }
}); });

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

@ -16,9 +16,9 @@ pandora.ui.mainPanel = function() {
} }
], ],
orientation: 'horizontal' orientation: 'horizontal'
}); })
pandora.UI.bind({ .bindEvent({
find: function() { pandora_find: function() {
var previousUI = pandora.UI.getPrevious(); var previousUI = pandora.UI.getPrevious();
if (pandora.user.ui._list == previousUI._list) { if (pandora.user.ui._list == previousUI._list) {
pandora.$ui.list.reloadList(); pandora.$ui.list.reloadList();
@ -34,8 +34,8 @@ pandora.ui.mainPanel = function() {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel()); that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
} }
}, },
item: function(value) { pandora_item: function(data) {
if (!value || !pandora.UI.getPrevious('item')) { if (!data.value || !data.previousValue) {
that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel()); that.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
} }
} }

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)) {
pandora.UI.bind({
itemView: function(value) {
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());
} }
} }
}) });
}
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,14 +19,12 @@ 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.UI.bind({
listView: function(value) {
that.selectItem(value);
}, },
itemView: function(value) { pandora_listview: function(data) {
that.selectItem(value); that.selectItem(data.value);
},
pandora_itemview: function(data) {
that.selectItem(data.value);
} }
}); });
return that; return that;