Skip to content

Commit

Permalink
Updated trunk to script.aculo.us 1.6.2
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4766 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
madrobby committed Aug 15, 2006
1 parent 5f3486c commit 6457b36
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 88 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN* *SVN*


* Updated to script.aculo.us 1.6.2 [Thomas Fuchs]

* Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar] * Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar]


* Add controller_paths variable to Routing. [Nicholas Seckar] * Add controller_paths variable to Routing. [Nicholas Seckar]
Expand Down
10 changes: 8 additions & 2 deletions actionpack/lib/action_view/helpers/javascripts/controls.js
Expand Up @@ -33,6 +33,9 @@
// useful when one of the tokens is \n (a newline), as it // useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks. // allows smart autocompletion after linebreaks.


if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library");

var Autocompleter = {} var Autocompleter = {}
Autocompleter.Base = function() {}; Autocompleter.Base = function() {};
Autocompleter.Base.prototype = { Autocompleter.Base.prototype = {
Expand Down Expand Up @@ -94,7 +97,7 @@ Autocompleter.Base.prototype = {
}, },


fixIEOverlapping: function() { fixIEOverlapping: function() {
Position.clone(this.update, this.iefix); Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
this.iefix.style.zIndex = 1; this.iefix.style.zIndex = 1;
this.update.style.zIndex = 2; this.update.style.zIndex = 2;
Element.show(this.iefix); Element.show(this.iefix);
Expand Down Expand Up @@ -202,11 +205,13 @@ Autocompleter.Base.prototype = {
markPrevious: function() { markPrevious: function() {
if(this.index > 0) this.index-- if(this.index > 0) this.index--
else this.index = this.entryCount-1; else this.index = this.entryCount-1;
this.getEntry(this.index).scrollIntoView(true);
}, },


markNext: function() { markNext: function() {
if(this.index < this.entryCount-1) this.index++ if(this.index < this.entryCount-1) this.index++
else this.index = 0; else this.index = 0;
this.getEntry(this.index).scrollIntoView(false);
}, },


getEntry: function(index) { getEntry: function(index) {
Expand Down Expand Up @@ -531,7 +536,7 @@ Ajax.InPlaceEditor.prototype = {
Element.hide(this.element); Element.hide(this.element);
this.createForm(); this.createForm();
this.element.parentNode.insertBefore(this.form, this.element); this.element.parentNode.insertBefore(this.form, this.element);
Field.scrollFreeActivate(this.editField); if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
// stop the event to avoid a page refresh in Safari // stop the event to avoid a page refresh in Safari
if (evt) { if (evt) {
Event.stop(evt); Event.stop(evt);
Expand Down Expand Up @@ -636,6 +641,7 @@ Ajax.InPlaceEditor.prototype = {
Element.removeClassName(this.form, this.options.loadingClassName); Element.removeClassName(this.form, this.options.loadingClassName);
this.editField.disabled = false; this.editField.disabled = false;
this.editField.value = transport.responseText.stripTags(); this.editField.value = transport.responseText.stripTags();
Field.scrollFreeActivate(this.editField);
}, },
onclickCancel: function() { onclickCancel: function() {
this.onComplete(); this.onComplete();
Expand Down
40 changes: 29 additions & 11 deletions actionpack/lib/action_view/helpers/javascripts/dragdrop.js
Expand Up @@ -5,6 +5,9 @@


/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/


if(typeof Effect == 'undefined')
throw("dragdrop.js requires including script.aculo.us' effects.js library");

var Droppables = { var Droppables = {
drops: [], drops: [],


Expand Down Expand Up @@ -204,19 +207,31 @@ var Draggables = {
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/


var Draggable = Class.create(); var Draggable = Class.create();
Draggable._revertCache = {};
Draggable._dragging = {};

Draggable.prototype = { Draggable.prototype = {
initialize: function(element) { initialize: function(element) {
var options = Object.extend({ var options = Object.extend({
handle: false, handle: false,
starteffect: function(element) { starteffect: function(element) {
new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7}); element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true;
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
}, },
reverteffect: function(element, top_offset, left_offset) { reverteffect: function(element, top_offset, left_offset) {
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur}); Draggable._revertCache[element] =
new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
queue: {scope:'_draggable', position:'end'}
});
}, },
endeffect: function(element) { endeffect: function(element) {
new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0}); var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'},
afterFinish: function(){ Draggable._dragging[element] = false }
});
}, },
zindex: 1000, zindex: 1000,
revert: false, revert: false,
Expand Down Expand Up @@ -262,6 +277,8 @@ Draggable.prototype = {
}, },


initDrag: function(event) { initDrag: function(event) {
if(typeof Draggable._dragging[this.element] != undefined &&
Draggable._dragging[this.element]) return;
if(Event.isLeftClick(event)) { if(Event.isLeftClick(event)) {
// abort on form elements, fixes a Firefox issue // abort on form elements, fixes a Firefox issue
var src = Event.element(event); var src = Event.element(event);
Expand All @@ -272,9 +289,9 @@ Draggable.prototype = {
src.tagName=='BUTTON' || src.tagName=='BUTTON' ||
src.tagName=='TEXTAREA')) return; src.tagName=='TEXTAREA')) return;


if(this.element._revert) { if(Draggable._revertCache[this.element]) {
this.element._revert.cancel(); Draggable._revertCache[this.element].cancel();
this.element._revert = null; Draggable._revertCache[this.element] = null;
} }


var pointer = [Event.pointerX(event), Event.pointerY(event)]; var pointer = [Event.pointerX(event), Event.pointerY(event)];
Expand Down Expand Up @@ -412,7 +429,7 @@ Draggable.prototype = {


if(this.options.snap) { if(this.options.snap) {
if(typeof this.options.snap == 'function') { if(typeof this.options.snap == 'function') {
p = this.options.snap(p[0],p[1]); p = this.options.snap(p[0],p[1],this);
} else { } else {
if(this.options.snap instanceof Array) { if(this.options.snap instanceof Array) {
p = p.map( function(v, i) { p = p.map( function(v, i) {
Expand Down Expand Up @@ -440,6 +457,7 @@ Draggable.prototype = {
}, },


startScrolling: function(speed) { startScrolling: function(speed) {
if(!(speed[0] || speed[1])) return;
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
this.lastScrolled = new Date(); this.lastScrolled = new Date();
this.scrollInterval = setInterval(this.scroll.bind(this), 10); this.scrollInterval = setInterval(this.scroll.bind(this), 10);
Expand Down Expand Up @@ -706,7 +724,7 @@ var Sortable = {
if(!Element.isParent(dropon, element)) { if(!Element.isParent(dropon, element)) {
var index; var index;


var children = Sortable.findElements(dropon, {tag: droponOptions.tag}); var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
var child = null; var child = null;


if(children) { if(children) {
Expand Down Expand Up @@ -867,7 +885,7 @@ var Sortable = {


if (options.tree) { if (options.tree) {
return Sortable.tree(element, arguments[1]).children.map( function (item) { return Sortable.tree(element, arguments[1]).children.map( function (item) {
return [name + Sortable._constructIndex(item) + "=" + return [name + Sortable._constructIndex(item) + "[id]=" +
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
}).flatten().join('&'); }).flatten().join('&');
} else { } else {
Expand Down
63 changes: 32 additions & 31 deletions actionpack/lib/action_view/helpers/javascripts/effects.js
Expand Up @@ -105,6 +105,9 @@ Array.prototype.call = function() {


var Effect = { var Effect = {
tagifyText: function(element) { tagifyText: function(element) {
if(typeof Builder == 'undefined')
throw("Effect.tagifyText requires including script.aculo.us' builder.js library");

var tagifyStyle = 'position:relative'; var tagifyStyle = 'position:relative';
if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
element = $(element); element = $(element);
Expand Down Expand Up @@ -161,9 +164,8 @@ var Effect2 = Effect; // deprecated


Effect.Transitions = {} Effect.Transitions = {}


Effect.Transitions.linear = function(pos) { Effect.Transitions.linear = Prototype.K;
return pos;
}
Effect.Transitions.sinoidal = function(pos) { Effect.Transitions.sinoidal = function(pos) {
return (-Math.cos(pos*Math.PI)/2) + 0.5; return (-Math.cos(pos*Math.PI)/2) + 0.5;
} }
Expand Down Expand Up @@ -353,7 +355,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
initialize: function(element) { initialize: function(element) {
this.element = $(element); this.element = $(element);
// make this work on IE on elements without 'layout' // make this work on IE on elements without 'layout'
if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) if(/MSIE/.test(navigator.userAgent) && (!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom: 1}); this.element.setStyle({zoom: 1});
var options = Object.extend({ var options = Object.extend({
from: this.element.getOpacity() || 0.0, from: this.element.getOpacity() || 0.0,
Expand Down Expand Up @@ -393,8 +395,8 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
}, },
update: function(position) { update: function(position) {
this.element.setStyle({ this.element.setStyle({
left: this.options.x * position + this.originalLeft + 'px', left: Math.round(this.options.x * position + this.originalLeft) + 'px',
top: this.options.y * position + this.originalTop + 'px' top: Math.round(this.options.y * position + this.originalTop) + 'px'
}); });
} }
}); });
Expand Down Expand Up @@ -433,7 +435,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
this.originalLeft = this.element.offsetLeft; this.originalLeft = this.element.offsetLeft;


var fontSize = this.element.getStyle('font-size') || '100%'; var fontSize = this.element.getStyle('font-size') || '100%';
['em','px','%'].each( function(fontSizeType) { ['em','px','%','pt'].each( function(fontSizeType) {
if(fontSize.indexOf(fontSizeType)>0) { if(fontSize.indexOf(fontSizeType)>0) {
this.fontSize = parseFloat(fontSize); this.fontSize = parseFloat(fontSize);
this.fontSizeType = fontSizeType; this.fontSizeType = fontSizeType;
Expand Down Expand Up @@ -462,8 +464,8 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
}, },
setDimensions: function(height, width) { setDimensions: function(height, width) {
var d = {}; var d = {};
if(this.options.scaleX) d.width = width + 'px'; if(this.options.scaleX) d.width = Math.round(width) + 'px';
if(this.options.scaleY) d.height = height + 'px'; if(this.options.scaleY) d.height = Math.round(height) + 'px';
if(this.options.scaleFromCenter) { if(this.options.scaleFromCenter) {
var topd = (height - this.dims[0])/2; var topd = (height - this.dims[0])/2;
var leftd = (width - this.dims[1])/2; var leftd = (width - this.dims[1])/2;
Expand Down Expand Up @@ -589,7 +591,7 @@ Effect.Puff = function(element) {
Effect.BlindUp = function(element) { Effect.BlindUp = function(element) {
element = $(element); element = $(element);
element.makeClipping(); element.makeClipping();
return new Effect.Scale(element, 0, return new Effect.Scale(element, 0,
Object.extend({ scaleContent: false, Object.extend({ scaleContent: false,
scaleX: false, scaleX: false,
restoreAfterFinish: true, restoreAfterFinish: true,
Expand All @@ -604,28 +606,27 @@ Effect.BlindUp = function(element) {
Effect.BlindDown = function(element) { Effect.BlindDown = function(element) {
element = $(element); element = $(element);
var elementDimensions = element.getDimensions(); var elementDimensions = element.getDimensions();
return new Effect.Scale(element, 100, return new Effect.Scale(element, 100, Object.extend({
Object.extend({ scaleContent: false, scaleContent: false,
scaleX: false, scaleX: false,
scaleFrom: 0, scaleFrom: 0,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
restoreAfterFinish: true, restoreAfterFinish: true,
afterSetup: function(effect) { afterSetup: function(effect) {
effect.element.makeClipping(); effect.element.makeClipping();
effect.element.setStyle({height: '0px'}); effect.element.setStyle({height: '0px'});
effect.element.show(); effect.element.show();
}, },
afterFinishInternal: function(effect) { afterFinishInternal: function(effect) {
effect.element.undoClipping(); effect.element.undoClipping();
} }
}, arguments[1] || {}) }, arguments[1] || {}));
);
} }


Effect.SwitchOff = function(element) { Effect.SwitchOff = function(element) {
element = $(element); element = $(element);
var oldOpacity = element.getInlineOpacity(); var oldOpacity = element.getInlineOpacity();
return new Effect.Appear(element, { return new Effect.Appear(element, Object.extend({
duration: 0.4, duration: 0.4,
from: 0, from: 0,
transition: Effect.Transitions.flicker, transition: Effect.Transitions.flicker,
Expand All @@ -645,7 +646,7 @@ Effect.SwitchOff = function(element) {
} }
}) })
} }
}); }, arguments[1] || {}));
} }


Effect.DropOut = function(element) { Effect.DropOut = function(element) {
Expand Down Expand Up @@ -701,7 +702,7 @@ Effect.SlideDown = function(element) {
return new Effect.Scale(element, 100, Object.extend({ return new Effect.Scale(element, 100, Object.extend({
scaleContent: false, scaleContent: false,
scaleX: false, scaleX: false,
scaleFrom: 0, scaleFrom: window.opera ? 0 : 1,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
restoreAfterFinish: true, restoreAfterFinish: true,
afterSetup: function(effect) { afterSetup: function(effect) {
Expand Down Expand Up @@ -729,12 +730,12 @@ Effect.SlideDown = function(element) {
}, arguments[1] || {}) }, arguments[1] || {})
); );
} }

Effect.SlideUp = function(element) { Effect.SlideUp = function(element) {
element = $(element); element = $(element);
element.cleanWhitespace(); element.cleanWhitespace();
var oldInnerBottom = $(element.firstChild).getStyle('bottom'); var oldInnerBottom = $(element.firstChild).getStyle('bottom');
return new Effect.Scale(element, 0, return new Effect.Scale(element, window.opera ? 0 : 1,
Object.extend({ scaleContent: false, Object.extend({ scaleContent: false,
scaleX: false, scaleX: false,
scaleMode: 'box', scaleMode: 'box',
Expand Down
2 changes: 2 additions & 0 deletions railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN* *SVN*


* Updated to script.aculo.us 1.6.2 [Thomas Fuchs]

* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar] * Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar]


* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar] * Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar]
Expand Down
10 changes: 8 additions & 2 deletions railties/html/javascripts/controls.js
Expand Up @@ -33,6 +33,9 @@
// useful when one of the tokens is \n (a newline), as it // useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks. // allows smart autocompletion after linebreaks.


if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library");

var Autocompleter = {} var Autocompleter = {}
Autocompleter.Base = function() {}; Autocompleter.Base = function() {};
Autocompleter.Base.prototype = { Autocompleter.Base.prototype = {
Expand Down Expand Up @@ -94,7 +97,7 @@ Autocompleter.Base.prototype = {
}, },


fixIEOverlapping: function() { fixIEOverlapping: function() {
Position.clone(this.update, this.iefix); Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
this.iefix.style.zIndex = 1; this.iefix.style.zIndex = 1;
this.update.style.zIndex = 2; this.update.style.zIndex = 2;
Element.show(this.iefix); Element.show(this.iefix);
Expand Down Expand Up @@ -202,11 +205,13 @@ Autocompleter.Base.prototype = {
markPrevious: function() { markPrevious: function() {
if(this.index > 0) this.index-- if(this.index > 0) this.index--
else this.index = this.entryCount-1; else this.index = this.entryCount-1;
this.getEntry(this.index).scrollIntoView(true);
}, },


markNext: function() { markNext: function() {
if(this.index < this.entryCount-1) this.index++ if(this.index < this.entryCount-1) this.index++
else this.index = 0; else this.index = 0;
this.getEntry(this.index).scrollIntoView(false);
}, },


getEntry: function(index) { getEntry: function(index) {
Expand Down Expand Up @@ -531,7 +536,7 @@ Ajax.InPlaceEditor.prototype = {
Element.hide(this.element); Element.hide(this.element);
this.createForm(); this.createForm();
this.element.parentNode.insertBefore(this.form, this.element); this.element.parentNode.insertBefore(this.form, this.element);
Field.scrollFreeActivate(this.editField); if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
// stop the event to avoid a page refresh in Safari // stop the event to avoid a page refresh in Safari
if (evt) { if (evt) {
Event.stop(evt); Event.stop(evt);
Expand Down Expand Up @@ -636,6 +641,7 @@ Ajax.InPlaceEditor.prototype = {
Element.removeClassName(this.form, this.options.loadingClassName); Element.removeClassName(this.form, this.options.loadingClassName);
this.editField.disabled = false; this.editField.disabled = false;
this.editField.value = transport.responseText.stripTags(); this.editField.value = transport.responseText.stripTags();
Field.scrollFreeActivate(this.editField);
}, },
onclickCancel: function() { onclickCancel: function() {
this.onComplete(); this.onComplete();
Expand Down

0 comments on commit 6457b36

Please sign in to comment.