Skip to content

Commit 6457b36

Browse files
committed
Updated trunk to script.aculo.us 1.6.2
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4766 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
1 parent 5f3486c commit 6457b36

File tree

8 files changed

+142
-88
lines changed

8 files changed

+142
-88
lines changed

actionpack/CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -1,5 +1,7 @@
1
*SVN*
1
*SVN*
2

2

3+
* Updated to script.aculo.us 1.6.2 [Thomas Fuchs]
4+
3
* Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar]
5
* Relax Routing's anchor pattern warning; it was preventing use of [^/] inside restrictions. [Nicholas Seckar]
4

6

5
* Add controller_paths variable to Routing. [Nicholas Seckar]
7
* Add controller_paths variable to Routing. [Nicholas Seckar]

actionpack/lib/action_view/helpers/javascripts/controls.js

Lines changed: 8 additions & 2 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -33,6 +33,9 @@
33
// useful when one of the tokens is \n (a newline), as it
33
// useful when one of the tokens is \n (a newline), as it
34
// allows smart autocompletion after linebreaks.
34
// allows smart autocompletion after linebreaks.
35

35

36+
if(typeof Effect == 'undefined')
37+
throw("controls.js requires including script.aculo.us' effects.js library");
38+
36
var Autocompleter = {}
39
var Autocompleter = {}
37
Autocompleter.Base = function() {};
40
Autocompleter.Base = function() {};
38
Autocompleter.Base.prototype = {
41
Autocompleter.Base.prototype = {
@@ -94,7 +97,7 @@ Autocompleter.Base.prototype = {
94
},
97
},
95

98

96
fixIEOverlapping: function() {
99
fixIEOverlapping: function() {
97-
Position.clone(this.update, this.iefix);
100+
Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
98
this.iefix.style.zIndex = 1;
101
this.iefix.style.zIndex = 1;
99
this.update.style.zIndex = 2;
102
this.update.style.zIndex = 2;
100
Element.show(this.iefix);
103
Element.show(this.iefix);
@@ -202,11 +205,13 @@ Autocompleter.Base.prototype = {
202
markPrevious: function() {
205
markPrevious: function() {
203
if(this.index > 0) this.index--
206
if(this.index > 0) this.index--
204
else this.index = this.entryCount-1;
207
else this.index = this.entryCount-1;
208+
this.getEntry(this.index).scrollIntoView(true);
205
},
209
},
206

210

207
markNext: function() {
211
markNext: function() {
208
if(this.index < this.entryCount-1) this.index++
212
if(this.index < this.entryCount-1) this.index++
209
else this.index = 0;
213
else this.index = 0;
214+
this.getEntry(this.index).scrollIntoView(false);
210
},
215
},
211

216

212
getEntry: function(index) {
217
getEntry: function(index) {
@@ -531,7 +536,7 @@ Ajax.InPlaceEditor.prototype = {
531
Element.hide(this.element);
536
Element.hide(this.element);
532
this.createForm();
537
this.createForm();
533
this.element.parentNode.insertBefore(this.form, this.element);
538
this.element.parentNode.insertBefore(this.form, this.element);
534-
Field.scrollFreeActivate(this.editField);
539+
if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
535
// stop the event to avoid a page refresh in Safari
540
// stop the event to avoid a page refresh in Safari
536
if (evt) {
541
if (evt) {
537
Event.stop(evt);
542
Event.stop(evt);
@@ -636,6 +641,7 @@ Ajax.InPlaceEditor.prototype = {
636
Element.removeClassName(this.form, this.options.loadingClassName);
641
Element.removeClassName(this.form, this.options.loadingClassName);
637
this.editField.disabled = false;
642
this.editField.disabled = false;
638
this.editField.value = transport.responseText.stripTags();
643
this.editField.value = transport.responseText.stripTags();
644+
Field.scrollFreeActivate(this.editField);
639
},
645
},
640
onclickCancel: function() {
646
onclickCancel: function() {
641
this.onComplete();
647
this.onComplete();

actionpack/lib/action_view/helpers/javascripts/dragdrop.js

Lines changed: 29 additions & 11 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -5,6 +5,9 @@
5

5

6
/*--------------------------------------------------------------------------*/
6
/*--------------------------------------------------------------------------*/
7

7

8+
if(typeof Effect == 'undefined')
9+
throw("dragdrop.js requires including script.aculo.us' effects.js library");
10+
8
var Droppables = {
11
var Droppables = {
9
drops: [],
12
drops: [],
10

13

@@ -204,19 +207,31 @@ var Draggables = {
204
/*--------------------------------------------------------------------------*/
207
/*--------------------------------------------------------------------------*/
205

208

206
var Draggable = Class.create();
209
var Draggable = Class.create();
210+
Draggable._revertCache = {};
211+
Draggable._dragging = {};
212+
207
Draggable.prototype = {
213
Draggable.prototype = {
208
initialize: function(element) {
214
initialize: function(element) {
209
var options = Object.extend({
215
var options = Object.extend({
210
handle: false,
216
handle: false,
211-
starteffect: function(element) {
217+
starteffect: function(element) {
212-
new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7});
218+
element._opacity = Element.getOpacity(element);
219+
Draggable._dragging[element] = true;
220+
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
213
},
221
},
214
reverteffect: function(element, top_offset, left_offset) {
222
reverteffect: function(element, top_offset, left_offset) {
215
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
223
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
216-
element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur});
224+
Draggable._revertCache[element] =
225+
new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
226+
queue: {scope:'_draggable', position:'end'}
227+
});
217
},
228
},
218-
endeffect: function(element) {
229+
endeffect: function(element) {
219-
new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
230+
var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
231+
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
232+
queue: {scope:'_draggable', position:'end'},
233+
afterFinish: function(){ Draggable._dragging[element] = false }
234+
});
220
},
235
},
221
zindex: 1000,
236
zindex: 1000,
222
revert: false,
237
revert: false,
@@ -262,6 +277,8 @@ Draggable.prototype = {
262
},
277
},
263

278

264
initDrag: function(event) {
279
initDrag: function(event) {
280+
if(typeof Draggable._dragging[this.element] != undefined &&
281+
Draggable._dragging[this.element]) return;
265
if(Event.isLeftClick(event)) {
282
if(Event.isLeftClick(event)) {
266
// abort on form elements, fixes a Firefox issue
283
// abort on form elements, fixes a Firefox issue
267
var src = Event.element(event);
284
var src = Event.element(event);
@@ -272,9 +289,9 @@ Draggable.prototype = {
272
src.tagName=='BUTTON' ||
289
src.tagName=='BUTTON' ||
273
src.tagName=='TEXTAREA')) return;
290
src.tagName=='TEXTAREA')) return;
274

291

275-
if(this.element._revert) {
292+
if(Draggable._revertCache[this.element]) {
276-
this.element._revert.cancel();
293+
Draggable._revertCache[this.element].cancel();
277-
this.element._revert = null;
294+
Draggable._revertCache[this.element] = null;
278
}
295
}
279

296

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

429

413
if(this.options.snap) {
430
if(this.options.snap) {
414
if(typeof this.options.snap == 'function') {
431
if(typeof this.options.snap == 'function') {
415-
p = this.options.snap(p[0],p[1]);
432+
p = this.options.snap(p[0],p[1],this);
416
} else {
433
} else {
417
if(this.options.snap instanceof Array) {
434
if(this.options.snap instanceof Array) {
418
p = p.map( function(v, i) {
435
p = p.map( function(v, i) {
@@ -440,6 +457,7 @@ Draggable.prototype = {
440
},
457
},
441

458

442
startScrolling: function(speed) {
459
startScrolling: function(speed) {
460+
if(!(speed[0] || speed[1])) return;
443
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
461
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
444
this.lastScrolled = new Date();
462
this.lastScrolled = new Date();
445
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
463
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
@@ -706,7 +724,7 @@ var Sortable = {
706
if(!Element.isParent(dropon, element)) {
724
if(!Element.isParent(dropon, element)) {
707
var index;
725
var index;
708

726

709-
var children = Sortable.findElements(dropon, {tag: droponOptions.tag});
727+
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
710
var child = null;
728
var child = null;
711

729

712
if(children) {
730
if(children) {
@@ -867,7 +885,7 @@ var Sortable = {
867

885

868
if (options.tree) {
886
if (options.tree) {
869
return Sortable.tree(element, arguments[1]).children.map( function (item) {
887
return Sortable.tree(element, arguments[1]).children.map( function (item) {
870-
return [name + Sortable._constructIndex(item) + "=" +
888+
return [name + Sortable._constructIndex(item) + "[id]=" +
871
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
889
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
872
}).flatten().join('&');
890
}).flatten().join('&');
873
} else {
891
} else {

actionpack/lib/action_view/helpers/javascripts/effects.js

Lines changed: 32 additions & 31 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -105,6 +105,9 @@ Array.prototype.call = function() {
105

105

106
var Effect = {
106
var Effect = {
107
tagifyText: function(element) {
107
tagifyText: function(element) {
108+
if(typeof Builder == 'undefined')
109+
throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
110+
108
var tagifyStyle = 'position:relative';
111
var tagifyStyle = 'position:relative';
109
if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
112
if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
110
element = $(element);
113
element = $(element);
@@ -161,9 +164,8 @@ var Effect2 = Effect; // deprecated
161

164

162
Effect.Transitions = {}
165
Effect.Transitions = {}
163

166

164-
Effect.Transitions.linear = function(pos) {
167+
Effect.Transitions.linear = Prototype.K;
165-
return pos;
168+
166-
}
167
Effect.Transitions.sinoidal = function(pos) {
169
Effect.Transitions.sinoidal = function(pos) {
168
return (-Math.cos(pos*Math.PI)/2) + 0.5;
170
return (-Math.cos(pos*Math.PI)/2) + 0.5;
169
}
171
}
@@ -353,7 +355,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
353
initialize: function(element) {
355
initialize: function(element) {
354
this.element = $(element);
356
this.element = $(element);
355
// make this work on IE on elements without 'layout'
357
// make this work on IE on elements without 'layout'
356-
if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
358+
if(/MSIE/.test(navigator.userAgent) && (!this.element.currentStyle.hasLayout))
357
this.element.setStyle({zoom: 1});
359
this.element.setStyle({zoom: 1});
358
var options = Object.extend({
360
var options = Object.extend({
359
from: this.element.getOpacity() || 0.0,
361
from: this.element.getOpacity() || 0.0,
@@ -393,8 +395,8 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
393
},
395
},
394
update: function(position) {
396
update: function(position) {
395
this.element.setStyle({
397
this.element.setStyle({
396-
left: this.options.x * position + this.originalLeft + 'px',
398+
left: Math.round(this.options.x * position + this.originalLeft) + 'px',
397-
top: this.options.y * position + this.originalTop + 'px'
399+
top: Math.round(this.options.y * position + this.originalTop) + 'px'
398
});
400
});
399
}
401
}
400
});
402
});
@@ -433,7 +435,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
433
this.originalLeft = this.element.offsetLeft;
435
this.originalLeft = this.element.offsetLeft;
434

436

435
var fontSize = this.element.getStyle('font-size') || '100%';
437
var fontSize = this.element.getStyle('font-size') || '100%';
436-
['em','px','%'].each( function(fontSizeType) {
438+
['em','px','%','pt'].each( function(fontSizeType) {
437
if(fontSize.indexOf(fontSizeType)>0) {
439
if(fontSize.indexOf(fontSizeType)>0) {
438
this.fontSize = parseFloat(fontSize);
440
this.fontSize = parseFloat(fontSize);
439
this.fontSizeType = fontSizeType;
441
this.fontSizeType = fontSizeType;
@@ -462,8 +464,8 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
462
},
464
},
463
setDimensions: function(height, width) {
465
setDimensions: function(height, width) {
464
var d = {};
466
var d = {};
465-
if(this.options.scaleX) d.width = width + 'px';
467+
if(this.options.scaleX) d.width = Math.round(width) + 'px';
466-
if(this.options.scaleY) d.height = height + 'px';
468+
if(this.options.scaleY) d.height = Math.round(height) + 'px';
467
if(this.options.scaleFromCenter) {
469
if(this.options.scaleFromCenter) {
468
var topd = (height - this.dims[0])/2;
470
var topd = (height - this.dims[0])/2;
469
var leftd = (width - this.dims[1])/2;
471
var leftd = (width - this.dims[1])/2;
@@ -589,7 +591,7 @@ Effect.Puff = function(element) {
589
Effect.BlindUp = function(element) {
591
Effect.BlindUp = function(element) {
590
element = $(element);
592
element = $(element);
591
element.makeClipping();
593
element.makeClipping();
592-
return new Effect.Scale(element, 0,
594+
return new Effect.Scale(element, 0,
593
Object.extend({ scaleContent: false,
595
Object.extend({ scaleContent: false,
594
scaleX: false,
596
scaleX: false,
595
restoreAfterFinish: true,
597
restoreAfterFinish: true,
@@ -604,28 +606,27 @@ Effect.BlindUp = function(element) {
604
Effect.BlindDown = function(element) {
606
Effect.BlindDown = function(element) {
605
element = $(element);
607
element = $(element);
606
var elementDimensions = element.getDimensions();
608
var elementDimensions = element.getDimensions();
607-
return new Effect.Scale(element, 100,
609+
return new Effect.Scale(element, 100, Object.extend({
608-
Object.extend({ scaleContent: false,
610+
scaleContent: false,
609-
scaleX: false,
611+
scaleX: false,
610-
scaleFrom: 0,
612+
scaleFrom: 0,
611-
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
613+
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
612-
restoreAfterFinish: true,
614+
restoreAfterFinish: true,
613-
afterSetup: function(effect) {
615+
afterSetup: function(effect) {
614-
effect.element.makeClipping();
616+
effect.element.makeClipping();
615-
effect.element.setStyle({height: '0px'});
617+
effect.element.setStyle({height: '0px'});
616-
effect.element.show();
618+
effect.element.show();
617-
},
619+
},
618-
afterFinishInternal: function(effect) {
620+
afterFinishInternal: function(effect) {
619-
effect.element.undoClipping();
621+
effect.element.undoClipping();
620-
}
622+
}
621-
}, arguments[1] || {})
623+
}, arguments[1] || {}));
622-
);
623
}
624
}
624

625

625
Effect.SwitchOff = function(element) {
626
Effect.SwitchOff = function(element) {
626
element = $(element);
627
element = $(element);
627
var oldOpacity = element.getInlineOpacity();
628
var oldOpacity = element.getInlineOpacity();
628-
return new Effect.Appear(element, {
629+
return new Effect.Appear(element, Object.extend({
629
duration: 0.4,
630
duration: 0.4,
630
from: 0,
631
from: 0,
631
transition: Effect.Transitions.flicker,
632
transition: Effect.Transitions.flicker,
@@ -645,7 +646,7 @@ Effect.SwitchOff = function(element) {
645
}
646
}
646
})
647
})
647
}
648
}
648-
});
649+
}, arguments[1] || {}));
649
}
650
}
650

651

651
Effect.DropOut = function(element) {
652
Effect.DropOut = function(element) {
@@ -701,7 +702,7 @@ Effect.SlideDown = function(element) {
701
return new Effect.Scale(element, 100, Object.extend({
702
return new Effect.Scale(element, 100, Object.extend({
702
scaleContent: false,
703
scaleContent: false,
703
scaleX: false,
704
scaleX: false,
704-
scaleFrom: 0,
705+
scaleFrom: window.opera ? 0 : 1,
705
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
706
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
706
restoreAfterFinish: true,
707
restoreAfterFinish: true,
707
afterSetup: function(effect) {
708
afterSetup: function(effect) {
@@ -729,12 +730,12 @@ Effect.SlideDown = function(element) {
729
}, arguments[1] || {})
730
}, arguments[1] || {})
730
);
731
);
731
}
732
}
732-
733+
733
Effect.SlideUp = function(element) {
734
Effect.SlideUp = function(element) {
734
element = $(element);
735
element = $(element);
735
element.cleanWhitespace();
736
element.cleanWhitespace();
736
var oldInnerBottom = $(element.firstChild).getStyle('bottom');
737
var oldInnerBottom = $(element.firstChild).getStyle('bottom');
737-
return new Effect.Scale(element, 0,
738+
return new Effect.Scale(element, window.opera ? 0 : 1,
738
Object.extend({ scaleContent: false,
739
Object.extend({ scaleContent: false,
739
scaleX: false,
740
scaleX: false,
740
scaleMode: 'box',
741
scaleMode: 'box',

railties/CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -1,5 +1,7 @@
1
*SVN*
1
*SVN*
2

2

3+
* Updated to script.aculo.us 1.6.2 [Thomas Fuchs]
4+
3
* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar]
5
* Assign Routing.controller_paths; fix script/about and rails info controller. [Nicholas Seckar]
4

6

5
* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar]
7
* Don't warn dispatcher of Reloadable deprecations. [Nicholas Seckar]

railties/html/javascripts/controls.js

Lines changed: 8 additions & 2 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -33,6 +33,9 @@
33
// useful when one of the tokens is \n (a newline), as it
33
// useful when one of the tokens is \n (a newline), as it
34
// allows smart autocompletion after linebreaks.
34
// allows smart autocompletion after linebreaks.
35

35

36+
if(typeof Effect == 'undefined')
37+
throw("controls.js requires including script.aculo.us' effects.js library");
38+
36
var Autocompleter = {}
39
var Autocompleter = {}
37
Autocompleter.Base = function() {};
40
Autocompleter.Base = function() {};
38
Autocompleter.Base.prototype = {
41
Autocompleter.Base.prototype = {
@@ -94,7 +97,7 @@ Autocompleter.Base.prototype = {
94
},
97
},
95

98

96
fixIEOverlapping: function() {
99
fixIEOverlapping: function() {
97-
Position.clone(this.update, this.iefix);
100+
Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
98
this.iefix.style.zIndex = 1;
101
this.iefix.style.zIndex = 1;
99
this.update.style.zIndex = 2;
102
this.update.style.zIndex = 2;
100
Element.show(this.iefix);
103
Element.show(this.iefix);
@@ -202,11 +205,13 @@ Autocompleter.Base.prototype = {
202
markPrevious: function() {
205
markPrevious: function() {
203
if(this.index > 0) this.index--
206
if(this.index > 0) this.index--
204
else this.index = this.entryCount-1;
207
else this.index = this.entryCount-1;
208+
this.getEntry(this.index).scrollIntoView(true);
205
},
209
},
206

210

207
markNext: function() {
211
markNext: function() {
208
if(this.index < this.entryCount-1) this.index++
212
if(this.index < this.entryCount-1) this.index++
209
else this.index = 0;
213
else this.index = 0;
214+
this.getEntry(this.index).scrollIntoView(false);
210
},
215
},
211

216

212
getEntry: function(index) {
217
getEntry: function(index) {
@@ -531,7 +536,7 @@ Ajax.InPlaceEditor.prototype = {
531
Element.hide(this.element);
536
Element.hide(this.element);
532
this.createForm();
537
this.createForm();
533
this.element.parentNode.insertBefore(this.form, this.element);
538
this.element.parentNode.insertBefore(this.form, this.element);
534-
Field.scrollFreeActivate(this.editField);
539+
if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
535
// stop the event to avoid a page refresh in Safari
540
// stop the event to avoid a page refresh in Safari
536
if (evt) {
541
if (evt) {
537
Event.stop(evt);
542
Event.stop(evt);
@@ -636,6 +641,7 @@ Ajax.InPlaceEditor.prototype = {
636
Element.removeClassName(this.form, this.options.loadingClassName);
641
Element.removeClassName(this.form, this.options.loadingClassName);
637
this.editField.disabled = false;
642
this.editField.disabled = false;
638
this.editField.value = transport.responseText.stripTags();
643
this.editField.value = transport.responseText.stripTags();
644+
Field.scrollFreeActivate(this.editField);
639
},
645
},
640
onclickCancel: function() {
646
onclickCancel: function() {
641
this.onComplete();
647
this.onComplete();

0 commit comments

Comments
 (0)