aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/javascripts/prototype.js279
1 files changed, 192 insertions, 87 deletions
diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js
index c3e373cd64..dd5c9b0f93 100644
--- a/actionpack/lib/action_view/helpers/javascripts/prototype.js
+++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js
@@ -1,12 +1,17 @@
-/* Prototype: an object-oriented Javascript library, version 1.1.0
+/* Prototype: an object-oriented Javascript library, version 1.2.0
* (c) 2005 Sam Stephenson <sam@conio.net>
*
- * Prototype is freely distributable under the terms of an MIT-style license.
- * For details, see http://prototype.conio.net/
- */
+ * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
+ * against the source tree, available from the Prototype darcs repository.
+ *
+ * Prototype is freely distributable under the terms of an MIT-style license.
+ *
+ * For details, see the Prototype web site: http://prototype.conio.net/
+ *
+/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.1.0'
+ Version: '1.2.0'
}
var Class = {
@@ -62,28 +67,33 @@ var Try = {
}
}
-// Deprecated accessor for Element.toggle
-var Toggle = { display: function() { Element.toggle(arguments); } }
+/*--------------------------------------------------------------------------*/
-var Element = {
- toggle: function() {
- for (var i = 0; i < arguments.length; i++) {
- var element = $(arguments[i]);
- element.style.display =
- (element.style.display == 'none' ? '' : 'none');
- }
- }
- hide: function() {
- for (var i = 0; i < arguments.length; i++) {
- var element = $(arguments[i]);
- element.style.display = 'none';
- }
- }
- show: function() {
- for (var i = 0; i < arguments.length; i++) {
- var element = $(arguments[i]);
- element.style.display = '';
+var PeriodicalExecuter = Class.create();
+PeriodicalExecuter.prototype = {
+ initialize: function(callback, frequency) {
+ this.callback = callback;
+ this.frequency = frequency;
+ this.currentlyExecuting = false;
+
+ this.registerCallback();
+ },
+
+ registerCallback: function() {
+ setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
+ },
+
+ onTimerEvent: function() {
+ if (!this.currentlyExecuting) {
+ try {
+ this.currentlyExecuting = true;
+ this.callback();
+ } finally {
+ this.currentlyExecuting = false;
+ }
}
+
+ this.registerCallback();
}
}
@@ -106,22 +116,34 @@ function $() {
return elements;
}
-function getElementsByClassName(className) {
- var children = document.getElementsByTagName('*') || document.all;
- var elements = new Array();
-
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- var classNames = child.className.split(' ');
- for (var j = 0; j < classNames.length; j++) {
- if (classNames[j] == className) {
- elements.push(child);
- break;
- }
- }
+/*--------------------------------------------------------------------------*/
+
+if (!Array.prototype.push) {
+ Array.prototype.push = function() {
+ var startLength = this.length;
+ for (var i = 0; i < arguments.length; i++)
+ this[startLength + i] = arguments[i];
+ return this.length;
+ }
+}
+
+if (!Function.prototype.apply) {
+ // Based on code from http://www.youngpup.net/
+ Function.prototype.apply = function(object, parameters) {
+ var parameterStrings = new Array();
+ if (!object) object = window;
+ if (!parameters) parameters = new Array();
+
+ for (var i = 0; i < parameters.length; i++)
+ parameterStrings[i] = 'x[' + i + ']';
+
+ object.__apply__ = this;
+ var result = eval('obj.__apply__(' +
+ parameterStrings[i].join(', ') + ')');
+ object.__apply__ = null;
+
+ return result;
}
-
- return elements;
}
/*--------------------------------------------------------------------------*/
@@ -169,6 +191,9 @@ Ajax.Request.prototype = (new Ajax.Base()).extend({
setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
}
+ this.transport.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ this.transport.setRequestHeader('X-Prototype-Version', Prototype.Version);
+
if (this.options.method == 'post') {
this.transport.setRequestHeader('Connection', 'close');
this.transport.setRequestHeader('Content-type',
@@ -212,11 +237,11 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
},
updateContent: function() {
- if (!this.options.insertion) {
- this.container.innerHTML = this.request.transport.responseText;
- } else {
+ if (this.options.insertion) {
new this.options.insertion(this.container,
this.request.transport.responseText);
+ } else {
+ this.container.innerHTML = this.request.transport.responseText;
}
if (this.onComplete) {
@@ -241,6 +266,15 @@ var Field = {
for (var i = 0; i < arguments.length; i++)
if ($(arguments[i]).value == '') return false;
return true;
+ },
+
+ select: function(element) {
+ $(element).select();
+ },
+
+ activate: function(element) {
+ $(element).focus();
+ $(element).select();
}
}
@@ -270,6 +304,31 @@ var Form = {
elements.push(tagElements[j]);
}
return elements;
+ },
+
+ disable: function(form) {
+ var elements = Form.getElements(form);
+ for (var i = 0; i < elements.length; i++) {
+ var element = elements[i];
+ element.blur();
+ element.disable = 'true';
+ }
+ },
+
+ focusFirstElement: function(form) {
+ form = $(form);
+ var elements = Form.getElements(form);
+ for (var i = 0; i < elements.length; i++) {
+ var element = elements[i];
+ if (element.type != 'hidden' && !element.disabled) {
+ Field.activate(element);
+ break;
+ }
+ }
+ },
+
+ reset: function(form) {
+ $(form).reset();
}
}
@@ -319,12 +378,17 @@ Form.Element.Serializers = {
select: function(element) {
var index = element.selectedIndex;
- return [element.name, (index >= 0) ? element.options[index].value : ''];
+ var value = element.options[index].value || element.options[index].text;
+ return [element.name, (index >= 0) ? value : ''];
}
}
/*--------------------------------------------------------------------------*/
+var $F = Form.Element.getValue;
+
+/*--------------------------------------------------------------------------*/
+
Abstract.TimedObserver = function() {}
Abstract.TimedObserver.prototype = {
initialize: function(element, frequency, callback) {
@@ -368,6 +432,65 @@ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({
/*--------------------------------------------------------------------------*/
+document.getElementsByClassName = function(className) {
+ var children = document.getElementsByTagName('*') || document.all;
+ var elements = new Array();
+
+ for (var i = 0; i < children.length; i++) {
+ var child = children[i];
+ var classNames = child.className.split(' ');
+ for (var j = 0; j < classNames.length; j++) {
+ if (classNames[j] == className) {
+ elements.push(child);
+ break;
+ }
+ }
+ }
+
+ return elements;
+}
+
+/*--------------------------------------------------------------------------*/
+
+var Element = {
+ toggle: function() {
+ for (var i = 0; i < arguments.length; i++) {
+ var element = $(arguments[i]);
+ element.style.display =
+ (element.style.display == 'none' ? '' : 'none');
+ }
+ },
+
+ hide: function() {
+ for (var i = 0; i < arguments.length; i++) {
+ var element = $(arguments[i]);
+ element.style.display = 'none';
+ }
+ },
+
+ show: function() {
+ for (var i = 0; i < arguments.length; i++) {
+ var element = $(arguments[i]);
+ element.style.display = '';
+ }
+ },
+
+ remove: function(element) {
+ element = $(element);
+ element.parentNode.removeChild(element);
+ },
+
+ getHeight: function(element) {
+ element = $(element);
+ return element.offsetHeight;
+ }
+}
+
+var Toggle = new Object();
+Toggle.display = Element.toggle;
+
+/*--------------------------------------------------------------------------*/
+
Abstract.Insertion = function(adjacency) {
this.adjacency = adjacency;
}
@@ -484,7 +607,7 @@ Effect.Fade.prototype = {
if (this.timer) clearTimeout(this.timer);
this.setOpacity(this.element, this.current);
this.current -= 10;
- this.timer = setTimeout(this.fade.bind(this), 100);
+ this.timer = setTimeout(this.fade.bind(this), 50);
},
isFinished: function() {
@@ -494,7 +617,7 @@ Effect.Fade.prototype = {
setOpacity: function(element, opacity) {
opacity = (opacity == 100) ? 99.999 : opacity;
element.style.filter = "alpha(opacity:"+opacity+")";
- element.style.opacity = opacity/100;
+ element.style.opacity = opacity/100 /*//*/;
}
}
@@ -503,13 +626,13 @@ Effect.Scale.prototype = {
initialize: function(element, percent) {
this.element = $(element);
this.startScale = 1.0;
- this.startHeight = this.element.height || this.element.offsetHeight;
- this.startWidth = this.element.width || this.element.offsetWidth;
+ this.startHeight = this.element.offsetHeight;
+ this.startWidth = this.element.offsetWidth;
this.currentHeight = this.startHeight;
this.currentWidth = this.startWidth;
- this.finishScale = (percent/100);
+ this.finishScale = (percent/100) /*//*/;
if (this.element.style.fontSize=="") this.sizeEm = 1.0;
- if (this.element.style.fontSize && this.element.style.fontSize.indexOf("em")>0)
+ if (this.element.style.fontSize.indexOf("em")>0)
this.sizeEm = parseFloat(this.element.style.fontSize);
if(this.element.effect_scale) {
clearTimeout(this.element.effect_scale.timer);
@@ -537,7 +660,7 @@ Effect.Scale.prototype = {
if (this.options.step) this.options.step(this);
this.setDimensions(this.element, this.currentWidth, this.currentHeight);
if(this.sizeEm) this.element.style.fontSize = this.sizeEm*this.currentScale + "em";
- this.currentScale += (this.factor/10);
+ this.currentScale += (this.factor/10) /*//*/;
this.currentWidth = this.startWidth * this.currentScale;
this.currentHeight = this.startHeight * this.currentScale;
this.timer = setTimeout(this.scale.bind(this), 50);
@@ -577,13 +700,9 @@ Effect.Puff.prototype = {
fade: function(effect) {
topd = (((effect.currentScale)*effect.startHeight) - effect.startHeight)/2;
leftd = (((effect.currentScale)*effect.startWidth) - effect.startWidth)/2;
- if(this.element.style.position='absolute') {
- this.element.style.top = this.startTop-topd + "px";
- this.element.style.left = this.startLeft-leftd + "px";
- } else {
- this.element.style.top = -topd + "px";
- this.element.style.left = -leftd + "px";
- }
+ this.element.style.position='absolute';
+ this.element.style.top = this.startTop-topd + "px";
+ this.element.style.left = this.startLeft-leftd + "px";
this.opacity -= 10;
this.setOpacity(this.element, this.opacity);
if(navigator.appVersion.indexOf('AppleWebKit')>0) this.element.innerHTML += ''; //force redraw on safari
@@ -594,7 +713,7 @@ Effect.Puff.prototype = {
setOpacity: function(element, opacity) {
opacity = (opacity == 100) ? 99.999 : opacity;
element.style.filter = "alpha(opacity:"+opacity+")";
- element.style.opacity = opacity/100;
+ element.style.opacity = opacity/100 /*//*/;
}
}
@@ -613,7 +732,7 @@ Effect.Appear.prototype = {
if (this.timer) clearTimeout(this.timer);
this.setOpacity(this.element, this.current);
this.current += 10;
- this.timer = setTimeout(this.fade.bind(this), 100);
+ this.timer = setTimeout(this.fade.bind(this), 50);
},
isFinished: function() {
@@ -623,37 +742,23 @@ Effect.Appear.prototype = {
setOpacity: function(element, opacity) {
opacity = (opacity == 100) ? 99.999 : opacity;
element.style.filter = "alpha(opacity:"+opacity+")";
- element.style.opacity = opacity/100;
+ element.style.opacity = opacity/100 /*//*/;
element.style.display = '';
}
}
-/*--------------------------------------------------------------------------*/
-
-PeriodicalExecuter = Class.create();
-PeriodicalExecuter.prototype = {
- initialize: function(what, frequency) {
- this.what = what;
- this.frequency = frequency;
- this.currentlyExecuting = false;
-
- this.registerCallback();
- },
-
- registerCallback: function() {
- setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
- },
-
- onTimerEvent: function() {
- if (!this.currentlyExecuting) {
- try {
- this.currentlyExecuting = true;
- this.what();
- } finally {
- this.currentlyExecuting = false;
- }
+Effect.ContentZoom = Class.create();
+Effect.ContentZoom.prototype = {
+ initialize: function(element, percent) {
+ this.element = $(element);
+ if (this.element.style.fontSize=="") this.sizeEm = 1.0;
+ if (this.element.style.fontSize.indexOf("em")>0)
+ this.sizeEm = parseFloat(this.element.style.fontSize);
+ if(this.element.effect_contentzoom) {
+ this.sizeEm = this.element.effect_contentzoom.sizeEm;
}
-
- this.registerCallback();
+ this.element.effect_contentzoom = this;
+ this.element.style.fontSize = this.sizeEm*(percent/100) + "em" /*//*/;
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) { this.element.scrollTop -= 1; };
}
}