From 1022e3debffc8be9798dd434569506c9ef169fdb Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 3 Mar 2015 10:36:21 +0000 Subject: [PATCH] fix drag and drop from edit to edit and from clips to edit fixes #2247 --- static/js/clipList.js | 29 ++++++++++++++--------------- static/js/editPanel.js | 8 +++++++- static/js/utils.js | 17 +++++++++-------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/static/js/clipList.js b/static/js/clipList.js index 281f6907..7a3836b3 100644 --- a/static/js/clipList.js +++ b/static/js/clipList.js @@ -136,22 +136,10 @@ pandora.ui.clipList = function(videoRatio) { .addClass('OxMedia') .bindEvent({ copy: function(data) { - var items = data.ids.map(function(id) { - var item = !ui.item ? id.split('/')[0] : ui.item, - annotations = that.value(id, 'annotations') || [], - annotation = annotations.length ? annotations[0].id : null; - return annotation || item + '/' + that.value(id, 'in') + '-' + that.value(id, 'out'); - }) - pandora.clipboard.copy(items, 'clip'); + pandora.clipboard.copy(serializeClips(data.ids), 'clip'); }, copyadd: function(data) { - var items = data.ids.map(function(id) { - var item = !ui.item ? id.split('/')[0] : ui.item, - annotations = that.value(id, 'annotations') || [], - annotation = annotations.length ? annotations[0].id : null; - return annotation || item + '/' + that.value(id, 'in') + '-' + that.value(id, 'out'); - }) - pandora.clipboard.add(items, 'clip'); + pandora.clipboard.add(serializeClips(data.ids), 'clip'); }, gainfocus: function() { pandora.$ui.mainMenu.replaceItemMenu(); @@ -290,7 +278,18 @@ pandora.ui.clipList = function(videoRatio) { } }); - pandora.enableDragAndDrop(that, true, 'edits'); + function serializeClips(ids) { + return ids.map(function(id) { + var item = !ui.item ? id.split('/')[0] : ui.item, + annotations = that.value(id, 'annotations') || [], + annotation = annotations.length ? annotations[0].id : null; + return annotation || item + '/' + that.value(id, 'in') + '-' + that.value(id, 'out'); + }); + } + + pandora.enableDragAndDrop(that, true, 'edits', function($list) { + return serializeClips($list.options('selected')); + }); return that; } diff --git a/static/js/editPanel.js b/static/js/editPanel.js index 36ddd928..23be3d88 100644 --- a/static/js/editPanel.js +++ b/static/js/editPanel.js @@ -23,7 +23,13 @@ pandora.ui.editPanel = function(isEmbed) { function enableDragAndDrop() { pandora.enableDragAndDrop( Ox.$elements[that.find('.OxIconList').data('oxid')], - edit.editable + edit.editable, + 'edits', + function($list) { + return serializeClips($list.options('selected')).map(function(id) { + return id.split('/').slice(0, 2).join('/'); + }); + } ); } diff --git a/static/js/utils.js b/static/js/utils.js index 5f8d30ff..c5678d1d 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -520,7 +520,7 @@ pandora.createLinks = function($element) { }()); -pandora.enableDragAndDrop = function($list, canMove, section) { +pandora.enableDragAndDrop = function($list, canMove, section, getItems) { section = section || pandora.user.ui.section; @@ -532,17 +532,18 @@ pandora.enableDragAndDrop = function($list, canMove, section) { $list.bindEvent({ draganddropstart: function(data) { - if (section != pandora.user.ui.section) { + var ui = pandora.user.ui; + if (section != ui.section) { pandora.$ui.mainPanel.replaceElement(0, pandora.$ui.leftPanel = pandora.ui.leftPanel(section) ); } drag.action = 'copy'; - drag.ids = $list.options('selected'), + drag.ids = getItems ? getItems($list) : $list.options('selected'); drag.item = drag.ids.length == 1 ? $list.value(drag.ids[0], 'title') || 1 : drag.ids.length; - drag.source = pandora.getListData(), + drag.source = pandora.getListData(); drag.targets = {}; //fixme instead of a fixed timeout, //bind to lists and update if they get new items @@ -564,7 +565,7 @@ pandora.enableDragAndDrop = function($list, canMove, section) { } }); }); - }, section != pandora.user.ui.section ? 2000 : 0); + }, section != ui.section ? 2000 : 0); $tooltip.options({title: getTitle()}).show(data.event); canMove && Ox.$window.on({ keydown: keydown, @@ -647,7 +648,7 @@ pandora.enableDragAndDrop = function($list, canMove, section) { if (section == 'items') { var targets = drag.action == 'copy' ? drag.target.id : [pandora.user.ui._list, drag.target.id]; - pandora.doHistory(drag.action, data.ids, targets, function() { + pandora.doHistory(drag.action, drag.ids, targets, function() { Ox.Request.clearCache('find'); pandora.api.find({ query: { @@ -666,8 +667,8 @@ pandora.enableDragAndDrop = function($list, canMove, section) { } else if (section == 'edits') { var targets = drag.action == 'copy' ? drag.target.id : [pandora.user.ui.edit, drag.target.id]; - pandora.doHistory(drag.action, data.ids, targets, function() { - Ox.print('FIXME, reload clipslist on move'); + pandora.doHistory(drag.action, drag.ids, targets, function() { + Ox.print('FIXME, reload clipslist on drag', drag.ids); pandora.$ui.editPanel && pandora.$ui.editPanel.updatePanel(); cleanup(250); });