drag and drop clips into edits

This commit is contained in:
j 2013-07-15 11:39:23 +00:00
parent 1e4dae0fbc
commit 30548547b8
12 changed files with 335 additions and 74 deletions

View file

@ -1,6 +1,7 @@
'use strict'; 'use strict';
pandora.ui.allItems = function() { pandora.ui.allItems = function(section) {
section = section || pandora.user.ui.section;
var canAddItems = !pandora.site.itemRequiresVideo && pandora.site.capabilities.canAddItems[pandora.user.level], var canAddItems = !pandora.site.itemRequiresVideo && pandora.site.capabilities.canAddItems[pandora.user.level],
canUploadVideo = pandora.site.capabilities.canAddItems[pandora.user.level], canUploadVideo = pandora.site.capabilities.canAddItems[pandora.user.level],
@ -14,10 +15,10 @@ pandora.ui.allItems = function() {
.on({ .on({
click: function() { click: function() {
that.gainFocus(); that.gainFocus();
if (pandora.user.ui.section == 'items') { if (section == 'items') {
pandora.user.ui._list && pandora.UI.set({find: {conditions: [], operator: '&'}}); pandora.user.ui._list && pandora.UI.set({find: {conditions: [], operator: '&'}});
} else { } else {
pandora.UI.set(pandora.user.ui.section.slice(0, -1), ''); pandora.UI.set(section.slice(0, -1), '');
} }
} }
}) })
@ -41,14 +42,14 @@ pandora.ui.allItems = function() {
whiteSpace: 'nowrap' whiteSpace: 'nowrap'
}) })
.html( .html(
pandora.user.ui.section == 'items' section == 'items'
? Ox._('All {0}', [Ox._(pandora.site.itemName.plural)]) ? Ox._('All {0}', [Ox._(pandora.site.itemName.plural)])
: Ox._('{0} ' + Ox.toTitleCase(pandora.user.ui.section), [pandora.site.site.name]) : Ox._('{0} ' + Ox.toTitleCase(section), [pandora.site.site.name])
) )
.appendTo(that), .appendTo(that),
$items; $items;
if (pandora.user.ui.section == 'items') { if (section == 'items') {
$items = $('<div>') $items = $('<div>')
.css({ .css({
float: 'left', float: 'left',
@ -86,7 +87,7 @@ pandora.ui.allItems = function() {
}, function(result) { }, function(result) {
that.update(result.data.items); that.update(result.data.items);
}); });
} else if (pandora.user.ui.section == 'texts') { } else if (section == 'texts') {
Ox.Button({ Ox.Button({
style: 'symbol', style: 'symbol',
title: 'file', title: 'file',
@ -112,9 +113,9 @@ pandora.ui.allItems = function() {
function updateSelected() { function updateSelected() {
that[ that[
(pandora.user.ui.section == 'items' && pandora.user.ui._list) (section == 'items' && pandora.user.ui._list)
|| (pandora.user.ui.section == 'edits' && pandora.user.ui.edit) || (section == 'edits' && pandora.user.ui.edit)
|| (pandora.user.ui.section == 'texts' && pandora.user.ui.text) || (section == 'texts' && pandora.user.ui.text)
? 'removeClass' : 'addClass' ? 'removeClass' : 'addClass'
]('OxSelected'); ]('OxSelected');
} }

View file

@ -10,6 +10,7 @@ pandora.ui.clipList = function(videoRatio) {
isClipView = !ui.item ? ui.listView == 'clip' : ui.itemView == 'clips', isClipView = !ui.item ? ui.listView == 'clip' : ui.itemView == 'clips',
isEmbed = pandora.isEmbedURL(), isEmbed = pandora.isEmbedURL(),
that = Ox.IconList({ that = Ox.IconList({
draggable: true,
find: !ui.item ? pandora.getItemFind(ui.find) : ui.itemFind, find: !ui.item ? pandora.getItemFind(ui.find) : ui.itemFind,
fixedRatio: fixedRatio, fixedRatio: fixedRatio,
item: function(data, sort, size) { item: function(data, sort, size) {
@ -269,6 +270,7 @@ pandora.ui.clipList = function(videoRatio) {
} }
}); });
pandora.enableDragAndDropClip(that, true);
return that; return that;
} }

View file

@ -1,14 +1,14 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.folderBrowser = function(id) { pandora.ui.folderBrowser = function(id, section) {
var that = Ox.SplitPanel({ var that = Ox.SplitPanel({
elements: [ elements: [
{ {
element: pandora.ui.folderBrowserBar(id), element: pandora.ui.folderBrowserBar(id, section),
size: 24 size: 24
}, },
{ {
element: pandora.$ui.folderList[id] = pandora.ui.folderBrowserList(id) element: pandora.$ui.folderList[id] = pandora.ui.folderBrowserList(id, section)
} }
], ],
orientation: 'vertical' orientation: 'vertical'

View file

@ -1,8 +1,9 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.folderBrowserBar = function(id) { pandora.ui.folderBrowserBar = function(id, section) {
section = section || pandora.user.ui.section;
var ui = pandora.user.ui, var ui = pandora.user.ui,
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section), folderItems = section == 'items' ? 'Lists' : Ox.toTitleCase(section),
folderItem = folderItems.slice(0, -1), folderItem = folderItems.slice(0, -1),
that = Ox.Bar({ that = Ox.Bar({
size: 24 size: 24

View file

@ -1,12 +1,13 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.folderBrowserList = function(id) { pandora.ui.folderBrowserList = function(id, section) {
// fixme: user and name are set to the same width here, // fixme: user and name are set to the same width here,
// but resizeFolders will set them to different widths // but resizeFolders will set them to different widths
section = pandora.user.ui.section;
var ui = pandora.user.ui, var ui = pandora.user.ui,
columnWidth = (ui.sidebarSize - Ox.UI.SCROLLBAR_SIZE - (ui.section == 'items' ? 96 : 48)) / 2, columnWidth = (ui.sidebarSize - Ox.UI.SCROLLBAR_SIZE - (section == 'items' ? 96 : 48)) / 2,
i = Ox.getIndexById(pandora.site.sectionFolders[ui.section], id), i = Ox.getIndexById(pandora.site.sectionFolders[section], id),
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section), folderItems = section == 'items' ? 'Lists' : Ox.toTitleCase(section),
folderItem = folderItems.slice(0, -1), folderItem = folderItems.slice(0, -1),
that = Ox.TableList({ that = Ox.TableList({
columns: [ columns: [
@ -65,12 +66,12 @@ pandora.ui.folderBrowserList = function(id) {
format: {type: 'number'}, format: {type: 'number'},
operator: '-', operator: '-',
title: Ox._('Items'), title: Ox._('Items'),
visible: ui.section == 'items', visible: section == 'items',
width: 48 width: 48
}, },
{ {
clickable: function(data) { clickable: function(data) {
return ui.section == 'items' && ( return section == 'items' && (
data.type == 'smart' || data.user == pandora.user.username data.type == 'smart' || data.user == pandora.user.username
); );
}, },
@ -88,7 +89,7 @@ pandora.ui.folderBrowserList = function(id) {
width: '10px', width: '10px',
height: '10px', height: '10px',
padding: '3px', padding: '3px',
opacity: ui.section == 'texts' || data.user == pandora.user.username ? 1 : 0.25 opacity: section == 'texts' || data.user == pandora.user.username ? 1 : 0.25
}); });
}, },
id: 'type', id: 'type',
@ -151,7 +152,7 @@ pandora.ui.folderBrowserList = function(id) {
// not-featured list may be in the user's favorites folder // not-featured list may be in the user's favorites folder
keys: id == 'featured' ? ['subscribed'] : [], keys: id == 'featured' ? ['subscribed'] : [],
pageLength: 1000, pageLength: 1000,
selected: pandora.getListData().folder == id ? [ui.section == 'items' ? ui._list : ui[ui.section.slice(0, -1)]] : [], selected: pandora.getListData().folder == id ? [section == 'items' ? ui._list : ui[section.slice(0, -1)]] : [],
sort: [{key: 'name', operator: '+'}], sort: [{key: 'name', operator: '+'}],
unique: 'id' unique: 'id'
}) })
@ -187,7 +188,7 @@ pandora.ui.folderBrowserList = function(id) {
} }
}, },
init: function(data) { init: function(data) {
pandora.site.sectionFolders[ui.section][i].items = data.items; pandora.site.sectionFolders[section][i].items = data.items;
pandora.$ui.folder[i].$content.css({ pandora.$ui.folder[i].$content.css({
height: 40 + data.items * 16 + 'px' height: 40 + data.items * 16 + 'px'
}); });
@ -197,7 +198,7 @@ pandora.ui.folderBrowserList = function(id) {
pandora.resizeFolders(); pandora.resizeFolders();
}, },
paste: function(data) { paste: function(data) {
if (ui.section == 'items') { if (section == 'items') {
pandora.$ui.list.triggerEvent('paste', data); pandora.$ui.list.triggerEvent('paste', data);
} }
}, },
@ -209,7 +210,7 @@ pandora.ui.folderBrowserList = function(id) {
id != id_ && $list.options('selected', []); id != id_ && $list.options('selected', []);
}); });
} }
if (ui.section == 'items') { if (section == 'items') {
pandora.UI.set({ pandora.UI.set({
find: { find: {
conditions: list ? [ conditions: list ? [
@ -219,7 +220,7 @@ pandora.ui.folderBrowserList = function(id) {
} }
}); });
} else { } else {
pandora.UI.set(ui.section.slice(0, -1), list); pandora.UI.set(section.slice(0, -1), list);
} }
} }
}); });

View file

@ -1,10 +1,11 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.folderList = function(id) { pandora.ui.folderList = function(id, section) {
section = section || pandora.user.section;
var ui = pandora.user.ui, var ui = pandora.user.ui,
i = Ox.getIndexById(pandora.site.sectionFolders[ui.section], id), i = Ox.getIndexById(pandora.site.sectionFolders[section], id),
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section), folderItems = section == 'items' ? 'Lists' : Ox.toTitleCase(section),
folderItem = folderItems.slice(0, -1), folderItem = folderItems.slice(0, -1),
canEditFeatured = pandora.site.capabilities['canEditFeatured' + folderItems][pandora.user.level], canEditFeatured = pandora.site.capabilities['canEditFeatured' + folderItems][pandora.user.level],
that; that;
@ -45,7 +46,7 @@ pandora.ui.folderList = function(id) {
visible: id == 'favorite', visible: id == 'favorite',
// fixme: user and name are set to the same width here, // fixme: user and name are set to the same width here,
// but resizeFolders will set them to different widths // but resizeFolders will set them to different widths
width: ui.sidebarWidth - (ui.section == 'items' ? 96 : 48) width: ui.sidebarWidth - (section == 'items' ? 96 : 48)
}, },
{ {
editable: function(data) { editable: function(data) {
@ -64,19 +65,19 @@ pandora.ui.folderList = function(id) {
return Ox.decodeHTMLEntities(value); return Ox.decodeHTMLEntities(value);
}, },
visible: id != 'favorite', visible: id != 'favorite',
width: ui.sidebarWidth - (ui.section == 'items' ? 96 : 48) width: ui.sidebarWidth - (section == 'items' ? 96 : 48)
}, },
{ {
align: 'right', align: 'right',
id: 'items', id: 'items',
format: {type: 'number'}, format: {type: 'number'},
operator: '-', operator: '-',
visible: ui.section == 'items', visible: section == 'items',
width: 48 width: 48
}, },
{ {
clickable: function(data) { clickable: function(data) {
return ui.section == 'items' && ( return section == 'items' && (
data.type == 'smart' || data.user == pandora.user.username data.type == 'smart' || data.user == pandora.user.username
); );
}, },
@ -94,7 +95,7 @@ pandora.ui.folderList = function(id) {
width: '10px', width: '10px',
height: '10px', height: '10px',
padding: '3px', padding: '3px',
opacity: ui.section == 'texts' || data.user == pandora.user.username ? 1 : 0.25 opacity: section == 'texts' || data.user == pandora.user.username ? 1 : 0.25
}); });
}, },
id: 'type', id: 'type',
@ -253,7 +254,7 @@ pandora.ui.folderList = function(id) {
that = Ox.TableList({ that = Ox.TableList({
columns: columns, columns: columns,
items: items, items: items,
keys: ['modified'].concat(ui.section == 'items' ? ['query'] : ['rightslevel']), keys: ['modified'].concat(section == 'items' ? ['query'] : ['rightslevel']),
max: 1, max: 1,
min: 0, min: 0,
pageLength: 1000, pageLength: 1000,
@ -363,8 +364,8 @@ pandora.ui.folderList = function(id) {
}, },
*/ */
init: function(data) { init: function(data) {
if (pandora.site.sectionFolders[ui.section][i]) { if (pandora.site.sectionFolders[section][i]) {
pandora.site.sectionFolders[ui.section][i].items = data.items; pandora.site.sectionFolders[section][i].items = data.items;
pandora.$ui.folder[i].$content.css({ pandora.$ui.folder[i].$content.css({
height: data.items * 16 + 'px' height: data.items * 16 + 'px'
}); });
@ -392,7 +393,7 @@ pandora.ui.folderList = function(id) {
id != id_ && $list.options('selected', []); id != id_ && $list.options('selected', []);
}); });
} }
if (ui.section == 'items') { if (section == 'items') {
pandora.UI.set({ pandora.UI.set({
find: { find: {
conditions: list ? [ conditions: list ? [
@ -402,7 +403,7 @@ pandora.ui.folderList = function(id) {
} }
}); });
} else { } else {
pandora.UI.set(ui.section.slice(0, -1), list); pandora.UI.set(section.slice(0, -1), list);
} }
}, },
submit: function(data) { submit: function(data) {

View file

@ -1,6 +1,7 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.folders = function() { pandora.ui.folders = function(section) {
section = section || pandora.user.ui.section;
var ui = pandora.user.ui, var ui = pandora.user.ui,
counter = 0, counter = 0,
that = Ox.Element() that = Ox.Element()
@ -8,11 +9,11 @@ pandora.ui.folders = function() {
.bindEvent({ .bindEvent({
resize: pandora.resizeFolders resize: pandora.resizeFolders
}), }),
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section), folderItems = section == 'items' ? 'Lists' : Ox.toTitleCase(section),
folderItem = folderItems.slice(0, -1); folderItem = folderItems.slice(0, -1);
//var $sections = []; //var $sections = [];
pandora.$ui.allItems = pandora.ui.allItems().appendTo(that); pandora.$ui.allItems = pandora.ui.allItems(section).appendTo(that);
pandora.$ui.folder = []; pandora.$ui.folder = [];
pandora.$ui.folderBrowser = {}; pandora.$ui.folderBrowser = {};
pandora.$ui.folderList = {}; pandora.$ui.folderList = {};
@ -20,17 +21,17 @@ pandora.ui.folders = function() {
pandora.$ui.findListSelect = {}; pandora.$ui.findListSelect = {};
pandora.$ui.findListInput = {}; pandora.$ui.findListInput = {};
pandora.$ui.manageListsButton = {}; pandora.$ui.manageListsButton = {};
pandora.site.sectionFolders[ui.section].forEach(function(folder, i) { pandora.site.sectionFolders[section].forEach(function(folder, i) {
var extras, $select; var extras, $select;
if (folder.id == 'personal') { if (folder.id == 'personal') {
if (pandora.user.level == 'guest') { if (pandora.user.level == 'guest') {
extras = [ extras = [
infoButton(Ox._('Personal {0}', [Ox._(folderItems)]), infoButton(Ox._('Personal {0}', [Ox._(folderItems)]),
Ox._('To create and share your own list of {0} please sign up or sign in.', [Ox._(pandora.site.itemName.plural.toLowerCase())]), Ox._('To create and share your own list of {0} please sign up or sign in.', [Ox._(pandora.site.itemName.plural.toLowerCase())]),
Ox._('To create and share your own {0} please sign up or sign in.', [ui.section])) Ox._('To create and share your own {0} please sign up or sign in.', [section]))
]; ];
} else { } else {
if (ui.section == 'items') { if (section == 'items') {
extras = [ extras = [
pandora.$ui.personalListsMenu = Ox.MenuButton({ pandora.$ui.personalListsMenu = Ox.MenuButton({
items: [ items: [
@ -82,7 +83,7 @@ pandora.ui.folders = function() {
} }
}) })
]; ];
} else if (ui.section == 'texts') { } else if (section == 'texts') {
extras = [ extras = [
pandora.$ui.personalListsMenu = Ox.MenuButton({ pandora.$ui.personalListsMenu = Ox.MenuButton({
items: [ items: [
@ -113,7 +114,7 @@ pandora.ui.folders = function() {
]('deletetext'); ]('deletetext');
}) })
]; ];
} else if (ui.section == 'edits') { } else if (section == 'edits') {
extras = [ extras = [
pandora.$ui.personalListsMenu = Ox.MenuButton({ pandora.$ui.personalListsMenu = Ox.MenuButton({
items: [ items: [
@ -161,11 +162,11 @@ pandora.ui.folders = function() {
change: function(data) { change: function(data) {
var listData; var listData;
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders[ui.section][i].showBrowser = !pandora.site.sectionFolders[ui.section][i].showBrowser; pandora.site.sectionFolders[section][i].showBrowser = !pandora.site.sectionFolders[section][i].showBrowser;
this.options({tooltip: data.value ? Ox._('Done') : Ox._('Manage Favorite {0}', [Ox._(folderItems)])}); this.options({tooltip: data.value ? Ox._('Done') : Ox._('Manage Favorite {0}', [Ox._(folderItems)])});
if (pandora.site.sectionFolders[ui.section][i].showBrowser) { if (pandora.site.sectionFolders[section][i].showBrowser) {
pandora.$ui.folderList.favorite.replaceWith( pandora.$ui.folderList.favorite.replaceWith(
pandora.$ui.folderBrowser.favorite = pandora.ui.folderBrowser('favorite') pandora.$ui.folderBrowser.favorite = pandora.ui.folderBrowser('favorite', section)
); );
} else { } else {
listData = pandora.getListData(); listData = pandora.getListData();
@ -175,7 +176,7 @@ pandora.ui.folders = function() {
) { ) {
// the selected list in the favorites browser is not in the favorites folder // the selected list in the favorites browser is not in the favorites folder
pandora.$ui.folderList.favorite.options({selected: []}); pandora.$ui.folderList.favorite.options({selected: []});
if (Ox.getObjectById(pandora.site.sectionFolders[ui.section], 'featured').showBrowser) { if (Ox.getObjectById(pandora.site.sectionFolders[section], 'featured').showBrowser) {
// but in the featured browser // but in the featured browser
pandora.$ui.folderList.featured.options({selected: [listData.id]}); pandora.$ui.folderList.featured.options({selected: [listData.id]});
} else { } else {
@ -186,7 +187,7 @@ pandora.ui.folders = function() {
} }
} }
pandora.$ui.folderBrowser.favorite.replaceWith( pandora.$ui.folderBrowser.favorite.replaceWith(
pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite') pandora.$ui.folderList.favorite = pandora.ui.folderList('favorite', section)
); );
} }
pandora.resizeFolders(); pandora.resizeFolders();
@ -210,11 +211,11 @@ pandora.ui.folders = function() {
change: function(data) { change: function(data) {
var listData; var listData;
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
pandora.site.sectionFolders[ui.section][i].showBrowser = !pandora.site.sectionFolders[ui.section][i].showBrowser; pandora.site.sectionFolders[section][i].showBrowser = !pandora.site.sectionFolders[section][i].showBrowser;
this.options({tooltip: data.value ? Ox._('Done') : Ox._('Manage Favorite {0}', [Ox._(folderItems)])}); this.options({tooltip: data.value ? Ox._('Done') : Ox._('Manage Favorite {0}', [Ox._(folderItems)])});
if (pandora.site.sectionFolders[ui.section][i].showBrowser) { if (pandora.site.sectionFolders[section][i].showBrowser) {
pandora.$ui.folderList.featured.replaceWith( pandora.$ui.folderList.featured.replaceWith(
pandora.$ui.folderBrowser.featured = pandora.ui.folderBrowser('featured') pandora.$ui.folderBrowser.featured = pandora.ui.folderBrowser('featured', section)
); );
} else { } else {
listData = pandora.getListData(); listData = pandora.getListData();
@ -230,7 +231,7 @@ pandora.ui.folders = function() {
pandora.$ui.folderList.personal.options({selected: [listData.id]}); pandora.$ui.folderList.personal.options({selected: [listData.id]});
} else if ( } else if (
listData.subscribed listData.subscribed
|| Ox.getObjectById(pandora.site.sectionFolders[ui.section], 'favorite').showBrowser || Ox.getObjectById(pandora.site.sectionFolders[section], 'favorite').showBrowser
) { ) {
// but in the favorites folder or browser // but in the favorites folder or browser
pandora.$ui.folderList.favorite.options({selected: [listData.id]}); pandora.$ui.folderList.favorite.options({selected: [listData.id]});
@ -242,7 +243,7 @@ pandora.ui.folders = function() {
} }
} }
pandora.$ui.folderBrowser.featured.replaceWith( pandora.$ui.folderBrowser.featured.replaceWith(
pandora.$ui.folderList.featured = pandora.ui.folderList('featured') pandora.$ui.folderList.featured = pandora.ui.folderList('featured', section)
); );
} }
pandora.resizeFolders(); pandora.resizeFolders();
@ -305,7 +306,7 @@ pandora.ui.folders = function() {
} else if (data.id == 'browse') { } else if (data.id == 'browse') {
// alert('??') // alert('??')
/* /*
pandora.$ui.sectionList[1].replaceWith(pandora.$ui.publicLists = pandora.ui.publicLists()); pandora.$sectionList[1].replaceWith(pandora.$ui.publicLists = pandora.ui.publicLists());
pandora.site.showAllPublicLists = true; pandora.site.showAllPublicLists = true;
*/ */
} }
@ -316,8 +317,8 @@ pandora.ui.folders = function() {
pandora.resizeFolders(); pandora.resizeFolders();
} }
}); });
//$sections.push(pandora.$ui.section[i]); //$sections.push(pandora.$section[i]);
pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id) pandora.$ui.folderList[folder.id] = pandora.ui.folderList(folder.id, section)
.bindEvent({ .bindEvent({
selectnext: function() { selectnext: function() {
// ... // ...
@ -328,7 +329,7 @@ pandora.ui.folders = function() {
}) })
.bindEventOnce({ .bindEventOnce({
init: function(data) { init: function(data) {
if (++counter == pandora.site.sectionFolders[ui.section].length) { if (++counter == pandora.site.sectionFolders[section].length) {
pandora.$ui.folder.forEach(function($folder) { pandora.$ui.folder.forEach(function($folder) {
that.append($folder); that.append($folder);
}); });

View file

@ -1,14 +1,14 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.leftPanel = function() { pandora.ui.leftPanel = function(section) {
var that = Ox.SplitPanel({ var that = Ox.SplitPanel({
elements: [ elements: [
{ {
element: pandora.$ui.sectionbar = pandora.ui.sectionbar('buttons'), element: pandora.$ui.sectionbar = pandora.ui.sectionbar('buttons', section),
size: 24 size: 24
}, },
{ {
element: pandora.$ui.folders = pandora.ui.folders() element: pandora.$ui.folders = pandora.ui.folders(section)
}, },
{ {
collapsed: !pandora.user.ui.showInfo, collapsed: !pandora.user.ui.showInfo,
@ -29,11 +29,11 @@ pandora.ui.leftPanel = function() {
if (data.size < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) { if (data.size < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) {
pandora.$ui.sectionButtons.remove(); pandora.$ui.sectionButtons.remove();
delete pandora.$ui.sectionButtons; delete pandora.$ui.sectionButtons;
pandora.$ui.sectionbar.append(pandora.$ui.sectionSelect = pandora.ui.sectionSelect()); pandora.$ui.sectionbar.append(pandora.$ui.sectionSelect = pandora.ui.sectionSelect(section));
} else if (data.size >= pandora.site.sectionButtonsWidth && pandora.$ui.sectionSelect) { } else if (data.size >= pandora.site.sectionButtonsWidth && pandora.$ui.sectionSelect) {
pandora.$ui.sectionSelect.remove(); pandora.$ui.sectionSelect.remove();
delete pandora.$ui.sectionSelect; delete pandora.$ui.sectionSelect;
pandora.$ui.sectionbar.append(pandora.$ui.sectionButtons = pandora.ui.sectionButtons()); pandora.$ui.sectionbar.append(pandora.$ui.sectionButtons = pandora.ui.sectionButtons(section));
} }
pandora.$ui.leftPanel.size(2, infoHeight); pandora.$ui.leftPanel.size(2, infoHeight);
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -infoHeight + 'px'}); !pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -infoHeight + 'px'});

View file

@ -1,6 +1,6 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.sectionButtons = function() { pandora.ui.sectionButtons = function(section) {
var that = Ox.ButtonGroup({ var that = Ox.ButtonGroup({
buttons: [ buttons: [
{id: 'items', title: Ox._(pandora.site.itemName.plural)}, {id: 'items', title: Ox._(pandora.site.itemName.plural)},
@ -9,7 +9,7 @@ pandora.ui.sectionButtons = function() {
], ],
id: 'sectionButtons', id: 'sectionButtons',
selectable: true, selectable: true,
value: pandora.user.ui.section value: section || pandora.user.ui.section
}).css({ }).css({
float: 'left', float: 'left',
margin: '4px' margin: '4px'

View file

@ -1,6 +1,6 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.sectionSelect = function() { pandora.ui.sectionSelect = function(section) {
// fixme: duplicated // fixme: duplicated
var that = Ox.Select({ var that = Ox.Select({
id: 'sectionSelect', id: 'sectionSelect',
@ -9,7 +9,7 @@ pandora.ui.sectionSelect = function() {
{id: 'edits', title: Ox._('Edits'), disabled: pandora.user.level != 'admin'}, {id: 'edits', title: Ox._('Edits'), disabled: pandora.user.level != 'admin'},
{id: 'texts', title: Ox._('Texts'), disabled: pandora.user.level != 'admin'} {id: 'texts', title: Ox._('Texts'), disabled: pandora.user.level != 'admin'}
], ],
value: pandora.user.ui.section value: section || pandora.user.ui.section
}).css({ }).css({
float: 'left', float: 'left',
margin: '4px' margin: '4px'

View file

@ -1,13 +1,13 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.sectionbar = function(mode) { pandora.ui.sectionbar = function(mode, isDragAndDrop) {
var that = Ox.Bar({ var that = Ox.Bar({
size: 24 size: 24
}) })
.append( .append(
mode == 'buttons' mode == 'buttons'
? pandora.$ui.sectionButtons = pandora.ui.sectionButtons() ? pandora.$ui.sectionButtons = pandora.ui.sectionButtons(isDragAndDrop)
: pandora.$ui.sectionSelect = pandora.ui.sectionSelect() : pandora.$ui.sectionSelect = pandora.ui.sectionSelect(isDragAndDrop)
) )
.bindEvent({ .bindEvent({
doubleclick: function(e) { doubleclick: function(e) {

View file

@ -526,6 +526,260 @@ pandora.enableDragAndDrop = function($list, canMove) {
} }
} }
};
pandora.enableDragAndDropClip = function($list, canMove) {
var $tooltip = Ox.Tooltip({
animate: false
}),
drag = {},
scrollInterval;
$list.bindEvent({
draganddropstart: function(data) {
pandora.$ui.mainPanel.replaceElement(0, pandora.$ui.leftPanel = pandora.ui.leftPanel('edits'));
drag.action = 'copy';
drag.ids = $list.options('selected'),
drag.item = drag.ids.length == 1
? $list.value(drag.ids[0], 'title')
: drag.ids.length;
drag.source = pandora.getListData(),
drag.targets = {};
//fixme instead of a fixed timeout,
//bind to lists and update if they get new items
setTimeout(function() {
Ox.forEach(pandora.$ui.folderList, function($list) {
$list.addClass('OxDroppable').find('.OxItem').each(function() {
var $item = $(this),
id = $item.data('id'),
data = $list.value(id);
drag.targets[id] = Ox.extend({
editable: data.user == pandora.user.username
&& data.type == 'static',
selected: $item.is('.OxSelected')
}, data);
if (!drag.targets[id].selected && drag.targets[id].editable) {
$item.addClass('OxDroppable');
}
});
});
}, 2000);
$tooltip.options({title: getTitle()}).show(data.event);
canMove && Ox.UI.$window.on({
keydown: keydown,
keyup: keyup
});
},
draganddrop: function(data) {
var event = data.event;
$tooltip.options({
title: getTitle(event)
}).show(event);
if (scrollInterval && !isAtListsTop(event) && !isAtListsBottom(event)) {
clearInterval(scrollInterval);
scrollInterval = 0;
}
},
draganddroppause: function(data) {
var event = data.event, scroll,
$parent, $grandparent, $panel, title;
// fixme: should be named showLists in the user ui prefs!
if (!pandora.user.ui.showSidebar) {
if (event.clientX < 16 && event.clientY >= 44
&& event.clientY < window.innerHeight - 16
) {
pandora.$ui.mainPanel.toggle(0);
}
} else {
$parent = $(event.target).parent();
$grandparent = $parent.parent();
$panel = $parent.is('.OxCollapsePanel') ? $parent
: $grandparent.is('.OxCollapsePanel') ? $grandparent : null;
if ($panel) {
title = $panel.children('.OxBar').children('.OxTitle')
.html().split(' ')[0].toLowerCase();
if (!pandora.user.ui.showFolder.items[title]) {
Ox.UI.elements[$panel.data('oxid')].options({collapsed: false});
}
}
if (!scrollInterval) {
scroll = isAtListsTop(event) ? -16
: isAtListsBottom(event) ? 16 : 0
if (scroll) {
scrollInterval = setInterval(function() {
pandora.$ui.folders.scrollTop(
pandora.$ui.folders.scrollTop() + scroll
);
}, 100);
}
}
}
},
draganddropenter: function(data) {
var $parent = $(data.event.target).parent(),
$item = $parent.is('.OxItem') ? $parent : $parent.parent(),
$list = $item.parent().parent().parent().parent();
if ($list.is('.OxDroppable')) {
$item.addClass('OxDrop');
drag.target = drag.targets[$item.data('id')];
} else {
drag.target = null;
}
},
draganddropleave: function(data) {
var $parent = $(data.event.target).parent(),
$item = $parent.is('.OxItem') ? $parent : $parent.parent();
if ($item.is('.OxDroppable')) {
$item.removeClass('OxDrop');
drag.target = null;
}
},
draganddropend: function(data) {
var clips;
Ox.Log('', data, drag, '------------');
canMove && Ox.UI.$window.off({
keydown: keydown,
keyup: keyup
});
if (drag.target && drag.target.editable && !drag.target.selected) {
if (drag.action == 'copy' || (
drag.action == 'move' && drag.source.editable
)) {
clips = data.ids.map(function(id) {
var split = id.split('/'),
item = split[0];
split = split[1].split('-');
return {
item: item,
'in': parseFloat(split[0]),
out: parseFloat(split[1]),
}
});
if (drag.action == 'move') {
pandora.api.removeClips({
edit: pandora.user.ui.edit,
items: clips
}, function() {
Ox.print('FIXME, reload clipslist')
});
}
console.log('adding clips', clips);
pandora.api.addClips({
edit: drag.target.id,
clips: clips
}, function() {
Ox.Request.clearCache('Edit');
cleanup(250);
});
}
} else {
cleanup(0);
}
function cleanup(ms) {
drag = {};
clearInterval(scrollInterval);
scrollInterval = 0;
setTimeout(function() {
$('.OxDroppable').removeClass('OxDroppable');
$('.OxDrop').removeClass('OxDrop');
$tooltip.hide();
setTimeout(function() {
pandora.$ui.mainPanel.replaceElement(0, pandora.$ui.leftPanel = pandora.ui.leftPanel());
}, 500);
}, ms);
}
}
});
function getTitle() {
var image, text;
if (drag.action == 'move' && drag.source.user != pandora.user.username) {
image = 'symbolClose';
text = Ox._('You can only remove {0}<br/>from your own edits.',
[pandora.site.itemName.plural.toLowerCase()]);
} else if (drag.action == 'move' && drag.source.type == 'smart') {
image = 'symbolClose';
text = Ox._('You can\'t remove clips<br/>from smart edits.');
} else if (drag.target && drag.target.user != pandora.user.username) {
image = 'symbolClose';
text = Ox._('You can only {0} clips<br/>to your own edits',
[drag.action]);
} else if (drag.target && drag.target.type == 'smart') {
image = 'symbolClose';
text = Ox._('You can\'t {0} clips<br/>to smart lists',
[drag.action]);
} else {
image = drag.action == 'copy' ? 'symbolAdd' : 'symbolRemove';
text = Ox._(Ox.toTitleCase(drag.action)) + ' ' + (
Ox.isString(drag.item)
? '"' + drag.item + '"'
: drag.item + ' ' + pandora.site.itemName[
drag.item == 1 ? 'singular' : 'plural'
].toLowerCase()
) + '<br/>' + (
drag.target && !drag.target.selected
? Ox._('to the edit "{0}"', [Ox.encodeHTMLEntities(drag.target.name)])
: Ox._('to an edit')
);
}
return $('<div>')
.append(
$('<div>')
.css({
float: 'left',
width: '16px',
height: '16px',
padding: '2px',
border: '2px solid rgb(' + Ox.Theme.getThemeData().symbolDefaultColor.join(', ') + ')',
borderRadius: '12px',
margin: '3px 2px 2px 2px'
})
.append(
$('<img>')
.attr({src: Ox.UI.getImageURL(image)})
.css({width: '16px', height: '16px'})
)
)
.append(
$('<div>')
.css({
float: 'left',
margin: '1px 2px 2px 2px',
fontSize: '11px',
whiteSpace: 'nowrap'
})
.html(text)
)
}
function isAtListsTop(e) {
return pandora.user.ui.showSidebar
&& e.clientX < pandora.user.ui.sidebarSize
&& e.clientY >= 44 && e.clientY < 60;
}
function isAtListsBottom(e) {
var listsBottom = window.innerHeight - pandora.getInfoHeight();
return pandora.user.ui.showSidebar
&& e.clientX < pandora.user.ui.sidebarSize
&& e.clientY >= listsBottom - 16 && e.clientY < listsBottom;
}
function keydown(e) {
if (e.metaKey) {
drag.action = 'move';
$tooltip.options({title: getTitle()}).show();
}
}
function keyup(e) {
if (drag.action == 'move') {
drag.action = 'copy';
$tooltip.options({title: getTitle()}).show();
}
}
}; };
pandora.enterFullscreen = function() { pandora.enterFullscreen = function() {