mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENHANCEMENT Removed CheckboxRange javascript from AssetAdmin.js, unnecessary complication of the UI with legacy prototypejs-based code.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92805 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ba931706d6
commit
dd52d7a804
@ -1,63 +1,3 @@
|
||||
// CheckBoxRange adapted from: http://jroller.com/page/rmcmahon?entry=checkboxrange_with_prototype
|
||||
var CheckBoxRange = Class.create();
|
||||
|
||||
CheckBoxRange.prototype = {
|
||||
currentBox: null,
|
||||
form: null,
|
||||
field: null,
|
||||
|
||||
initialize: function(form, field) {
|
||||
this.form = form;
|
||||
this.field = field;
|
||||
this.eventPossibleCheckHappened = this.possibleCheckHappened.bindAsEventListener(this);
|
||||
if(form) {
|
||||
Event.observe(form, "click", this.eventPossibleCheckHappened);
|
||||
Event.observe(form, "keyup", this.eventPossibleCheckHappened);
|
||||
}
|
||||
},
|
||||
|
||||
possibleCheckHappened: function(event) {
|
||||
var target = Event.element(event);
|
||||
|
||||
if ((event.button == 0 || event.keyCode == 32 || event.keyCode == 17) &&
|
||||
this.isCheckBox(target) && target.form == $(this.form) && target.name == this.field) {
|
||||
// If ctrl or shift is keys are pressed
|
||||
if ((event.shiftKey || event.ctrlKey ) && this.currentBox)
|
||||
this.updateCheckBoxRange(this.currentBox, target);
|
||||
this.currentBox = target;
|
||||
}
|
||||
},
|
||||
|
||||
isCheckBox: function(e) {
|
||||
return (e.tagName.toLowerCase() == "input" && e.type.toLowerCase() == "checkbox");
|
||||
},
|
||||
|
||||
updateCheckBoxRange: function(start, end) {
|
||||
var last_clicked = end;
|
||||
var checkboxes = Form.getInputs(this.form, 'checkbox', this.field);
|
||||
var checkbox;
|
||||
var last;
|
||||
|
||||
for (var i=0; (checkbox = checkboxes[i]); ++i) {
|
||||
if (checkbox == end) {
|
||||
last = start;
|
||||
break;
|
||||
}
|
||||
if (checkbox == start) {
|
||||
last = end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (; (checkbox = checkboxes[i]); ++i) {
|
||||
if (checkbox != last_clicked && checkbox.checked != last_clicked.checked)
|
||||
checkbox.click();
|
||||
if (checkbox == last)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SubsDraggable adapted from http://dev.rubyonrails.org/ticket/5771
|
||||
|
||||
// extentions for scriptaculous dragdrop.js
|
||||
|
@ -283,5 +283,4 @@ jQuery(document).ready(function() {
|
||||
Element.hide('Form_DeleteItemsForm');
|
||||
}
|
||||
|
||||
new CheckBoxRange($('Form_EditForm'), 'Files[]');
|
||||
});
|
Loading…
Reference in New Issue
Block a user