2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* File: AssetAdmin.js
|
|
|
|
*/
|
|
|
|
|
2009-11-21 04:18:25 +01:00
|
|
|
(function($) {
|
2009-11-21 04:19:14 +01:00
|
|
|
/**
|
|
|
|
* Delete selected folders through "batch actions" tab.
|
|
|
|
*/
|
2009-11-21 04:19:59 +01:00
|
|
|
$(document).ready(function() {
|
2010-04-13 07:55:56 +02:00
|
|
|
$('#Form_BatchActionsForm').entwine('ss').register(
|
2009-11-21 04:19:41 +01:00
|
|
|
// TODO Hardcoding of base URL
|
|
|
|
'admin/assets/batchactions/delete',
|
|
|
|
function(ids) {
|
|
|
|
var confirmed = confirm(
|
|
|
|
ss.i18n.sprintf(
|
|
|
|
ss.i18n._t('AssetAdmin.BATCHACTIONSDELETECONFIRM'),
|
|
|
|
ids.length
|
|
|
|
)
|
|
|
|
);
|
|
|
|
return (confirmed) ? ids : false;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2009-11-21 04:19:14 +01:00
|
|
|
|
2010-04-13 07:55:56 +02:00
|
|
|
$.entwine('ss', function($){
|
2012-02-21 21:17:49 +01:00
|
|
|
|
2012-02-23 17:32:00 +01:00
|
|
|
/**
|
|
|
|
* Load folder detail view via controller methods
|
|
|
|
* rather than built-in GridField view (which is only geared towards showing files).
|
|
|
|
*/
|
2012-02-21 21:17:49 +01:00
|
|
|
$('#Form_EditForm_File .ss-gridfield-item').entwine({
|
|
|
|
onclick: function(e) {
|
2012-02-23 17:32:00 +01:00
|
|
|
// Let actions do their own thing
|
|
|
|
if($(e.target).is('.action')) return;
|
|
|
|
|
2012-02-23 16:08:27 +01:00
|
|
|
var grid = this.closest('.ss-gridfield');
|
2012-02-21 21:17:49 +01:00
|
|
|
if(this.data('class') == 'Folder') {
|
|
|
|
var url = grid.data('urlFolderTemplate').replace('%s', this.data('id'));
|
|
|
|
$('.cms-container').loadPanel(url);
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2012-02-23 17:32:00 +01:00
|
|
|
|
|
|
|
$('.cms-edit-form :submit[name=action_delete]').entwine({
|
|
|
|
onclick: function(e) {
|
|
|
|
if(!confirm(ss.i18n._t('AssetAdmin.ConfirmDelete'))) return false;
|
|
|
|
else this._super(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Class: #Form_SyncForm
|
|
|
|
*/
|
2010-04-13 07:55:56 +02:00
|
|
|
$('#Form_SyncForm').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onsubmit
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2009-11-21 04:19:59 +01:00
|
|
|
onsubmit: function(e) {
|
2009-11-21 04:19:05 +01:00
|
|
|
var button = jQuery(this).find(':submit:first');
|
|
|
|
button.addClass('loading');
|
2011-03-15 22:13:49 +01:00
|
|
|
$.ajax({
|
|
|
|
url: jQuery(this).attr('action'),
|
|
|
|
data: this.serializeArray(),
|
|
|
|
success: function() {
|
2009-11-21 04:19:05 +01:00
|
|
|
button.removeClass('loading');
|
2009-11-21 04:21:03 +01:00
|
|
|
// reload current form and tree
|
2011-04-17 10:04:46 +02:00
|
|
|
var currNode = $('.cms-tree')[0].firstSelected();
|
2009-11-21 04:19:43 +01:00
|
|
|
if(currNode) {
|
|
|
|
var url = $(currNode).find('a').attr('href');
|
2012-02-21 21:17:49 +01:00
|
|
|
$('.cms-content').loadForm(url);
|
2009-11-21 04:19:43 +01:00
|
|
|
}
|
2011-04-17 10:04:46 +02:00
|
|
|
$('.cms-tree')[0].setCustomURL('admin/assets/getsubtree');
|
|
|
|
$('.cms-tree')[0].reload({onSuccess: function() {
|
2009-11-21 04:21:03 +01:00
|
|
|
// TODO Reset current tree node
|
|
|
|
}});
|
2009-11-21 04:19:05 +01:00
|
|
|
}
|
2011-03-15 22:13:49 +01:00
|
|
|
});
|
2009-11-21 04:19:05 +01:00
|
|
|
|
|
|
|
return false;
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:19:05 +01:00
|
|
|
});
|
2009-11-21 04:19:18 +01:00
|
|
|
}(jQuery));
|