New: Upgrade Scriptaculous to 1.8.2 and Prototype to 1.6.0.3

This commit is contained in:
Regis Houssin 2009-03-02 23:18:56 +00:00
parent 88fa56f9ca
commit 05a48da313
14 changed files with 770 additions and 630 deletions

View File

@ -23,9 +23,9 @@ FPDI_Protection 1.0.2 Apache Software License 2.0 No GPL3 only PDF encr
MagPieRss 0.72 GPL 2.0 Yes Load RSS MagPieRss 0.72 GPL 2.0 Yes Load RSS
NuSoap 0.6.5 LGPL 2.1 Yes Interfaces with third tools NuSoap 0.6.5 LGPL 2.1 Yes Interfaces with third tools
PHP_WriteExcel 0.3.0 LGPL 2.1 Yes Excel files generation PHP_WriteExcel 0.3.0 LGPL 2.1 Yes Excel files generation
Prototype 1.6.0.2 MIT License Yes Ajax library Prototype 1.6.0.3 MIT License Yes Ajax library
PWC 1.3 MIT License Yes Ajax library PWC 1.3 MIT License Yes Ajax library
Scriptaculous 1.8.1 MIT License Yes Ajax library Scriptaculous 1.8.2 MIT License Yes Ajax library
VCard 2.0 GPL 2.0 Yes Fonctions vcard VCard 2.0 GPL 2.0 Yes Fonctions vcard
For licenses compatibility informations: For licenses compatibility informations:

View File

@ -19,6 +19,7 @@ For users:
- New: Added product label in invoice exports fields. - New: Added product label in invoice exports fields.
- New: Add VAT number in export fields. - New: Add VAT number in export fields.
- New: Upgrade FPDF to 1.6 - New: Upgrade FPDF to 1.6
- New: Upgrade Scriptaculous to 1.8.2 and Prototype to 1.6.0.3
- New: Added keywords in PDF. - New: Added keywords in PDF.
- New: Add hidden option MAIN_DISABLE_PDF_COMPRESSION. - New: Add hidden option MAIN_DISABLE_PDF_COMPRESSION.
- New: Add attachments on intervention cards. - New: Add attachments on intervention cards.

View File

@ -1,3 +1,29 @@
*V1.8.2* (November 18, 2008)
* Update to Prototype 1.6.0.3
* Make sure InPlaceEditor converts HTML entities to text. [Sean Kirby]
* Fix that Builder.node did not return extended elements on IE. Closes #71 and #77.
* Fix a bug in Sortable.destroy to make sure it's called on the referenced Sortable only, which allows for the correct intialization of nested Sortables. Closes Trac #8615. [Leon Chevalier]
* Change Effect.Base#render not to use eval(), so certain JavaScript runtime environments (like Adobe AIR) that do not support eval() work. [King Maxemilian, John-David Dalton]
* Fixed a calculation error in Effect.Transitions.pulse that could lead to flickering, add easing and change it to be a normal 0 to 1 transition that can be used with any effects; Effect.Pulsate now uses its own implementation. [Thomas Fuchs]
* Fixed Effect.ScrollTo. Changeset 8686 had a typo, document.viewport.getScrollOffsets[0] is always undefined. Removed the max check as it is not a cross-browser way to get scroll height and breaks the effect. Depending on scrollTo to do the right thing. Closes #11306. [Nick Stakenburg]
* Update version check so all Prototype versions can be required, not just x.x.x. Closes #10966. [Nick Stakenburg]
* Using $$ in the loader instead of getElementsByTagName to prevent limitations. Closes #9032. [Nick Stakenburg]
* Fix some missing semicolons. [jdalton]
* Fix an issue with Effect.ScrollTo that caused Firefox to scroll to the wrong offset in some situations. Closes #10245. [nik.wakelin]
* Fixes an issue with IE ghosting on non-absolute elements. Closes #10423. [Tanrikut, tdd]
*V1.8.1* (January 3, 2008) *V1.8.1* (January 3, 2008)
* Fix Element#getStyles in IE. Closes #10563. [Tobie Langel] * Fix Element#getStyles in IE. Closes #10563. [Tobie Langel]

View File

@ -1,4 +1,4 @@
Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -14,6 +14,9 @@ For more information, see http://script.aculo.us/
See the CHANGELOG file for information on what's new. See the CHANGELOG file for information on what's new.
You can follow http://twitter.com/scriptaculous if you want
to be updated as we fix bugs and add new features.
== Installation/Usage == Installation/Usage
script.aculo.us includes the Prototype JavaScript Framework script.aculo.us includes the Prototype JavaScript Framework

View File

