diff options
author | Thomas Fuchs <thomas@fesch.at> | 2006-02-14 10:29:12 +0000 |
---|---|---|
committer | Thomas Fuchs <thomas@fesch.at> | 2006-02-14 10:29:12 +0000 |
commit | e8c4cc95030155168bee38567b6f8497a669e99e (patch) | |
tree | dae6dc62e0c59bbf0e9aadacc1e22d469cc34145 /railties | |
parent | c7f5a848f107bf294302b7eca606930168cc9e98 (diff) | |
download | rails-e8c4cc95030155168bee38567b6f8497a669e99e.tar.gz rails-e8c4cc95030155168bee38567b6f8497a669e99e.tar.bz2 rails-e8c4cc95030155168bee38567b6f8497a669e99e.zip |
Update script.aculo.us in Rails trunk to V1.5.2
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3595 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/html/javascripts/dragdrop.js | 86 | ||||
-rw-r--r-- | railties/html/javascripts/effects.js | 23 |
3 files changed, 97 insertions, 14 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 9758f2d96b..9c88925c8a 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Update script.aculo.us to V1.5.2 [Thomas Fuchs] + * Changed default lighttpd.conf to use CWD from lighttpd 1.4.10 that allows the same configuration to be used for both detach and not. Also ensured that auto-repeaping of FCGIs only happens when lighttpd is not detached. [DHH] * Added Configuration#after_initialize for registering a block which gets called after the framework is fully initialized. Useful for things like per-environment configuration of plugins. [Michael Koziarski] diff --git a/railties/html/javascripts/dragdrop.js b/railties/html/javascripts/dragdrop.js index 818ef5e0ed..57dab290b2 100644 --- a/railties/html/javascripts/dragdrop.js +++ b/railties/html/javascripts/dragdrop.js @@ -128,7 +128,7 @@ var Draggables = { this.activeDraggable = draggable; }, - deactivate: function(draggbale) { + deactivate: function() { this.activeDraggable = null; }, @@ -199,6 +199,9 @@ Draggable.prototype = { }, zindex: 1000, revert: false, + scroll: false, + scrollSensitivity: 20, + scrollSpeed: 15, snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] } }, arguments[1] || {}); @@ -208,6 +211,8 @@ Draggable.prototype = { this.handle = Element.childrenWithClassName(this.element, options.handle)[0]; if(!this.handle) this.handle = $(options.handle); if(!this.handle) this.handle = this.element; + + if(options.scroll) options.scroll = $(options.scroll); Element.makePositioned(this.element); // fix IE @@ -239,6 +244,7 @@ Draggable.prototype = { if(src.tagName && ( src.tagName=='INPUT' || src.tagName=='SELECT' || + src.tagName=='OPTION' || src.tagName=='BUTTON' || src.tagName=='TEXTAREA')) return; @@ -270,6 +276,11 @@ Draggable.prototype = { this.element.parentNode.insertBefore(this._clone, this.element); } + if(this.options.scroll) { + this.originalScrollLeft = this.options.scroll.scrollLeft; + this.originalScrollTop = this.options.scroll.scrollTop; + } + Draggables.notify('onStart', this, event); if(this.options.starteffect) this.options.starteffect(this.element); }, @@ -282,8 +293,25 @@ Draggable.prototype = { this.draw(pointer); if(this.options.change) this.options.change(this); + if(this.options.scroll) { + //if(this.scrollInterval) this.scroll(); + this.stopScrolling(); + var p = Position.page(this.options.scroll); + p[0] += this.options.scroll.scrollLeft; + p[1] += this.options.scroll.scrollTop; + p.push(p[0]+this.options.scroll.offsetWidth); + p.push(p[1]+this.options.scroll.offsetHeight); + var speed = [0,0]; + if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity); + if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity); + if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity); + if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity); + this.startScrolling(speed); + } + // fix AppleWebKit rendering if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); + Event.stop(event); }, @@ -328,6 +356,7 @@ Draggable.prototype = { endDrag: function(event) { if(!this.dragging) return; + this.stopScrolling(); this.finishDrag(event, true); Event.stop(event); }, @@ -337,7 +366,14 @@ Draggable.prototype = { var d = this.currentDelta(); pos[0] -= d[0]; pos[1] -= d[1]; - var p = [0,1].map(function(i){ return (point[i]-pos[i]-this.offset[i]) }.bind(this)); + if(this.options.scroll) { + pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; + pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; + } + + var p = [0,1].map(function(i){ + return (point[i]-pos[i]-this.offset[i]) + }.bind(this)); if(this.options.snap) { if(typeof this.options.snap == 'function') { @@ -358,6 +394,34 @@ Draggable.prototype = { if((!this.options.constraint) || (this.options.constraint=='vertical')) style.top = p[1] + "px"; if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering + }, + + stopScrolling: function() { + if(this.scrollInterval) { + clearInterval(this.scrollInterval); + this.scrollInterval = null; + } + }, + + startScrolling: function(speed) { + this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; + this.lastScrolled = new Date(); + this.scrollInterval = setInterval(this.scroll.bind(this), 10); + }, + + scroll: function() { + var current = new Date(); + var delta = current - this.lastScrolled; + this.lastScrolled = current; + this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; + this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; + + Position.prepare(); + Droppables.show(Draggables._lastPointer, this.element); + Draggables.notify('onDrag', this); + this.draw(Draggables._lastPointer); + + if(this.options.change) this.options.change(this); } } @@ -414,6 +478,7 @@ var Sortable = { only: false, hoverclass: null, ghosting: false, + scroll: false, format: null, onChange: Prototype.emptyFunction, onUpdate: Prototype.emptyFunction @@ -425,6 +490,7 @@ var Sortable = { // build options for the draggables var options_for_draggable = { revert: true, + scroll: options.scroll, ghosting: options.ghosting, constraint: options.constraint, handle: options.handle }; @@ -568,7 +634,7 @@ var Sortable = { Element.show(Sortable._marker); }, - serialize: function(element) { + sequence: function(element) { element = $(element); var sortableOptions = this.options(element); var options = Object.extend({ @@ -578,8 +644,14 @@ var Sortable = { format: sortableOptions.format || /^[^_]*_(.*)$/ }, arguments[1] || {}); return $(this.findElements(element, options) || []).map( function(item) { - return (encodeURIComponent(options.name) + "[]=" + - encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : '')); - }).join("&"); + return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; + }); + }, + + serialize: function(element) { + element = $(element); + return Sortable.sequence(element, arguments[1]).map( function(item) { + return encodeURIComponent(element.id) + "[]=" + encodeURIComponent(item); + }).join('&'); } -}
\ No newline at end of file +} diff --git a/railties/html/javascripts/effects.js b/railties/html/javascripts/effects.js index d3940a82b5..e74b2ad1d0 100644 --- a/railties/html/javascripts/effects.js +++ b/railties/html/javascripts/effects.js @@ -35,7 +35,7 @@ Element.collectTextNodesIgnoreClass = function(element, className) { return $A($(element).childNodes).collect( function(node) { return (node.nodeType==3 ? node.nodeValue : ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? - Element.collectTextNodes(node) : '')); + Element.collectTextNodesIgnoreClass(node, className) : '')); }).flatten().join(''); } @@ -137,7 +137,7 @@ var Effect = { element = $(element); effect = (effect || 'appear').toLowerCase(); var options = Object.extend({ - queue: { position:'end', scope:(element.id || 'global') } + queue: { position:'end', scope:(element.id || 'global'), limit: 1 } }, arguments[2] || {}); Effect[Element.visible(element) ? Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); @@ -209,7 +209,10 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), { effect.startOn += timestamp; effect.finishOn += timestamp; - this.effects.push(effect); + + if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) + this.effects.push(effect); + if(!this.interval) this.interval = setInterval(this.loop.bind(this), 40); }, @@ -690,8 +693,14 @@ Effect.SlideDown = function(element) { (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, afterFinishInternal: function(effect) { with(Element) { undoClipping(effect.element); - undoPositioned(effect.element.firstChild); - undoPositioned(effect.element); + // IE will crash if child is undoPositioned first + if(/MSIE/.test(navigator.userAgent)){ + undoPositioned(effect.element); + undoPositioned(effect.element.firstChild); + }else{ + undoPositioned(effect.element.firstChild); + undoPositioned(effect.element); + } setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} }, arguments[1] || {}) ); @@ -741,7 +750,7 @@ Effect.Grow = function(element) { element = $(element); var options = Object.extend({ direction: 'center', - moveTransistion: Effect.Transitions.sinoidal, + moveTransition: Effect.Transitions.sinoidal, scaleTransition: Effect.Transitions.sinoidal, opacityTransition: Effect.Transitions.full }, arguments[1] || {}); @@ -817,7 +826,7 @@ Effect.Shrink = function(element) { element = $(element); var options = Object.extend({ direction: 'center', - moveTransistion: Effect.Transitions.sinoidal, + moveTransition: Effect.Transitions.sinoidal, scaleTransition: Effect.Transitions.sinoidal, opacityTransition: Effect.Transitions.none }, arguments[1] || {}); |