From 2c6e0c277b8cdf7f52621a8644175fe2818602dd Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 22 Apr 2011 23:34:01 +1200 Subject: [PATCH] MINOR Adapted CMS batch actions form to work outside of tabset context --- admin/code/LeftAndMain.php | 11 +-------- admin/javascript/LeftAndMain.BatchActions.js | 25 +++++++++++++------- admin/javascript/LeftAndMain.Tree.js | 15 ++++++++++-- admin/javascript/LeftAndMain.js | 21 ---------------- admin/scss/_forms.scss | 22 +++++++++++++++-- 5 files changed, 50 insertions(+), 44 deletions(-) diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php index f006df5b8..275e9320c 100644 --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -935,22 +935,13 @@ class LeftAndMain extends Controller { */ function BatchActionsForm() { $actions = $this->batchactions()->batchActionList(); - $actionsMap = array(); + $actionsMap = array('-1' => _t('LeftAndMain.DropdownBatchActionsDefault', 'Actions')); foreach($actions as $action) $actionsMap[$action->Link] = $action->Title; $form = new Form( $this, 'BatchActionsForm', new FieldSet( - new LiteralField( - 'Intro', - sprintf('

%s

', - _t( - 'CMSMain_left.ss.SELECTPAGESACTIONS', - 'Select the pages that you want to change & then click an action:' - ) - ) - ), new HiddenField('csvIDs'), new DropdownField( 'Action', diff --git a/admin/javascript/LeftAndMain.BatchActions.js b/admin/javascript/LeftAndMain.BatchActions.js index ead11b008..4c8c44fad 100644 --- a/admin/javascript/LeftAndMain.BatchActions.js +++ b/admin/javascript/LeftAndMain.BatchActions.js @@ -44,16 +44,12 @@ self.serializeFromTree(); }); - // if tab which contains this form is shown, make the tree selectable - $('#TreeActions').bind('tabsselect', function(e, ui) { - // if we are selecting another tab, or the panel is visible (meaning about to be closed), - // disable tree selection and reset any values. Otherwise enable it. - if($(ui.panel).attr('id') != 'TreeActions-batchactions' || $(ui.panel).is(':visible')) { - // @TODO: this is unneccessarily fired also when switching between two other tabs - tree.removeClass('multiple'); - } else { + $('.cms-tree-tools :input[name=view-mode]').bind('click', function(e) { + if($(e.target).val() == 'multiselect') { tree.addClass('multiple'); self.serializeFromTree(); + } else { + tree.removeClass('multiple'); } }); @@ -295,6 +291,11 @@ */ $('#Form_BatchActionsForm select[name=Action]').entwine({ + onmatch: function() { + this.trigger('change'); + this._super(); + }, + /** * Function: onchange * @@ -302,7 +303,13 @@ * (Event) e */ onchange: function(e) { - $(e.target.form).entwine('ss').refreshSelected(); + var form = $(e.target.form), btn = form.find(':submit'); + if($(e.target).val() == -1) { + btn.attr('disabled', 'disabled'); + } else { + btn.removeAttr('disabled'); + form.entwine('ss').refreshSelected(); + } } }); diff --git a/admin/javascript/LeftAndMain.Tree.js b/admin/javascript/LeftAndMain.Tree.js index 92c88e9fd..55b6bd311 100755 --- a/admin/javascript/LeftAndMain.Tree.js +++ b/admin/javascript/LeftAndMain.Tree.js @@ -109,8 +109,8 @@ }) .bind('before.jstree', function(e, data) { if(data.func == 'start_drag') { - // Only allow drag'n'drop if it has been specifically enabled, or the tree is in search mode - if(!$('input[id=sortitems]').is(':checked') || self.data('searchparams')) { + // Don't allow drag'n'drop if multi-select is enabled' + if(!self.hasClass('draggable') || self.hasClass('multiselect')) { e.stopImmediatePropagation(); return false; } @@ -297,5 +297,16 @@ return this.data('id'); } }); + + $('.cms-tree-tools :input[name=view-mode]').entwine({ + onmatch: function() { + // set active by default + this.trigger('click'); + this._super(); + }, + onclick: function(e) { + $('.cms-tree').toggleClass('draggable', $(e.target).val() == 'draggable'); + } + }); }(jQuery)); \ No newline at end of file diff --git a/admin/javascript/LeftAndMain.js b/admin/javascript/LeftAndMain.js index 392d485df..fb3e0dba8 100644 --- a/admin/javascript/LeftAndMain.js +++ b/admin/javascript/LeftAndMain.js @@ -124,27 +124,6 @@ } }); - /** - * Class: #TreeActions - * - * Container for tree actions like "create", "search", etc. - */ - $('#TreeActions').entwine({ - /** - * Constructor: onmatch - * - * Setup "create", "search", "batch actions" layers above tree. - * All tab contents are closed by default. - */ - onmatch: function() { - this.tabs({ - collapsible: true, - selected: parseInt(jQuery.cookie('ui-tabs-TreeActions'), 10) || null, - cookie: { expires: 30, path: '/', name: 'ui-tabs-TreeActions' } - }); - } - }); - /** * Class: a#EditMemberProfile * diff --git a/admin/scss/_forms.scss b/admin/scss/_forms.scss index e6f57ad20..b541e5bfc 100644 --- a/admin/scss/_forms.scss +++ b/admin/scss/_forms.scss @@ -10,7 +10,7 @@ display: block; padding: 10px 0; border-bottom: 1px solid $color-shadow-light; - + label { float: left; width: 10em; @@ -31,7 +31,12 @@ width: auto; } } - + } + + .field.nolabel { + .middleColumn { + margin-left: 0; + } } input, textarea { @@ -76,4 +81,17 @@ text-align: right; } } + + .cms-content-tools { + .field { + label { + float: none; + width: auto; + } + + .middleColumn { + margin-left: 0; + } + } + } } \ No newline at end of file