2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* File: AssetAdmin.js
|
|
|
|
*/
|
|
|
|
|
2009-11-21 04:18:25 +01:00
|
|
|
(function($) {
|
2010-04-13 07:55:56 +02:00
|
|
|
$.entwine('ss', function($){
|
2012-05-11 07:37:31 +02:00
|
|
|
/**
|
|
|
|
* Delete selected folders through "batch actions" tab.
|
|
|
|
*/
|
2012-06-15 05:50:11 +02:00
|
|
|
/* assets don't currently have batch actions; disabling for now
|
2012-05-11 07:37:31 +02:00
|
|
|
$(document).ready(function() {
|
2012-05-22 01:28:27 +02:00
|
|
|
$('#Form_BatchActionsForm').entwine('.ss.tree').register(
|
2012-05-11 07:37:31 +02:00
|
|
|
// TODO Hardcoding of base URL
|
2016-01-06 00:42:07 +01:00
|
|
|
'admin/assets/batchactions/delete',
|
2012-05-11 07:37:31 +02:00
|
|
|
function(ids) {
|
|
|
|
var confirmed = confirm(
|
|
|
|
ss.i18n.sprintf(
|
|
|
|
ss.i18n._t('AssetAdmin.BATCHACTIONSDELETECONFIRM'),
|
|
|
|
ids.length
|
|
|
|
)
|
|
|
|
);
|
|
|
|
return (confirmed) ? ids : false;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2012-06-15 05:50:11 +02:00
|
|
|
*/
|
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-03-08 17:26:34 +01:00
|
|
|
$('.AssetAdmin.cms-edit-form .ss-gridfield-item').entwine({
|
2012-02-21 21:17:49 +01:00
|
|
|
onclick: function(e) {
|
2012-02-23 17:32:00 +01:00
|
|
|
// Let actions do their own thing
|
2012-03-08 17:26:34 +01:00
|
|
|
if($(e.target).closest('.action').length) {
|
2012-03-01 00:15:28 +01:00
|
|
|
this._super(e);
|
2012-02-28 16:56:21 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-02-23 17:32:00 +01:00
|
|
|
|
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);
|
2012-03-01 00:15:28 +01:00
|
|
|
return false;
|
2012-02-21 21:17:49 +01:00
|
|
|
}
|
2012-06-05 13:46:22 +02:00
|
|
|
|
|
|
|
this._super(e);
|
2012-02-21 21:17:49 +01:00
|
|
|
}
|
|
|
|
});
|
2012-02-23 17:32:00 +01:00
|
|
|
|
2013-12-17 10:54:14 +01:00
|
|
|
$('.AssetAdmin.cms-edit-form .ss-gridfield .col-buttons .action.gridfield-button-delete, .AssetAdmin.cms-edit-form .Actions button.action.action-delete').entwine({
|
2012-03-08 17:26:34 +01:00
|
|
|
onclick: function(e) {
|
2012-03-09 21:12:22 +01:00
|
|
|
var msg;
|
|
|
|
if(this.closest('.ss-gridfield-item').data('class') == 'Folder') {
|
|
|
|
msg = ss.i18n._t('AssetAdmin.ConfirmDelete');
|
|
|
|
} else {
|
|
|
|
msg = ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE');
|
2016-01-06 00:42:07 +01:00
|
|
|
}
|
2012-03-09 21:12:22 +01:00
|
|
|
if(!confirm(msg)) return false;
|
2012-03-08 17:26:34 +01:00
|
|
|
|
|
|
|
this.getGridField().reload({data: [{name: this.attr('name'), value: this.val()}]});
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.AssetAdmin.cms-edit-form :submit[name=action_delete]').entwine({
|
2012-02-23 17:32:00 +01:00
|
|
|
onclick: function(e) {
|
2012-03-09 21:12:22 +01:00
|
|
|
if(!confirm(ss.i18n._t('AssetAdmin.ConfirmDelete'))) return false;
|
2012-02-23 17:32:00 +01:00
|
|
|
else this._super(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-03-08 17:26:02 +01:00
|
|
|
/**
|
|
|
|
* Prompt for a new foldername, rather than using dedicated form.
|
|
|
|
* Better usability, but less flexibility in terms of inputs and validation.
|
|
|
|
* Mainly necessary because AssetAdmin->AddForm() returns don't play nicely
|
|
|
|
* with the nested AssetAdmin->EditForm() DOM structures.
|
|
|
|
*/
|
|
|
|
$('.AssetAdmin .cms-add-folder-link').entwine({
|
|
|
|
onclick: function(e) {
|
|
|
|
var name = prompt(ss.i18n._t('Folder.Name'));
|
|
|
|
if(!name) return false;
|
|
|
|
|
|
|
|
this.closest('.cms-container').loadPanel(this.data('url') + '&Name=' + name);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* 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-04-12 23:55:37 +02:00
|
|
|
$('.cms-content').loadPanel(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
|
|
|
});
|
2012-05-11 07:37:31 +02:00
|
|
|
}(jQuery));
|