Index: openacs-4/packages/ajaxhelper/ajaxhelper.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/ajaxhelper.info,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/ajaxhelper.info 9 Feb 2006 08:35:42 -0000 1.1
+++ openacs-4/packages/ajaxhelper/ajaxhelper.info 31 Mar 2006 08:15:35 -0000 1.2
@@ -8,13 +8,13 @@
t
ajax
-
+
Hamilton Chua
- Provides helper procs to generate javascript for XMHTTP calls and cinematic effects using the Scriptaculous javascript library (http://script.aculo.us/) and RICO (http://www.openrico.org) javascript library
- Solutiongrove
+ Provides helper procs to generate javascript for XMHTTP calls and cinematic effects using the Scriptaculous javascript library (http://script.aculo.us/)
+ Solution Grove
0
-
+
Index: openacs-4/packages/ajaxhelper/www/prototype/prototype.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/prototype/Attic/prototype.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/www/prototype/prototype.js 9 Feb 2006 08:35:44 -0000 1.1
+++ openacs-4/packages/ajaxhelper/www/prototype/prototype.js 31 Mar 2006 08:15:36 -0000 1.2
@@ -1,17 +1,13 @@
-/* Prototype JavaScript framework, version 1.4.0
+/* Prototype JavaScript framework, version 1.5.0_pre1
* (c) 2005 Sam Stephenson
*
- * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
- * against the source tree, available from the Prototype darcs repository.
- *
* Prototype is freely distributable under the terms of an MIT-style license.
- *
* For details, see the Prototype web site: http://prototype.conio.net/
*
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.4.0',
+ Version: '1.5.0_pre1',
ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)',
emptyFunction: function() {},
@@ -120,26 +116,49 @@
}
}
}
+Object.extend(String.prototype, {
+ gsub: function(pattern, replacement) {
+ var result = '', source = this, match;
+ replacement = arguments.callee.prepareReplacement(replacement);
-/*--------------------------------------------------------------------------*/
+ while (source.length > 0) {
+ if (match = source.match(pattern)) {
+ result += source.slice(0, match.index);
+ result += (replacement(match) || '').toString();
+ source = source.slice(match.index + match[0].length);
+ } else {
+ result += source, source = '';
+ }
+ }
+ return result;
+ },
-function $() {
- var elements = new Array();
+ sub: function(pattern, replacement, count) {
+ replacement = this.gsub.prepareReplacement(replacement);
+ count = count === undefined ? 1 : count;
- for (var i = 0; i < arguments.length; i++) {
- var element = arguments[i];
- if (typeof element == 'string')
- element = document.getElementById(element);
+ return this.gsub(pattern, function(match) {
+ if (--count < 0) return match[0];
+ return replacement(match);
+ });
+ },
- if (arguments.length == 1)
- return element;
+ scan: function(pattern, iterator) {
+ this.gsub(pattern, iterator);
+ return this;
+ },
- elements.push(element);
- }
+ truncate: function(length, truncation) {
+ length = length || 30;
+ truncation = truncation === undefined ? '...' : truncation;
+ return this.length > length ?
+ this.slice(0, length - truncation.length) + truncation : this;
+ },
- return elements;
-}
-Object.extend(String.prototype, {
+ strip: function() {
+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
+ },
+
stripTags: function() {
return this.replace(/<\/?[^>]+>/gi, '');
},
@@ -203,12 +222,35 @@
},
inspect: function() {
- return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
+ return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'";
}
});
+String.prototype.gsub.prepareReplacement = function(replacement) {
+ if (typeof replacement == 'function') return replacement;
+ var template = new Template(replacement);
+ return function(match) { return template.evaluate(match) };
+}
+
String.prototype.parseQuery = String.prototype.toQueryParams;
+var Template = Class.create();
+Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
+Template.prototype = {
+ initialize: function(template, pattern) {
+ this.template = template.toString();
+ this.pattern = pattern || Template.Pattern;
+ },
+
+ evaluate: function(object) {
+ return this.template.gsub(this.pattern, function(match) {
+ var before = match[1];
+ if (before == '\\') return match[2];
+ return before + (object[match[3]] || '').toString();
+ });
+ }
+}
+
var $break = new Object();
var $continue = new Object();
@@ -375,8 +417,7 @@
var collections = [this].concat(args).map($A);
return this.map(function(value, index) {
- iterator(value = collections.pluck(index));
- return value;
+ return iterator(collections.pluck(index));
});
},
@@ -662,7 +703,8 @@
setRequestHeaders: function() {
var requestHeaders =
['X-Requested-With', 'XMLHttpRequest',
- 'X-Prototype-Version', Prototype.Version];
+ 'X-Prototype-Version', Prototype.Version,
+ 'Accept', 'text/javascript, text/html, application/xml, text/xml, */*'];
if (this.options.method == 'post') {
requestHeaders.push('Content-type',
@@ -831,22 +873,48 @@
this.updater = new Ajax.Updater(this.container, this.url, this.options);
}
});
+function $() {
+ var results = [], element;
+ for (var i = 0; i < arguments.length; i++) {
+ element = arguments[i];
+ if (typeof element == 'string')
+ element = document.getElementById(element);
+ results.push(Element.extend(element));
+ }
+ return results.length < 2 ? results[0] : results;
+}
+
document.getElementsByClassName = function(className, parentElement) {
var children = ($(parentElement) || document.body).getElementsByTagName('*');
return $A(children).inject([], function(elements, child) {
if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
- elements.push(child);
+ elements.push(Element.extend(child));
return elements;
});
}
/*--------------------------------------------------------------------------*/
-if (!window.Element) {
+if (!window.Element)
var Element = new Object();
+
+Element.extend = function(element) {
+ if (!element) return;
+
+ if (!element._extended && element.tagName && element != window) {
+ var methods = Element.Methods;
+ for (property in methods) {
+ var value = methods[property];
+ if (typeof value == 'function')
+ element[property] = value.bind(null, element);
+ }
+ }
+
+ element._extended = true;
+ return element;
}
-Object.extend(Element, {
+Element.Methods = {
visible: function(element) {
return $(element).style.display != 'none';
},
@@ -882,6 +950,19 @@
setTimeout(function() {html.evalScripts()}, 10);
},
+ replace: function(element, html) {
+ element = $(element);
+ if (element.outerHTML) {
+ element.outerHTML = html.stripScripts();
+ } else {
+ var range = element.ownerDocument.createRange();
+ range.selectNodeContents(element);
+ element.parentNode.replaceChild(
+ range.createContextualFragment(html.stripScripts()), element);
+ }
+ setTimeout(function() {html.evalScripts()}, 10);
+ },
+
getHeight: function(element) {
element = $(element);
return element.offsetHeight;
@@ -920,6 +1001,13 @@
return $(element).innerHTML.match(/^\s*$/);
},
+ childOf: function(element, ancestor) {
+ element = $(element), ancestor = $(ancestor);
+ while (element = element.parentNode)
+ if (element == ancestor) return true;
+ return false;
+ },
+
scrollTo: function(element) {
element = $(element);
var x = element.x ? element.x : element.offsetLeft,
@@ -1013,8 +1101,10 @@
element.style.overflow = element._overflow;
element._overflow = undefined;
}
-});
+}
+Object.extend(Element, Element.Methods);
+
var Toggle = new Object();
Toggle.display = Element.toggle;
@@ -1148,6 +1238,116 @@
}
Object.extend(Element.ClassNames.prototype, Enumerable);
+var Selector = Class.create();
+Selector.prototype = {
+ initialize: function(expression) {
+ this.params = {classNames: []};
+ this.expression = expression.toString().strip();
+ this.parseExpression();
+ this.compileMatcher();
+ },
+
+ parseExpression: function() {
+ function abort(message) { throw 'Parse error in selector: ' + message; }
+
+ if (this.expression == '') abort('empty expression');
+
+ var params = this.params, expr = this.expression, match, modifier, clause, rest;
+ while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
+ params.attributes = params.attributes || [];
+ params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
+ expr = match[1];
+ }
+
+ if (expr == '*') return this.params.wildcard = true;
+
+ while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
+ modifier = match[1], clause = match[2], rest = match[3];
+ switch (modifier) {
+ case '#': params.id = clause; break;
+ case '.': params.classNames.push(clause); break;
+ case '':
+ case undefined: params.tagName = clause.toUpperCase(); break;
+ default: abort(expr.inspect());
+ }
+ expr = rest;
+ }
+
+ if (expr.length > 0) abort(expr.inspect());
+ },
+
+ buildMatchExpression: function() {
+ var params = this.params, conditions = [], clause;
+
+ if (params.wildcard)
+ conditions.push('true');
+ if (clause = params.id)
+ conditions.push('element.id == ' + clause.inspect());
+ if (clause = params.tagName)
+ conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
+ if ((clause = params.classNames).length > 0)
+ for (var i = 0; i < clause.length; i++)
+ conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')');
+ if (clause = params.attributes) {
+ clause.each(function(attribute) {
+ var value = 'element.getAttribute(' + attribute.name.inspect() + ')';
+ var splitValueBy = function(delimiter) {
+ return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
+ }
+
+ switch (attribute.operator) {
+ case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
+ case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
+ case '|=': conditions.push(
+ splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
+ ); break;
+ case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
+ case '':
+ case undefined: conditions.push(value + ' != null'); break;
+ default: throw 'Unknown operator ' + attribute.operator + ' in selector';
+ }
+ });
+ }
+
+ return conditions.join(' && ');
+ },
+
+ compileMatcher: function() {
+ this.match = new Function('element', 'if (!element.tagName) return false; \
+ return ' + this.buildMatchExpression());
+ },
+
+ findElements: function(scope) {
+ var element;
+
+ if (element = $(this.params.id))
+ if (this.match(element))
+ if (!scope || Element.childOf(element, scope))
+ return [element];
+
+ scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
+
+ var results = [];
+ for (var i = 0; i < scope.length; i++)
+ if (this.match(element = scope[i]))
+ results.push(Element.extend(element));
+
+ return results;
+ },
+
+ toString: function() {
+ return this.expression;
+ }
+}
+
+function $$() {
+ return $A(arguments).map(function(expression) {
+ return expression.strip().split(/\s+/).inject([null], function(results, expr) {
+ var selector = new Selector(expr);
+ return results.map(selector.findElements.bind(selector)).flatten();
+ });
+ }).flatten();
+}
var Field = {
clear: function() {
for (var i = 0; i < arguments.length; i++)
Index: openacs-4/packages/ajaxhelper/www/scriptaculous/MIT-LICENSE
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/scriptaculous/Attic/MIT-LICENSE,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/ajaxhelper/www/scriptaculous/MIT-LICENSE 31 Mar 2006 08:15:36 -0000 1.1
@@ -0,0 +1,20 @@
+Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
Index: openacs-4/packages/ajaxhelper/www/scriptaculous/controls.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/scriptaculous/Attic/controls.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/www/scriptaculous/controls.js 9 Feb 2006 08:35:44 -0000 1.1
+++ openacs-4/packages/ajaxhelper/www/scriptaculous/controls.js 31 Mar 2006 08:15:36 -0000 1.2
@@ -141,8 +141,8 @@
return;
}
else
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN)
- return;
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
@@ -152,6 +152,12 @@
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
},
+ activate: function() {
+ this.changed = false;
+ this.hasFocus = true;
+ this.getUpdatedChoices();
+ },
+
onHover: function(event) {
var element = Event.findElement(event, 'LI');
if(this.index != element.autocompleteIndex)
@@ -310,7 +316,7 @@
Ajax.Autocompleter = Class.create();
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
initialize: function(element, update, url, options) {
- this.baseInitialize(element, update, options);
+ this.baseInitialize(element, update, options);
this.options.asynchronous = true;
this.options.onComplete = this.onComplete.bind(this);
this.options.defaultParams = this.options.parameters || null;
@@ -477,9 +483,10 @@
formClassName: 'inplaceeditor-form',
highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
highlightendcolor: "#FFFFFF",
- externalControl: null,
+ externalControl: null,
submitOnBlur: false,
- ajaxOptions: {}
+ ajaxOptions: {},
+ evalScripts: false
}, options || {});
if(!this.options.formId && this.element.id) {
@@ -548,6 +555,7 @@
okButton = document.createElement("input");
okButton.type = "submit";
okButton.value = this.options.okText;
+ okButton.className = 'editor_ok_button';
this.form.appendChild(okButton);
}
@@ -556,6 +564,7 @@
cancelLink.href = "#";
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
cancelLink.onclick = this.onclickCancel.bind(this);
+ cancelLink.className = 'editor_cancel';
this.form.appendChild(cancelLink);
}
},
@@ -584,6 +593,7 @@
textField.name = "value";
textField.value = text;
textField.style.backgroundColor = this.options.highlightcolor;
+ textField.className = 'editor_field';
var size = this.options.size || this.options.cols || 0;
if (size != 0) textField.size = size;
if (this.options.submitOnBlur)
@@ -597,6 +607,7 @@
textArea.value = this.convertHTMLLineBreaks(text);
textArea.rows = this.options.rows;
textArea.cols = this.options.cols || 40;
+ textArea.className = 'editor_field';
if (this.options.submitOnBlur)
textArea.onblur = this.onSubmit.bind(this);
this.editField = textArea;
@@ -649,19 +660,26 @@
// to be displayed indefinitely
this.onLoading();
- new Ajax.Updater(
- {
- success: this.element,
- // don't update on failure (this could be an option)
- failure: null
- },
- this.url,
- Object.extend({
- parameters: this.options.callback(form, value),
- onComplete: this.onComplete.bind(this),
- onFailure: this.onFailure.bind(this)
- }, this.options.ajaxOptions)
- );
+ if (this.options.evalScripts) {
+ new Ajax.Request(
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this),
+ asynchronous:true,
+ evalScripts:true
+ }, this.options.ajaxOptions));
+ } else {
+ new Ajax.Updater(
+ { success: this.element,
+ // don't update on failure (this could be an option)
+ failure: null },
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this)
+ }, this.options.ajaxOptions));
+ }
// stop the event to avoid a page refresh in Safari
if (arguments.length > 1) {
Event.stop(arguments[0]);
@@ -743,6 +761,33 @@
}
};
+Ajax.InPlaceCollectionEditor = Class.create();
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
+ createEditField: function() {
+ if (!this.cached_selectTag) {
+ var selectTag = document.createElement("select");
+ var collection = this.options.collection || [];
+ var optionTag;
+ collection.each(function(e,i) {
+ optionTag = document.createElement("option");
+ optionTag.value = (e instanceof Array) ? e[0] : e;
+ if(this.options.value==optionTag.value) optionTag.selected = true;
+ optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
+ selectTag.appendChild(optionTag);
+ }.bind(this));
+ this.cached_selectTag = selectTag;
+ }
+
+ this.editField = this.cached_selectTag;
+ if(this.options.loadTextURL) this.loadExternalText();
+ this.form.appendChild(this.editField);
+ this.options.callback = function(form, value) {
+ return "value=" + encodeURIComponent(value);
+ }
+ }
+});
+
// Delayed observer, like Form.Element.Observer,
// but waits for delay after last key input
// Ideal for live-search fields
Index: openacs-4/packages/ajaxhelper/www/scriptaculous/dragdrop.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/scriptaculous/Attic/dragdrop.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/www/scriptaculous/dragdrop.js 9 Feb 2006 08:35:44 -0000 1.1
+++ openacs-4/packages/ajaxhelper/www/scriptaculous/dragdrop.js 31 Mar 2006 08:15:36 -0000 1.2
@@ -128,7 +128,7 @@
this.activeDraggable = draggable;
},
- deactivate: function(draggbale) {
+ deactivate: function() {
this.activeDraggable = null;
},
@@ -199,15 +199,21 @@
},
zindex: 1000,
revert: false,
+ scroll: false,
+ scrollSensitivity: 20,
+ scrollSpeed: 15,
snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] }
}, arguments[1] || {});
this.element = $(element);
if(options.handle && (typeof options.handle == 'string'))
- this.handle = Element.childrenWithClassName(this.element, options.handle)[0];
+ this.handle = Element.childrenWithClassName(this.element, options.handle, true)[0];
if(!this.handle) this.handle = $(options.handle);
if(!this.handle) this.handle = this.element;
+
+ if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML)
+ options.scroll = $(options.scroll);
Element.makePositioned(this.element); // fix IE
@@ -239,6 +245,7 @@
if(src.tagName && (
src.tagName=='INPUT' ||
src.tagName=='SELECT' ||
+ src.tagName=='OPTION' ||
src.tagName=='BUTTON' ||
src.tagName=='TEXTAREA')) return;
@@ -270,6 +277,17 @@
this.element.parentNode.insertBefore(this._clone, this.element);
}
+ if(this.options.scroll) {
+ if (this.options.scroll == window) {
+ var where = this._getWindowScroll(this.options.scroll);
+ this.originalScrollLeft = where.left;
+ this.originalScrollTop = where.top;
+ } else {
+ this.originalScrollLeft = this.options.scroll.scrollLeft;
+ this.originalScrollTop = this.options.scroll.scrollTop;
+ }
+ }
+
Draggables.notify('onStart', this, event);
if(this.options.starteffect) this.options.starteffect(this.element);
},
@@ -282,8 +300,30 @@
this.draw(pointer);
if(this.options.change) this.options.change(this);
+ if(this.options.scroll) {
+ this.stopScrolling();
+
+ var p;
+ if (this.options.scroll == window) {
+ with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
+ } else {
+ p = Position.page(this.options.scroll);
+ p[0] += this.options.scroll.scrollLeft;
+ p[1] += this.options.scroll.scrollTop;
+ p.push(p[0]+this.options.scroll.offsetWidth);
+ p.push(p[1]+this.options.scroll.offsetHeight);
+ }
+ var speed = [0,0];
+ if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity);
+ if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity);
+ if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity);
+ if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
+ this.startScrolling(speed);
+ }
+
// fix AppleWebKit rendering
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+
Event.stop(event);
},
@@ -321,13 +361,14 @@
},
keyPress: function(event) {
- if(!event.keyCode==Event.KEY_ESC) return;
+ if(event.keyCode!=Event.KEY_ESC) return;
this.finishDrag(event, false);
Event.stop(event);
},
endDrag: function(event) {
if(!this.dragging) return;
+ this.stopScrolling();
this.finishDrag(event, true);
Event.stop(event);
},
@@ -337,8 +378,15 @@
var d = this.currentDelta();
pos[0] -= d[0]; pos[1] -= d[1];
- var p = [0,1].map(function(i){ return (point[i]-pos[i]-this.offset[i]) }.bind(this));
+ if(this.options.scroll && (this.options.scroll != window)) {
+ pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
+ pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
+ }
+ var p = [0,1].map(function(i){
+ return (point[i]-pos[i]-this.offset[i])
+ }.bind(this));
+
if(this.options.snap) {
if(typeof this.options.snap == 'function') {
p = this.options.snap(p[0],p[1]);
@@ -358,6 +406,67 @@
if((!this.options.constraint) || (this.options.constraint=='vertical'))
style.top = p[1] + "px";
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+ },
+
+ stopScrolling: function() {
+ if(this.scrollInterval) {
+ clearInterval(this.scrollInterval);
+ this.scrollInterval = null;
+ }
+ },
+
+ startScrolling: function(speed) {
+ this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
+ this.lastScrolled = new Date();
+ this.scrollInterval = setInterval(this.scroll.bind(this), 10);
+ },
+
+ scroll: function() {
+ var current = new Date();
+ var delta = current - this.lastScrolled;
+ this.lastScrolled = current;
+ if(this.options.scroll == window) {
+ with (this._getWindowScroll(this.options.scroll)) {
+ if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
+ var d = delta / 1000;
+ this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] );
+ }
+ }
+ } else {
+ this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
+ this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
+ }
+
+ Position.prepare();
+ Droppables.show(Draggables._lastPointer, this.element);
+ Draggables.notify('onDrag', this);
+ this.draw(Draggables._lastPointer);
+
+ if(this.options.change) this.options.change(this);
+ },
+
+ _getWindowScroll: function(w) {
+ var T, L, W, H;
+ with (w.document) {
+ if (w.document.documentElement && documentElement.scrollTop) {
+ T = documentElement.scrollTop;
+ L = documentElement.scrollLeft;
+ } else if (w.document.body) {
+ T = body.scrollTop;
+ L = body.scrollLeft;
+ }
+ if (w.innerWidth) {
+ W = w.innerWidth;
+ H = w.innerHeight;
+ } else if (w.document.documentElement && documentElement.clientWidth) {
+ W = documentElement.clientWidth;
+ H = documentElement.clientHeight;
+ } else {
+ W = body.offsetWidth;
+ H = body.offsetHeight
+ }
+ }
+ return { top: T, left: L, width: W, height: H };
}
}
@@ -414,7 +523,10 @@
only: false,
hoverclass: null,
ghosting: false,
- format: null,
+ scroll: false,
+ scrollSensitivity: 20,
+ scrollSpeed: 15,
+ format: /^[^_]*_(.*)$/,
onChange: Prototype.emptyFunction,
onUpdate: Prototype.emptyFunction
}, arguments[1] || {});
@@ -425,6 +537,9 @@
// build options for the draggables
var options_for_draggable = {
revert: true,
+ scroll: options.scroll,
+ scrollSpeed: options.scrollSpeed,
+ scrollSensitivity: options.scrollSensitivity,
ghosting: options.ghosting,
constraint: options.constraint,
handle: options.handle };
@@ -492,9 +607,10 @@
findElements: function(element, options) {
if(!element.hasChildNodes()) return null;
var elements = [];
+ var only = options.only ? [options.only].flatten() : null;
$A(element.childNodes).each( function(e) {
if(e.tagName && e.tagName.toUpperCase()==options.tag.toUpperCase() &&
- (!options.only || (Element.hasClassName(e, options.only))))
+ (!only || (Element.classNames(e).detect(function(v) { return only.include(v) }))))
elements.push(e);
if(options.tree) {
var grandchildren = this.findElements(e, options);
@@ -568,18 +684,41 @@
Element.show(Sortable._marker);
},
- serialize: function(element) {
+ sequence: function(element) {
element = $(element);
- var sortableOptions = this.options(element);
- var options = Object.extend({
- tag: sortableOptions.tag,
- only: sortableOptions.only,
- name: element.id,
- format: sortableOptions.format || /^[^_]*_(.*)$/
- }, arguments[1] || {});
+ var options = Object.extend(this.options(element), arguments[1] || {});
+
return $(this.findElements(element, options) || []).map( function(item) {
- return (encodeURIComponent(options.name) + "[]=" +
- encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : ''));
- }).join("&");
+ return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
+ });
+ },
+
+ setSequence: function(element, new_sequence) {
+ element = $(element);
+ var options = Object.extend(this.options(element), arguments[2] || {});
+
+ var nodeMap = {};
+ this.findElements(element, options).each( function(n) {
+ if (n.id.match(options.format))
+ nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
+ n.parentNode.removeChild(n);
+ });
+
+ new_sequence.each(function(ident) {
+ var n = nodeMap[ident];
+ if (n) {
+ n[1].appendChild(n[0]);
+ delete nodeMap[ident];
+ }
+ });
+ },
+
+ serialize: function(element) {
+ element = $(element);
+ var name = encodeURIComponent(
+ (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
+ return Sortable.sequence(element, arguments[1]).map( function(item) {
+ return name + "[]=" + encodeURIComponent(item);
+ }).join('&');
}
-}
\ No newline at end of file
+}
Index: openacs-4/packages/ajaxhelper/www/scriptaculous/effects.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/scriptaculous/Attic/effects.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/www/scriptaculous/effects.js 9 Feb 2006 08:35:44 -0000 1.1
+++ openacs-4/packages/ajaxhelper/www/scriptaculous/effects.js 31 Mar 2006 08:15:36 -0000 1.2
@@ -6,8 +6,6 @@
//
// See scriptaculous.js for full license.
-/* ------------- element ext -------------- */
-
// converts rgb() and #xxx to #xxxxxx format,
// returns self (or first argument) if not convertable
String.prototype.parseColor = function() {
@@ -24,6 +22,8 @@
return(color.length==7 ? color : (arguments[0] || this));
}
+/*--------------------------------------------------------------------------*/
+
Element.collectTextNodes = function(element) {
return $A($(element).childNodes).collect( function(node) {
return (node.nodeType==3 ? node.nodeValue :
@@ -35,18 +35,14 @@
return $A($(element).childNodes).collect( function(node) {
return (node.nodeType==3 ? node.nodeValue :
((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
- Element.collectTextNodes(node) : ''));
+ Element.collectTextNodesIgnoreClass(node, className) : ''));
}).flatten().join('');
}
-Element.setStyle = function(element, style) {
- element = $(element);
- for(k in style) element.style[k.camelize()] = style[k];
-}
-
-Element.setContentZoom = function(element, percent) {
+Element.setContentZoom = function(element, percent) {
+ element = $(element);
Element.setStyle(element, {fontSize: (percent/100) + 'em'});
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
}
Element.getOpacity = function(element){
@@ -73,18 +69,35 @@
Element.setStyle(element,
{ filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
'alpha(opacity='+value*100+')' });
- }
+ }
}
Element.getInlineOpacity = function(element){
return $(element).style.opacity || '';
}
-Element.childrenWithClassName = function(element, className) {
- return $A($(element).getElementsByTagName('*')).select(
- function(c) { return Element.hasClassName(c, className) });
+Element.childrenWithClassName = function(element, className, findFirst) {
+ return [$A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {
+ return c.className ? Element.hasClassName(c, className) : false;
+ })].flatten();
}
+Element.forceRerendering = function(element) {
+ try {
+ element = $(element);
+ var n = document.createTextNode(' ');
+ element.appendChild(n);
+ element.removeChild(n);
+ } catch(e) { }
+};
+
+['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
+ 'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
+ function(f) { Element.Methods[f] = Element[f]; }
+);
+
+/*--------------------------------------------------------------------------*/
+
Array.prototype.call = function() {
var args = arguments;
this.each(function(f){ f.apply(this, args) });
@@ -137,9 +150,9 @@
element = $(element);
effect = (effect || 'appear').toLowerCase();
var options = Object.extend({
- queue: { position:'end', scope:(element.id || 'global') }
+ queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
}, arguments[2] || {});
- Effect[Element.visible(element) ?
+ Effect[element.visible() ?
Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
}
};
@@ -209,7 +222,10 @@
effect.startOn += timestamp;
effect.finishOn += timestamp;
- this.effects.push(effect);
+
+ if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
+ this.effects.push(effect);
+
if(!this.interval)
this.interval = setInterval(this.loop.bind(this), 40);
},
@@ -340,15 +356,15 @@
this.element = $(element);
// make this work on IE on elements without 'layout'
if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
- Element.setStyle(this.element, {zoom: 1});
+ this.element.setStyle({zoom: 1});
var options = Object.extend({
- from: Element.getOpacity(this.element) || 0.0,
+ from: this.element.getOpacity() || 0.0,
to: 1.0
}, arguments[1] || {});
this.start(options);
},
update: function(position) {
- Element.setOpacity(this.element, position);
+ this.element.setOpacity(position);
}
});
@@ -368,17 +384,17 @@
// relative element that does not have top/left explicitly set.
// ==> Always set top and left for position relative elements in your stylesheets
// (to 0 if you do not need them)
- Element.makePositioned(this.element);
- this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
- this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0');
+ this.element.makePositioned();
+ this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
+ this.originalTop = parseFloat(this.element.getStyle('top') || '0');
if(this.options.mode == 'absolute') {
// absolute movement, so we need to calc deltaX and deltaY
this.options.x = this.options.x - this.originalLeft;
this.options.y = this.options.y - this.originalTop;
}
},
update: function(position) {
- Element.setStyle(this.element, {
+ this.element.setStyle({
left: this.options.x * position + this.originalLeft + 'px',
top: this.options.y * position + this.originalTop + 'px'
});
@@ -408,7 +424,7 @@
},
setup: function() {
this.restoreAfterFinish = this.options.restoreAfterFinish || false;
- this.elementPositioning = Element.getStyle(this.element,'position');
+ this.elementPositioning = this.element.getStyle('position');
this.originalStyle = {};
['top','left','width','height','fontSize'].each( function(k) {
@@ -418,7 +434,7 @@
this.originalTop = this.element.offsetTop;
this.originalLeft = this.element.offsetLeft;
- var fontSize = Element.getStyle(this.element,'font-size') || '100%';
+ var fontSize = this.element.getStyle('font-size') || '100%';
['em','px','%'].each( function(fontSizeType) {
if(fontSize.indexOf(fontSizeType)>0) {
this.fontSize = parseFloat(fontSize);
@@ -440,11 +456,11 @@
update: function(position) {
var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
if(this.options.scaleContent && this.fontSize)
- Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType });
+ this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
},
finish: function(position) {
- if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle);
+ if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
},
setDimensions: function(height, width) {
var d = {};
@@ -461,7 +477,7 @@
if(this.options.scaleX) d.left = -leftd + 'px';
}
}
- Element.setStyle(this.element, d);
+ this.element.setStyle(d);
}
});
@@ -474,25 +490,25 @@
},
setup: function() {
// Prevent executing on elements not in the layout flow
- if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; }
+ if(this.element.getStyle('display')=='none') { this.cancel(); return; }
// Disable background image during the effect
this.oldStyle = {
- backgroundImage: Element.getStyle(this.element, 'background-image') };
- Element.setStyle(this.element, {backgroundImage: 'none'});
+ backgroundImage: this.element.getStyle('background-image') };
+ this.element.setStyle({backgroundImage: 'none'});
if(!this.options.endcolor)
- this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
+ this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
if(!this.options.restorecolor)
- this.options.restorecolor = Element.getStyle(this.element, 'background-color');
+ this.options.restorecolor = this.element.getStyle('background-color');
// init color calculations
this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
},
update: function(position) {
- Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){
+ this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
},
finish: function() {
- Element.setStyle(this.element, Object.extend(this.oldStyle, {
+ this.element.setStyle(Object.extend(this.oldStyle, {
backgroundColor: this.options.restorecolor
}));
}
@@ -526,85 +542,91 @@
/* ------------- combination effects ------------- */
Effect.Fade = function(element) {
- var oldOpacity = Element.getInlineOpacity(element);
+ element = $(element);
+ var oldOpacity = element.getInlineOpacity();
var options = Object.extend({
- from: Element.getOpacity(element) || 1.0,
+ from: element.getOpacity() || 1.0,
to: 0.0,
- afterFinishInternal: function(effect) { with(Element) {
+ afterFinishInternal: function(effect) {
if(effect.options.to!=0) return;
- hide(effect.element);
- setStyle(effect.element, {opacity: oldOpacity}); }}
- }, arguments[1] || {});
+ effect.element.hide();
+ effect.element.setStyle({opacity: oldOpacity});
+ }}, arguments[1] || {});
return new Effect.Opacity(element,options);
}
Effect.Appear = function(element) {
+ element = $(element);
var options = Object.extend({
- from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
+ from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
to: 1.0,
- beforeSetup: function(effect) { with(Element) {
- setOpacity(effect.element, effect.options.from);
- show(effect.element); }}
- }, arguments[1] || {});
+ // force Safari to render floated elements properly
+ afterFinishInternal: function(effect) {
+ effect.element.forceRerendering();
+ },
+ beforeSetup: function(effect) {
+ effect.element.setOpacity(effect.options.from);
+ effect.element.show();
+ }}, arguments[1] || {});
return new Effect.Opacity(element,options);
}
Effect.Puff = function(element) {
element = $(element);
- var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') };
+ var oldStyle = { opacity: element.getInlineOpacity(), position: element.getStyle('position') };
return new Effect.Parallel(
[ new Effect.Scale(element, 200,
{ sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
Object.extend({ duration: 1.0,
- beforeSetupInternal: function(effect) { with(Element) {
- setStyle(effect.effects[0].element, {position: 'absolute'}); }},
- afterFinishInternal: function(effect) { with(Element) {
- hide(effect.effects[0].element);
- setStyle(effect.effects[0].element, oldStyle); }}
+ beforeSetupInternal: function(effect) {
+ effect.effects[0].element.setStyle({position: 'absolute'}); },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide();
+ effect.effects[0].element.setStyle(oldStyle); }
}, arguments[1] || {})
);
}
Effect.BlindUp = function(element) {
element = $(element);
- Element.makeClipping(element);
+ element.makeClipping();
return new Effect.Scale(element, 0,
Object.extend({ scaleContent: false,
scaleX: false,
restoreAfterFinish: true,
- afterFinishInternal: function(effect) { with(Element) {
- [hide, undoClipping].call(effect.element); }}
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ }
}, arguments[1] || {})
);
}
Effect.BlindDown = function(element) {
element = $(element);
- var oldHeight = Element.getStyle(element, 'height');
- var elementDimensions = Element.getDimensions(element);
+ var elementDimensions = element.getDimensions();
return new Effect.Scale(element, 100,
Object.extend({ scaleContent: false,
scaleX: false,
scaleFrom: 0,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
restoreAfterFinish: true,
- afterSetup: function(effect) { with(Element) {
- makeClipping(effect.element);
- setStyle(effect.element, {height: '0px'});
- show(effect.element);
- }},
- afterFinishInternal: function(effect) { with(Element) {
- undoClipping(effect.element);
- setStyle(effect.element, {height: oldHeight});
- }}
+ afterSetup: function(effect) {
+ effect.element.makeClipping();
+ effect.element.setStyle({height: '0px'});
+ effect.element.show();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.undoClipping();
+ }
}, arguments[1] || {})
);
}
Effect.SwitchOff = function(element) {
element = $(element);
- var oldOpacity = Element.getInlineOpacity(element);
+ var oldOpacity = element.getInlineOpacity();
return new Effect.Appear(element, {
duration: 0.4,
from: 0,
@@ -613,13 +635,16 @@
new Effect.Scale(effect.element, 1, {
duration: 0.3, scaleFromCenter: true,
scaleX: false, scaleContent: false, restoreAfterFinish: true,
- beforeSetup: function(effect) { with(Element) {
- [makePositioned,makeClipping].call(effect.element);
- }},
- afterFinishInternal: function(effect) { with(Element) {
- [hide,undoClipping,undoPositioned].call(effect.element);
- setStyle(effect.element, {opacity: oldOpacity});
- }}
+ beforeSetup: function(effect) {
+ effect.element.makePositioned();
+ effect.element.makeClipping();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ effect.element.undoPositioned();
+ effect.element.setStyle({opacity: oldOpacity});
+ }
})
}
});
@@ -628,99 +653,110 @@
Effect.DropOut = function(element) {
element = $(element);
var oldStyle = {
- top: Element.getStyle(element, 'top'),
- left: Element.getStyle(element, 'left'),
- opacity: Element.getInlineOpacity(element) };
+ top: element.getStyle('top'),
+ left: element.getStyle('left'),
+ opacity: element.getInlineOpacity() };
return new Effect.Parallel(
[ new Effect.Move(element, {x: 0, y: 100, sync: true }),
new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
Object.extend(
{ duration: 0.5,
- beforeSetup: function(effect) { with(Element) {
- makePositioned(effect.effects[0].element); }},
- afterFinishInternal: function(effect) { with(Element) {
- [hide, undoPositioned].call(effect.effects[0].element);
- setStyle(effect.effects[0].element, oldStyle); }}
+ beforeSetup: function(effect) {
+ effect.effects[0].element.makePositioned();
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide();
+ effect.effects[0].element.undoPositioned();
+ effect.effects[0].element.setStyle(oldStyle);
+ }
}, arguments[1] || {}));
}
Effect.Shake = function(element) {
element = $(element);
var oldStyle = {
- top: Element.getStyle(element, 'top'),
- left: Element.getStyle(element, 'left') };
- return new Effect.Move(element,
- { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
- new Effect.Move(effect.element,
- { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
- new Effect.Move(effect.element,
- { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
- new Effect.Move(effect.element,
- { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
- new Effect.Move(effect.element,
- { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
- new Effect.Move(effect.element,
- { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { with(Element) {
- undoPositioned(effect.element);
- setStyle(effect.element, oldStyle);
- }}}) }}) }}) }}) }}) }});
+ top: element.getStyle('top'),
+ left: element.getStyle('left') };
+ return new Effect.Move(element,
+ { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ effect.element.undoPositioned();
+ effect.element.setStyle(oldStyle);
+ }}) }}) }}) }}) }}) }});
}
Effect.SlideDown = function(element) {
element = $(element);
- Element.cleanWhitespace(element);
+ element.cleanWhitespace();
// SlideDown need to have the content of the element wrapped in a container element with fixed height!
- var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
- var elementDimensions = Element.getDimensions(element);
+ var oldInnerBottom = $(element.firstChild).getStyle('bottom');
+ var elementDimensions = element.getDimensions();
return new Effect.Scale(element, 100, Object.extend({
scaleContent: false,
scaleX: false,
scaleFrom: 0,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
restoreAfterFinish: true,
- afterSetup: function(effect) { with(Element) {
- makePositioned(effect.element);
- makePositioned(effect.element.firstChild);
- if(window.opera) setStyle(effect.element, {top: ''});
- makeClipping(effect.element);
- setStyle(effect.element, {height: '0px'});
- show(element); }},
- afterUpdateInternal: function(effect) { with(Element) {
- setStyle(effect.element.firstChild, {bottom:
- (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
- afterFinishInternal: function(effect) { with(Element) {
- undoClipping(effect.element);
- undoPositioned(effect.element.firstChild);
- undoPositioned(effect.element);
- setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
+ afterSetup: function(effect) {
+ effect.element.makePositioned();
+ effect.element.firstChild.makePositioned();
+ if(window.opera) effect.element.setStyle({top: ''});
+ effect.element.makeClipping();
+ effect.element.setStyle({height: '0px'});
+ effect.element.show(); },
+ afterUpdateInternal: function(effect) {
+ effect.element.firstChild.setStyle({bottom:
+ (effect.dims[0] - effect.element.clientHeight) + 'px' });
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.undoClipping();
+ // IE will crash if child is undoPositioned first
+ if(/MSIE/.test(navigator.userAgent)){
+ effect.element.undoPositioned();
+ effect.element.firstChild.undoPositioned();
+ }else{
+ effect.element.firstChild.undoPositioned();
+ effect.element.undoPositioned();
+ }
+ effect.element.firstChild.setStyle({bottom: oldInnerBottom}); }
}, arguments[1] || {})
);
}
Effect.SlideUp = function(element) {
element = $(element);
- Element.cleanWhitespace(element);
- var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
+ element.cleanWhitespace();
+ var oldInnerBottom = $(element.firstChild).getStyle('bottom');
return new Effect.Scale(element, 0,
Object.extend({ scaleContent: false,
scaleX: false,
scaleMode: 'box',
scaleFrom: 100,
restoreAfterFinish: true,
- beforeStartInternal: function(effect) { with(Element) {
- makePositioned(effect.element);
- makePositioned(effect.element.firstChild);
- if(window.opera) setStyle(effect.element, {top: ''});
- makeClipping(effect.element);
- show(element); }},
- afterUpdateInternal: function(effect) { with(Element) {
- setStyle(effect.element.firstChild, {bottom:
- (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
- afterFinishInternal: function(effect) { with(Element) {
- [hide, undoClipping].call(effect.element);
- undoPositioned(effect.element.firstChild);
- undoPositioned(effect.element);
- setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
+ beforeStartInternal: function(effect) {
+ effect.element.makePositioned();
+ effect.element.firstChild.makePositioned();
+ if(window.opera) effect.element.setStyle({top: ''});
+ effect.element.makeClipping();
+ effect.element.show(); },
+ afterUpdateInternal: function(effect) {
+ effect.element.firstChild.setStyle({bottom:
+ (effect.dims[0] - effect.element.clientHeight) + 'px' }); },
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ effect.element.firstChild.undoPositioned();
+ effect.element.undoPositioned();
+ effect.element.setStyle({bottom: oldInnerBottom}); }
}, arguments[1] || {})
);
}
@@ -729,19 +765,19 @@
Effect.Squish = function(element) {
return new Effect.Scale(element, window.opera ? 1 : 0,
{ restoreAfterFinish: true,
- beforeSetup: function(effect) { with(Element) {
- makeClipping(effect.element); }},
- afterFinishInternal: function(effect) { with(Element) {
- hide(effect.element);
- undoClipping(effect.element); }}
+ beforeSetup: function(effect) {
+ effect.element.makeClipping(effect.element); },
+ afterFinishInternal: function(effect) {
+ effect.element.hide(effect.element);
+ effect.element.undoClipping(effect.element); }
});
}
Effect.Grow = function(element) {
element = $(element);
var options = Object.extend({
direction: 'center',
- moveTransistion: Effect.Transitions.sinoidal,
+ moveTransition: Effect.Transitions.sinoidal,
scaleTransition: Effect.Transitions.sinoidal,
opacityTransition: Effect.Transitions.full
}, arguments[1] || {});
@@ -750,9 +786,9 @@
left: element.style.left,
height: element.style.height,
width: element.style.width,
- opacity: Element.getInlineOpacity(element) };
+ opacity: element.getInlineOpacity() };
- var dims = Element.getDimensions(element);
+ var dims = element.getDimensions();
var initialMoveX, initialMoveY;
var moveX, moveY;
@@ -788,11 +824,11 @@
x: initialMoveX,
y: initialMoveY,
duration: 0.01,
- beforeSetup: function(effect) { with(Element) {
- hide(effect.element);
- makeClipping(effect.element);
- makePositioned(effect.element);
- }},
+ beforeSetup: function(effect) {
+ effect.element.hide();
+ effect.element.makeClipping();
+ effect.element.makePositioned();
+ },
afterFinishInternal: function(effect) {
new Effect.Parallel(
[ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
@@ -801,12 +837,15 @@
scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
], Object.extend({
- beforeSetup: function(effect) { with(Element) {
- setStyle(effect.effects[0].element, {height: '0px'});
- show(effect.effects[0].element); }},
- afterFinishInternal: function(effect) { with(Element) {
- [undoClipping, undoPositioned].call(effect.effects[0].element);
- setStyle(effect.effects[0].element, oldStyle); }}
+ beforeSetup: function(effect) {
+ effect.effects[0].element.setStyle({height: '0px'});
+ effect.effects[0].element.show();
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.undoClipping();
+ effect.effects[0].element.undoPositioned();
+ effect.effects[0].element.setStyle(oldStyle);
+ }
}, options)
)
}
@@ -817,7 +856,7 @@
element = $(element);
var options = Object.extend({
direction: 'center',
- moveTransistion: Effect.Transitions.sinoidal,
+ moveTransition: Effect.Transitions.sinoidal,
scaleTransition: Effect.Transitions.sinoidal,
opacityTransition: Effect.Transitions.none
}, arguments[1] || {});
@@ -826,9 +865,9 @@
left: element.style.left,
height: element.style.height,
width: element.style.width,
- opacity: Element.getInlineOpacity(element) };
+ opacity: element.getInlineOpacity() };
- var dims = Element.getDimensions(element);
+ var dims = element.getDimensions();
var moveX, moveY;
switch (options.direction) {
@@ -858,25 +897,28 @@
new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
], Object.extend({
- beforeStartInternal: function(effect) { with(Element) {
- [makePositioned, makeClipping].call(effect.effects[0].element) }},
- afterFinishInternal: function(effect) { with(Element) {
- [hide, undoClipping, undoPositioned].call(effect.effects[0].element);
- setStyle(effect.effects[0].element, oldStyle); }}
+ beforeStartInternal: function(effect) {
+ effect.effects[0].element.makePositioned();
+ effect.effects[0].element.makeClipping(); },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide();
+ effect.effects[0].element.undoClipping();
+ effect.effects[0].element.undoPositioned();
+ effect.effects[0].element.setStyle(oldStyle); }
}, options)
);
}
Effect.Pulsate = function(element) {
element = $(element);
var options = arguments[1] || {};
- var oldOpacity = Element.getInlineOpacity(element);
+ var oldOpacity = element.getInlineOpacity();
var transition = options.transition || Effect.Transitions.sinoidal;
var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
reverser.bind(transition);
return new Effect.Opacity(element,
Object.extend(Object.extend({ duration: 3.0, from: 0,
- afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); }
+ afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
}, options), {transition: reverser}));
}
@@ -895,9 +937,17 @@
new Effect.Scale(element, 1, {
scaleContent: false,
scaleY: false,
- afterFinishInternal: function(effect) { with(Element) {
- [hide, undoClipping].call(effect.element);
- setStyle(effect.element, oldStyle);
- }} });
+ afterFinishInternal: function(effect) {
+ effect.element.hide();
+ effect.element.undoClipping();
+ effect.element.setStyle(oldStyle);
+ } });
}}, arguments[1] || {}));
}
+
+Element.Methods.visualEffect = function(element, effect, options) {
+ s = effect.gsub(/_/, '-').camelize();
+ effect_class = s.charAt(0).toUpperCase() + s.substring(1);
+ new Effect[effect_class](element, options);
+ return $(element);
+};
\ No newline at end of file
Index: openacs-4/packages/ajaxhelper/www/scriptaculous/scriptaculous.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/scriptaculous/Attic/scriptaculous.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/www/scriptaculous/scriptaculous.js 9 Feb 2006 08:35:44 -0000 1.1
+++ openacs-4/packages/ajaxhelper/www/scriptaculous/scriptaculous.js 31 Mar 2006 08:15:36 -0000 1.2
@@ -20,16 +20,18 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var Scriptaculous = {
- Version: '1.5.1',
+ Version: '1.6',
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('');
},
load: function() {
- if((typeof Prototype=='undefined') ||
- parseFloat(Prototype.Version.split(".")[0] + "." +
- Prototype.Version.split(".")[1]) < 1.4)
- throw("script.aculo.us requires the Prototype JavaScript framework >= 1.4.0");
+ if((typeof Prototype=='undefined') ||
+ (typeof Element == 'undefined') ||
+ (typeof Element.Methods=='undefined') ||
+ parseFloat(Prototype.Version.split(".")[0] + "." +
+ Prototype.Version.split(".")[1]) < 1.5)
+ throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
$A(document.getElementsByTagName("script")).findAll( function(s) {
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
Index: openacs-4/packages/ajaxhelper/www/scriptaculous/slider.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/scriptaculous/Attic/slider.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/www/scriptaculous/slider.js 9 Feb 2006 08:35:44 -0000 1.1
+++ openacs-4/packages/ajaxhelper/www/scriptaculous/slider.js 31 Mar 2006 08:15:36 -0000 1.2
@@ -200,10 +200,10 @@
setSpan: function(span, range) {
if(this.isVertical()) {
span.style.top = this.translateToPx(range.start);
- span.style.height = this.translateToPx(range.end - range.start);
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
} else {
span.style.left = this.translateToPx(range.start);
- span.style.width = this.translateToPx(range.end - range.start);
+ span.style.width = this.translateToPx(range.end - range.start + this.range.start);
}
},
updateStyles: function() {
Index: openacs-4/packages/ajaxhelper/www/scriptaculous/unittest.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ajaxhelper/www/scriptaculous/Attic/unittest.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/ajaxhelper/www/scriptaculous/unittest.js 9 Feb 2006 08:35:44 -0000 1.1
+++ openacs-4/packages/ajaxhelper/www/scriptaculous/unittest.js 31 Mar 2006 08:15:36 -0000 1.2
@@ -2,8 +2,26 @@
// (c) 2005 Jon Tirsen (http://www.tirsen.com)
// (c) 2005 Michael Schuerig (http://www.schuerig.de/michael/)
//
-// See scriptaculous.js for full license.
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
// experimental, Firefox-only
Event.simulateMouse = function(element, eventName) {
var options = Object.extend({
@@ -64,25 +82,8 @@
Test.Unit = {};
// security exception workaround
-Test.Unit.inspect = function(obj) {
- var info = [];
+Test.Unit.inspect = Object.inspect;
- if(typeof obj=="string" ||
- typeof obj=="number") {
- return obj;
- } else {
- for(property in obj)
- if(typeof obj[property]!="function")
- info.push(property + ' => ' +
- (typeof obj[property] == "string" ?
- '"' + obj[property] + '"' :
- obj[property]));
- }
-
- return ("'" + obj + "' #" + typeof obj +
- ": {" + info.join(", ") + "}");
-}
-
Test.Unit.Logger = Class.create();
Test.Unit.Logger.prototype = {
initialize: function(log) {
@@ -279,6 +280,14 @@
'", actual "' + Test.Unit.inspect(actual) + '"'); }
catch(e) { this.error(e); }
},
+ assertEnumEqual: function(expected, actual) {
+ var message = arguments[2] || "assertEnumEqual";
+ try { $A(expected).length == $A(actual).length &&
+ expected.zip(actual).all(function(pair) { return pair[0] == pair[1] }) ?
+ this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) +
+ ', actual ' + Test.Unit.inspect(actual)); }
+ catch(e) { this.error(e); }
+ },
assertNotEqual: function(expected, actual) {
var message = arguments[2] || "assertNotEqual";
try { (expected != actual) ? this.pass() :
@@ -360,4 +369,4 @@
}
catch(e) { this.error(e); }
}
-});
\ No newline at end of file
+});