@ -1,4 +1,4 @@
/* Prototype JavaScript framework, version 1.6.0.2 /* Prototype JavaScript framework, version 1.6.0.3
* (c) 2005-2008 Sam Stephenson * (c) 2005-2008 Sam Stephenson
* *
* Prototype is freely distributable under the terms of an MIT-style license. * Prototype is freely distributable under the terms of an MIT-style license.
@ -7,23 +7,26 @@
*--------------------------------------------------------------------------*/ *--------------------------------------------------------------------------*/
var Prototype = { var Prototype = {
Version: '1.6.0.2', Version: '1.6.0.3',
Browser: { Browser: {
IE: !!(window.attachEvent && !window.opera), IE: !!(window.attachEvent &&
Opera: !!window.opera, navigator.userAgent.indexOf('Opera') === -1),
Opera: navigator.userAgent.indexOf('Opera') > -1,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1, Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
navigator.userAgent.indexOf('KHTML') === -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
}, },
BrowserFeatures: { BrowserFeatures: {
XPath: !!document.evaluate, XPath: !!document.evaluate,
SelectorsAPI: !!document.querySelector,
ElementExtensions: !!window.HTMLElement, ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions: SpecificElementExtensions:
document.createElement('div').__proto__ && document.createElement('div')['__proto__'] &&
document.createElement('div').__proto__ !== document.createElement('div')['__proto__'] !==
document.createElement('form').__proto__ document.createElement('form')['__proto__']
}, },
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
@ -83,12 +86,13 @@ Class.Methods = {
var property = properties[i], value = source[property]; var property = properties[i], value = source[property];
if (ancestor && Object.isFunction(value) && if (ancestor && Object.isFunction(value) &&
value.argumentNames().first() == "$super") { value.argumentNames().first() == "$super") {
var method = value, value = Object.extend((function(m) { var method = value;
value = (function(m) {
return function() { return ancestor[m].apply(this, arguments) }; return function() { return ancestor[m].apply(this, arguments) };
})(property).wrap(method), { })(property).wrap(method);
valueOf: function() { return method },
toString: function() { return method.toString() } value.valueOf = method.valueOf.bind(method);
}); value.toString = method.toString.bind(method);
} }
this.prototype[property] = value; this.prototype[property] = value;
} }
@ -167,7 +171,7 @@ Object.extend(Object, {
}, },
isElement: function(object) { isElement: function(object) {
return object && object.nodeType == 1; return !!(object && object.nodeType == 1);
}, },
isArray: function(object) { isArray: function(object) {
@ -198,7 +202,8 @@ Object.extend(Object, {
Object.extend(Function.prototype, { Object.extend(Function.prototype, {
argumentNames: function() { argumentNames: function() {
var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip"); var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
.replace(/\s+/g, '').split(',');
return names.length == 1 && !names[0] ? [] : names; return names.length == 1 && !names[0] ? [] : names;
}, },
@ -232,6 +237,11 @@ Object.extend(Function.prototype, {
}, timeout); }, timeout);
}, },
defer: function() {
var args = [0.01].concat($A(arguments));
return this.delay.apply(this, args);
},
wrap: function(wrapper) { wrap: function(wrapper) {
var __method = this; var __method = this;
return function() { return function() {
@ -248,8 +258,6 @@ Object.extend(Function.prototype, {
} }
}); });
Function.prototype.defer = Function.prototype.delay.curry(0.01);
Date.prototype.toJSON = function() { Date.prototype.toJSON = function() {
return '"' + this.getUTCFullYear() + '-' + return '"' + this.getUTCFullYear() + '-' +
(this.getUTCMonth() + 1).toPaddedString(2) + '-' + (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
@ -530,7 +538,7 @@ if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.proto
return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}, },
unescapeHTML: function() { unescapeHTML: function() {
return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>'); return this.stripTags().replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
} }
}); });
@ -547,7 +555,7 @@ Object.extend(String.prototype.escapeHTML, {
text: document.createTextNode('') text: document.createTextNode('')
}); });
with (String.prototype.escapeHTML) div.appendChild(text); String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);
var Template = Class.create({ var Template = Class.create({
initialize: function(template, pattern) { initialize: function(template, pattern) {
@ -589,10 +597,9 @@ var $break = { };
var Enumerable = { var Enumerable = {
each: function(iterator, context) { each: function(iterator, context) {
var index = 0; var index = 0;
iterator = iterator.bind(context);
try { try {
this._each(function(value) { this._each(function(value) {
iterator(value, index++); iterator.call(context, value, index++);
}); });
} catch (e) { } catch (e) {
if (e != $break) throw e; if (e != $break) throw e;
@ -601,47 +608,46 @@ var Enumerable = {
}, },
eachSlice: function(number, iterator, context) { eachSlice: function(number, iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K;
var index = -number, slices = [], array = this.toArray(); var index = -number, slices = [], array = this.toArray();
if (number < 1) return array;
while ((index += number) < array.length) while ((index += number) < array.length)
slices.push(array.slice(index, index+number)); slices.push(array.slice(index, index+number));
return slices.collect(iterator, context); return slices.collect(iterator, context);
}, },
all: function(iterator, context) { all: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K; iterator = iterator || Prototype.K;
var result = true; var result = true;
this.each(function(value, index) { this.each(function(value, index) {
result = result && !!iterator(value, index); result = result && !!iterator.call(context, value, index);
if (!result) throw $break; if (!result) throw $break;
}); });
return result; return result;
}, },
any: function(iterator, context) { any: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K; iterator = iterator || Prototype.K;
var result = false; var result = false;
this.each(function(value, index) { this.each(function(value, index) {
if (result = !!iterator(value, index)) if (result = !!iterator.call(context, value, index))
throw $break; throw $break;
}); });
return result; return result;
}, },
collect: function(iterator, context) { collect: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K; iterator = iterator || Prototype.K;
var results = []; var results = [];
this.each(function(value, index) { this.each(function(value, index) {
results.push(iterator(value, index)); results.push(iterator.call(context, value, index));
}); });
return results; return results;
}, },
detect: function(iterator, context) { detect: function(iterator, context) {
iterator = iterator.bind(context);
var result; var result;
this.each(function(value, index) { this.each(function(value, index) {
if (iterator(value, index)) { if (iterator.call(context, value, index)) {
result = value; result = value;
throw $break; throw $break;
} }
@ -650,17 +656,16 @@ var Enumerable = {
}, },
findAll: function(iterator, context) { findAll: function(iterator, context) {
iterator = iterator.bind(context);
var results = []; var results = [];
this.each(function(value, index) { this.each(function(value, index) {
if (iterator(value, index)) if (iterator.call(context, value, index))
results.push(value); results.push(value);
}); });
return results; return results;
}, },
grep: function(filter, iterator, context) { grep: function(filter, iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K; iterator = iterator || Prototype.K;
var results = []; var results = [];
if (Object.isString(filter)) if (Object.isString(filter))
@ -668,7 +673,7 @@ var Enumerable = {
this.each(function(value, index) { this.each(function(value, index) {
if (filter.match(value)) if (filter.match(value))
results.push(iterator(value, index)); results.push(iterator.call(context, value, index));
}); });
return results; return results;
}, },
@ -696,9 +701,8 @@ var Enumerable = {
}, },
inject: function(memo, iterator, context) { inject: function(memo, iterator, context) {
iterator = iterator.bind(context);
this.each(function(value, index) { this.each(function(value, index) {
memo = iterator(memo, value, index); memo = iterator.call(context, memo, value, index);
}); });
return memo; return memo;
}, },
@ -711,10 +715,10 @@ var Enumerable = {
}, },
max: function(iterator, context) { max: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K; iterator = iterator || Prototype.K;
var result; var result;
this.each(function(value, index) { this.each(function(value, index) {
value = iterator(value, index); value = iterator.call(context, value, index);
if (result == null || value >= result) if (result == null || value >= result)
result = value; result = value;
}); });
@ -722,10 +726,10 @@ var Enumerable = {
}, },
min: function(iterator, context) { min: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K; iterator = iterator || Prototype.K;
var result; var result;
this.each(function(value, index) { this.each(function(value, index) {
value = iterator(value, index); value = iterator.call(context, value, index);
if (result == null || value < result) if (result == null || value < result)
result = value; result = value;
}); });
@ -733,10 +737,10 @@ var Enumerable = {
}, },
partition: function(iterator, context) { partition: function(iterator, context) {
iterator = iterator ? iterator.bind(context) : Prototype.K; iterator = iterator || Prototype.K;
var trues = [], falses = []; var trues = [], falses = [];
this.each(function(value, index) { this.each(function(value, index) {
(iterator(value, index) ? (iterator.call(context, value, index) ?
trues : falses).push(value); trues : falses).push(value);
}); });
return [trues, falses]; return [trues, falses];
@ -751,19 +755,20 @@ var Enumerable = {
}, },
reject: function(iterator, context) { reject: function(iterator, context) {
iterator = iterator.bind(context);
var results = []; var results = [];
this.each(function(value, index) { this.each(function(value, index) {
if (!iterator(value, index)) if (!iterator.call(context, value, index))
results.push(value); results.push(value);
}); });
return results; return results;
}, },
sortBy: function(iterator, context) { sortBy: function(iterator, context) {
iterator = iterator.bind(context);
return this.map(function(value, index) { return this.map(function(value, index) {
return {value: value, criteria: iterator(value, index)}; return {
value: value,
criteria: iterator.call(context, value, index)
};
}).sort(function(left, right) { }).sort(function(left, right) {
var a = left.criteria, b = right.criteria; var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0; return a < b ? -1 : a > b ? 1 : 0;
@ -815,8 +820,12 @@ function $A(iterable) {
if (Prototype.Browser.WebKit) { if (Prototype.Browser.WebKit) {
$A = function(iterable) { $A = function(iterable) {
if (!iterable) return []; if (!iterable) return [];
if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') && // In Safari, only use the `toArray` method if it's not a NodeList.
iterable.toArray) return iterable.toArray(); // A NodeList is a function, has an function `item` property, and a numeric
// `length` property. Adapted from Google Doctype.
if (!(typeof iterable === 'function' && typeof iterable.length ===
'number' && typeof iterable.item === 'function') && iterable.toArray)
return iterable.toArray();
var length = iterable.length || 0, results = new Array(length); var length = iterable.length || 0, results = new Array(length);
while (length--) results[length] = iterable[length]; while (length--) results[length] = iterable[length];
return results; return results;
@ -963,8 +972,8 @@ Object.extend(Number.prototype, {
return this + 1; return this + 1;
}, },
times: function(iterator) { times: function(iterator, context) {
$R(0, this, true).each(iterator); $R(0, this, true).each(iterator, context);
return this; return this;
}, },
@ -1011,7 +1020,9 @@ var Hash = Class.create(Enumerable, (function() {
}, },
get: function(key) { get: function(key) {
return this._object[key]; // simulating poorly supported hasOwnProperty
if (this._object[key] !== Object.prototype[key])
return this._object[key];
}, },
unset: function(key) { unset: function(key) {
@ -1051,14 +1062,14 @@ var Hash = Class.create(Enumerable, (function() {
}, },
toQueryString: function() { toQueryString: function() {
return this.map(function(pair) { return this.inject([], function(results, pair) {
var key = encodeURIComponent(pair.key), values = pair.value; var key = encodeURIComponent(pair.key), values = pair.value;
if (values && typeof values == 'object') { if (values && typeof values == 'object') {
if (Object.isArray(values)) if (Object.isArray(values))
return values.map(toQueryPair.curry(key)).join('&'); return results.concat(values.map(toQueryPair.curry(key)));
} } else results.push(toQueryPair(key, values));
return toQueryPair(key, values); return results;
}).join('&'); }).join('&');
}, },
@ -1558,6 +1569,7 @@ if (!Node.ELEMENT_NODE) {
return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
}; };
Object.extend(this.Element, element || { }); Object.extend(this.Element, element || { });
if (element) this.Element.prototype = element.prototype;
}).call(window); }).call(window);
Element.cache = { }; Element.cache = { };
@ -1574,12 +1586,14 @@ Element.Methods = {
}, },
hide: function(element) { hide: function(element) {
$(element).style.display = 'none'; element = $(element);
element.style.display = 'none';
return element; return element;
}, },
show: function(element) { show: function(element) {
$(element).style.display = ''; element = $(element);
element.style.display = '';
return element; return element;
}, },
@ -1733,7 +1747,7 @@ Element.Methods = {
element = $(element); element = $(element);
if (arguments.length == 1) return element.firstDescendant(); if (arguments.length == 1) return element.firstDescendant();
return Object.isNumber(expression) ? element.descendants()[expression] : return Object.isNumber(expression) ? element.descendants()[expression] :
element.select(expression)[index || 0]; Element.select(element, expression)[index || 0];
}, },
previous: function(element, expression, index) { previous: function(element, expression, index) {
@ -1863,24 +1877,16 @@ Element.Methods = {
descendantOf: function(element, ancestor) { descendantOf: function(element, ancestor) {
element = $(element), ancestor = $(ancestor); element = $(element), ancestor = $(ancestor);
var originalAncestor = ancestor;
if (element.compareDocumentPosition) if (element.compareDocumentPosition)
return (element.compareDocumentPosition(ancestor) & 8) === 8; return (element.compareDocumentPosition(ancestor) & 8) === 8;
if (element.sourceIndex && !Prototype.Browser.Opera) { if (ancestor.contains)
var e = element.sourceIndex, a = ancestor.sourceIndex, return ancestor.contains(element) && ancestor !== element;
nextAncestor = ancestor.nextSibling;
if (!nextAncestor) {
do { ancestor = ancestor.parentNode; }
while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
}
if (nextAncestor && nextAncestor.sourceIndex)
return (e > a && e < nextAncestor.sourceIndex);
}
while (element = element.parentNode) while (element = element.parentNode)
if (element == originalAncestor) return true; if (element == ancestor) return true;
return false; return false;
}, },
@ -1895,7 +1901,7 @@ Element.Methods = {
element = $(element); element = $(element);
style = style == 'float' ? 'cssFloat' : style.camelize(); style = style == 'float' ? 'cssFloat' : style.camelize();
var value = element.style[style]; var value = element.style[style];
if (!value) { if (!value || value == 'auto') {
var css = document.defaultView.getComputedStyle(element, null); var css = document.defaultView.getComputedStyle(element, null);
value = css ? css[style] : null; value = css ? css[style] : null;
} }
@ -1934,7 +1940,7 @@ Element.Methods = {
getDimensions: function(element) { getDimensions: function(element) {
element = $(element); element = $(element);
var display = $(element).getStyle('display'); var display = element.getStyle('display');
if (display != 'none' && display != null) // Safari bug if (display != 'none' && display != null) // Safari bug
return {width: element.offsetWidth, height: element.offsetHeight}; return {width: element.offsetWidth, height: element.offsetHeight};
@ -1963,7 +1969,7 @@ Element.Methods = {
element.style.position = 'relative'; element.style.position = 'relative';
// Opera returns the offset relative to the positioning context, when an // Opera returns the offset relative to the positioning context, when an
// element is position relative but top and left have not been defined // element is position relative but top and left have not been defined
if (window.opera) { if (Prototype.Browser.Opera) {
element.style.top = 0; element.style.top = 0;
element.style.left = 0; element.style.left = 0;
} }
@ -2018,7 +2024,7 @@ Element.Methods = {
valueL += element.offsetLeft || 0; valueL += element.offsetLeft || 0;
element = element.offsetParent; element = element.offsetParent;
if (element) { if (element) {
if (element.tagName == 'BODY') break; if (element.tagName.toUpperCase() == 'BODY') break;
var p = Element.getStyle(element, 'position'); var p = Element.getStyle(element, 'position');
if (p !== 'static') break; if (p !== 'static') break;
} }
@ -2028,7 +2034,7 @@ Element.Methods = {
absolutize: function(element) { absolutize: function(element) {
element = $(element); element = $(element);
if (element.getStyle('position') == 'absolute') return; if (element.getStyle('position') == 'absolute') return element;
// Position.prepare(); // To be done manually by Scripty when it needs it. // Position.prepare(); // To be done manually by Scripty when it needs it.
var offsets = element.positionedOffset(); var offsets = element.positionedOffset();
@ -2052,7 +2058,7 @@ Element.Methods = {
relativize: function(element) { relativize: function(element) {
element = $(element); element = $(element);
if (element.getStyle('position') == 'relative') return; if (element.getStyle('position') == 'relative') return element;
// Position.prepare(); // To be done manually by Scripty when it needs it. // Position.prepare(); // To be done manually by Scripty when it needs it.
element.style.position = 'relative'; element.style.position = 'relative';
@ -2103,7 +2109,7 @@ Element.Methods = {
element = forElement; element = forElement;
do { do {
if (!Prototype.Browser.Opera || element.tagName == 'BODY') { if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) {
valueT -= element.scrollTop || 0; valueT -= element.scrollTop || 0;
valueL -= element.scrollLeft || 0; valueL -= element.scrollLeft || 0;
} }
@ -2218,6 +2224,9 @@ else if (Prototype.Browser.IE) {
Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
function(proceed, element) { function(proceed, element) {
element = $(element); element = $(element);
// IE throws an error if element is not in document
try { element.offsetParent }
catch(e) { return $(document.body) }
var position = element.getStyle('position'); var position = element.getStyle('position');
if (position !== 'static') return proceed(element); if (position !== 'static') return proceed(element);
element.setStyle({ position: 'relative' }); element.setStyle({ position: 'relative' });
@ -2231,6 +2240,8 @@ else if (Prototype.Browser.IE) {
Element.Methods[method] = Element.Methods[method].wrap( Element.Methods[method] = Element.Methods[method].wrap(
function(proceed, element) { function(proceed, element) {
element = $(element); element = $(element);
try { element.offsetParent }
catch(e) { return Element._returnOffset(0,0) }
var position = element.getStyle('position'); var position = element.getStyle('position');
if (position !== 'static') return proceed(element); if (position !== 'static') return proceed(element);
// Trigger hasLayout on the offset parent so that IE6 reports // Trigger hasLayout on the offset parent so that IE6 reports
@ -2246,6 +2257,14 @@ else if (Prototype.Browser.IE) {
); );
}); });
Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
function(proceed, element) {
try { element.offsetParent }
catch(e) { return Element._returnOffset(0,0) }
return proceed(element);
}
);
Element.Methods.getStyle = function(element, style) { Element.Methods.getStyle = function(element, style) {
element = $(element); element = $(element);
style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
@ -2337,7 +2356,7 @@ else if (Prototype.Browser.IE) {
Element._attributeTranslations.has = {}; Element._attributeTranslations.has = {};
$w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
'encType maxLength readOnly longDesc').each(function(attr) { 'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
Element._attributeTranslations.has[attr.toLowerCase()] = attr; Element._attributeTranslations.has[attr.toLowerCase()] = attr;
}); });
@ -2390,7 +2409,7 @@ else if (Prototype.Browser.WebKit) {
(value < 0.00001) ? 0 : value; (value < 0.00001) ? 0 : value;
if (value == 1) if (value == 1)
if(element.tagName == 'IMG' && element.width) { if(element.tagName.toUpperCase() == 'IMG' && element.width) {
element.width++; element.width--; element.width++; element.width--;
} else try { } else try {
var n = document.createTextNode(' '); var n = document.createTextNode(' ');
@ -2521,7 +2540,7 @@ Element.Methods.Simulated = {
hasAttribute: function(element, attribute) { hasAttribute: function(element, attribute) {
attribute = Element._attributeTranslations.has[attribute] || attribute; attribute = Element._attributeTranslations.has[attribute] || attribute;
var node = $(element).getAttributeNode(attribute); var node = $(element).getAttributeNode(attribute);
return node && node.specified; return !!(node && node.specified);
} }
}; };
@ -2530,9 +2549,9 @@ Element.Methods.ByTag = { };
Object.extend(Element, Element.Methods); Object.extend(Element, Element.Methods);
if (!Prototype.BrowserFeatures.ElementExtensions && if (!Prototype.BrowserFeatures.ElementExtensions &&
document.createElement('div').__proto__) { document.createElement('div')['__proto__']) {
window.HTMLElement = { }; window.HTMLElement = { };
window.HTMLElement.prototype = document.createElement('div').__proto__; window.HTMLElement.prototype = document.createElement('div')['__proto__'];
Prototype.BrowserFeatures.ElementExtensions = true; Prototype.BrowserFeatures.ElementExtensions = true;
} }
@ -2547,7 +2566,7 @@ Element.extend = (function() {
element.nodeType != 1 || element == window) return element; element.nodeType != 1 || element == window) return element;
var methods = Object.clone(Methods), var methods = Object.clone(Methods),
tagName = element.tagName, property, value; tagName = element.tagName.toUpperCase(), property, value;
// extend methods for specific tags // extend methods for specific tags
if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
@ -2643,7 +2662,7 @@ Element.addMethods = function(methods) {
if (window[klass]) return window[klass]; if (window[klass]) return window[klass];
window[klass] = { }; window[klass] = { };
window[klass].prototype = document.createElement(tagName).__proto__; window[klass].prototype = document.createElement(tagName)['__proto__'];
return window[klass]; return window[klass];
} }
@ -2669,12 +2688,18 @@ Element.addMethods = function(methods) {
document.viewport = { document.viewport = {
getDimensions: function() { getDimensions: function() {
var dimensions = { }; var dimensions = { }, B = Prototype.Browser;
var B = Prototype.Browser;
$w('width height').each(function(d) { $w('width height').each(function(d) {
var D = d.capitalize(); var D = d.capitalize();
dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] : if (B.WebKit && !document.evaluate) {
(B.Opera) ? document.body['client' + D] : document.documentElement['client' + D]; // Safari <3.0 needs self.innerWidth/Height
dimensions[d] = self['inner' + D];
} else if (B.Opera && parseFloat(window.opera.version()) < 9.5) {
// Opera <9.5 needs document.body.clientWidth/Height
dimensions[d] = document.body['client' + D]
} else {
dimensions[d] = document.documentElement['client' + D];
}
}); });
return dimensions; return dimensions;
}, },
@ -2693,14 +2718,24 @@ document.viewport = {
window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
} }
}; };
/* Portions of the Selector class are derived from Jack Slocum’s DomQuery, /* Portions of the Selector class are derived from Jack Slocum's DomQuery,
* part of YUI-Ext version 0.40, distributed under the terms of an MIT-style * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
* license. Please see http://www.yui-ext.com/ for more information. */ * license. Please see http://www.yui-ext.com/ for more information. */
var Selector = Class.create({ var Selector = Class.create({
initialize: function(expression) { initialize: function(expression) {
this.expression = expression.strip(); this.expression = expression.strip();
this.compileMatcher();
if (this.shouldUseSelectorsAPI()) {
this.mode = 'selectorsAPI';
} else if (this.shouldUseXPath()) {
this.mode = 'xpath';
this.compileXPathMatcher();
} else {
this.mode = "normal";
this.compileMatcher();
}
}, },
shouldUseXPath: function() { shouldUseXPath: function() {
@ -2715,16 +2750,29 @@ var Selector = Class.create({
// XPath can't do namespaced attributes, nor can it read // XPath can't do namespaced attributes, nor can it read
// the "checked" property from DOM nodes // the "checked" property from DOM nodes
if ((/(\[[\w-]*?:|:checked)/).test(this.expression)) if ((/(\[[\w-]*?:|:checked)/).test(e))
return false; return false;
return true; return true;
}, },
compileMatcher: function() { shouldUseSelectorsAPI: function() {
if (this.shouldUseXPath()) if (!Prototype.BrowserFeatures.SelectorsAPI) return false;
return this.compileXPathMatcher();
if (!Selector._div) Selector._div = new Element('div');
// Make sure the browser treats the selector as valid. Test on an
// isolated element to minimize cost of this check.
try {
Selector._div.querySelector(this.expression);
} catch(e) {
return false;
}
return true;
},
compileMatcher: function() {
var e = this.expression, ps = Selector.patterns, h = Selector.handlers, var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
c = Selector.criteria, le, p, m; c = Selector.criteria, le, p, m;
@ -2742,7 +2790,7 @@ var Selector = Class.create({
p = ps[i]; p = ps[i];
if (m = e.match(p)) { if (m = e.match(p)) {
this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
new Template(c[i]).evaluate(m)); new Template(c[i]).evaluate(m));
e = e.replace(m[0], ''); e = e.replace(m[0], '');
break; break;
} }
@ -2781,8 +2829,27 @@ var Selector = Class.create({
findElements: function(root) { findElements: function(root) {
root = root || document; root = root || document;
if (this.xpath) return document._getElementsByXPath(this.xpath, root); var e = this.expression, results;
return this.matcher(root);
switch (this.mode) {
case 'selectorsAPI':
// querySelectorAll queries document-wide, then filters to descendants
// of the context element. That's not what we want.
// Add an explicit context to the selector if necessary.
if (root !== document) {
var oldId = root.id, id = $(root).identify();
e = "#" + id + " " + e;
}
results = $A(root.querySelectorAll(e)).map(Element.extend);
root.id = oldId;
return results;
case 'xpath':
return document._getElementsByXPath(this.xpath, root);
default:
return this.matcher(root);
}
}, },
match: function(element) { match: function(element) {
@ -2873,10 +2940,10 @@ Object.extend(Selector, {
'first-child': '[not(preceding-sibling::*)]', 'first-child': '[not(preceding-sibling::*)]',
'last-child': '[not(following-sibling::*)]', 'last-child': '[not(following-sibling::*)]',
'only-child': '[not(preceding-sibling::* or following-sibling::*)]', 'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]", 'empty': "[count(*) = 0 and (count(text()) = 0)]",
'checked': "[@checked]", 'checked': "[@checked]",
'disabled': "[@disabled]", 'disabled': "[(@disabled) and (@type!='hidden')]",
'enabled': "[not(@disabled)]", 'enabled': "[not(@disabled) and (@type!='hidden')]",
'not': function(m) { 'not': function(m) {
var e = m[6], p = Selector.patterns, var e = m[6], p = Selector.patterns,
x = Selector.xpath, le, v; x = Selector.xpath, le, v;
@ -2968,7 +3035,7 @@ Object.extend(Selector, {
className: /^\.([\w\-\*]+)(\b|$)/, className: /^\.([\w\-\*]+)(\b|$)/,
pseudo: pseudo:
/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/, /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,
attrPresence: /^\[([\w]+)\]/, attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/,
attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
}, },
@ -3081,7 +3148,7 @@ Object.extend(Selector, {
nextElementSibling: function(node) { nextElementSibling: function(node) {
while (node = node.nextSibling) while (node = node.nextSibling)
if (node.nodeType == 1) return node; if (node.nodeType == 1) return node;
return null; return null;
}, },
@ -3270,7 +3337,7 @@ Object.extend(Selector, {
'empty': function(nodes, value, root) { 'empty': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) { for (var i = 0, results = [], node; node = nodes[i]; i++) {
// IE treats comments as element nodes // IE treats comments as element nodes
if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue; if (node.tagName == '!' || node.firstChild) continue;
results.push(node); results.push(node);
} }
return results; return results;
@ -3288,7 +3355,8 @@ Object.extend(Selector, {
'enabled': function(nodes, value, root) { 'enabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) for (var i = 0, results = [], node; node = nodes[i]; i++)
if (!node.disabled) results.push(node); if (!node.disabled && (!node.type || node.type !== 'hidden'))
results.push(node);
return results; return results;
}, },
@ -3308,11 +3376,14 @@ Object.extend(Selector, {
operators: { operators: {
'=': function(nv, v) { return nv == v; }, '=': function(nv, v) { return nv == v; },
'!=': function(nv, v) { return nv != v; }, '!=': function(nv, v) { return nv != v; },
'^=': function(nv, v) { return nv.startsWith(v); }, '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); },
'$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); },
'*=': function(nv, v) { return nv == v || nv && nv.include(v); },
'$=': function(nv, v) { return nv.endsWith(v); }, '$=': function(nv, v) { return nv.endsWith(v); },
'*=': function(nv, v) { return nv.include(v); }, '*=': function(nv, v) { return nv.include(v); },
'~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
'|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() +
'-').include('-' + (v || "").toUpperCase() + '-'); }
}, },
split: function(expression) { split: function(expression) {
@ -3386,7 +3457,7 @@ var Form = {
var data = elements.inject({ }, function(result, element) { var data = elements.inject({ }, function(result, element) {
if (!element.disabled && element.name) { if (!element.disabled && element.name) {
key = element.name; value = $(element).getValue(); key = element.name; value = $(element).getValue();
if (value != null && (element.type != 'submit' || (!submitted && if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
submit !== false && (!submit || key == submit) && (submitted = true)))) { submit !== false && (!submit || key == submit) && (submitted = true)))) {
if (key in result) { if (key in result) {
// a key is already present; construct an array of values // a key is already present; construct an array of values
@ -3547,7 +3618,6 @@ Form.Element.Methods = {
disable: function(element) { disable: function(element) {
element = $(element); element = $(element);
element.blur();
element.disabled = true; element.disabled = true;
return element; return element;
}, },
@ -3587,22 +3657,22 @@ Form.Element.Serializers = {
else element.value = value; else element.value = value;
}, },
select: function(element, index) { select: function(element, value) {
if (Object.isUndefined(index)) if (Object.isUndefined(value))
return this[element.type == 'select-one' ? return this[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element); 'selectOne' : 'selectMany'](element);
else { else {
var opt, value, single = !Object.isArray(index); var opt, currentValue, single = !Object.isArray(value);
for (var i = 0, length = element.length; i < length; i++) { for (var i = 0, length = element.length; i < length; i++) {
opt = element.options[i]; opt = element.options[i];
value = this.optionValue(opt); currentValue = this.optionValue(opt);
if (single) { if (single) {
if (value == index) { if (currentValue == value) {
opt.selected = true; opt.selected = true;
return; return;
} }
} }
else opt.selected = index.include(value); else opt.selected = value.include(currentValue);
} }
} }
}, },
@ -3773,8 +3843,23 @@ Event.Methods = (function() {
isRightClick: function(event) { return isButton(event, 2) }, isRightClick: function(event) { return isButton(event, 2) },
element: function(event) { element: function(event) {
var node = Event.extend(event).target; event = Event.extend(event);
return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
var node = event.target,
type = event.type,
currentTarget = event.currentTarget;
if (currentTarget && currentTarget.tagName) {
// Firefox screws up the "click" event when moving between radio buttons
// via arrow keys. It also screws up the "load" and "error" events on images,
// reporting the document as the target instead of the original image.
if (type === 'load' || type === 'error' ||
(type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
&& currentTarget.type === 'radio'))
node = currentTarget;
}
if (node.nodeType == Node.TEXT_NODE) node = node.parentNode;
return Element.extend(node);
}, },
findElement: function(event, expression) { findElement: function(event, expression) {
@ -3785,11 +3870,15 @@ Event.Methods = (function() {
}, },
pointer: function(event) { pointer: function(event) {
var docElement = document.documentElement,
body = document.body || { scrollLeft: 0, scrollTop: 0 };
return { return {
x: event.pageX || (event.clientX + x: event.pageX || (event.clientX +
(document.documentElement.scrollLeft || document.body.scrollLeft)), (docElement.scrollLeft || body.scrollLeft) -
(docElement.clientLeft || 0)),
y: event.pageY || (event.clientY + y: event.pageY || (event.clientY +
(document.documentElement.scrollTop || document.body.scrollTop)) (docElement.scrollTop || body.scrollTop) -
(docElement.clientTop || 0))
}; };
}, },
@ -3834,7 +3923,7 @@ Event.extend = (function() {
}; };
} else { } else {
Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__; Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__'];
Object.extend(Event.prototype, methods); Object.extend(Event.prototype, methods);
return Prototype.K; return Prototype.K;
} }
@ -3899,10 +3988,20 @@ Object.extend(Event, (function() {
cache[id][eventName] = null; cache[id][eventName] = null;
} }
// Internet Explorer needs to remove event handlers on page unload
// in order to avoid memory leaks.
if (window.attachEvent) { if (window.attachEvent) {
window.attachEvent("onunload", destroyCache); window.attachEvent("onunload", destroyCache);
} }
// Safari has a dummy event handler on page unload so that it won't
// use its bfcache. Safari <= 3.1 has an issue with restoring the "document"
// object when page is returned to via the back button using its bfcache.
if (Prototype.Browser.WebKit) {
window.addEventListener('unload', Prototype.emptyFunction, false);
}
return { return {
observe: function(element, eventName, handler) { observe: function(element, eventName, handler) {
element = $(element); element = $(element);

View File

@ -1,6 +1,6 @@
// script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us builder.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// //
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/
@ -74,7 +74,7 @@ var Builder = {
if(arguments[2]) if(arguments[2])
this._children(element, arguments[2]); this._children(element, arguments[2]);
return element; return $(element);
}, },
_text: function(text) { _text: function(text) {
return document.createTextNode(text); return document.createTextNode(text);
@ -100,7 +100,7 @@ var Builder = {
if(typeof children=='object') { // array can hold nodes and text if(typeof children=='object') { // array can hold nodes and text
children.flatten().each( function(e) { children.flatten().each( function(e) {
if(typeof e=='object') if(typeof e=='object')
element.appendChild(e) element.appendChild(e);
else else
if(Builder._isStringOrNumber(e)) if(Builder._isStringOrNumber(e))
element.appendChild(Builder._text(e)); element.appendChild(Builder._text(e));
@ -130,7 +130,7 @@ var Builder = {
tags.each( function(tag){ tags.each( function(tag){
scope[tag] = function() { scope[tag] = function() {
return Builder.node.apply(Builder, [tag].concat($A(arguments))); return Builder.node.apply(Builder, [tag].concat($A(arguments)));
} };
}); });
} }
} };

View File

@ -1,8 +1,8 @@
// script.aculo.us controls.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us controls.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) // (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) // (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
// Contributors: // Contributors:
// Richard Livsey // Richard Livsey
// Rahul Bhargava // Rahul Bhargava
@ -39,10 +39,10 @@
if(typeof Effect == 'undefined') if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library"); throw("controls.js requires including script.aculo.us' effects.js library");
var Autocompleter = { } var Autocompleter = { };
Autocompleter.Base = Class.create({ Autocompleter.Base = Class.create({
baseInitialize: function(element, update, options) { baseInitialize: function(element, update, options) {
element = $(element) element = $(element);
this.element = element; this.element = element;
this.update = $(update); this.update = $(update);
this.hasFocus = false; this.hasFocus = false;
@ -211,13 +211,13 @@ Autocompleter.Base = Class.create({
}, },
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); 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); this.getEntry(this.index).scrollIntoView(false);
}, },
@ -459,7 +459,7 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
} }
} }
if (partial.length) if (partial.length)
ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)) ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
return "<ul>" + ret.join('') + "</ul>"; return "<ul>" + ret.join('') + "</ul>";
} }
}, options || { }); }, options || { });
@ -476,7 +476,7 @@ Field.scrollFreeActivate = function(field) {
setTimeout(function() { setTimeout(function() {
Field.activate(field); Field.activate(field);
}, 1); }, 1);
} };
Ajax.InPlaceEditor = Class.create({ Ajax.InPlaceEditor = Class.create({
initialize: function(element, url, options) { initialize: function(element, url, options) {
@ -606,7 +606,7 @@ Ajax.InPlaceEditor = Class.create({
this.triggerCallback('onEnterHover'); this.triggerCallback('onEnterHover');
}, },
getText: function() { getText: function() {
return this.element.innerHTML; return this.element.innerHTML.unescapeHTML();
}, },
handleAJAXFailure: function(transport) { handleAJAXFailure: function(transport) {
this.triggerCallback('onFailure', transport); this.triggerCallback('onFailure', transport);
@ -782,7 +782,7 @@ Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
onSuccess: function(transport) { onSuccess: function(transport) {
var js = transport.responseText.strip(); var js = transport.responseText.strip();
if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
throw 'Server returned an invalid collection representation.'; throw('Server returned an invalid collection representation.');
this._collection = eval(js); this._collection = eval(js);
this.checkForExternalText(); this.checkForExternalText();
}.bind(this), }.bind(this),

View File

@ -1,7 +1,7 @@
// script.aculo.us dragdrop.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us dragdrop.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) // (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
// //
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/
@ -123,7 +123,7 @@ var Droppables = {
if(this.last_active) if(this.last_active)
this.deactivate(this.last_active); this.deactivate(this.last_active);
} }
} };
var Draggables = { var Draggables = {
drags: [], drags: [],
@ -220,7 +220,7 @@ var Draggables = {
).length; ).length;
}); });
} }
} };
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -333,8 +333,8 @@ var Draggable = Class.create({
if(this.options.ghosting) { if(this.options.ghosting) {
this._clone = this.element.cloneNode(true); this._clone = this.element.cloneNode(true);
this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute'); this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
if (!this.element._originallyAbsolute) if (!this._originallyAbsolute)
Position.absolutize(this.element); Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element); this.element.parentNode.insertBefore(this._clone, this.element);
} }
@ -405,9 +405,9 @@ var Draggable = Class.create({
} }
if(this.options.ghosting) { if(this.options.ghosting) {
if (!this.element._originallyAbsolute) if (!this._originallyAbsolute)
Position.relativize(this.element); Position.relativize(this.element);
delete this.element._originallyAbsolute; delete this._originallyAbsolute;
Element.remove(this._clone); Element.remove(this._clone);
this._clone = null; this._clone = null;
} }
@ -480,10 +480,10 @@ var Draggable = Class.create({
} else { } else {
if(Object.isArray(this.options.snap)) { if(Object.isArray(this.options.snap)) {
p = p.map( function(v, i) { p = p.map( function(v, i) {
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this)) return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
} else { } else {
p = p.map( function(v) { p = p.map( function(v) {
return (v/this.options.snap).round()*this.options.snap }.bind(this)) return (v/this.options.snap).round()*this.options.snap }.bind(this));
} }
}} }}
@ -562,7 +562,7 @@ var Draggable = Class.create({
H = documentElement.clientHeight; H = documentElement.clientHeight;
} else { } else {
W = body.offsetWidth; W = body.offsetWidth;
H = body.offsetHeight H = body.offsetHeight;
} }
} }
return { top: T, left: L, width: W, height: H }; return { top: T, left: L, width: W, height: H };
@ -610,7 +610,8 @@ var Sortable = {
}, },
destroy: function(element){ destroy: function(element){
var s = Sortable.options(element); element = $(element);
var s = Sortable.sortables[element.id];
if(s) { if(s) {
Draggables.removeObserver(s.element); Draggables.removeObserver(s.element);
@ -691,14 +692,14 @@ var Sortable = {
tree: options.tree, tree: options.tree,
hoverclass: options.hoverclass, hoverclass: options.hoverclass,
onHover: Sortable.onHover onHover: Sortable.onHover
} };
var options_for_tree = { var options_for_tree = {
onHover: Sortable.onEmptyHover, onHover: Sortable.onEmptyHover,
overlap: options.overlap, overlap: options.overlap,
containment: options.containment, containment: options.containment,
hoverclass: options.hoverclass hoverclass: options.hoverclass
} };
// fix for gecko engine // fix for gecko engine
Element.cleanWhitespace(element); Element.cleanWhitespace(element);
@ -853,11 +854,11 @@ var Sortable = {
children: [], children: [],
position: parent.children.length, position: parent.children.length,
container: $(children[i]).down(options.treeTag) container: $(children[i]).down(options.treeTag)
} };
/* Get the element containing the children and recurse over it */ /* Get the element containing the children and recurse over it */
if (child.container) if (child.container)
this._tree(child.container, options, child) this._tree(child.container, options, child);
parent.children.push (child); parent.children.push (child);
} }
@ -882,7 +883,7 @@ var Sortable = {
children: [], children: [],
container: element, container: element,
position: 0 position: 0
} };
return Sortable._tree(element, options, root); return Sortable._tree(element, options, root);
}, },
@ -942,14 +943,14 @@ var Sortable = {
}).join('&'); }).join('&');
} }
} }
} };
// Returns true if child is contained within element // Returns true if child is contained within element
Element.isParent = function(child, element) { Element.isParent = function(child, element) {
if (!child.parentNode || child == element) return false; if (!child.parentNode || child == element) return false;
if (child.parentNode == element) return true; if (child.parentNode == element) return true;
return Element.isParent(child.parentNode, element); return Element.isParent(child.parentNode, element);
} };
Element.findChildren = function(element, only, recursive, tagName) { Element.findChildren = function(element, only, recursive, tagName) {
if(!element.hasChildNodes()) return null; if(!element.hasChildNodes()) return null;
@ -967,8 +968,8 @@ Element.findChildren = function(element, only, recursive, tagName) {
}); });
return (elements.length>0 ? elements.flatten() : []); return (elements.length>0 ? elements.flatten() : []);
} };
Element.offsetSize = function (element, type) { Element.offsetSize = function (element, type) {
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
} };

View File

@ -1,6 +1,6 @@
// script.aculo.us effects.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us effects.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors: // Contributors:
// Justin Palmer (http://encytemedia.com/) // Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/) // Mark Pilgrim (http://diveintomark.org/)
@ -72,25 +72,20 @@ var Effect = {
Transitions: { Transitions: {
linear: Prototype.K, linear: Prototype.K,
sinoidal: function(pos) { sinoidal: function(pos) {
return (-Math.cos(pos*Math.PI)/2) + 0.5; return (-Math.cos(pos*Math.PI)/2) + .5;
}, },
reverse: function(pos) { reverse: function(pos) {
return 1-pos; return 1-pos;
}, },
flicker: function(pos) { flicker: function(pos) {
var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4;
return pos > 1 ? 1 : pos; return pos > 1 ? 1 : pos;
}, },
wobble: function(pos) { wobble: function(pos) {
return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5;
}, },
pulse: function(pos, pulses) { pulse: function(pos, pulses) {
pulses = pulses || 5; return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5;
return (
((pos % (1/pulses)) * pulses).round() == 0 ?
((pos * pulses * 2) - (pos * pulses * 2).floor()) :
1 - ((pos * pulses * 2) - (pos * pulses * 2).floor())
);
}, },
spring: function(pos) { spring: function(pos) {
return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6));
@ -251,18 +246,30 @@ Effect.Base = Class.create({
this.totalTime = this.finishOn-this.startOn; this.totalTime = this.finishOn-this.startOn;
this.totalFrames = this.options.fps*this.options.duration; this.totalFrames = this.options.fps*this.options.duration;
eval('this.render = function(pos){ '+ this.render = (function() {
'if (this.state=="idle"){this.state="running";'+ function dispatch(effect, eventName) {
codeForEvent(this.options,'beforeSetup')+ if (effect.options[eventName + 'Internal'])
(this.setup ? 'this.setup();':'')+ effect.options[eventName + 'Internal'](effect);
codeForEvent(this.options,'afterSetup')+ if (effect.options[eventName])
'};if (this.state=="running"){'+ effect.options[eventName](effect);
'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+ }
'this.position=pos;'+
codeForEvent(this.options,'beforeUpdate')+ return function(pos) {
(this.update ? 'this.update(pos);':'')+ if (this.state === "idle") {
codeForEvent(this.options,'afterUpdate')+ this.state = "running";
'}}'); dispatch(this, 'beforeSetup');
if (this.setup) this.setup();
dispatch(this, 'afterSetup');
}
if (this.state === "running") {
pos = (this.options.transition(pos) * this.fromToDelta) + this.options.from;
this.position = pos;
dispatch(this, 'beforeUpdate');
if (this.update) this.update(pos);
dispatch(this, 'afterUpdate');
}
};
})();
this.event('beforeStart'); this.event('beforeStart');
if (!this.options.sync) if (!this.options.sync)
@ -509,17 +516,16 @@ Effect.Highlight = Class.create(Effect.Base, {
Effect.ScrollTo = function(element) { Effect.ScrollTo = function(element) {
var options = arguments[1] || { }, var options = arguments[1] || { },
scrollOffsets = document.viewport.getScrollOffsets(), scrollOffsets = document.viewport.getScrollOffsets(),
elementOffsets = $(element).cumulativeOffset(), elementOffsets = $(element).cumulativeOffset();
max = (window.height || document.body.scrollHeight) - document.viewport.getHeight();
if (options.offset) elementOffsets[1] += options.offset; if (options.offset) elementOffsets[1] += options.offset;
return new Effect.Tween(null, return new Effect.Tween(null,
scrollOffsets.top, scrollOffsets.top,
elementOffsets[1] > max ? max : elementOffsets[1], elementOffsets[1],
options, options,
function(p){ scrollTo(scrollOffsets.left, p.round()) } function(p){ scrollTo(scrollOffsets.left, p.round()); }
); );
}; };
@ -570,7 +576,7 @@ Effect.Puff = function(element) {
new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
Object.extend({ duration: 1.0, Object.extend({ duration: 1.0,
beforeSetupInternal: function(effect) { beforeSetupInternal: function(effect) {
Position.absolutize(effect.effects[0].element) Position.absolutize(effect.effects[0].element);
}, },
afterFinishInternal: function(effect) { afterFinishInternal: function(effect) {
effect.effects[0].element.hide().setStyle(oldStyle); } effect.effects[0].element.hide().setStyle(oldStyle); }
@ -627,7 +633,7 @@ Effect.SwitchOff = function(element) {
afterFinishInternal: function(effect) { afterFinishInternal: function(effect) {
effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
} }
}) });
} }
}, arguments[1] || { })); }, arguments[1] || { }));
}; };
@ -676,7 +682,7 @@ Effect.Shake = function(element) {
new Effect.Move(effect.element, new Effect.Move(effect.element,
{ x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) { { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) {
effect.element.undoPositioned().setStyle(oldStyle); effect.element.undoPositioned().setStyle(oldStyle);
}}) }}) }}) }}) }}) }}); }}); }}); }}); }}); }}); }});
}; };
Effect.SlideDown = function(element) { Effect.SlideDown = function(element) {
@ -818,7 +824,7 @@ Effect.Grow = function(element) {
effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
} }
}, options) }, options)
) );
} }
}); });
}; };
@ -879,11 +885,13 @@ Effect.Shrink = function(element) {
Effect.Pulsate = function(element) { Effect.Pulsate = function(element) {
element = $(element); element = $(element);
var options = arguments[1] || { }; var options = arguments[1] || { },
var oldOpacity = element.getInlineOpacity(); oldOpacity = element.getInlineOpacity(),
var transition = options.transition || Effect.Transitions.sinoidal; transition = options.transition || Effect.Transitions.linear,
var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) }; reverser = function(pos){
reverser.bind(transition); return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5);
};
return new Effect.Opacity(element, return new Effect.Opacity(element,
Object.extend(Object.extend({ duration: 2.0, from: 0, Object.extend(Object.extend({ duration: 2.0, from: 0,
afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
@ -936,7 +944,7 @@ Effect.Morph = Class.create(Effect.Base, {
effect.transforms.each(function(transform) { effect.transforms.each(function(transform) {
effect.element.style[transform.style] = ''; effect.element.style[transform.style] = '';
}); });
} };
} }
} }
this.start(options); this.start(options);
@ -947,7 +955,7 @@ Effect.Morph = Class.create(Effect.Base, {
if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
color = color.parseColor(); color = color.parseColor();
return $R(0,2).map(function(i){ return $R(0,2).map(function(i){
return parseInt( color.slice(i*2+1,i*2+3), 16 ) return parseInt( color.slice(i*2+1,i*2+3), 16 );
}); });
} }
this.transforms = this.style.map(function(pair){ this.transforms = this.style.map(function(pair){
@ -980,7 +988,7 @@ Effect.Morph = Class.create(Effect.Base, {
transform.unit != 'color' && transform.unit != 'color' &&
(isNaN(transform.originalValue) || isNaN(transform.targetValue)) (isNaN(transform.originalValue) || isNaN(transform.targetValue))
) )
) );
}); });
}, },
update: function(position) { update: function(position) {
@ -1083,7 +1091,7 @@ if (document.defaultView && document.defaultView.getComputedStyle) {
if (!styles.opacity) styles.opacity = element.getOpacity(); if (!styles.opacity) styles.opacity = element.getOpacity();
return styles; return styles;
}; };
}; }
Effect.Methods = { Effect.Methods = {
morph: function(element, style) { morph: function(element, style) {
@ -1092,7 +1100,7 @@ Effect.Methods = {
return element; return element;
}, },
visualEffect: function(element, effect, options) { visualEffect: function(element, effect, options) {
element = $(element) element = $(element);
var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1); var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1);
new Effect[klass](element, options); new Effect[klass](element, options);
return element; return element;
@ -1111,7 +1119,7 @@ $w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+
element = $(element); element = $(element);
Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options);
return element; return element;
} };
} }
); );

View File

@ -1,6 +1,6 @@
// script.aculo.us scriptaculous.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us scriptaculous.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// //
// Permission is hereby granted, free of charge, to any person obtaining // Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the // a copy of this software and associated documentation files (the
@ -24,16 +24,17 @@
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = { var Scriptaculous = {
Version: '1.8.1', Version: '1.8.2',
require: function(libraryName) { require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach // inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>'); document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
}, },
REQUIRED_PROTOTYPE: '1.6.0', REQUIRED_PROTOTYPE: '1.6.0.3',
load: function() { load: function() {
function convertVersionString(versionString){ function convertVersionString(versionString) {
var r = versionString.split('.'); var v = versionString.replace(/_.*|\./g, '');
return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]); v = parseInt(v + '0'.times(4-v.length));
return versionString.indexOf('_') > -1 ? v-1 : v;
} }
if((typeof Prototype=='undefined') || if((typeof Prototype=='undefined') ||
@ -44,15 +45,16 @@ var Scriptaculous = {
throw("script.aculo.us requires the Prototype JavaScript framework >= " + throw("script.aculo.us requires the Prototype JavaScript framework >= " +
Scriptaculous.REQUIRED_PROTOTYPE); Scriptaculous.REQUIRED_PROTOTYPE);
$A(document.getElementsByTagName("script")).findAll( function(s) { var js = /scriptaculous\.js(\?.*)?$/;
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/)) $$('head script[src]').findAll(function(s) {
}).each( function(s) { return s.src.match(js);
var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,''); }).each(function(s) {
var includes = s.src.match(/\?.*load=([a-z,]*)/); var path = s.src.replace(js, ''),
includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each( (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') }); function(include) { Scriptaculous.require(path+include+'.js') });
}); });
} }
} };
Scriptaculous.load(); Scriptaculous.load();

View File

@ -1,6 +1,6 @@
// script.aculo.us slider.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us slider.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Marty Haught, Thomas Fuchs // Copyright (c) 2005-2008 Marty Haught, Thomas Fuchs
// //
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/

View File

@ -1,6 +1,6 @@
// script.aculo.us sound.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us sound.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// //
// Based on code created by Jules Gravinese (http://www.webveteran.com/) // Based on code created by Jules Gravinese (http://www.webveteran.com/)
// //
@ -29,12 +29,12 @@ Sound = {
var sound = $('sound_'+options.track+'_'+id); var sound = $('sound_'+options.track+'_'+id);
sound.Stop && sound.Stop(); sound.Stop && sound.Stop();
sound.remove(); sound.remove();
}) });
this.tracks[options.track] = null; this.tracks[options.track] = null;
} }
if(!this.tracks[options.track]) if(!this.tracks[options.track])
this.tracks[options.track] = { id: 0 } this.tracks[options.track] = { id: 0 };
else else
this.tracks[options.track].id++; this.tracks[options.track].id++;
@ -49,7 +49,7 @@ Sound = {
if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){ if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 })) if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>') Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>');
else else
Sound.play = function(){} Sound.play = function(){};
} }

