MINOR Adapted CMS batch actions form to work outside of tabset context

This commit is contained in:
Ingo Schommer 2011-04-22 23:34:01 +12:00
parent b08fc52da4
commit 2c6e0c277b
5 changed files with 50 additions and 44 deletions

View File

@ -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('<p><small>%s</small></p>',
_t(
'CMSMain_left.ss.SELECTPAGESACTIONS',
'Select the pages that you want to change &amp; then click an action:'
)
)
),
new HiddenField('csvIDs'),
new DropdownField(
'Action',

View File

@ -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();
}
}
});

View File

@ -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));

View File

@ -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
*

View File

@ -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;
}
}
}
}