2007-07-19 12:40:05 +02:00
|
|
|
/**
|
|
|
|
* Configuration for the left hand tree
|
|
|
|
*/
|
|
|
|
if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {};
|
|
|
|
SiteTreeHandlers.parentChanged_url = 'admin/assets/ajaxupdateparent';
|
|
|
|
SiteTreeHandlers.orderChanged_url = 'admin/assets/ajaxupdatesort';
|
|
|
|
SiteTreeHandlers.loadPage_url = 'admin/assets/getitem';
|
|
|
|
SiteTreeHandlers.loadTree_url = 'admin/assets/getsubtree';
|
|
|
|
SiteTreeHandlers.showRecord_url = 'admin/assets/show/';
|
2007-09-04 06:12:30 +02:00
|
|
|
SiteTreeHandlers.controller_url = 'admin/assets';
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
var _HANDLER_FORMS = {
|
2009-11-21 04:19:05 +01:00
|
|
|
addpage : 'Form_AddForm',
|
2009-01-06 03:18:33 +01:00
|
|
|
deletepage : 'Form_DeleteItemsForm',
|
2007-07-19 12:40:05 +02:00
|
|
|
sortitems : 'sortitems_options'
|
|
|
|
};
|
|
|
|
|
2009-11-21 04:18:25 +01:00
|
|
|
(function($) {
|
2009-11-21 04:19:14 +01:00
|
|
|
$('.AssetAdmin').concrete('ss', function($) {
|
|
|
|
return {
|
|
|
|
onmatch: function() {
|
|
|
|
|
|
|
|
this._super();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete selected folders through "batch actions" tab.
|
|
|
|
*/
|
|
|
|
$('#Form_BatchActionsForm').concrete('ss').register(
|
|
|
|
'admin/assets/batchactions/delete',
|
|
|
|
function(ids) {
|
|
|
|
var confirmed = confirm(
|
|
|
|
ss.i18n.sprintf(
|
|
|
|
ss.i18n._t(
|
|
|
|
'AssetAdmin.BATCHACTIONSDELETECONFIRM',
|
|
|
|
"Do you really want to delete %d folders?"
|
|
|
|
),
|
|
|
|
ids.length
|
|
|
|
)
|
|
|
|
);
|
|
|
|
return (confirmed) ? ids : false;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2009-11-21 04:18:25 +01:00
|
|
|
/**
|
2009-11-21 04:19:05 +01:00
|
|
|
* @class Simple form with a page type dropdown
|
|
|
|
* which creates a new page through #Form_EditForm and adds a new tree node.
|
|
|
|
* @name ss.Form_AddForm
|
|
|
|
* @requires ss.i18n
|
|
|
|
* @requires ss.Form_EditForm
|
2009-11-21 04:18:25 +01:00
|
|
|
*/
|
2009-11-21 04:19:05 +01:00
|
|
|
$('#Form_AddForm').concrete(function($) {
|
|
|
|
return/** @lends ss.Form_AddForm */{
|
|
|
|
/**
|
|
|
|
* @type DOMElement
|
|
|
|
*/
|
|
|
|
Tree: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type Array Internal counter to create unique page identifiers prior to ajax saving
|
|
|
|
*/
|
|
|
|
_NewPages: [],
|
|
|
|
|
2009-11-21 04:18:25 +01:00
|
|
|
onmatch: function() {
|
2009-11-21 04:19:05 +01:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.bind('submit', function(e) {
|
|
|
|
return self._submit(e);
|
|
|
|
});
|
|
|
|
|
|
|
|
Observable.applyTo(this[0]);
|
|
|
|
|
|
|
|
var tree = jQuery('#sitetree')[0];
|
|
|
|
this.setTree(tree);
|
|
|
|
},
|
|
|
|
|
|
|
|
_submit: function(e) {
|
|
|
|
var newPages = this._NewPages();
|
|
|
|
var tree = this.Tree();
|
|
|
|
var parentID = (tree.firstSelected()) ? tree.getIdxOf(tree.firstSelected()) : 0;
|
|
|
|
|
|
|
|
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
|
|
|
|
if(parentID && parentID.substr(0,3) == 'new') {
|
|
|
|
alert(ss.i18n._t('CMSMAIN.WARNINGSAVEPAGESBEFOREADDING'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tree.firstSelected() && jQuery(tree.firstSelected()).hasClass("nochildren")) {
|
|
|
|
alert(ss.i18n._t('CMSMAIN.CANTADDCHILDREN') );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Optionally initalize the new pages tracker
|
|
|
|
if(!newPages[parentID] ) newPages[parentID] = 1;
|
2009-11-21 04:18:25 +01:00
|
|
|
|
2009-11-21 04:19:05 +01:00
|
|
|
// default to first button
|
|
|
|
var button = jQuery(this).find(':submit:first');
|
|
|
|
button.addClass('loading');
|
|
|
|
|
|
|
|
// collect data and submit the form
|
|
|
|
var data = jQuery(this).serializeArray();
|
|
|
|
data.push({name:'Suffix',value:newPages[parentID]++});
|
|
|
|
data.push({name:button.attr('name'),value:button.val()});
|
|
|
|
jQuery('#Form_EditForm').concrete('ss').loadForm(
|
|
|
|
jQuery(this).attr('action'),
|
|
|
|
function() {
|
|
|
|
button.removeClass('loading');
|
|
|
|
},
|
|
|
|
{type: 'POST', data: data}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.set_NewPages(newPages);
|
|
|
|
|
|
|
|
return false;
|
2007-09-15 22:47:35 +02:00
|
|
|
}
|
2009-11-21 04:18:25 +01:00
|
|
|
};
|
|
|
|
});
|
2007-07-19 12:40:05 +02:00
|
|
|
|
2009-11-21 04:19:05 +01:00
|
|
|
$('#Form_SyncForm').concrete('ss', function($) {
|
|
|
|
return {
|
|
|
|
onmatch: function() {
|
|
|
|
this.bind('submit', this._onsubmit);
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
_onsubmit: function(e) {
|
|
|
|
var button = jQuery(this).find(':submit:first');
|
|
|
|
button.addClass('loading');
|
|
|
|
$.get(
|
|
|
|
jQuery(this).attr('action'),
|
|
|
|
function() {
|
|
|
|
button.removeClass('loading');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
2007-07-19 12:40:05 +02:00
|
|
|
}
|
2009-11-21 04:19:05 +01:00
|
|
|
};
|
|
|
|
});
|
2009-11-21 04:19:18 +01:00
|
|
|
}(jQuery));
|