Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

script.aculo.us: Update to Prototype 1.6.0_rc0

git-svn-id: http://svn.rubyonrails.org/rails/spinoffs/scriptaculous@7323 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit f239e1d2e1a72e0cb5f2cd66dbeb5ed947c59e3c 1 parent c167cd1
Thomas Fuchs madrobby authored
Showing with 77 additions and 81 deletions.
  1. +2 −0  CHANGELOG
  2. +75 −60 lib/prototype.js
  3. +0 −21 src/effects.js
2  CHANGELOG
View
@@ -1,5 +1,7 @@
*SVN*
+* Update to Prototype 1.6.0_rc0.
+
* Some effect code refactoring to take advantage of new Prototype 1.6 features.
* Effect.ScrollTo is now no longer a core effect (returns a Effect.Tween instance now).
135 lib/prototype.js
View
@@ -1,4 +1,4 @@
-/* Prototype JavaScript framework, version 1.6.0_pre1
+/* Prototype JavaScript framework, version 1.6.0_rc0
* (c) 2005-2007 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
@@ -7,7 +7,7 @@
*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.6.0_pre1',
+ Version: '1.6.0_rc0',
Browser: {
IE: !!(window.attachEvent && !window.opera),
@@ -51,7 +51,6 @@ var Class = {
if (Object.isFunction(parent)) {
Class.extending = true;
method.prototype = new parent();
- method.prototype.constructor = method;
parent.subclasses.push(method);
@@ -59,6 +58,7 @@ var Class = {
}
if (methods) Class.extend(method, methods);
+ method.prototype.constructor = method;
return method;
},
@@ -1801,6 +1801,10 @@ Element.Methods = {
var t = Element._attributeTranslations.read;
if (t.values[name]) return t.values[name](element, name);
if (t.names[name]) name = t.names[name];
+ if (name.include(':')) {
+ return (!element.attributes || !element.attributes[name]) ? null :
+ element.attributes[name].value;
+ }
}
return element.getAttribute(name);
},
@@ -2265,6 +2269,20 @@ if (Prototype.Browser.Opera) {
}
else if (Prototype.Browser.IE) {
+ $w('positionedOffset getOffsetParent viewportOffset').each(function(method) {
+ Element.Methods[method] = Element.Methods[method].wrap(
+ function(proceed, element) {
+ element = $(element);
+ var position = element.getStyle('position');
+ if (position != 'static') return proceed(element);
+ element.setStyle({ position: 'relative' });
+ var value = proceed(element);
+ element.setStyle({ position: position });
+ return value;
+ }
+ );
+ });
+
Element.Methods.getStyle = function(element, style) {
element = $(element);
style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
@@ -2311,6 +2329,10 @@ else if (Prototype.Browser.IE) {
_getAttr: function(element, attribute) {
return element.getAttribute(attribute, 2);
},
+ _getAttrNode: function(element, attribute) {
+ var node = element.getAttributeNode(attribute);
+ return node ? node.value : "";
+ },
_getEv: function(element, attribute) {
var attribute = element.getAttribute(attribute);
return attribute ? attribute.toString().slice(23, -2) : null;
@@ -2329,19 +2351,7 @@ else if (Prototype.Browser.IE) {
};
Element._attributeTranslations.write = {
- names: Object.extend({
- colspan: 'colSpan',
- rowspan: 'rowSpan',
- valign: 'vAlign',
- datetime: 'dateTime',
- accesskey: 'accessKey',
- tabindex: 'tabIndex',
- enctype: 'encType',
- maxlength: 'maxLength',
- readonly: 'readOnly',
- longdesc: 'longDesc'
- }, Element._attributeTranslations.read.names),
-
+ names: Object.clone(Element._attributeTranslations.read.names),
values: {
checked: function(element, value) {
element.checked = !!value;
@@ -2353,15 +2363,24 @@ else if (Prototype.Browser.IE) {
}
};
+ Element._attributeTranslations.has = {};
+
+ $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
+ 'encType maxLength readOnly longDesc').each(function(attr) {
+ Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
+ Element._attributeTranslations.has[attr.toLowerCase()] = attr;
+ });
+
(function(v) {
Object.extend(v, {
- href: v._getAttr,
- src: v._getAttr,
- type: v._getAttr,
- disabled: v._flag,
- checked: v._flag,
- readonly: v._flag,
- multiple: v._flag,
+ href: v._getAttr,
+ src: v._getAttr,
+ type: v._getAttr,
+ action: v._getAttrNode,
+ disabled: v._flag,
+ checked: v._flag,
+ readonly: v._flag,
+ multiple: v._flag,
onload: v._getEv,
onunload: v._getEv,
onclick: v._getEv,
@@ -2425,7 +2444,7 @@ else if (Prototype.Browser.WebKit) {
element = element.offsetParent;
} while (element);
- return [valueL, valueT];
+ return Element._returnOffset(valueL, valueT);
};
}
@@ -2550,9 +2569,8 @@ Element._insertionTranslations = {
Element.Methods.Simulated = {
hasAttribute: function(element, attribute) {
- var t = Element._attributeTranslations.read, node;
- attribute = t.names[attribute] || attribute;
- node = $(element).getAttributeNode(attribute);
+ attribute = Element._attributeTranslations.has[attribute] || attribute;
+ var node = $(element).getAttributeNode(attribute);
return node && node.specified;
}
};
@@ -3730,11 +3748,9 @@ Object.extend(Event, {
DOMEvents: ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover',
'mousemove', 'mouseout', 'keypress', 'keydown', 'keyup',
'load', 'unload', 'abort', 'error', 'resize', 'scroll',
- 'select', 'change', 'submit', 'reset', 'focus', 'blur',
- 'DOMFocusIn', 'DOMFocusOut', 'DOMActivate',
- 'DOMSubtreeModified', 'DOMNodeInserted',
- 'NodeInsertedIntoDocument', 'DOMAttrModified',
- 'DOMCharacterDataModified'],
+ 'select', 'change', 'submit', 'reset', 'focus', 'blur'],
+
+ cache: { },
relatedTarget: function(event) {
var element;
@@ -3817,7 +3833,7 @@ Event.extend = (function() {
})();
Object.extend(Event, (function() {
- var cache = { };
+ var cache = Event.cache;
function getEventID(element) {
if (element._eventID) return element._eventID;
@@ -3862,9 +3878,9 @@ Object.extend(Event, (function() {
}
function destroyWrapper(id, eventName, handler) {
- var c = getCacheForID(id), name = getDOMEventName(eventName);
- if (!c[name]) return false;
- c[name] = c[name].without(findWrapper(id, eventName, handler));
+ var c = getCacheForID(id);
+ if (!c[eventName]) return false;
+ c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
}
function destroyCache() {
@@ -3883,13 +3899,15 @@ Object.extend(Event, (function() {
var id = getEventID(element), name = getDOMEventName(eventName);
var wrapper = createWrapper(id, eventName, handler);
- if (!wrapper) return false;
+ if (!wrapper) return element;
if (element.addEventListener) {
element.addEventListener(name, wrapper, false);
} else {
element.attachEvent("on" + name, wrapper);
}
+
+ return element;
},
stopObserving: function(element, eventName, handler) {
@@ -3897,24 +3915,30 @@ Object.extend(Event, (function() {
var id = getEventID(element), name = getDOMEventName(eventName);
if (!handler && eventName) {
- return getWrappersForEventName(id, eventName).each(function(wrapper) {
+ getWrappersForEventName(id, eventName).each(function(wrapper) {
element.stopObserving(eventName, wrapper.handler);
- }) && false;
+ });
+ return element;
} else if (!eventName) {
- return Object.keys(getCacheForID(id)).each(function(eventName) {
+ Object.keys(getCacheForID(id)).each(function(eventName) {
element.stopObserving(eventName);
- }) && false;
+ });
+ return element;
}
var wrapper = findWrapper(id, eventName, handler);
- if (!wrapper) return false;
+ if (!wrapper) return element;
if (element.removeEventListener) {
element.removeEventListener(name, wrapper, false);
} else {
element.detachEvent("on" + name, wrapper);
}
+
+ destroyWrapper(id, eventName, handler);
+
+ return element;
},
fire: function(element, eventName, memo) {
@@ -3939,7 +3963,7 @@ Object.extend(Event, (function() {
element.fireEvent(event.eventType, event);
}
- return element;
+ return event;
}
};
})());
@@ -3947,20 +3971,9 @@ Object.extend(Event, (function() {
Object.extend(Event, Event.Methods);
Element.addMethods({
- fire: function() {
- Event.fire.apply(Event, arguments);
- return $A(arguments).first();
- },
-
- observe: function() {
- Event.observe.apply(Event, arguments);
- return $A(arguments).first();
- },
-
- stopObserving: function() {
- Event.stopObserving.apply(Event, arguments);
- return $A(arguments).first();
- }
+ fire: Event.fire,
+ observe: Event.observe,
+ stopObserving: Event.stopObserving
});
Object.extend(document, {
@@ -3992,12 +4005,14 @@ Object.extend(document, {
Event.observe(window, "load", fireContentLoadedEvent);
} else {
- document.addEventListener("DOMContentLoaded", fireContentLoadedEvent, false);
+ document.addEventListener("DOMContentLoaded",
+ fireContentLoadedEvent, false);
}
} else {
- var dummy = location.protocol == "https:" ? "https://javascript:void(0)" : "javascript:void(0)";
- document.write("<script id=__onDOMContentLoaded defer src='" + dummy + "'><\/script>");
+ document.write("<script id=__onDOMContentLoaded defer " +
+ "src='://javascript:void(0)'><\/script>");
+
$("__onDOMContentLoaded").onreadystatechange = function() {
if (this.readyState == "complete") {
this.onreadystatechange = null;
21 src/effects.js
View
@@ -534,27 +534,6 @@ Effect.ScrollTo = function(element) {
function(p){ scrollTo(scrollOffsets.left, p.round()) }
);
};
-/* this.element = $(element);
- this.start(arguments[1] || {});
- },
- setup: function() {
- Position.prepare();
- var offsets = Position.cumulativeOffset(this.element);
- if(this.options.offset) offsets[1] += this.options.offset;
- var max = window.innerHeight ?
- window.height - window.innerHeight :
- document.body.scrollHeight -
- (document.documentElement.clientHeight ?
- document.documentElement.clientHeight : document.body.clientHeight);
- this.scrollStart = Position.deltaY;
- this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
- },
- update: function(position) {
- Position.prepare();
- window.scrollTo(Position.deltaX,
- this.scrollStart + (position*this.delta));
- }
-});*/
/* ------------- combination effects ------------- */
Please sign in to comment.
Something went wrong with that request. Please try again.