From bb7408fd4ca0cfe41b4145fec088b36c185c969e Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Wed, 22 Feb 2006 09:59:22 +0000 Subject: Update script.aculo.us to V1.5.3 [Thomas Fuchs] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3634 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../action_view/helpers/javascripts/dragdrop.js | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'actionpack/lib/action_view/helpers/javascripts/dragdrop.js') diff --git a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js index 57dab290b2..b44afe4881 100644 --- a/actionpack/lib/action_view/helpers/javascripts/dragdrop.js +++ b/actionpack/lib/action_view/helpers/javascripts/dragdrop.js @@ -349,7 +349,7 @@ Draggable.prototype = { }, keyPress: function(event) { - if(!event.keyCode==Event.KEY_ESC) return; + if(event.keyCode!=Event.KEY_ESC) return; this.finishDrag(event, false); Event.stop(event); }, @@ -479,7 +479,7 @@ var Sortable = { hoverclass: null, ghosting: false, scroll: false, - format: null, + format: /^[^_]*_(.*)$/, onChange: Prototype.emptyFunction, onUpdate: Prototype.emptyFunction }, arguments[1] || {}); @@ -636,22 +636,39 @@ var Sortable = { sequence: function(element) { element = $(element); - var sortableOptions = this.options(element); - var options = Object.extend({ - tag: sortableOptions.tag, - only: sortableOptions.only, - name: element.id, - format: sortableOptions.format || /^[^_]*_(.*)$/ - }, arguments[1] || {}); + var options = Object.extend(this.options(element), arguments[1] || {}); + return $(this.findElements(element, options) || []).map( function(item) { return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; }); }, + setSequence: function(element, new_sequence) { + element = $(element); + var options = Object.extend(this.options(element), arguments[2] || {}); + + var nodeMap = {}; + this.findElements(element, options).each( function(n) { + if (n.id.match(options.format)) + nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; + n.parentNode.removeChild(n); + }); + + new_sequence.each(function(ident) { + var n = nodeMap[ident]; + if (n) { + n[1].appendChild(n[0]); + delete nodeMap[ident]; + } + }); + }, + serialize: function(element) { element = $(element); + var name = encodeURIComponent( + (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); return Sortable.sequence(element, arguments[1]).map( function(item) { - return encodeURIComponent(element.id) + "[]=" + encodeURIComponent(item); + return name + "[]=" + encodeURIComponent(item); }).join('&'); } } -- cgit v1.2.3