diff --git a/javascript/AssetAdmin.DragDrop.js b/javascript/AssetAdmin.DragDrop.js index abeb6b88..7a265d52 100644 --- a/javascript/AssetAdmin.DragDrop.js +++ b/javascript/AssetAdmin.DragDrop.js @@ -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 diff --git a/javascript/AssetAdmin.js b/javascript/AssetAdmin.js index 53b329b8..3e61d0c4 100755 --- a/javascript/AssetAdmin.js +++ b/javascript/AssetAdmin.js @@ -283,5 +283,4 @@ jQuery(document).ready(function() { Element.hide('Form_DeleteItemsForm'); } - new CheckBoxRange($('Form_EditForm'), 'Files[]'); }); \ No newline at end of file