')
+ .attr({id: q})
+ .css({
+ float: 'left',
+ width: '126px',
+ height: '126px',
+ border: '1px solid rgba(255, 255, 255, ' + (i == quarter ? 0.75 : 0) + ')',
+ background: 'rgba(0, 0, 0, ' + (i == quarter ? 0 : 0.75) + ')'
+ })
+ .css('border-' + q + '-radius', '64px')
+ );
+ });
+ }
+
+ function setPosterFrame(item, position) {
+ var posterFrame = {item: item, position: position};
+ if (posterFrames.length) {
+ posterFrames[quarter] = posterFrame;
+ } else {
+ posterFrames = Ox.repeat([posterFrame], 4);
+ }
+ pandora.api.editList({
+ id: listData.id,
+ posterFrames: posterFrames
+ }, function() {
+ $icon.attr({src: '/list/' + listData.id + '/icon256.jpg?' + Ox.uid()});
+ });
+ $preview.options({position: position});
+ }
+
+ });
function renderFrame() {
$frame.css({borderRadius: 0});
- $frame.css('border-' + quarter + '-radius', '128px');
+ $frame.css('border-' + quarters[quarter] + '-radius', '128px');
}
- function renderQuarters() {
- $interface.empty();
- ['top-left', 'top-right', 'bottom-left', 'bottom-right'].forEach(function(q) {
- $interface.append(
- $('
')
- .attr({id: q})
- .css({
- float: 'left',
- width: '126px',
- height: '126px',
- border: '1px solid rgba(255, 255, 255, ' + (q == quarter ? 0.75 : 0) + ')',
- background: 'rgba(0, 0, 0, ' + (q == quarter ? 0 : 0.75) + ')'
- })
- .css('border-' + q + '-radius', '64px')
- );
- });
- }
-
- var that = Ox.SplitPanel({
- elements: [
- {
- element: Ox.Element({}).append(
- $('
![]()
').css({position: 'absolute', margin: '16px'}).attr({src: '/static/png/icon256.png'})
- ).append(
- $interface
- ),
- size: 288
- },
- {
- element: Ox.SplitPanel({
- elements: [
- {
- element: Ox.Bar({size: 24}).append(
- Ox.FormElementGroup({
- elements: [
- pandora.$ui.findIconItemSelect = Ox.Select({
- items: pandora.site.findKeys,
- overlap: 'right',
- type: 'image'
- })
- .bindEvent({
- change: function(data) {
- }
- }),
- pandora.$ui.findIconItemInput = Ox.Input({
- changeOnKeypress: true,
- clear: true,
- placeholder: 'Find: Foo',
- width: 120
- })
- .bindEvent({
- change: function(data) {
-
- }
- })
- ],
- })
- .css({
- float: 'right',
- margin: '4px',
- align: 'right'
- })
- ),
- size: 24
- },
- {
- element: $list
- }
- ],
- orientation: 'vertical'
- })
- },
- {
- element: $preview,
- size: 272
- }
- ],
- orientation: 'horizontal'
- })
return that;
+
}
diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js
index 55a64299..7e801d0a 100644
--- a/static/js/pandora/ui/menu.js
+++ b/static/js/pandora/ui/menu.js
@@ -203,6 +203,16 @@ pandora.ui.mainMenu = function() {
'signup', 'signin', 'signout', 'preferences', 'help'
].indexOf(data.id) > -1) {
pandora.URL.push('/' + data.id);
+ } else if ([
+ 'newlist', 'newlistfromselection', 'newsmartlist', 'newsmartlistfromresults'
+ ].indexOf(data.id) > -1) {
+ pandora.addList(data.id.indexOf('smart') > -1, data.id.indexOf('from') > -1);
+ } else if (data.id == 'duplicatelist') {
+ pandora.addList(pandora.user.ui._list);
+ } else if (data.id == 'editlist') {
+ pandora.ui.listDialog().open();
+ } else if (data.id == 'deletelist') {
+ pandora.ui.deleteListDialog().open();
} else if (data.id == 'stills') {
var id = pandora.user.ui.item || pandora.user.ui.listItem;
pandora.$ui.postersDialog = pandora.ui.framesDialog(id).open();
@@ -230,7 +240,19 @@ pandora.ui.mainMenu = function() {
Ox.Request.clearCache();
}
},
- pandora_listView: function(data) {
+ pandora_find: function() {
+ var action = ui._list
+ && pandora.getListData(ui._list).user == pandora.user.username
+ ? 'enableItem' : 'disableItem';
+ that[action]('editlist');
+ that[action]('duplicatelist');
+ that[action]('deletelist');
+ that[pandora.user.ui.listSelection.length ? 'enableItem' : 'disableItem']('newlistfromselection');
+ },
+ pandora_listselection: function(data) {
+ that[data.value.length ? 'enableItem' : 'disableItem']('newlistfromselection');
+ },
+ pandora_listview: function(data) {
if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
that.replaceMenu('sortMenu', getSortMenu());
}
@@ -259,15 +281,14 @@ pandora.ui.mainMenu = function() {
}),
[
{},
- { id: 'newlist', title: 'New List...', keyboard: 'control n' },
- { id: 'newlistfromselection', title: 'New List from Selection...', disabled: true, keyboard: 'shift control n' },
- { id: 'newsmartlist', title: 'New Smart List...', keyboard: 'alt control n' },
- { id: 'newsmartlistfromresults', title: 'New Smart List from Results...', keyboard: 'shift alt control n' },
- { id: 'duplicatelist', title: 'Duplicate Selected List', keyboard: 'control d' },
+ { id: 'newlist', title: 'New List', keyboard: 'control n' },
+ { id: 'newlistfromselection', title: 'New List from Selection', disabled: ui.listSelection.length == 0, keyboard: 'shift control n' },
+ { id: 'newsmartlist', title: 'New Smart List', keyboard: 'alt control n' },
+ { id: 'newsmartlistfromresults', title: 'New Smart List from Results', keyboard: 'shift alt control n' },
{},
- { id: 'addmovietolist', title: ['Add Selected ' + pandora.site.itemName.singular + ' to List...', 'Add Selected ' + pandora.site.itemName.plural + ' to List...'], disabled: true },
- {},
- { id: 'setposterframe', title: 'Set Poster Frame', disabled: true }
+ { id: 'duplicatelist', title: 'Duplicate Selected List', disabled: !pandora.user.ui._list, keyboard: 'control d' },
+ { id: 'editlist', title: 'Edit Selected List...', disabled: !pandora.user.ui._list, keyboard: 'control e' },
+ { id: 'deletelist', title: 'Delete Selected List...', disabled: !pandora.user.ui._list, keyboard: 'delete' },
]
)};
};
diff --git a/static/js/pandora/ui/videoPreview.js b/static/js/pandora/ui/videoPreview.js
index b3ca98cd..7f172a4c 100644
--- a/static/js/pandora/ui/videoPreview.js
+++ b/static/js/pandora/ui/videoPreview.js
@@ -14,29 +14,10 @@ pandora.ui.videoPreview = function(data) {
frameCSS: data.frameCSS,
frameRatio: data.frameRatio,
height: data.height,
+ position: data.position,
scaleToFill: true,
timeline: '/' + data.id + '/timeline16p.png',
width: data.width
- })
- .bindEvent({
- click: function(event) {
- pandora.UI.set(
- 'videoPoints.' + data.id,
- {'in': 0, out: 0, position: event.position}
- );
- if (pandora.user.ui.item && ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) {
- pandora.$ui[
- pandora.user.ui.itemView == 'video' ? 'player' : 'editor'
- ].options({
- position: event.position
- });
- } else {
- pandora.UI.set({
- item: data.id,
- itemView: pandora.user.ui.videoView
- });
- }
- }
});
return that;
};
diff --git a/static/js/pandora/pandora.js b/static/js/pandora/utils.js
similarity index 85%
rename from static/js/pandora/pandora.js
rename to static/js/pandora/utils.js
index e3a528ad..d766b812 100644
--- a/static/js/pandora/pandora.js
+++ b/static/js/pandora/utils.js
@@ -1,5 +1,139 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
+pandora.addList = function() {
+ // addList(isSmart, isFrom) or addList(list) [=duplicate]
+ var $folderList = pandora.$ui.folderList.personal,
+ isDuplicate = arguments.length == 1,
+ isSmart, isFrom, list, listData, data;
+ if (!isDuplicate) {
+ isSmart = arguments[0];
+ isFrom = arguments[1];
+ data = {
+ name: 'Untitled',
+ status: 'private',
+ type: !isSmart ? 'static' : 'smart'
+ };
+ if (isFrom) {
+ if (!isSmart) {
+ data.items = pandora.user.ui.listSelection;
+ } else {
+ data.query = pandora.user.ui.find;
+ }
+ }
+ } else {
+ list = arguments[0];
+ listData = pandora.getListData();
+ data = {
+ name: listData.name,
+ status: listData.status,
+ type: listData.type
+ };
+ if (data.type == 'smart') {
+ data.query = listData.query;
+ }
+ }
+ if (isDuplicate && listData.type == 'static') {
+ var query = {
+ conditions: [{key: 'list', value: list, operator: '=='}],
+ operator: '&'
+ };
+ pandora.api.find({
+ query: query
+ }, function(result) {
+ if (result.data.items) {
+ pandora.api.find({
+ query: query,
+ keys: ['id'],
+ sort: [{key: 'id', operator: ''}]
+ }, function(result) {
+ var items = result.data.items.map(function(item) {
+ return item.id;
+ });
+ addList(items);
+ })
+ } else {
+ addList();
+ }
+ })
+ } else {
+ addList();
+ }
+ function addList(items) {
+ pandora.api.addList(data, function(result) {
+ var newList = result.data.id;
+ if (items) {
+ pandora.api.addListItems({
+ list: newList,
+ items: items
+ }, function() {
+ getPosterFrames(newList);
+ })
+ } else {
+ getPosterFrames(newList);
+ }
+ });
+ }
+ function getPosterFrames(newList) {
+ if (!isDuplicate) {
+ pandora.api.find({
+ query: {
+ conditions: [{key: 'list', value: newList, operator: '=='}],
+ operator: '&'
+ },
+ keys: ['id', 'posterFrame'],
+ sort: [{key: 'votes', operator: ''}], // fixme: may not always exist
+ range: [0, 4]
+ }, function(result) {
+ var posterFrames = result.data.items.map(function(item) {
+ return {item: item.id, position: item.posterFrame};
+ });
+ posterFrames = posterFrames.length == 1
+ ? Ox.repeat([posterFrames[0]], 4)
+ : posterFrames.length == 2
+ ? [posterFrames[0], posterFrames[1], posterFrames[1], posterFrames[0]]
+ : posterFrames.length == 3
+ ? [posterFrames[0], posterFrames[1], posterFrames[2], posterFrames[0]]
+ : posterFrames;
+ setPosterFrames(newList, posterFrames);
+ })
+ } else {
+ pandora.api.findLists({
+ query: {
+ conditions: [{key: 'id', value: list, operator: '=='}],
+ operator: '&'
+ },
+ keys: ['posterFrames']
+ }, function(result) {
+ setPosterFrames(newList, result.data.items[0].posterFrames);
+ });
+ }
+ }
+ function setPosterFrames(newList, posterFrames) {
+ pandora.api.editList({
+ id: newList,
+ posterFrames: posterFrames
+ }, function() {
+ reloadFolder(newList);
+ });
+ }
+ function reloadFolder(newList) {
+ Ox.Request.clearCache('findLists');
+ $folderList.bindEventOnce({
+ load: function(data) {
+ $folderList.gainFocus()
+ .options({selected: [list]})
+ .editCell(newList, 'name');
+ pandora.UI.set({
+ find: {
+ conditions: [{key: 'list', value: newList, operator: '=='}],
+ operator: '&'
+ }
+ });
+ }
+ }).reloadList();
+ }
+};
+
pandora.enableDragAndDrop = function($list, canMove) {
var $tooltip = Ox.Tooltip({
@@ -482,6 +616,7 @@ pandora.signin = function(data) {
pandora.user = data.user;
pandora.Query.updateGroups();
Ox.Theme(pandora.user.ui.theme);
+ pandora.UI.set({find: pandora.user.ui.find})
pandora.$ui.appPanel.reload();
};
@@ -489,6 +624,7 @@ pandora.signout = function(data) {
pandora.user = data.user;
pandora.Query.updateGroups();
Ox.Theme(pandora.site.user.ui.theme);
+ pandora.UI.set({find: pandora.user.ui.find})
pandora.$ui.appPanel.reload();
};
@@ -713,4 +849,4 @@ pandora.selectList = function() {
return state;
};
-}());
\ No newline at end of file
+}());
diff --git a/static/json/pandora.json b/static/json/pandora.json
index 86d017cd..349325ab 100644
--- a/static/json/pandora.json
+++ b/static/json/pandora.json
@@ -1,51 +1,52 @@
[
- "js/pandora/pandora.js",
- "js/pandora/URL.js",
"js/pandora/Query.js",
- "js/pandora/autovalidate.js",
"js/pandora/UI.js",
- "js/pandora/ui/info.js",
- "js/pandora/ui/rightPanel.js",
- "js/pandora/ui/folderBrowserList.js",
- "js/pandora/ui/homePage.js",
- "js/pandora/ui/group.js",
- "js/pandora/ui/toolbar.js",
- "js/pandora/ui/statusbar.js",
- "js/pandora/ui/sectionButtons.js",
- "js/pandora/ui/item.js",
- "js/pandora/ui/folderBrowser.js",
- "js/pandora/ui/publicLists.js",
- "js/pandora/ui/filter.js",
- "js/pandora/ui/status.js",
- "js/pandora/ui/sectionbar.js",
- "js/pandora/ui/folders.js",
- "js/pandora/ui/mainPanel.js",
- "js/pandora/ui/viewSelect.js",
- "js/pandora/ui/sortSelect.js",
- "js/pandora/ui/orderButton.js",
- "js/pandora/ui/menu.js",
+ "js/pandora/URL.js",
+ "js/pandora/autovalidate.js",
+ "js/pandora/utils.js",
"js/pandora/ui/Ox.FilesView.js",
- "js/pandora/ui/browser.js",
- "js/pandora/ui/list.js",
- "js/pandora/ui/folderList.js",
- "js/pandora/ui/findElement.js",
- "js/pandora/ui/filterDialog.js",
"js/pandora/ui/account.js",
- "js/pandora/ui/folderBrowserBar.js",
- "js/pandora/ui/sectionSelect.js",
- "js/pandora/ui/placesDialog.js",
- "js/pandora/ui/contentPanel.js",
- "js/pandora/ui/backButton.js",
- "js/pandora/ui/leftPanel.js",
"js/pandora/ui/appPanel.js",
- "js/pandora/ui/videoPreview.js",
+ "js/pandora/ui/backButton.js",
+ "js/pandora/ui/browser.js",
+ "js/pandora/ui/contentPanel.js",
+ "js/pandora/ui/deleteListDialog.js",
"js/pandora/ui/editor.js",
- "js/pandora/ui/infoView.js",
- "js/pandora/ui/mediaView.js",
- "js/pandora/ui/home.js",
- "js/pandora/ui/preferencesDialog.js",
- "js/pandora/ui/listDialog.js",
- "js/pandora/ui/siteDialog.js",
"js/pandora/ui/eventsDialog.js",
- "js/pandora/ui/usersDialog.js"
+ "js/pandora/ui/filter.js",
+ "js/pandora/ui/filterDialog.js",
+ "js/pandora/ui/findElement.js",
+ "js/pandora/ui/folderBrowser.js",
+ "js/pandora/ui/folderBrowserBar.js",
+ "js/pandora/ui/folderBrowserList.js",
+ "js/pandora/ui/folderList.js",
+ "js/pandora/ui/folders.js",
+ "js/pandora/ui/group.js",
+ "js/pandora/ui/home.js",
+ "js/pandora/ui/homePage.js",
+ "js/pandora/ui/info.js",
+ "js/pandora/ui/infoView.js",
+ "js/pandora/ui/item.js",
+ "js/pandora/ui/leftPanel.js",
+ "js/pandora/ui/list.js",
+ "js/pandora/ui/listDialog.js",
+ "js/pandora/ui/mainPanel.js",
+ "js/pandora/ui/mediaView.js",
+ "js/pandora/ui/menu.js",
+ "js/pandora/ui/orderButton.js",
+ "js/pandora/ui/placesDialog.js",
+ "js/pandora/ui/preferencesDialog.js",
+ "js/pandora/ui/publicLists.js",
+ "js/pandora/ui/rightPanel.js",
+ "js/pandora/ui/sectionButtons.js",
+ "js/pandora/ui/sectionSelect.js",
+ "js/pandora/ui/sectionbar.js",
+ "js/pandora/ui/siteDialog.js",
+ "js/pandora/ui/sortSelect.js",
+ "js/pandora/ui/status.js",
+ "js/pandora/ui/statusbar.js",
+ "js/pandora/ui/toolbar.js",
+ "js/pandora/ui/usersDialog.js",
+ "js/pandora/ui/videoPreview.js",
+ "js/pandora/ui/viewSelect.js"
]
diff --git a/static/png/list256.png b/static/png/list256.png
new file mode 100644
index 00000000..21fffbf0
Binary files /dev/null and b/static/png/list256.png differ