diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 19aa5e42..aa2bfc4e 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -228,6 +228,7 @@ class LeftAndMain extends Controller { Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.js'); Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.Tree.js'); Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.EditForm.js'); + Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.AddForm.js'); Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.BatchActions.js'); Requirements::themedCSS('typography'); diff --git a/javascript/AssetAdmin.js b/javascript/AssetAdmin.js index 2c50a134..c0633bd6 100755 --- a/javascript/AssetAdmin.js +++ b/javascript/AssetAdmin.js @@ -44,78 +44,6 @@ var _HANDLER_FORMS = { } ); - /** - * @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 - */ - $('#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: [], - - onmatch: function() { - 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; - - // 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; - } - }; - }); - $('#Form_SyncForm').concrete('ss', function($) { return { onmatch: function() { diff --git a/javascript/CMSMain.js b/javascript/CMSMain.js index 38b3ce75..3d23451a 100644 --- a/javascript/CMSMain.js +++ b/javascript/CMSMain.js @@ -153,111 +153,6 @@ }; }); - /** - * @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 - */ - $('#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: [], - - onmatch: function() { - var self = this; - - this.bind('submit', function(e) { - return self._submit(e); - }); - - Observable.applyTo(this[0]); - - var tree = jQuery('#sitetree')[0]; - this.setTree(tree); - jQuery(tree).bind('selectionchanged', function(e, data) {self.treeSelectionChanged(e, data);}); - - this.find(':input[name=PageType]').bind('change', this.typeDropdownChanged); - }, - - _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; - - // 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; - }, - - treeSelectionChanged : function(e, data) { - var selectedNode = data.node; - - if(selectedNode.hints && selectedNode.hints.defaultChild) { - this.find(':input[name=PageType]').val(selectedNode.hints.defaultChild); - } - - var parentID = this.Tree().getIdxOf(selectedNode); - this.find(':input[name=ParentID]').val(parentID ? parentID : 0); - }, - - typeDropdownChanged : function() { - var tree = this.Tree(); - - // Don't do anything if we're already on an appropriate node - var sel = tree.firstSelected(); - if(sel && sel.hints && sel.hints.allowedChildren) { - var allowed = sel.hints.allowedChildren; - for(i=0;i