From be21e64f59ef9d012b4d129a11b3a949ba702441 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 23 Jan 2014 14:36:11 +0000 Subject: [PATCH] embedList.js -> embedGrid.js --- static/js/embedGrid.js | 82 ++++++++++++++++++++++++++++++++++++++++++ static/js/embedList.js | 13 ------- 2 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 static/js/embedGrid.js delete mode 100644 static/js/embedList.js diff --git a/static/js/embedGrid.js b/static/js/embedGrid.js new file mode 100644 index 000000000..1fea8466d --- /dev/null +++ b/static/js/embedGrid.js @@ -0,0 +1,82 @@ +'use strict'; + +pandora.ui.embedGrid = function() { + + var ui = pandora.user.ui, + + $list = Ox.IconList({ + borderRadius: ui.icons == 'posters' ? 0 : 16, + defaultRatio: ui.icons == 'posters' ? pandora.site.posters.ratio : 1, + id: 'list', + item: function(data, sort, size) { + var ratio = ui.icons == 'posters' + ? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1, + url = '/' + data.id + '/' + ( + ui.icons == 'posters' + ? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon' + ) + size + '.jpg?' + data.modified, + format, info, sortKey = sort[0].key; + if (['title', 'director', 'random'].indexOf(sortKey) > -1) { + info = data['year']; + } else { + format = pandora.getSortKeyData(sortKey).format; + if (format) { + info = ( + /^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox + )['format' + Ox.toTitleCase(format.type)].apply( + this, [data[sortKey]].concat(format.args || []) + ); + if (sortKey == 'rightslevel') { + info.css({width: size * 0.75 + 'px'}); + } + } else { + info = data[sortKey]; + } + } + size = size || 128; + return { + height: Math.round(ratio <= 1 ? size : size / ratio), + id: data.id, + info: info, + title: data.title + (data.director && data.director.length ? ' (' + data.director.join(', ') + ')' : ''), + url: url, + width: Math.round(ratio >= 1 ? size : size * ratio) + }; + }, + items: function(data, callback) { + pandora.api.find(Ox.extend(data, { + query: ui.find + }), callback); + return Ox.clone(data, true); + }, + keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'], + selected: ui.listSelection, + size: 128, + sort: ui.listSort, + unique: 'id' + }) + .addClass('OxMedia') + .bindEvent({ + open: function() { + window.open('/' + item + '', '_blank'); + } + }), + + $statusbar = Ox.Bar({size: 16}), + + that = Ox.SplitPanel({ + elements: [ + {element: $list}, + {element: $statusbar, size: 16} + ], + orientation: 'vertical' + }); + + that.resizePanel = function() { + $list.size(); + return that; + }; + + return that; + +}; \ No newline at end of file diff --git a/static/js/embedList.js b/static/js/embedList.js deleted file mode 100644 index fb6992173..000000000 --- a/static/js/embedList.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -pandora.ui.embedList = function() { - - var that = Ox.Element(); - - that.resizePanel = function() { - return that; - }; - - return that; - -}; \ No newline at end of file