2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* File: AssetAdmin.DragDrop.js
|
|
|
|
*/
|
2009-11-21 04:20:11 +01:00
|
|
|
(function($) {
|
2010-04-13 07:55:56 +02:00
|
|
|
$.entwine('ss', function($){
|
2009-11-21 04:20:11 +01:00
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Class: .AssetTableField.dragdrop
|
|
|
|
*/
|
2010-04-13 07:55:56 +02:00
|
|
|
$('.AssetTableField.dragdrop').entwine({
|
2009-11-21 04:20:11 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
2011-04-17 10:04:46 +02:00
|
|
|
$('.cms-tree li').each(function() {
|
2009-11-21 04:20:11 +01:00
|
|
|
$(this).droppable({
|
|
|
|
greedy: true,
|
|
|
|
hoverClass: 'over', // same hover effect as normal tree
|
|
|
|
drop: function(e, ui) {self.drop(e, ui);}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: drop
|
|
|
|
*
|
2009-11-21 04:20:11 +01:00
|
|
|
* Take selected files and move them to a folder target in the tree.
|
|
|
|
*/
|
|
|
|
drop: function(e, ui) {
|
|
|
|
var self = this;
|
|
|
|
if(e.target.id.match(/-([^-]+)$/)) {
|
|
|
|
var folderId = RegExp.$1;
|
|
|
|
$.post(
|
|
|
|
this.attr('href') + '/movemarked',
|
|
|
|
this.parents('form').serialize() + '&DestFolderID=' + folderId,
|
|
|
|
function(data, status) {
|
|
|
|
self.refresh();
|
|
|
|
}
|
|
|
|
)
|
2009-11-21 04:18:57 +01:00
|
|
|
}
|
2009-11-21 04:20:11 +01:00
|
|
|
},
|
2010-05-08 04:45:05 +02:00
|
|
|
|
2009-11-21 04:20:11 +01:00
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: getSelected
|
|
|
|
*
|
2009-11-21 04:20:11 +01:00
|
|
|
* Get the IDs of all selected files in the table.
|
|
|
|
* Used for drag'n'drop.
|
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Returns:
|
|
|
|
* Array
|
2009-11-21 04:20:11 +01:00
|
|
|
*/
|
|
|
|
getSelected: function() {
|
|
|
|
return this.find(':input[name=Files\[\]]:checked').map(function() {
|
|
|
|
return $(this).val();
|
|
|
|
});
|
2009-11-21 04:18:57 +01:00
|
|
|
}
|
2009-11-21 04:20:11 +01:00
|
|
|
});
|
|
|
|
|
2010-04-13 07:55:56 +02:00
|
|
|
$('.AssetTableField .dragfile').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
// Constructor: onmatch
|
2009-11-21 04:20:11 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
|
|
|
var container = this.parents('.AssetTableField');
|
|
|
|
|
|
|
|
this.draggable({
|
|
|
|
zIndex: 4000,
|
|
|
|
appendTo: 'body',
|
|
|
|
helper: function() {
|
|
|
|
return $(
|
|
|
|
'<div class="NumFilesIndicator">' +
|
|
|
|
ss.i18n.sprintf(ss.i18n._t('AssetTableField.MOVING'),container.getSelected().length) +
|
|
|
|
'</div>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
/**
|
2010-05-08 04:45:05 +02:00
|
|
|
* Function: onmousedown
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*
|
2009-11-21 04:20:11 +01:00
|
|
|
* Automatically select the checkbox in the same table row
|
|
|
|
* to signify that this element is moved, and hint that
|
|
|
|
* all checkboxed elements will be moved along with it.
|
|
|
|
*/
|
|
|
|
onmousedown: function(e) {
|
|
|
|
this.siblings('.markingcheckbox').find(':input').attr('checked', 'checked');
|
2009-11-21 04:18:57 +01:00
|
|
|
}
|
|
|
|
});
|
2009-11-21 04:20:11 +01:00
|
|
|
});
|
|
|
|
}(jQuery));
|