View File

@ -1,8 +1,8 @@
// script.aculo.us unittest.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 // script.aculo.us unittest.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) // (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
// (c) 2005-2007 Michael Schuerig (http://www.schuerig.de/michael/) // (c) 2005-2008 Michael Schuerig (http://www.schuerig.de/michael/)
// //
// script.aculo.us is freely distributable under the terms of an MIT-style license. // script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ // For details, see the script.aculo.us web site: http://script.aculo.us/
@ -32,8 +32,8 @@ Event.simulateMouse = function(element, eventName) {
this.mark.style.left = options.pointerX + "px"; this.mark.style.left = options.pointerX + "px";
this.mark.style.width = "5px"; this.mark.style.width = "5px";
this.mark.style.height = "5px;"; this.mark.style.height = "5px;";
this.mark.style.borderTop = "1px solid red;" this.mark.style.borderTop = "1px solid red;";
this.mark.style.borderLeft = "1px solid red;" this.mark.style.borderLeft = "1px solid red;";
if(this.step) if(this.step)
alert('['+new Date().getTime().toString()+'] '+eventName+'/'+Test.Unit.inspect(options)); alert('['+new Date().getTime().toString()+'] '+eventName+'/'+Test.Unit.inspect(options));
@ -67,7 +67,7 @@ Event.simulateKeys = function(element, command) {
} }
}; };
var Test = {} var Test = {};
Test.Unit = {}; Test.Unit = {};
// security exception workaround // security exception workaround
@ -117,7 +117,7 @@ Test.Unit.Logger.prototype = {
'<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' + '<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' +
'<tbody id="loglines"></tbody>' + '<tbody id="loglines"></tbody>' +
'</table>'; '</table>';
this.logsummary = $('logsummary') this.logsummary = $('logsummary');
this.loglines = $('loglines'); this.loglines = $('loglines');
}, },
_toHTML: function(txt) { _toHTML: function(txt) {
@ -125,15 +125,15 @@ Test.Unit.Logger.prototype = {
}, },
addLinksToResults: function(){ addLinksToResults: function(){
$$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log $$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log
td.title = "Run only this test" td.title = "Run only this test";
Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;}); Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;});
}); });
$$("tr.passed .nameCell").each( function(td){ // todo: limit to children of this.log $$("tr.passed .nameCell").each( function(td){ // todo: limit to children of this.log
td.title = "Run all tests" td.title = "Run all tests";
Event.observe(td, 'click', function(){ window.location.search = "";}); Event.observe(td, 'click', function(){ window.location.search = "";});
}); });
} }
} };
Test.Unit.Runner = Class.create(); Test.Unit.Runner = Class.create();
Test.Unit.Runner.prototype = { Test.Unit.Runner.prototype = {
@ -246,7 +246,7 @@ Test.Unit.Runner.prototype = {
failures + " failures, " + failures + " failures, " +
errors + " errors"); errors + " errors");
} }
} };
Test.Unit.Assertions = Class.create(); Test.Unit.Assertions = Class.create();
Test.Unit.Assertions.prototype = { Test.Unit.Assertions.prototype = {
@ -331,7 +331,7 @@ Test.Unit.Assertions.prototype = {
catch(e) { this.error(e); } catch(e) { this.error(e); }
}, },
assertNull: function(obj) { assertNull: function(obj) {
var message = arguments[1] || 'assertNull' var message = arguments[1] || 'assertNull';
try { (obj==null) ? this.pass() : try { (obj==null) ? this.pass() :
this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); } this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); }
catch(e) { this.error(e); } catch(e) { this.error(e); }
@ -461,7 +461,7 @@ Test.Unit.Assertions.prototype = {
iterations + ' iterations in ' + (timeTaken/1000)+'s' ); iterations + ' iterations in ' + (timeTaken/1000)+'s' );
return timeTaken; return timeTaken;
} }
} };
Test.Unit.Testcase = Class.create(); Test.Unit.Testcase = Class.create();
Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.prototype), { Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.prototype), {
@ -526,7 +526,7 @@ Test.setupBDDExtensionMethods = function(){
}; };
var makeAssertion = function(assertion, args, object) { var makeAssertion = function(assertion, args, object) {
this[assertion].apply(this,(args || []).concat([object])); this[assertion].apply(this,(args || []).concat([object]));
} };
Test.BDDMethods = {}; Test.BDDMethods = {};
$H(METHODMAP).each(function(pair) { $H(METHODMAP).each(function(pair) {
@ -539,7 +539,7 @@ Test.setupBDDExtensionMethods = function(){
[Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each( [Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each(
function(p){ Object.extend(p, Test.BDDMethods) } function(p){ Object.extend(p, Test.BDDMethods) }
); );
} };
Test.context = function(name, spec, log){ Test.context = function(name, spec, log){
Test.setupBDDExtensionMethods(); Test.setupBDDExtensionMethods();