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:
Ingo Schommer 2009-11-21 03:19:12 +00:00
parent ba931706d6
commit dd52d7a804
2 changed files with 0 additions and 61 deletions

View File

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

View File

@ -283,5 +283,4 @@ jQuery(document).ready(function() {
Element.hide('Form_DeleteItemsForm');
}
new CheckBoxRange($('Form_EditForm'), 'Files[]');
});