Merge pull request #437 from mateusz/sapphire

---

http://open.silverstripe.org/ticket/7304

When the actions dropdown is loaded from deferred cache, the Chosen does not apply because of stale classess and markup.
This commit is contained in:
Ingo Schommer 2012-05-11 11:17:39 +02:00
commit d5ebdf91b6
3 changed files with 24 additions and 8 deletions

View File

@ -805,7 +805,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
}
}
$this->response->addHeader('X-Status', _t('LeftAndMain.SAVED','saved'));
$this->response->addHeader('X-Status', _t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.'));
}
// Update sorting
@ -826,7 +826,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
}
}
$this->response->addHeader('X-Status', _t('LeftAndMain.SAVED','saved'));
$this->response->addHeader('X-Status', _t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.'));
}
return Convert::raw2json($statusUpdates);

View File

@ -43,7 +43,7 @@
tree.bind('check_node.jstree', function(e, data) {
self.serializeFromTree();
});
$('.cms-tree-view-modes :input[name=view-mode]').bind('click', function(e) {
var val = $(e.target).val(), dropdown = self.find(':input[name=Action]');
if(val == 'multiselect') {
@ -53,14 +53,26 @@
tree.removeClass('multiple');
}
// Batch actions only make sense when multiselect is enabled
if(val == 'multiselect') dropdown.removeAttr('disabled').change();
else dropdown.attr('disabled', 'disabled').change();
self._updateStateFromViewMode();
});
self._updateStateFromViewMode();
this._super();
},
/**
* Updates the select box state according to the current view mode.
*/
_updateStateFromViewMode: function() {
var viewMode = $('.cms-tree-view-modes :input[name=view-mode]:checked').val();
var dropdown = this.find(':input[name=Action]');
// Batch actions only make sense when multiselect is enabled.
if(viewMode == 'multiselect') dropdown.removeAttr('disabled').trigger("liszt:updated");
else dropdown.attr('disabled', true).trigger("liszt:updated");
},
/**
* Function: register
*
@ -350,4 +362,4 @@
});
});
})(jQuery);
})(jQuery);

View File

@ -489,6 +489,10 @@ jQuery.noConflict();
// Explicitly disable default placeholder if no custom one is defined
if(!this.data('placeholder')) this.data('placeholder', ' ');
// We could've gotten stale classes and DOM elements from deferred cache.
this.removeClass('has-chzn chzn-done');
this.siblings('.chzn-container').remove();
// Apply Chosen
applyChosen(this);