+2007-11-08 Oliver Hader <oh@inpublica.de>
+
+ * Updated JavaScript frameworks in typo3/contrib: prototype (1.6.0) and script.aculo.us (1.8.0)
+
2007-11-07 Stanislas Rolland <stanislas.rolland@fructifor.ca>
* Added feature #6668: Let htmlArea RTE use the Ajax request of the Prototype framework
-/* Prototype JavaScript framework, version 1.6.0_rc0
+/* Prototype JavaScript framework, version 1.6.0
* (c) 2005-2007 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.6.0_rc0',
+ Version: '1.6.0',
Browser: {
IE: !!(window.attachEvent && !window.opera),
XPath: !!document.evaluate,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
+ document.createElement('div').__proto__ &&
document.createElement('div').__proto__ !==
- document.createElement('form').__proto__
+ document.createElement('form').__proto__
},
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
if (Prototype.Browser.MobileSafari)
Prototype.BrowserFeatures.SpecificElementExtensions = false;
+if (Prototype.Browser.WebKit)
+ Prototype.BrowserFeatures.XPath = false;
+
/* Based on Alex Arnell's inheritance implementation. */
var Class = {
create: function() {
Class.Methods = {
addMethods: function(source) {
- var ancestor = this.superclass && this.superclass.prototype;
+ var ancestor = this.superclass && this.superclass.prototype;
+ var properties = Object.keys(source);
+
+ if (!Object.keys({ toString: true }).length)
+ properties.push("toString", "valueOf");
- for (var property in source) {
- var value = source[property];
+ for (var i = 0, length = properties.length; i < length; i++) {
+ var property = properties[i], value = source[property];
if (ancestor && Object.isFunction(value) &&
value.argumentNames().first() == "$super") {
var method = value, value = Object.extend((function(m) {
return '{' + results.join(', ') + '}';
},
+ toQueryString: function(object) {
+ return $H(object).toQueryString();
+ },
+
toHTML: function(object) {
return object && object.toHTML ? object.toHTML() : String.interpret(object);
},
return object && object.constructor === Array;
},
+ isHash: function(object) {
+ return object instanceof Hash;
+ },
+
isFunction: function(object) {
return typeof object == "function";
},
Object.extend(Function.prototype, {
argumentNames: function() {
- var names = this.toString().match(/^[\s\(]*function\s*\((.*?)\)/)[1].split(",").invoke("strip");
+ var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");
return names.length == 1 && !names[0] ? [] : names;
},
},
times: function(count) {
- var result = '';
- for (var i = 0; i < count; i++) result += this;
- return result;
+ return count < 1 ? '' : new Array(count + 1).join(this);
},
camelize: function() {
var ctx = object, expr = match[3];
var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr);
- if (match == null) return '';
+ if (match == null) return before;
while (match != null) {
var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
function $A(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
- else {
- var results = [];
- for (var i = 0, length = iterable.length; i < length; i++)
- results.push(iterable[i]);
- return results;
- }
+ var length = iterable.length, results = new Array(length);
+ while (length--) results[length] = iterable[length];
+ return results;
}
if (Prototype.Browser.WebKit) {
function $A(iterable) {
if (!iterable) return [];
if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
- iterable.toArray) {
- return iterable.toArray();
- } else {
- var results = [];
- for (var i = 0, length = iterable.length; i < length; i++)
- results.push(iterable[i]);
- return results;
- }
+ iterable.toArray) return iterable.toArray();
+ var length = iterable.length, results = new Array(length);
+ while (length--) results[length] = iterable[length];
+ return results;
}
}
Array.prototype.toArray = Array.prototype.clone;
function $w(string) {
+ if (!Object.isString(string)) return [];
string = string.strip();
return string ? string.split(/\s+/) : [];
}
$w('abs round ceil floor').each(function(method){
Number.prototype[method] = Math[method].methodize();
});
-var Hash = function(object) {
- if (object instanceof Hash) this.merge(object);
- else Object.extend(this, object || { });
+function $H(object) {
+ return new Hash(object);
};
-Object.extend(Hash, {
- toQueryString: function(obj) {
- var parts = [];
- parts.add = arguments.callee.addPair;
+var Hash = Class.create(Enumerable, (function() {
+ if (function() {
+ var i = 0, Test = function(value) { this.key = value };
+ Test.prototype.key = 'foo';
+ for (var property in new Test('bar')) i++;
+ return i > 1;
+ }()) {
+ function each(iterator) {
+ var cache = [];
+ for (var key in this._object) {
+ var value = this._object[key];
+ if (cache.include(key)) continue;
+ cache.push(key);
+ var pair = [key, value];
+ pair.key = key;
+ pair.value = value;
+ iterator(pair);
+ }
+ }
+ } else {
+ function each(iterator) {
+ for (var key in this._object) {
+ var value = this._object[key], pair = [key, value];
+ pair.key = key;
+ pair.value = value;
+ iterator(pair);
+ }
+ }
+ }
- this.prototype._each.call(obj, function(pair) {
- if (!pair.key) return;
- var value = pair.value;
+ function toQueryPair(key, value) {
+ if (Object.isUndefined(value)) return key;
+ return key + '=' + encodeURIComponent(String.interpret(value));
+ }
- if (value && typeof value == 'object') {
- if (Object.isArray(value)) value.each(function(value) {
- parts.add(pair.key, value);
- });
- return;
- }
- parts.add(pair.key, value);
- });
+ return {
+ initialize: function(object) {
+ this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
+ },
- return parts.join('&');
- },
+ _each: each,
- toJSON: function(object) {
- var results = [];
- this.prototype._each.call(object, function(pair) {
- var value = Object.toJSON(pair.value);
- if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value);
- });
- return '{' + results.join(', ') + '}';
- }
-});
+ set: function(key, value) {
+ return this._object[key] = value;
+ },
-Hash.toQueryString.addPair = function(key, value, prefix) {
- key = encodeURIComponent(key);
- if (value === undefined) this.push(key);
- else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));
-};
+ get: function(key) {
+ return this._object[key];
+ },
-Object.extend(Hash.prototype, Enumerable);
-Object.extend(Hash.prototype, {
- _each: function(iterator) {
- for (var key in this) {
- var value = this[key];
- if (value && value == Hash.prototype[key]) continue;
-
- var pair = [key, value];
- pair.key = key;
- pair.value = value;
- iterator(pair);
- }
- },
+ unset: function(key) {
+ var value = this._object[key];
+ delete this._object[key];
+ return value;
+ },
- keys: function() {
- return this.pluck('key');
- },
+ toObject: function() {
+ return Object.clone(this._object);
+ },
- values: function() {
- return this.pluck('value');
- },
+ keys: function() {
+ return this.pluck('key');
+ },
- index: function(value) {
- var match = this.detect(function(pair) {
- return pair.value === value;
- });
- return match && match.key;
- },
+ values: function() {
+ return this.pluck('value');
+ },
- merge: function(hash) {
- return $H(hash).inject(this, function(mergedHash, pair) {
- mergedHash[pair.key] = pair.value;
- return mergedHash;
- });
- },
+ index: function(value) {
+ var match = this.detect(function(pair) {
+ return pair.value === value;
+ });
+ return match && match.key;
+ },
- remove: function() {
- var result;
- for(var i = 0, length = arguments.length; i < length; i++) {
- var value = this[arguments[i]];
- if (value !== undefined){
- if (result === undefined) result = value;
- else {
- if (!Object.isArray(result)) result = [result];
- result.push(value);
- }
- }
- delete this[arguments[i]];
- }
- return result;
- },
+ merge: function(object) {
+ return this.clone().update(object);
+ },
- toQueryString: function() {
- return Hash.toQueryString(this);
- },
+ update: function(object) {
+ return new Hash(object).inject(this, function(result, pair) {
+ result.set(pair.key, pair.value);
+ return result;
+ });
+ },
- inspect: function() {
- return '#<Hash:{' + this.map(function(pair) {
- return pair.map(Object.inspect).join(': ');
- }).join(', ') + '}>';
- },
+ toQueryString: function() {
+ return this.map(function(pair) {
+ var key = encodeURIComponent(pair.key), values = pair.value;
- toJSON: function() {
- return Hash.toJSON(this);
- }
-});
+ if (values && typeof values == 'object') {
+ if (Object.isArray(values))
+ return values.map(toQueryPair.curry(key)).join('&');
+ }
+ return toQueryPair(key, values);
+ }).join('&');
+ },
-function $H(object) {
- if (object instanceof Hash) return object;
- return new Hash(object);
-};
+ inspect: function() {
+ return '#<Hash:{' + this.map(function(pair) {
+ return pair.map(Object.inspect).join(': ');
+ }).join(', ') + '}>';
+ },
-// Safari iterates over shadowed properties
-if (function() {
- var i = 0, Test = function(value) { this.key = value };
- Test.prototype.key = 'foo';
- for (var property in new Test('bar')) i++;
- return i > 1;
-}()) Hash.prototype._each = function(iterator) {
- var cache = [];
- for (var key in this) {
- var value = this[key];
- if ((value && value == Hash.prototype[key]) || cache.include(key)) continue;
- cache.push(key);
- var pair = [key, value];
- pair.key = key;
- pair.value = value;
- iterator(pair);
+ toJSON: function() {
+ return Object.toJSON(this.toObject());
+ },
+
+ clone: function() {
+ return new Hash(this);
+ }
}
-};
-ObjectRange = Class.create({
+})());
+
+Hash.prototype.toTemplateReplacements = Hash.prototype.toObject;
+Hash.from = $H;
+var ObjectRange = Class.create(Enumerable, {
initialize: function(start, end, exclusive) {
this.start = start;
this.end = end;
iterator(value);
value = value.succ();
}
+ },
+
+ include: function(value) {
+ if (value < this.start)
+ return false;
+ if (this.exclusive)
+ return value < this.end;
+ return value <= this.end;
}
});
-Object.extend(ObjectRange.prototype, Enumerable);
-
-ObjectRange.prototype.include = function(value) {
- if (value < this.start)
- return false;
- if (this.exclusive)
- return value < this.end;
- return value <= this.end;
-};
-
var $R = function(start, end, exclusive) {
return new ObjectRange(start, end, exclusive);
};
this.parameters = params;
- if (params = Hash.toQueryString(params)) {
+ if (params = Object.toQueryString(params)) {
// when GET, append parameters to URL
if (this.method == 'get')
this.url += (this.url.include('?') ? '&' : '?') + params;
this.status = this.getStatus();
this.statusText = this.getStatusText();
this.responseText = String.interpret(transport.responseText);
- this.headerJSON = this.getHeaderJSON();
+ this.headerJSON = this._getHeaderJSON();
}
if(readyState == 4) {
var xml = transport.responseXML;
this.responseXML = xml === undefined ? null : xml;
- this.responseJSON = this.getResponseJSON();
+ this.responseJSON = this._getResponseJSON();
}
},
return this.transport.getAllResponseHeaders();
},
- getHeaderJSON: function() {
+ _getHeaderJSON: function() {
var json = this.getHeader('X-JSON');
+ if (!json) return null;
+ json = decodeURIComponent(escape(json));
try {
- return json ? json.evalJSON(this.request.options.sanitizeJSON) : null;
+ return json.evalJSON(this.request.options.sanitizeJSON);
} catch (e) {
this.request.dispatchException(e);
}
},
- getResponseJSON: function() {
+ _getResponseJSON: function() {
var options = this.request.options;
+ if (!options.evalJSON || (options.evalJSON != 'force' &&
+ !(this.getHeader('Content-type') || '').include('application/json')))
+ return null;
try {
- if (options.evalJSON == 'force' || (options.evalJSON &&
- (this.getHeader('Content-type') || '').include('application/json')))
- return this.transport.responseText.evalJSON(options.sanitizeJSON);
- return null;
+ return this.transport.responseText.evalJSON(options.sanitizeJSON);
} catch (e) {
this.request.dispatchException(e);
}
if (!(element = $(element))) return;
var elementClassName = element.className;
return (elementClassName.length > 0 && (elementClassName == className ||
- elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))));
+ new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
},
addClassName: function(element, className) {
descendantOf: function(element, ancestor) {
element = $(element), ancestor = $(ancestor);
+
+ if (element.compareDocumentPosition)
+ return (element.compareDocumentPosition(ancestor) & 8) === 8;
+
+ if (element.sourceIndex && !Prototype.Browser.Opera) {
+ var e = element.sourceIndex, a = ancestor.sourceIndex,
+ nextAncestor = ancestor.nextSibling;
+ if (!nextAncestor) {
+ do { ancestor = ancestor.parentNode; }
+ while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
+ }
+ if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex);
+ }
+
while (element = element.parentNode)
if (element == ancestor) return true;
return false;
makeClipping: function(element) {
element = $(element);
if (element._overflow) return element;
- element._overflow = element.style.overflow || 'auto';
- if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
+ element._overflow = Element.getStyle(element, 'overflow') || 'auto';
+ if (element._overflow !== 'hidden')
element.style.overflow = 'hidden';
return element;
},
return filter.replace(/alpha\([^\)]*\)/gi,'');
}
element = $(element);
- if (!element.currentStyle.hasLayout) element.style.zoom = 1;
+ var currentStyle = element.currentStyle;
+ if ((currentStyle && !currentStyle.hasLayout) ||
+ (!currentStyle && element.style.zoom == 'normal'))
+ element.style.zoom = 1;
+
var filter = element.getStyle('filter'), style = element.style;
if (value == 1 || value === '') {
(filter = stripAlpha(filter)) ?
})(Element._attributeTranslations.read.values);
}
-else if (Prototype.Browser.Gecko) {
+else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
Element.Methods.setOpacity = function(element, value) {
element = $(element);
element.style.opacity = (value == 1) ? 0.999999 :
compileMatcher: function() {
// Selectors with namespaced attributes can't use the XPath version
- if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression))
+ if (Prototype.BrowserFeatures.XPath && !(/(\[[\w-]*?:|:checked)/).test(this.expression))
return this.compileXPathMatcher();
var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
id: /^#([\w\-\*]+)(\b|$)/,
className: /^\.([\w\-\*]+)(\b|$)/,
- pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,
+ pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/,
attrPresence: /^\[([\w]+)\]/,
attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
},
},
attrPresence: function(nodes, root, attr) {
+ if (!nodes) nodes = root.getElementsByTagName("*");
var results = [];
for (var i = 0, node; node = nodes[i]; i++)
if (Element.hasAttribute(node, attr)) results.push(node);
return result;
});
- return options.hash ? data : Hash.toQueryString(data);
+ return options.hash ? data : Object.toQueryString(data);
}
};
if (value != undefined) {
var pair = { };
pair[element.name] = value;
- return Hash.toQueryString(pair);
+ return Object.toQueryString(pair);
}
}
return '';
}
});
-Event.Methods = {
- element: function(event) {
- var node = event.target;
- return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
- },
+Event.Methods = (function() {
+ var isButton;
- findElement: function(event, expression) {
- var element = Event.element(event);
- return element.match(expression) ? element : element.up(expression);
- },
+ if (Prototype.Browser.IE) {
+ var buttonMap = { 0: 1, 1: 4, 2: 2 };
+ isButton = function(event, code) {
+ return event.button == buttonMap[code];
+ };
- isLeftClick: function(event) {
- return (((event.which) && (event.which == 1)) ||
- ((event.button) && (event.button == 1)));
- },
+ } else if (Prototype.Browser.WebKit) {
+ isButton = function(event, code) {
+ switch (code) {
+ case 0: return event.which == 1 && !event.metaKey;
+ case 1: return event.which == 1 && event.metaKey;
+ default: return false;
+ }
+ };
- pointer: function(event) {
- return {
- x: event.pageX || (event.clientX +
- (document.documentElement.scrollLeft || document.body.scrollLeft)),
- y: event.pageY || (event.clientY +
- (document.documentElement.scrollTop || document.body.scrollTop))
+ } else {
+ isButton = function(event, code) {
+ return event.which ? (event.which === code + 1) : (event.button === code);
};
- },
+ }
- pointerX: function(event) { return Event.pointer(event).x },
- pointerY: function(event) { return Event.pointer(event).y },
+ return {
+ isLeftClick: function(event) { return isButton(event, 0) },
+ isMiddleClick: function(event) { return isButton(event, 1) },
+ isRightClick: function(event) { return isButton(event, 2) },
- stop: function(event) {
- event.preventDefault();
- event.stopPropagation();
- }
-};
+ element: function(event) {
+ var node = Event.extend(event).target;
+ return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
+ },
+
+ findElement: function(event, expression) {
+ var element = Event.element(event);
+ return element.match(expression) ? element : element.up(expression);
+ },
+
+ pointer: function(event) {
+ return {
+ x: event.pageX || (event.clientX +
+ (document.documentElement.scrollLeft || document.body.scrollLeft)),
+ y: event.pageY || (event.clientY +
+ (document.documentElement.scrollTop || document.body.scrollTop))
+ };
+ },
+
+ pointerX: function(event) { return Event.pointer(event).x },
+ pointerY: function(event) { return Event.pointer(event).y },
+
+ stop: function(event) {
+ Event.extend(event);
+ event.preventDefault();
+ event.stopPropagation();
+ event.stopped = true;
+ }
+ };
+})();
Event.extend = (function() {
var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
}
function getDOMEventName(eventName) {
- if (eventName && eventName.match(/:/)) return "dataavailable";
- return { keypress: "keydown" }[eventName] || eventName;
+ if (eventName && eventName.include(':')) return "dataavailable";
+ return eventName;
}
function getCacheForID(id) {
if (c.pluck("handler").include(handler)) return false;
var wrapper = function(event) {
- if (event.eventName && event.eventName != eventName)
- return false;
+ if (!Event || !Event.extend ||
+ (event.eventName && event.eventName != eventName))
+ return false;
Event.extend(event);
handler.call(element, event)
})();
/*------------------------------- DEPRECATED -------------------------------*/
+Hash.toQueryString = Object.toQueryString;
+
var Toggle = { display: Element.toggle };
Element.Methods.childOf = Element.Methods.descendantOf;
-// script.aculo.us builder.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us builder.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
-// script.aculo.us controls.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us controls.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
// enables autocompletion on multiple tokens. This is most
// useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks.
-//
-// vim:expandtab ts=8 sw=2
if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library");
var Autocompleter = { }
-Autocompleter.Base = function() { };
-Autocompleter.Base.prototype = {
+Autocompleter.Base = Class.create({
baseInitialize: function(element, update, options) {
element = $(element)
this.element = element;
}
var value = '';
if (this.options.select) {
- var nodes = document.getElementsByClassName(this.options.select, selectedElement) || [];
+ var nodes = $(selectedElement).select('.' + this.options.select) || [];
if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
} else
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
}
return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
}
-}
+});
Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
var boundary = Math.min(newS.length, oldS.length);
return boundary;
};
-Ajax.Autocompleter = Class.create();
-Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
+Ajax.Autocompleter = Class.create(Autocompleter.Base, {
initialize: function(element, update, url, options) {
this.baseInitialize(element, update, options);
this.options.asynchronous = true;
onComplete: function(request) {
this.updateChoices(request.responseText);
}
-
});
// The local array autocompleter. Used when you'd prefer to
// In that case, the other options above will not apply unless
// you support them.
-Autocompleter.Local = Class.create();
-Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
+Autocompleter.Local = Class.create(Autocompleter.Base, {
initialize: function(element, update, array, options) {
this.baseInitialize(element, update, options);
this.options.array = array;
}, 1);
}
-Ajax.InPlaceEditor = Class.create();
-Object.extend(Ajax.InPlaceEditor, {
- DefaultOptions: {
- ajaxOptions: { },
- autoRows: 3, // Use when multi-line w/ rows == 1
- cancelControl: 'link', // 'link'|'button'|false
- cancelText: 'cancel',
- clickToEditText: 'Click to edit',
- externalControl: null, // id|elt
- externalControlOnly: false,
- fieldPostCreation: 'activate', // 'activate'|'focus'|false
- formClassName: 'inplaceeditor-form',
- formId: null, // id|elt
- highlightColor: '#ffff99',
- highlightEndColor: '#ffffff',
- hoverClassName: '',
- htmlResponse: true,
- loadingClassName: 'inplaceeditor-loading',
- loadingText: 'Loading...',
- okControl: 'button', // 'link'|'button'|false
- okText: 'ok',
- paramName: 'value',
- rows: 1, // If 1 and multi-line, uses autoRows
- savingClassName: 'inplaceeditor-saving',
- savingText: 'Saving...',
- size: 0,
- stripLoadedTextTags: false,
- submitOnBlur: false,
- textAfterControls: '',
- textBeforeControls: '',
- textBetweenControls: ''
- },
- DefaultCallbacks: {
- callback: function(form) {
- return Form.serialize(form);
- },
- onComplete: function(transport, element) {
- // For backward compatibility, this one is bound to the IPE, and passes
- // the element directly. It was too often customized, so we don't break it.
- new Effect.Highlight(element, {
- startcolor: this.options.highlightColor, keepBackgroundImage: true });
- },
- onEnterEditMode: null,
- onEnterHover: function(ipe) {
- ipe.element.style.backgroundColor = ipe.options.highlightColor;
- if (ipe._effect)
- ipe._effect.cancel();
- },
- onFailure: function(transport, ipe) {
- alert('Error communication with the server: ' + transport.responseText.stripTags());
- },
- onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.
- onLeaveEditMode: null,
- onLeaveHover: function(ipe) {
- ipe._effect = new Effect.Highlight(ipe.element, {
- startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,
- restorecolor: ipe._originalBackground, keepBackgroundImage: true
- });
- }
- },
- Listeners: {
- click: 'enterEditMode',
- keydown: 'checkForEscapeOrReturn',
- mouseover: 'enterHover',
- mouseout: 'leaveHover'
- }
-});
-Ajax.InPlaceEditor.prototype = {
+Ajax.InPlaceEditor = Class.create({
initialize: function(element, url, options) {
this.url = url;
this.element = element = $(element);
var form = this._form;
var value = $F(this._controls.editor);
this.prepareSubmission();
- var params = this.options.callback(form, value);
- params = (params ? params + '&' : '?') + 'editorId=' + this.element.id;
+ var params = this.options.callback(form, value) || '';
+ if (Object.isString(params))
+ params = params.toQueryParams();
+ params.editorId = this.element.id;
if (this.options.htmlResponse) {
var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);
Object.extend(options, {
// binding + direct element
this._boundComplete(transport, this.element);
}
-};
+});
+
Object.extend(Ajax.InPlaceEditor.prototype, {
dispose: Ajax.InPlaceEditor.prototype.destroy
});
-
-Ajax.InPlaceCollectionEditor = Class.create();
-Ajax.InPlaceCollectionEditor.DefaultOptions = {
- loadingCollectionText: 'Loading options...'
-};
-Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
-Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
- initialize: function(element, url, options) {
+Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
+ initialize: function($super, element, url, options) {
this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
- Ajax.InPlaceEditor.prototype.initialize.call(this, element, url, options);
+ $super(element, url, options);
},
createEditField: function() {
fallback('highlightEndColor', options.highlightendcolor);
};
+Object.extend(Ajax.InPlaceEditor, {
+ DefaultOptions: {
+ ajaxOptions: { },
+ autoRows: 3, // Use when multi-line w/ rows == 1
+ cancelControl: 'link', // 'link'|'button'|false
+ cancelText: 'cancel',
+ clickToEditText: 'Click to edit',
+ externalControl: null, // id|elt
+ externalControlOnly: false,
+ fieldPostCreation: 'activate', // 'activate'|'focus'|false
+ formClassName: 'inplaceeditor-form',
+ formId: null, // id|elt
+ highlightColor: '#ffff99',
+ highlightEndColor: '#ffffff',
+ hoverClassName: '',
+ htmlResponse: true,
+ loadingClassName: 'inplaceeditor-loading',
+ loadingText: 'Loading...',
+ okControl: 'button', // 'link'|'button'|false
+ okText: 'ok',
+ paramName: 'value',
+ rows: 1, // If 1 and multi-line, uses autoRows
+ savingClassName: 'inplaceeditor-saving',
+ savingText: 'Saving...',
+ size: 0,
+ stripLoadedTextTags: false,
+ submitOnBlur: false,
+ textAfterControls: '',
+ textBeforeControls: '',
+ textBetweenControls: ''
+ },
+ DefaultCallbacks: {
+ callback: function(form) {
+ return Form.serialize(form);
+ },
+ onComplete: function(transport, element) {
+ // For backward compatibility, this one is bound to the IPE, and passes
+ // the element directly. It was too often customized, so we don't break it.
+ new Effect.Highlight(element, {
+ startcolor: this.options.highlightColor, keepBackgroundImage: true });
+ },
+ onEnterEditMode: null,
+ onEnterHover: function(ipe) {
+ ipe.element.style.backgroundColor = ipe.options.highlightColor;
+ if (ipe._effect)
+ ipe._effect.cancel();
+ },
+ onFailure: function(transport, ipe) {
+ alert('Error communication with the server: ' + transport.responseText.stripTags());
+ },
+ onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.
+ onLeaveEditMode: null,
+ onLeaveHover: function(ipe) {
+ ipe._effect = new Effect.Highlight(ipe.element, {
+ startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,
+ restorecolor: ipe._originalBackground, keepBackgroundImage: true
+ });
+ }
+ },
+ Listeners: {
+ click: 'enterEditMode',
+ keydown: 'checkForEscapeOrReturn',
+ mouseover: 'enterHover',
+ mouseout: 'leaveHover'
+ }
+});
+
+Ajax.InPlaceCollectionEditor.DefaultOptions = {
+ loadingCollectionText: 'Loading options...'
+};
// Delayed observer, like Form.Element.Observer,
// but waits for delay after last key input
// Ideal for live-search fields
-Form.Element.DelayedObserver = Class.create();
-Form.Element.DelayedObserver.prototype = {
+Form.Element.DelayedObserver = Class.create({
initialize: function(element, delay, callback) {
this.delay = delay || 0.5;
this.element = $(element);
this.timer = null;
this.callback(this.element, $F(this.element));
}
-};
+});
-// script.aculo.us dragdrop.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us dragdrop.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
/*--------------------------------------------------------------------------*/
-var Draggable = Class.create();
-Draggable._dragging = { };
-
-Draggable.prototype = {
+var Draggable = Class.create({
initialize: function(element) {
var defaults = {
handle: false,
}
return { top: T, left: L, width: W, height: H };
}
-}
+});
+
+Draggable._dragging = { };
/*--------------------------------------------------------------------------*/
-var SortableObserver = Class.create();
-SortableObserver.prototype = {
+var SortableObserver = Class.create({
initialize: function(element, observer) {
this.element = $(element);
this.observer = observer;
if(this.lastValue != Sortable.serialize(this.element))
this.observer(this.element)
}
-}
+});
var Sortable = {
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
(options.elements || this.findElements(element, options) || []).each( function(e,i) {
var handle = options.handles ? $(options.handles[i]) :
- (options.handle ? $(e).getElementsByClassName(options.handle)[0] : e);
+ (options.handle ? $(e).select('.' + options.handle)[0] : e);
options.draggables.push(
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
Droppables.add(e, options_for_droppable);
-// script.aculo.us effects.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us effects.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
get: function(queueName) {
if (!Object.isString(queueName)) return queueName;
- if (!this.instances[queueName])
- this.instances[queueName] = new Effect.ScopedQueue();
-
- return this.instances[queueName];
+ return this.instances.get(queueName) ||
+ this.instances.set(queueName, new Effect.ScopedQueue());
}
};
Effect.Queue = Effect.Queues.get('global');
-Effect.Base = Class.create();
-Effect.Base.prototype = {
+Effect.Base = Class.create({
position: null,
start: function(options) {
function codeForEvent(options,eventName){
inspect: function() {
var data = $H();
for(property in this)
- if (!Object.isFunction(this[property])) data[property] = this[property];
+ if (!Object.isFunction(this[property])) data.set(property, this[property]);
return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
}
-};
+});
Effect.Parallel = Class.create(Effect.Base, {
initialize: function(effects) {
Effect.Shake = function(element) {
element = $(element);
+ var options = Object.extend({
+ distance: 20,
+ duration: 0.5
+ }, arguments[1] || {});
+ var distance = parseFloat(options.distance);
+ var split = parseFloat(options.duration) / 10.0;
var oldStyle = {
top: element.getStyle('top'),
left: element.getStyle('left') };
- return new Effect.Move(element,
- { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ return new Effect.Move(element,
+ { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
- { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
- { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
- { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
- { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
- { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) {
effect.element.undoPositioned().setStyle(oldStyle);
}}) }}) }}) }}) }}) }});
};
},
addTracks: function(tracks){
tracks.each(function(track){
- var data = $H(track).values().first();
+ track = $H(track);
+ var data = track.values().first();
this.tracks.push($H({
- ids: $H(track).keys().first(),
+ ids: track.keys().first(),
effect: Effect.Morph,
options: { style: data }
}));
play: function(){
return new Effect.Parallel(
this.tracks.map(function(track){
- var elements = [$(track.ids) || $$(track.ids)].flatten();
- return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) });
+ var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options');
+ var elements = [$(ids) || $$(ids)].flatten();
+ return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) });
}).flatten(),
this.options
);
}
Element.CSS_PROPERTIES.each(function(property){
- if (style[property]) styleRules[property] = style[property];
+ if (style[property]) styleRules.set(property, style[property]);
});
if (Prototype.Browser.IE && this.include('opacity'))
- styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
+ styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);
return styleRules;
};
element = $(element);
var css = element.currentStyle, styles;
styles = Element.CSS_PROPERTIES.inject({ }, function(hash, property) {
- hash[property] = css[property];
+ hash.set(property, css[property]);
return hash;
});
- if (!styles.opacity) styles.opacity = element.getOpacity();
+ if (!styles.opacity) styles.set('opacity', element.getOpacity());
return styles;
};
};
function(f) { Effect.Methods[f] = Element[f]; }
);
-Element.addMethods(Effect.Methods);
\ No newline at end of file
+Element.addMethods(Effect.Methods);
-// script.aculo.us scriptaculous.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us scriptaculous.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = {
- Version: '1.8.0_pre1',
+ Version: '1.8.0',
require: function(libraryName) {
// 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',
load: function() {
-// script.aculo.us slider.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us slider.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Marty Haught, Thomas Fuchs
//
// For details, see the script.aculo.us web site: http://script.aculo.us/
if (!Control) var Control = { };
-Control.Slider = Class.create();
// options:
// axis: 'vertical', or 'horizontal' (default)
// callbacks:
// onChange(value)
// onSlide(value)
-Control.Slider.prototype = {
+Control.Slider = Class.create({
initialize: function(handle, track, options) {
var slider = this;
(this.track.offsetHeight != 0 ? this.track.offsetHeight :
this.track.style.height.replace(/px$/,"")) - this.alignY :
(this.track.offsetWidth != 0 ? this.track.offsetWidth :
- this.track.style.width.replace(/px$/,"")) - this.alignY);
+ this.track.style.width.replace(/px$/,"")) - this.alignX);
},
isVertical: function(){
return (this.axis == 'vertical');
this.options.onChange(this.values.length>1 ? this.values : this.value, this);
this.event = null;
}
-}
\ No newline at end of file
+});
-// script.aculo.us sound.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us sound.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
-// script.aculo.us unittest.js v1.8.0_pre1, Fri Oct 12 21:34:51 +0200 2007
+// script.aculo.us unittest.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)