Author: julien(a)jboss.com
Date: 2007-03-31 10:25:31 -0400 (Sat, 31 Mar 2007)
New Revision: 6896
Added:
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
Removed:
trunk/theme/src/bin/portal-ajax-war/js/portal/event.js
Modified:
trunk/theme/src/bin/portal-ajax-war/js/portal/builder.js
trunk/theme/src/bin/portal-ajax-war/js/portal/controls.js
trunk/theme/src/bin/portal-ajax-war/js/portal/dragdrop.js
trunk/theme/src/bin/portal-ajax-war/js/portal/effects.js
trunk/theme/src/bin/portal-ajax-war/js/portal/prototype.js
trunk/theme/src/bin/portal-ajax-war/js/portal/scriptaculous.js
trunk/theme/src/bin/portal-ajax-war/js/portal/slider.js
trunk/theme/src/bin/portal-ajax-war/js/portal/unittest.js
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
Log:
- updated to scriptaculous 1.7
- put dyna scripts in dyna.js instead of inlining them in the markup
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/builder.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/builder.js 2007-03-31 14:21:37 UTC (rev
6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/builder.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -1,8 +1,9 @@
-// script.aculo.us builder.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
+// Copyright (c) 2005, 2006 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
//
-// See scriptaculous.js for full license.
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site:
http://script.aculo.us/
var Builder = {
NODEMAP: {
@@ -35,7 +36,7 @@
var element = parentElement.firstChild || null;
// see if browser added wrapping tags
- if(element && (element.tagName != elementName))
+ if(element && (element.tagName.toUpperCase() != elementName))
element = element.getElementsByTagName(elementName)[0];
// fallback to createElement approach
@@ -63,7 +64,7 @@
for(attr in arguments[1])
element[attr == 'class' ? 'className' : attr] =
arguments[1][attr];
}
- if(element.tagName != elementName)
+ if(element.tagName.toUpperCase() != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
}
}
@@ -77,10 +78,16 @@
_text: function(text) {
return document.createTextNode(text);
},
+
+ ATTR_MAP: {
+ 'className': 'class',
+ 'htmlFor': 'for'
+ },
+
_attributes: function(attributes) {
var attrs = [];
for(attribute in attributes)
- attrs.push((attribute=='className' ? 'class' : attribute) +
+ attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
'="' + attributes[attribute].toString().escapeHTML() +
'"');
return attrs.join(" ");
},
@@ -100,6 +107,11 @@
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
},
+ build: function(html) {
+ var element = this.node('div');
+ $(element).update(html.strip());
+ return element.down();
+ },
dump: function(scope) {
if(typeof scope != 'object' && typeof scope != 'function')
scope = window; //global scope
@@ -116,4 +128,4 @@
}
});
}
-}
\ No newline at end of file
+}
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/controls.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/controls.js 2007-03-31 14:21:37 UTC (rev
6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/controls.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -1,14 +1,15 @@
-// script.aculo.us controls.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+// script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
-// (c) 2005 Ivan Krstic (
http://blogs.law.harvard.edu/ivan)
-// (c) 2005 Jon Tirsen (
http://www.tirsen.com)
+// Copyright (c) 2005, 2006 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
+// (c) 2005, 2006 Ivan Krstic (
http://blogs.law.harvard.edu/ivan)
+// (c) 2005, 2006 Jon Tirsen (
http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
// Rob Wills
//
-// See scriptaculous.js for full license.
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site:
http://script.aculo.us/
// Autocompleter.Base handles all the autocompletion functionality
// that's independent of the data source for autocompletion. This
@@ -264,11 +265,11 @@
if(!this.changed && this.hasFocus) {
this.update.innerHTML = choices;
Element.cleanWhitespace(this.update);
- Element.cleanWhitespace(this.update.firstChild);
+ Element.cleanWhitespace(this.update.down());
- if(this.update.firstChild && this.update.firstChild.childNodes) {
+ if(this.update.firstChild && this.update.down().childNodes) {
this.entryCount =
- this.update.firstChild.childNodes.length;
+ this.update.down().childNodes.length;
for (var i = 0; i < this.entryCount; i++) {
var entry = this.getEntry(i);
entry.autocompleteIndex = i;
@@ -474,6 +475,7 @@
this.element = $(element);
this.options = Object.extend({
+ paramName: "value",
okButton: true,
okText: "ok",
cancelLink: true,
@@ -605,7 +607,7 @@
var textField = document.createElement("input");
textField.obj = this;
textField.type = "text";
- textField.name = "value";
+ textField.name = this.options.paramName;
textField.value = text;
textField.style.backgroundColor = this.options.highlightcolor;
textField.className = 'editor_field';
@@ -618,7 +620,7 @@
this.options.textarea = true;
var textArea = document.createElement("textarea");
textArea.obj = this;
- textArea.name = "value";
+ textArea.name = this.options.paramName;
textArea.value = this.convertHTMLLineBreaks(text);
textArea.rows = this.options.rows;
textArea.cols = this.options.cols || 40;
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/dragdrop.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dragdrop.js 2007-03-31 14:21:37 UTC (rev
6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dragdrop.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -1,12 +1,11 @@
-// script.aculo.us dragdrop.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+// script.aculo.us dragdrop.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
-// (c) 2005 Sammi Williams (
http://www.oriontransfer.co.nz,
sammi(a)oriontransfer.co.nz)
-//
-// See scriptaculous.js for full license.
+// Copyright (c) 2005, 2006 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
+// (c) 2005, 2006 Sammi Williams (
http://www.oriontransfer.co.nz,
sammi(a)oriontransfer.co.nz)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site:
http://script.aculo.us/
-/*--------------------------------------------------------------------------*/
-
if(typeof Effect == 'undefined')
throw("dragdrop.js requires including script.aculo.us' effects.js
library");
@@ -29,14 +28,14 @@
if(options.containment) {
options._containers = [];
var containment = options.containment;
- if((typeof containment == 'object') &&
+ if((typeof containment == 'object') &&
(containment.constructor == Array)) {
containment.each( function(c) { options._containers.push($(c)) });
} else {
options._containers.push($(containment));
}
}
-
+
if(options.accept) options.accept = [options.accept].flatten();
Element.makePositioned(element); // fix IE
@@ -44,34 +43,34 @@
this.drops.push(options);
},
-
+
findDeepestChild: function(drops) {
deepest = drops[0];
-
+
for (i = 1; i < drops.length; ++i)
if (Element.isParent(drops[i].element, deepest.element))
deepest = drops[i];
-
+
return deepest;
},
isContained: function(element, drop) {
var containmentNode;
if(drop.tree) {
- containmentNode = element.treeNode;
+ containmentNode = element.treeNode;
} else {
containmentNode = element.parentNode;
}
return drop._containers.detect(function(c) { return containmentNode == c });
},
-
+
isAffected: function(point, element, drop) {
return (
(drop.element!=element) &&
((!drop._containers) ||
this.isContained(element, drop)) &&
((!drop.accept) ||
- (Element.classNames(element).detect(
+ (Element.classNames(element).detect(
function(v) { return drop.accept.include(v) } ) )) &&
Position.within(drop.element, point[0], point[1]) );
},
@@ -91,19 +90,19 @@
show: function(point, element) {
if(!this.drops.length) return;
var affected = [];
-
+
if(this.last_active) this.deactivate(this.last_active);
this.drops.each( function(drop) {
if(Droppables.isAffected(point, element, drop))
affected.push(drop);
});
-
+
if(affected.length>0) {
drop = Droppables.findDeepestChild(affected);
Position.within(drop.element, point[0], point[1]);
if(drop.onHover)
drop.onHover(element, drop.element, Position.overlap(drop.overlap,
drop.element));
-
+
Droppables.activate(drop);
}
},
@@ -113,7 +112,7 @@
Position.prepare();
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element,
this.last_active))
- if (this.last_active.onDrop)
+ if (this.last_active.onDrop)
this.last_active.onDrop(element, this.last_active.element, event);
},
@@ -126,20 +125,20 @@
var Draggables = {
drags: [],
observers: [],
-
+
register: function(draggable) {
if(this.drags.length == 0) {
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress = this.keyPress.bindAsEventListener(this);
-
+
Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress);
}
this.drags.push(draggable);
},
-
+
unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) {
@@ -148,24 +147,24 @@
Event.stopObserving(document, "keypress", this.eventKeypress);
}
},
-
+
activate: function(draggable) {
- if(draggable.options.delay) {
- this._timeout = setTimeout(function() {
- Draggables._timeout = null;
- window.focus();
- Draggables.activeDraggable = draggable;
- }.bind(this), draggable.options.delay);
+ if(draggable.options.delay) {
+ this._timeout = setTimeout(function() {
+ Draggables._timeout = null;
+ window.focus();
+ Draggables.activeDraggable = draggable;
+ }.bind(this), draggable.options.delay);
} else {
window.focus(); // allows keypress events if window isn't currently focused,
fails for Safari
this.activeDraggable = draggable;
}
},
-
+
deactivate: function() {
this.activeDraggable = null;
},
-
+
updateDrag: function(event) {
if(!this.activeDraggable) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
@@ -173,36 +172,36 @@
// the same coordinates, prevent needless redrawing (moz bug?)
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect()))
return;
this._lastPointer = pointer;
-
+
this.activeDraggable.updateDrag(event, pointer);
},
-
+
endDrag: function(event) {
- if(this._timeout) {
- clearTimeout(this._timeout);
- this._timeout = null;
+ if(this._timeout) {
+ clearTimeout(this._timeout);
+ this._timeout = null;
}
if(!this.activeDraggable) return;
this._lastPointer = null;
this.activeDraggable.endDrag(event);
this.activeDraggable = null;
},
-
+
keyPress: function(event) {
if(this.activeDraggable)
this.activeDraggable.keyPress(event);
},
-
+
addObserver: function(observer) {
this.observers.push(observer);
this._cacheObserverCallbacks();
},
-
+
removeObserver: function(element) { // element instead of observer fixes mem leaks
this.observers = this.observers.reject( function(o) { return o.element==element });
this._cacheObserverCallbacks();
},
-
+
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd',
'onDrag'
if(this[eventName+'Count'] > 0)
this.observers.each( function(o) {
@@ -210,7 +209,7 @@
});
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
},
-
+
_cacheObserverCallbacks: function() {
['onStart','onEnd','onDrag'].each( function(eventName) {
Draggables[eventName+'Count'] = Draggables.observers.select(
@@ -237,12 +236,12 @@
},
endeffect: function(element) {
var toOpacity = typeof element._opacity == 'number' ? element._opacity :
1.0;
- new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'},
- afterFinish: function(){
- Draggable._dragging[element] = false
+ afterFinish: function(){
+ Draggable._dragging[element] = false
}
- });
+ });
},
zindex: 1000,
revert: false,
@@ -252,91 +251,90 @@
snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
delay: 0
};
-
- if(arguments[1] && typeof arguments[1].endeffect == 'undefined')
+
+ if(!arguments[1] || typeof arguments[1].endeffect == 'undefined')
Object.extend(defaults, {
starteffect: function(element) {
element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true;
- new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
+ new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
}
});
-
+
var options = Object.extend(defaults, arguments[1] || {});
this.element = $(element);
-
- if(options.handle && (typeof options.handle == 'string')) {
- var h = Element.childrenWithClassName(this.element, options.handle, true);
- if(h.length>0) this.handle = h[0];
- }
+
+ if(options.handle && (typeof options.handle == 'string'))
+ this.handle = this.element.down('.'+options.handle, 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);
this._isScrollChild = Element.childOf(this.element, options.scroll);
}
- Element.makePositioned(this.element); // fix IE
+ Element.makePositioned(this.element); // fix IE
this.delta = this.currentDelta();
this.options = options;
- this.dragging = false;
+ this.dragging = false;
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
Event.observe(this.handle, "mousedown", this.eventMouseDown);
-
+
Draggables.register(this);
},
-
+
destroy: function() {
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
Draggables.unregister(this);
},
-
+
currentDelta: function() {
return([
parseInt(Element.getStyle(this.element,'left') || '0'),
parseInt(Element.getStyle(this.element,'top') || '0')]);
},
-
+
initDrag: function(event) {
if(typeof Draggable._dragging[this.element] != 'undefined' &&
Draggable._dragging[this.element]) return;
- if(Event.isLeftClick(event)) {
+ if(Event.isLeftClick(event)) {
// abort on form elements, fixes a Firefox issue
var src = Event.element(event);
- if(src.tagName && (
- src.tagName=='INPUT' ||
- src.tagName=='SELECT' ||
- src.tagName=='OPTION' ||
- src.tagName=='BUTTON' ||
- src.tagName=='TEXTAREA')) return;
-
+ if((tag_name = src.tagName.toUpperCase()) && (
+ tag_name=='INPUT' ||
+ tag_name=='SELECT' ||
+ tag_name=='OPTION' ||
+ tag_name=='BUTTON' ||
+ tag_name=='TEXTAREA')) return;
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var pos = Position.cumulativeOffset(this.element);
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
-
+
Draggables.activate(this);
Event.stop(event);
}
},
-
+
startDrag: function(event) {
this.dragging = true;
-
+
if(this.options.zindex) {
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
this.element.style.zIndex = this.options.zindex;
}
-
+
if(this.options.ghosting) {
this._clone = this.element.cloneNode(true);
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element);
}
-
+
if(this.options.scroll) {
if (this.options.scroll == window) {
var where = this._getWindowScroll(this.options.scroll);
@@ -347,35 +345,31 @@
this.originalScrollTop = this.options.scroll.scrollTop;
}
}
-
+
Draggables.notify('onStart', this, event);
-
+
if(this.options.starteffect) this.options.starteffect(this.element);
},
-
+
updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event);
Position.prepare();
Droppables.show(pointer, this.element);
Draggables.notify('onDrag', this, event);
-
+
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[0] += (window.pageXOffset || document.documentElement.scrollLeft ||
document.body.scrollLeft || 0);
- p[1] += (window.pageYOffset || document.documentElement.scrollTop ||
document.body.scrollTop || 0);
-
+ p[0] += this.options.scroll.scrollLeft + Position.deltaX;
+ p[1] += this.options.scroll.scrollTop + Position.deltaY;
p.push(p[0]+this.options.scroll.offsetWidth);
p.push(p[1]+this.options.scroll.offsetHeight);
}
@@ -386,13 +380,13 @@
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);
},
-
+
finishDrag: function(event, success) {
this.dragging = false;
@@ -407,10 +401,10 @@
var revert = this.options.revert;
if(revert && typeof revert == 'function') revert =
revert(this.element);
-
+
var d = this.currentDelta();
if(revert && this.options.reverteffect) {
- this.options.reverteffect(this.element,
+ this.options.reverteffect(this.element,
d[1]-this.delta[1], d[0]-this.delta[0]);
} else {
this.delta = d;
@@ -419,46 +413,45 @@
if(this.options.zindex)
this.element.style.zIndex = this.originalZ;
- if(this.options.endeffect)
+ if(this.options.endeffect)
this.options.endeffect(this.element);
-
+
Draggables.deactivate(this);
Droppables.reset();
},
-
+
keyPress: function(event) {
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);
},
-
+
draw: function(point) {
var pos = Position.cumulativeOffset(this.element);
if(this.options.ghosting) {
var r = Position.realOffset(this.element);
- window.status = r.inspect();
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
}
-
+
var d = this.currentDelta();
pos[0] -= d[0]; pos[1] -= d[1];
-
+
if(this.options.scroll && (this.options.scroll != window &&
this._isScrollChild)) {
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])
+
+ 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],this);
@@ -471,16 +464,16 @@
return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
}
}}
-
+
var style = this.element.style;
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
style.left = p[0] + "px";
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);
@@ -488,14 +481,14 @@
Draggables._lastScrollPointer = null;
}
},
-
+
startScrolling: function(speed) {
if(!(speed[0] || speed[1])) return;
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;
@@ -511,7 +504,7 @@
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);
@@ -525,10 +518,10 @@
Draggables._lastScrollPointer[1] = 0;
this.draw(Draggables._lastScrollPointer);
}
-
+
if(this.options.change) this.options.change(this);
},
-
+
_getWindowScroll: function(w) {
var T, L, W, H;
with (w.document) {
@@ -563,11 +556,11 @@
this.observer = observer;
this.lastValue = Sortable.serialize(this.element);
},
-
+
onStart: function() {
this.lastValue = Sortable.serialize(this.element);
},
-
+
onEnd: function() {
Sortable.unmark();
if(this.lastValue != Sortable.serialize(this.element))
@@ -577,11 +570,11 @@
var Sortable = {
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
-
+
sortables: {},
-
+
_findRootElement: function(element) {
- while (element.tagName != "BODY") {
+ while (element.tagName.toUpperCase() != "BODY") {
if(element.id && Sortable.sortables[element.id]) return element;
element = element.parentNode;
}
@@ -592,22 +585,22 @@
if(!element) return;
return Sortable.sortables[element.id];
},
-
+
destroy: function(element){
var s = Sortable.options(element);
-
+
if(s) {
Draggables.removeObserver(s.element);
s.droppables.each(function(d){ Droppables.remove(d) });
s.draggables.invoke('destroy');
-
+
delete Sortable.sortables[s.element.id];
}
},
create: function(element) {
element = $(element);
- var options = Object.extend({
+ var options = Object.extend({
element: element,
tag: 'li', // assumes li children, override with tag:
'tagname'
dropOnEmpty: false,
@@ -660,16 +653,15 @@
if(options.zindex)
options_for_draggable.zindex = options.zindex;
- // build options for the droppables
+ // build options for the droppables
var options_for_droppable = {
overlap: options.overlap,
containment: options.containment,
tree: options.tree,
hoverclass: options.hoverclass,
onHover: Sortable.onHover
- //greedy: !options.dropOnEmpty
}
-
+
var options_for_tree = {
onHover: Sortable.onEmptyHover,
overlap: options.overlap,
@@ -678,7 +670,7 @@
}
// fix for gecko engine
- Element.cleanWhitespace(element);
+ Element.cleanWhitespace(element);
options.draggables = [];
options.droppables = [];
@@ -691,15 +683,15 @@
(this.findElements(element, options) || []).each( function(e) {
// handles are per-draggable
- var handle = options.handle ?
- Element.childrenWithClassName(e, options.handle)[0] : e;
+ var handle = options.handle ?
+ $(e).down('.'+options.handle,0) : e;
options.draggables.push(
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
Droppables.add(e, options_for_droppable);
if(options.tree) e.treeNode = element;
- options.droppables.push(e);
+ options.droppables.push(e);
});
-
+
if(options.tree) {
(Sortable.findTreeElements(element, options) || []).each( function(e) {
Droppables.add(e, options_for_tree);
@@ -721,7 +713,7 @@
return Element.findChildren(
element, options.only, options.tree ? true : false, options.tag);
},
-
+
findTreeElements: function(element, options) {
return Element.findChildren(
element, options.only, options.tree ? true : false, options.treeTag);
@@ -737,51 +729,38 @@
if(dropon.previousSibling != element) {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
-
- Sortable.createGuide(element);
dropon.parentNode.insertBefore(element, dropon);
- dropon.parentNode.insertBefore(Sortable._guide, element);
- Sortable.markEmptyPlace(element);
-
- if(dropon.parentNode!=oldParentNode)
+ if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
} else {
Sortable.mark(dropon, 'after');
var nextElement = dropon.nextSibling || null;
-
if(nextElement != element) {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
-
- Sortable.createGuide(element);
dropon.parentNode.insertBefore(element, nextElement);
- dropon.parentNode.insertBefore(Sortable._guide, element);
- Sortable.markEmptyPlace(element);
-
- if(dropon.parentNode!=oldParentNode)
+ if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
}
},
-
-
-
+
onEmptyHover: function(element, dropon, overlap) {
var oldParentNode = element.parentNode;
var droponOptions = Sortable.options(dropon);
-
+
if(!Element.isParent(dropon, element)) {
var index;
-
+
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only:
droponOptions.only});
var child = null;
-
+
if(children) {
var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 -
overlap);
-
+
for (index = 0; index < children.length; index += 1) {
if (offset - Element.offsetSize (children[index], droponOptions.overlap) >=
0) {
offset -= Element.offsetSize (children[index], droponOptions.overlap);
@@ -794,133 +773,68 @@
}
}
}
-
- Sortable.createGuide(element);
+
dropon.insertBefore(element, child);
- dropon.insertBefore(Sortable._guide, element);
- Sortable.markEmptyPlace(element);
-
+
Sortable.options(oldParentNode).onChange(element);
droponOptions.onChange(element);
}
},
- createGuide : function (element) {
- if(!Sortable._guide) {
- Sortable._guide = $('_guide') ||
document.createElement('DIV');
- Sortable._guide.style.position = 'relative';
- Sortable._guide.style.width = '1px';
- Sortable._guide.style.height = '0px';
- Sortable._guide.style.left == '0px';
- Sortable._guide.style.top == '0px';
- Sortable._guide.style.cssFloat = 'left';
- Sortable._guide.id = 'guide';
-
-
document.getElementsByTagName("body").item(0).appendChild(Sortable._guide);
- }
-
- },
-
- markEmptyPlace: function(element) {
-
- if(!Sortable._emptyPlaceMarker) {
- Sortable._emptyPlaceMarker = $('emptyPlaceMarker') ||
document.createElement('DIV');
- Element.hide(Sortable._emptyPlaceMarker);
- Element.addClassName(Sortable._emptyPlaceMarker, 'emptyPlaceMarker');
- Sortable._emptyPlaceMarker.style.position = 'absolute';
-
document.getElementsByTagName("body").item(0).appendChild(Sortable._emptyPlaceMarker);
- }
-
- var pos = Position.cumulativeOffset(Sortable._guide);
- Sortable._emptyPlaceMarker.style.left = (pos[0] + 5)+ 'px';
- Sortable._emptyPlaceMarker.style.top = (pos[1] + 5) + 'px';
-
- var dim = {};
- dim.width = (Element.getDimensions(element).width-5) + 'px';
- dim.height = (Element.getDimensions(element).height-5) + 'px';
- Sortable._emptyPlaceMarker.setStyle(dim);
-
- var mg = Element.getStyle(element, 'margin');
- if(mg && mg != '') {
- Sortable._emptyPlaceMarker.setStyle({margin : mg});
- } else {
- Sortable._emptyPlaceMarker.setStyle({ margin : ''});
- }
-
- Element.show(Sortable._emptyPlaceMarker);
- },
-
unmark: function() {
- if(Sortable._marker) Element.hide(Sortable._marker);
- if(Sortable._guide && Sortable._guide.parentNode){
- Sortable._guide.parentNode.removeChild(Sortable._guide);
- }
- if(Sortable._emptyPlaceMarker) Element.hide(Sortable._emptyPlaceMarker);
+ if(Sortable._marker) Sortable._marker.hide();
},
mark: function(dropon, position) {
// mark on ghosting only
var sortable = Sortable.options(dropon.parentNode);
- if(sortable && !sortable.ghosting) return;
+ if(sortable && !sortable.ghosting) return;
if(!Sortable._marker) {
- Sortable._marker = $('dropmarker') ||
document.createElement('DIV');
- Element.hide(Sortable._marker);
- Element.addClassName(Sortable._marker, 'dropmarker');
- Sortable._marker.style.position = 'absolute';
+ Sortable._marker =
+ ($('dropmarker') ||
Element.extend(document.createElement('DIV'))).
+
hide().addClassName('dropmarker').setStyle({position:'absolute'});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
- }
+ }
var offsets = Position.cumulativeOffset(dropon);
- Sortable._marker.style.left = offsets[0] + 'px';
- Sortable._marker.style.top = offsets[1] + 'px';
-
+ Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] +
'px'});
+
if(position=='after')
- if(sortable.overlap == 'horizontal')
- Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px';
+ if(sortable.overlap == 'horizontal')
+ Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) +
'px'});
else
- Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
-
- Element.show(Sortable._marker);
+ Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) +
'px'});
+
+ Sortable._marker.show();
},
-
+
_tree: function(element, options, parent) {
var children = Sortable.findElements(element, options) || [];
-
+
for (var i = 0; i < children.length; ++i) {
var match = children[i].id.match(options.format);
if (!match) continue;
-
+
var child = {
id: encodeURIComponent(match ? match[1] : null),
element: element,
parent: parent,
- children: new Array,
+ children: [],
position: parent.children.length,
- container: Sortable._findChildrenElement(children[i],
options.treeTag.toUpperCase())
+ container: $(children[i]).down(options.treeTag)
}
-
+
/* Get the element containing the children and recurse over it */
if (child.container)
this._tree(child.container, options, child)
-
+
parent.children.push (child);
}
- return parent;
+ return parent;
},
- /* Finds the first element of the given tag type within a parent element.
- Used for finding the first LI[ST] within a L[IST]I[TEM].*/
- _findChildrenElement: function (element, containerTag) {
- if (element && element.hasChildNodes)
- for (var i = 0; i < element.childNodes.length; ++i)
- if (element.childNodes[i].tagName == containerTag)
- return element.childNodes[i];
-
- return null;
- },
-
tree: function(element) {
element = $(element);
var sortableOptions = this.options(element);
@@ -931,16 +845,16 @@
name: element.id,
format: sortableOptions.format
}, arguments[1] || {});
-
+
var root = {
id: null,
parent: null,
- children: new Array,
+ children: [],
container: element,
position: 0
}
-
- return Sortable._tree (element, options, root);
+
+ return Sortable._tree(element, options, root);
},
/* Construct a [i] index for a particular node */
@@ -955,7 +869,7 @@
sequence: function(element) {
element = $(element);
var options = Object.extend(this.options(element), arguments[1] || {});
-
+
return $(this.findElements(element, options) || []).map( function(item) {
return item.id.match(options.format) ? item.id.match(options.format)[1] :
'';
});
@@ -964,14 +878,14 @@
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) {
@@ -980,16 +894,16 @@
}
});
},
-
+
serialize: function(element) {
element = $(element);
var options = Object.extend(Sortable.options(element), arguments[1] || {});
var name = encodeURIComponent(
(arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
-
+
if (options.tree) {
return Sortable.tree(element, arguments[1]).children.map( function (item) {
- return [name + Sortable._constructIndex(item) + "[id]=" +
+ return [name + Sortable._constructIndex(item) + "[id]=" +
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
}).flatten().join('&');
} else {
@@ -1000,16 +914,14 @@
}
}
-/* Returns true if child is contained within element */
+// Returns true if child is contained within element
Element.isParent = function(child, element) {
if (!child.parentNode || child == element) return false;
-
if (child.parentNode == element) return true;
-
return Element.isParent(child.parentNode, element);
}
-Element.findChildren = function(element, only, recursive, tagName) {
+Element.findChildren = function(element, only, recursive, tagName) {
if(!element.hasChildNodes()) return null;
tagName = tagName.toUpperCase();
if(only) only = [only].flatten();
@@ -1028,8 +940,5 @@
}
Element.offsetSize = function (element, type) {
- if (type == 'vertical' || type == 'height')
- return element.offsetHeight;
- else
- return element.offsetWidth;
-}
\ No newline at end of file
+ return element['offset' + ((type=='vertical' || type=='height')
? 'Height' : 'Width')];
+}
Added: trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js (rev 0)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -0,0 +1,134 @@
+function sendData(action, windowId, fromPos, fromRegionId, toPos, toRegionId) {
+ var options = {
+ method: "post",
+ postBody: "action=" + action + "&windowId=" + windowId +
"&fromPos=" + fromPos + "&fromRegion=" + fromRegionId +
"&toPos=" + toPos + "&toRegion=" + toRegionId,
+ onSuccess: function(t)
+ {
+ },
+ on404: function(t)
+ {
+ alert("Error 404: location " + t.statusText + " was not
found.");
+ },
+ onFailure: function(t)
+ {
+ alert("Error " + t.status + " -- " + t.statusText);
+ },
+ onLoading: function(t)
+ {
+ }
+ }
+ new Ajax.Request(async_server_url, options);
+}
+
+function snapshot() {
+
+ // Find draggable regions
+ var regions_on_page = document.getElementsByClassName("dyna-region");
+
+ // Save current state in the DOM itself
+ for(var i = 0;i < regions_on_page.length;i++) {
+ var regionDiv = regions_on_page[i]
+ for (var j = 0;j < regionDiv.childNodes.length;j++) {
+ var child = regionDiv.childNodes[j];
+ child["regionId"] = regionDiv.id;
+ child["pos"] = j;
+ }
+ }
+}
+
+function bilto(event)
+{
+
+ // Find container
+ var source = Event.element(event);
+ var container = Element.up(source, "div.dyna-portlet");
+
+ // We found the div container
+ if (container != null) {
+
+ // Handle links
+ if (source.nodeName == "A") {
+
+// " var url = source.href;
+// " var parameters = \"\";
+// " var pos = url.indexOf(\"?\");
+// " if (pos != -1) {
+// " parameters = url.substring(pos + 1);
+// " url = url.substring(0, pos);
+// " }
+// " var options = {
+// " parameters:parameters,
+// " asynchronous:true,
+// " method:\"get\",
+// " requestHeaders:[\"ajax\",\"true\"],
+// " };" +
+// " new Ajax.Request(url, options);
+ }
+
+// " Element.replace(container, \"Some new content from the
server\");
+// " Event.stop(event);
+ }
+
+}
+
+
+function footer()
+{
+ //
+ var WindowMoveObserver = Class.create();
+ WindowMoveObserver.prototype =
+ {
+ initialize: function(element)
+ {
+ this.element = $(element);
+ },
+ onStart: function()
+ {
+ },
+ onEnd: function()
+ {
+ var elt = Draggables.activeDraggable.element;
+ var fromRegionId = elt["regionId"];
+ var fromPos = elt["pos"];
+ snapshot();
+ var toRegionId = elt["regionId"];
+ var toPos = elt["pos"];
+ sendData("windowmove", elt.id, fromPos, fromRegionId, toPos,
toRegionId);
+ }
+ };
+
+ // Find the draggable regions
+ var regions_on_page = document.getElementsByClassName("dyna-region");
+
+ // Create draggable regions
+ for(var i = 0;i < regions_on_page.length;i++) {
+ var region = regions_on_page[i];
+ Sortable.create(region,
{dropOnEmpty:true,handle:"handle",tag:"div",containment:regions_on_page,constraint:false});
+ }
+
+ //
+ Draggables.addObserver(new WindowMoveObserver());
+ snapshot();
+
+ // Find the dyna portlets
+ var portlets_on_page = document.getElementsByClassName("dyna-portlet");
+
+ // Add listener for teh dyna portlets
+ for(var i = 0;i < portlets_on_page.length;i++) {
+ var portlet = portlets_on_page[i];
+ Event.observe(portlet, "click", bilto);
+ }
+}
+
+
+// String u = "" +
+// "function removeWindow(elementId)\n" +
+// "{\n" +
+// " var effectElement = document.getElementById(elementId)\n"
+
+// " new Effect.BlindUp(effectElement);\n" +
+// "\n" +
+// " //removeElement(effectElement);\n" +
+// "\n" +
+// " sendData('windowremove', elementId);\n" +
+// "}\n";
+// markup.append(u);
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/effects.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/effects.js 2007-03-31 14:21:37 UTC (rev
6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/effects.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -1,17 +1,18 @@
-// script.aculo.us effects.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+// script.aculo.us effects.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
+// Copyright (c) 2005, 2006 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
// Contributors:
// Justin Palmer (
http://encytemedia.com/)
// Mark Pilgrim (
http://diveintomark.org/)
// Martin Bialasinki
//
-// See scriptaculous.js for full license.
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site:
http://script.aculo.us/
// converts rgb() and #xxx to #xxxxxx format,
// returns self (or first argument) if not convertable
String.prototype.parseColor = function() {
- var color = '#';
+ var color = '#';
if(this.slice(0,4) == 'rgb(') {
var cols = this.slice(4,this.length-1).split(',');
var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
@@ -43,48 +44,21 @@
Element.setContentZoom = function(element, percent) {
element = $(element);
- Element.setStyle(element, {fontSize: (percent/100) + 'em'});
+ element.setStyle({fontSize: (percent/100) + 'em'});
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ return element;
}
-Element.getOpacity = function(element){
- var opacity;
- if (opacity = Element.getStyle(element, 'opacity'))
- return parseFloat(opacity);
- if (opacity = (Element.getStyle(element, 'filter') ||
'').match(/alpha\(opacity=(.*)\)/))
- if(opacity[1]) return parseFloat(opacity[1]) / 100;
- return 1.0;
+Element.getOpacity = function(element){
+ return $(element).getStyle('opacity');
}
-Element.setOpacity = function(element, value){
- element= $(element);
- if (value == 1){
- Element.setStyle(element, { opacity:
- (/Gecko/.test(navigator.userAgent) &&
!/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
- 0.999999 : 1.0 });
- if(/MSIE/.test(navigator.userAgent) && !window.opera)
- Element.setStyle(element, {filter:
Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
- } else {
- if(value < 0.00001) value = 0;
- Element.setStyle(element, {opacity: value});
- if(/MSIE/.test(navigator.userAgent) && !window.opera)
- Element.setStyle(element,
- { filter:
Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
- 'alpha(opacity='+value*100+')' });
- }
-}
-
-Element.getInlineOpacity = function(element){
+Element.setOpacity = function(element, value){
+ return $(element).setStyle({opacity:value});
+}
+
+Element.getInlineOpacity = function(element){
return $(element).style.opacity || '';
-}
-
-Element.childrenWithClassName = function(element, className, findFirst) {
- var classNameRegExp = new RegExp("(^|\\s)" + className +
"(\\s|$)");
- var results = $A($(element).getElementsByTagName('*'))[findFirst ?
'detect' : 'select']( function(c) {
- return (c.className && c.className.match(classNameRegExp));
- });
- if(!results) results = [];
- return results;
}
Element.forceRerendering = function(element) {
@@ -116,6 +90,7 @@
var tagifyStyle = 'position:relative';
if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle +=
';zoom:1';
+
element = $(element);
$A(element.childNodes).each( function(child) {
if(child.nodeType==3) {
@@ -168,33 +143,36 @@
/* ------------- transitions ------------- */
-Effect.Transitions = {}
+Effect.Transitions = {
+ linear: Prototype.K,
+ sinoidal: function(pos) {
+ return (-Math.cos(pos*Math.PI)/2) + 0.5;
+ },
+ reverse: function(pos) {
+ return 1-pos;
+ },
+ flicker: function(pos) {
+ return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
+ },
+ wobble: function(pos) {
+ return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
+ },
+ pulse: function(pos, pulses) {
+ pulses = pulses || 5;
+ return (
+ Math.round((pos % (1/pulses)) * pulses) == 0 ?
+ ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) :
+ 1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
+ );
+ },
+ none: function(pos) {
+ return 0;
+ },
+ full: function(pos) {
+ return 1;
+ }
+};
-Effect.Transitions.linear = Prototype.K;
-
-Effect.Transitions.sinoidal = function(pos) {
- return (-Math.cos(pos*Math.PI)/2) + 0.5;
-}
-Effect.Transitions.reverse = function(pos) {
- return 1-pos;
-}
-Effect.Transitions.flicker = function(pos) {
- return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
-}
-Effect.Transitions.wobble = function(pos) {
- return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
-}
-Effect.Transitions.pulse = function(pos) {
- return (Math.floor(pos*10) % 2 == 0 ?
- (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
-}
-Effect.Transitions.none = function(pos) {
- return 0;
-}
-Effect.Transitions.full = function(pos) {
- return 1;
-}
-
/* ------------- core effects ------------- */
Effect.ScopedQueue = Class.create();
@@ -220,6 +198,9 @@
e.finishOn += effect.finishOn;
});
break;
+ case 'with-last':
+ timestamp = this.effects.pluck('startOn').max() || timestamp;
+ break;
case 'end':
// start effect after last queued effect has finished
timestamp = this.effects.pluck('finishOn').max() || timestamp;
@@ -233,7 +214,7 @@
this.effects.push(effect);
if(!this.interval)
- this.interval = setInterval(this.loop.bind(this), 40);
+ this.interval = setInterval(this.loop.bind(this), 15);
},
remove: function(effect) {
this.effects = this.effects.reject(function(e) { return e==effect });
@@ -244,7 +225,8 @@
},
loop: function() {
var timePos = new Date().getTime();
- this.effects.invoke('loop', timePos);
+ for(var i=0, len=this.effects.length;i<len;i++)
+ if(this.effects[i]) this.effects[i].loop(timePos);
}
});
@@ -264,7 +246,7 @@
Effect.DefaultOptions = {
transition: Effect.Transitions.sinoidal,
duration: 1.0, // seconds
- fps: 25.0, // max. 25fps due to Effect.Queue implementation
+ fps: 60.0, // max. 60fps due to Effect.Queue implementation
sync: false, // true for combining
from: 0.0,
to: 1.0,
@@ -332,7 +314,10 @@
if(this.options[eventName]) this.options[eventName](this);
},
inspect: function() {
- return '#<Effect:' + $H(this).inspect() + ',options:' +
$H(this.options).inspect() + '>';
+ var data = $H();
+ for(property in this)
+ if(typeof this[property] != 'function') data[property] = this[property];
+ return '#<Effect:' + data.inspect() + ',options:' +
$H(this.options).inspect() + '>';
}
}
@@ -356,6 +341,17 @@
}
});
+Effect.Event = Class.create();
+Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {
+ initialize: function() {
+ var options = Object.extend({
+ duration: 0
+ }, arguments[0] || {});
+ this.start(options);
+ },
+ update: Prototype.emptyFunction
+});
+
Effect.Opacity = Class.create();
Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
initialize: function(element) {
@@ -469,7 +465,7 @@
this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
},
finish: function(position) {
- if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
+ if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
},
setDimensions: function(height, width) {
var d = {};
@@ -502,9 +498,11 @@
// Prevent executing on elements not in the layout flow
if(this.element.getStyle('display')=='none') { this.cancel(); return;
}
// Disable background image during the effect
- this.oldStyle = {
- backgroundImage: this.element.getStyle('background-image') };
- this.element.setStyle({backgroundImage: 'none'});
+ this.oldStyle = {};
+ if (!this.options.keepBackgroundImage) {
+ this.oldStyle.backgroundImage = this.element.getStyle('background-image');
+ this.element.setStyle({backgroundImage: 'none'});
+ }
if(!this.options.endcolor)
this.options.endcolor =
this.element.getStyle('background-color').parseColor('#ffffff');
if(!this.options.restorecolor)
@@ -559,8 +557,7 @@
to: 0.0,
afterFinishInternal: function(effect) {
if(effect.options.to!=0) return;
- effect.element.hide();
- effect.element.setStyle({opacity: oldOpacity});
+ effect.element.hide().setStyle({opacity: oldOpacity});
}}, arguments[1] || {});
return new Effect.Opacity(element,options);
}
@@ -575,8 +572,7 @@
effect.element.forceRerendering();
},
beforeSetup: function(effect) {
- effect.element.setOpacity(effect.options.from);
- effect.element.show();
+ effect.element.setOpacity(effect.options.from).show();
}}, arguments[1] || {});
return new Effect.Opacity(element,options);
}
@@ -600,8 +596,7 @@
Position.absolutize(effect.effects[0].element)
},
afterFinishInternal: function(effect) {
- effect.effects[0].element.hide();
- effect.effects[0].element.setStyle(oldStyle); }
+ effect.effects[0].element.hide().setStyle(oldStyle); }
}, arguments[1] || {})
);
}
@@ -614,8 +609,7 @@
scaleX: false,
restoreAfterFinish: true,
afterFinishInternal: function(effect) {
- effect.element.hide();
- effect.element.undoClipping();
+ effect.element.hide().undoClipping();
}
}, arguments[1] || {})
);
@@ -631,9 +625,7 @@
scaleMode: {originalHeight: elementDimensions.height, originalWidth:
elementDimensions.width},
restoreAfterFinish: true,
afterSetup: function(effect) {
- effect.element.makeClipping();
- effect.element.setStyle({height: '0px'});
- effect.element.show();
+ effect.element.makeClipping().setStyle({height: '0px'}).show();
},
afterFinishInternal: function(effect) {
effect.element.undoClipping();
@@ -653,14 +645,10 @@
duration: 0.3, scaleFromCenter: true,
scaleX: false, scaleContent: false, restoreAfterFinish: true,
beforeSetup: function(effect) {
- effect.element.makePositioned();
- effect.element.makeClipping();
+ effect.element.makePositioned().makeClipping();
},
afterFinishInternal: function(effect) {
- effect.element.hide();
- effect.element.undoClipping();
- effect.element.undoPositioned();
- effect.element.setStyle({opacity: oldOpacity});
+ effect.element.hide().undoClipping().undoPositioned().setStyle({opacity:
oldOpacity});
}
})
}
@@ -682,9 +670,7 @@
effect.effects[0].element.makePositioned();
},
afterFinishInternal: function(effect) {
- effect.effects[0].element.hide();
- effect.effects[0].element.undoPositioned();
- effect.effects[0].element.setStyle(oldStyle);
+ effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
}
}, arguments[1] || {}));
}
@@ -706,16 +692,14 @@
{ 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.element.undoPositioned().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.firstChild).getStyle('bottom');
+ var oldInnerBottom = element.down().getStyle('bottom');
var elementDimensions = element.getDimensions();
return new Effect.Scale(element, 100, Object.extend({
scaleContent: false,
@@ -725,34 +709,24 @@
restoreAfterFinish: true,
afterSetup: function(effect) {
effect.element.makePositioned();
- effect.element.firstChild.makePositioned();
+ effect.element.down().makePositioned();
if(window.opera) effect.element.setStyle({top: ''});
- effect.element.makeClipping();
- effect.element.setStyle({height: '0px'});
- effect.element.show(); },
+ effect.element.makeClipping().setStyle({height: '0px'}).show();
+ },
afterUpdateInternal: function(effect) {
- effect.element.firstChild.setStyle({bottom:
+ effect.element.down().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) && !window.opera){
- effect.element.undoPositioned();
- effect.element.firstChild.undoPositioned();
- }else{
- effect.element.firstChild.undoPositioned();
- effect.element.undoPositioned();
- }
- effect.element.firstChild.setStyle({bottom: oldInnerBottom}); }
+ effect.element.undoClipping().undoPositioned();
+ effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
}, arguments[1] || {})
);
}
Effect.SlideUp = function(element) {
- element = $(element);
- element.cleanWhitespace();
- var oldInnerBottom = $(element.firstChild).getStyle('bottom');
+ element = $(element).cleanWhitespace();
+ var oldInnerBottom = element.down().getStyle('bottom');
return new Effect.Scale(element, window.opera ? 0 : 1,
Object.extend({ scaleContent: false,
scaleX: false,
@@ -761,32 +735,32 @@
restoreAfterFinish: true,
beforeStartInternal: function(effect) {
effect.element.makePositioned();
- effect.element.firstChild.makePositioned();
+ effect.element.down().makePositioned();
if(window.opera) effect.element.setStyle({top: ''});
- effect.element.makeClipping();
- effect.element.show(); },
+ effect.element.makeClipping().show();
+ },
afterUpdateInternal: function(effect) {
- effect.element.firstChild.setStyle({bottom:
- (effect.dims[0] - effect.element.clientHeight) + 'px' }); },
+ effect.element.down().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}); }
+ effect.element.hide().undoClipping().undoPositioned().setStyle({bottom:
oldInnerBottom});
+ effect.element.down().undoPositioned();
+ }
}, arguments[1] || {})
);
}
// Bug in opera makes the TD containing this element expand for a instance after finish
Effect.Squish = function(element) {
- return new Effect.Scale(element, window.opera ? 1 : 0,
- { restoreAfterFinish: true,
- beforeSetup: function(effect) {
- effect.element.makeClipping(effect.element); },
- afterFinishInternal: function(effect) {
- effect.element.hide(effect.element);
- effect.element.undoClipping(effect.element); }
+ return new Effect.Scale(element, window.opera ? 1 : 0, {
+ restoreAfterFinish: true,
+ beforeSetup: function(effect) {
+ effect.element.makeClipping();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.hide().undoClipping();
+ }
});
}
@@ -842,9 +816,7 @@
y: initialMoveY,
duration: 0.01,
beforeSetup: function(effect) {
- effect.element.hide();
- effect.element.makeClipping();
- effect.element.makePositioned();
+ effect.element.hide().makeClipping().makePositioned();
},
afterFinishInternal: function(effect) {
new Effect.Parallel(
@@ -855,13 +827,10 @@
sync: true, scaleFrom: window.opera ? 1 : 0, transition:
options.scaleTransition, restoreAfterFinish: true})
], Object.extend({
beforeSetup: function(effect) {
- effect.effects[0].element.setStyle({height: '0px'});
- effect.effects[0].element.show();
+ effect.effects[0].element.setStyle({height: '0px'}).show();
},
afterFinishInternal: function(effect) {
- effect.effects[0].element.undoClipping();
- effect.effects[0].element.undoPositioned();
- effect.effects[0].element.setStyle(oldStyle);
+
effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
}
}, options)
)
@@ -915,13 +884,10 @@
new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition:
options.moveTransition })
], Object.extend({
beforeStartInternal: function(effect) {
- effect.effects[0].element.makePositioned();
- effect.effects[0].element.makeClipping(); },
+ effect.effects[0].element.makePositioned().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); }
+
effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
}, options)
);
}
@@ -931,10 +897,10 @@
var options = arguments[1] || {};
var oldOpacity = element.getInlineOpacity();
var transition = options.transition || Effect.Transitions.sinoidal;
- var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
+ var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos,
options.pulses)) };
reverser.bind(transition);
return new Effect.Opacity(element,
- Object.extend(Object.extend({ duration: 3.0, from: 0,
+ Object.extend(Object.extend({ duration: 2.0, from: 0,
afterFinishInternal: function(effect) { effect.element.setStyle({opacity:
oldOpacity}); }
}, options), {transition: reverser}));
}
@@ -946,7 +912,7 @@
left: element.style.left,
width: element.style.width,
height: element.style.height };
- Element.makeClipping(element);
+ element.makeClipping();
return new Effect.Scale(element, 5, Object.extend({
scaleContent: false,
scaleX: false,
@@ -955,15 +921,162 @@
scaleContent: false,
scaleY: false,
afterFinishInternal: function(effect) {
- effect.element.hide();
- effect.element.undoClipping();
- effect.element.setStyle(oldStyle);
+ effect.element.hide().undoClipping().setStyle(oldStyle);
} });
}}, arguments[1] || {}));
};
+Effect.Morph = Class.create();
+Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({
+ style: {}
+ }, arguments[1] || {});
+ if (typeof options.style == 'string') {
+ if(options.style.indexOf(':') == -1) {
+ var cssText = '', selector = '.' + options.style;
+ $A(document.styleSheets).reverse().each(function(styleSheet) {
+ if (styleSheet.cssRules) cssRules = styleSheet.cssRules;
+ else if (styleSheet.rules) cssRules = styleSheet.rules;
+ $A(cssRules).reverse().each(function(rule) {
+ if (selector == rule.selectorText) {
+ cssText = rule.style.cssText;
+ throw $break;
+ }
+ });
+ if (cssText) throw $break;
+ });
+ this.style = cssText.parseStyle();
+ options.afterFinishInternal = function(effect){
+ effect.element.addClassName(effect.options.style);
+ effect.transforms.each(function(transform) {
+ if(transform.style != 'opacity')
+ effect.element.style[transform.style.camelize()] = '';
+ });
+ }
+ } else this.style = options.style.parseStyle();
+ } else this.style = $H(options.style)
+ this.start(options);
+ },
+ setup: function(){
+ function parseColor(color){
+ if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color))
color = '#ffffff';
+ color = color.parseColor();
+ return $R(0,2).map(function(i){
+ return parseInt( color.slice(i*2+1,i*2+3), 16 )
+ });
+ }
+ this.transforms = this.style.map(function(pair){
+ var property = pair[0].underscore().dasherize(), value = pair[1], unit = null;
+
+ if(value.parseColor('#zzzzzz') != '#zzzzzz') {
+ value = value.parseColor();
+ unit = 'color';
+ } else if(property == 'opacity') {
+ value = parseFloat(value);
+ if(/MSIE/.test(navigator.userAgent) && !window.opera &&
(!this.element.currentStyle.hasLayout))
+ this.element.setStyle({zoom: 1});
+ } else if(Element.CSS_LENGTH.test(value))
+ var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/),
+ value = parseFloat(components[1]), unit = (components.length == 3) ?
components[2] : null;
+
+ var originalValue = this.element.getStyle(property);
+ return $H({
+ style: property,
+ originalValue: unit=='color' ? parseColor(originalValue) :
parseFloat(originalValue || 0),
+ targetValue: unit=='color' ? parseColor(value) : value,
+ unit: unit
+ });
+ }.bind(this)).reject(function(transform){
+ return (
+ (transform.originalValue == transform.targetValue) ||
+ (
+ transform.unit != 'color' &&
+ (isNaN(transform.originalValue) || isNaN(transform.targetValue))
+ )
+ )
+ });
+ },
+ update: function(position) {
+ var style = $H(), value = null;
+ this.transforms.each(function(transform){
+ value = transform.unit=='color' ?
+ $R(0,2).inject('#',function(m,v,i){
+ return m+(Math.round(transform.originalValue[i]+
+ (transform.targetValue[i] -
transform.originalValue[i])*position)).toColorPart() }) :
+ transform.originalValue + Math.round(
+ ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 +
transform.unit;
+ style[transform.style] = value;
+ });
+ this.element.setStyle(style);
+ }
+});
+
+Effect.Transform = Class.create();
+Object.extend(Effect.Transform.prototype, {
+ initialize: function(tracks){
+ this.tracks = [];
+ this.options = arguments[1] || {};
+ this.addTracks(tracks);
+ },
+ addTracks: function(tracks){
+ tracks.each(function(track){
+ var data = $H(track).values().first();
+ this.tracks.push($H({
+ ids: $H(track).keys().first(),
+ effect: Effect.Morph,
+ options: { style: data }
+ }));
+ }.bind(this));
+ return this;
+ },
+ 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)) });
+ }).flatten(),
+ this.options
+ );
+ }
+});
+
+Element.CSS_PROPERTIES = $w(
+ 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' +
+ 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' +
+ 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' +
+ 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' +
+ 'fontSize fontWeight height left letterSpacing lineHeight ' +
+ 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+
+ 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' +
+ 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' +
+ 'right textIndent top width wordSpacing zIndex');
+
+Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
+
+String.prototype.parseStyle = function(){
+ var element = Element.extend(document.createElement('div'));
+ element.innerHTML = '<div style="' + this +
'"></div>';
+ var style = element.down().style, styleRules = $H();
+
+ Element.CSS_PROPERTIES.each(function(property){
+ if(style[property]) styleRules[property] = style[property];
+ });
+ if(/MSIE/.test(navigator.userAgent) && !window.opera &&
this.indexOf('opacity') > -1) {
+ styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
+ }
+ return styleRules;
+};
+
+Element.morph = function(element, style) {
+ new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {}));
+ return element;
+};
+
['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
-
'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
+ 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(
function(f) { Element.Methods[f] = Element[f]; }
);
Deleted: trunk/theme/src/bin/portal-ajax-war/js/portal/event.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/event.js 2007-03-31 14:21:37 UTC (rev
6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/event.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -1,247 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*
-* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
-*/
-
-var o_el_regionA = new Array();
-var o_el_regionB = new Array();
-
-/**
- AJAX Send function. Assembles post data, and handles process
- **/
-function sendData(action, windowId, fromPos, fromRegion, toPos, toRegion)
-{
- var options = {
- method: 'post',
- postBody: 'action=' + action + '&windowId=' + windowId +
'&fromPos=' + fromPos + '&fromRegion=' + fromRegion +
'&toPos=' + toPos + '&toRegion=' + toRegion,
- onSuccess: function(t)
- {
-// a = document.getElementById("ReqProgressIndicator");
-// document.body.removeChild(a);
- },
- onSuccess: function(t)
- {
-// a = document.getElementById("ReqProgressIndicator");
-// document.body.removeChild(a);
- },
- on404: function(t)
- {
-// a = document.getElementById("ReqProgressIndicator");
-// document.body.removeChild(a);
- alert('Error 404: location "' + t.statusText + '" was not
found.');
- },
- onFailure: function(t)
- {
-// a = document.getElementById("ReqProgressIndicator");
-// document.body.removeChild(a);
- alert('Error ' + t.status + ' -- ' + t.statusText);
- },
- onLoading: function(t)
- {
- }
- }
-
- new Ajax.Request(remote_server_url, options);
-
-/*
- a = document.createElement("div");
- a.id = "ReqProgressIndicator";
- a.style.position = "absolute";
- a.style.left = "50%";
- a.style.bottom = "50%";
- a.style.width = "200px";
- a.style.height = "20px"
- a.style.verticalAlign = "bottom";
- a.style.display = '';
- a.innerHTML = "<img style='VERTICAL-ALIGN:bottom'
src='images/roller.gif'>";
- document.body.appendChild(a);
-*/
-}
-
-/**
- Class that tracks window movement and updates DOM on move end.
- **/
-try
-{
- var WindowMoveObserver = Class.create();
- WindowMoveObserver.prototype =
- {
- initialize: function(element)
- {
- this.element = $(element);
- },
- onStart: function()
- {
- },
- onEnd: function()
- {
- var children = this.element.childNodes;
- for(var i = 0; i < children.length; i = i + 1)
- {
- if(Draggables.activeDraggable.element == children[i])
- {
- fromPos = findWindowPos(children[i]);
- fromRegion = findWindowRegion(children[i]);
-
- //alert("Moved: " + thischild.id + " from: " +
fromRegion + " pos: " + fromPos);
- //alert("Moved: " + thischild.id + " to: " +
this.element.id + " pos: " + i);
-
- // window moved, update DOM
- updateDOM();
-
- // send Data
- sendData('windowmove', children[i].id, fromPos, fromRegion, i,
this.element.id);
- break;
- // or FF continues looping.
- }
- }
- }
- }
-}
-catch(e)
-{
- alert(e);
-}
-
-/**
- Creates sortables (drag/drop windows), attach observers and initialize the DOM
- **/
-try
-{
- Sortable.create("regionA",
{dropOnEmpty:true,handle:'handle',tag:'div',containment:["regionA","regionB"],constraint:false,
ghosting: false,
- onChange: function(el)
- {
- },
- onUpdate: function (el)
- {
- }
- });
-
- Sortable.create("regionB",
{dropOnEmpty:true,handle:'handle',tag:'div',containment:["regionA","regionB"],constraint:false,
ghosting: false,
- onChange: function(el)
- {
- },
- onUpdate: function (el)
- {
- }
- });
-
- // attach observers to regions
- Draggables.addObserver(new WindowMoveObserver($('regionA')));
- Draggables.addObserver(new WindowMoveObserver($('regionB')));
-
- // initialize DOM
- updateDOM();
-}
-catch(e)
-{
- alert(e);
-}
-
-/**
- Update th DOM order in our global array. Later used to compare move from/to
- **/
-function updateDOM()
-{
- try
- {
- // reset to 0
- o_el_regionA = new Array();
- o_el_regionB = new Array();
-
- var regionA = this.document.getElementById("regionA");
- for(var i = 0; i < regionA.childNodes.length; i = i + 1)
- {
- o_el_regionA[i] = regionA.childNodes[i];
- }
- var regionB = this.document.getElementById("regionB");
- for(var i = 0; i < regionB.childNodes.length; i = i + 1)
- {
- o_el_regionB[i] = regionB.childNodes[i];
- }
- //alert("New A: " + o_el_regionA.length + " New B: " +
o_el_regionB.length);
- }
- catch(e)
- {
- alert("Error updateDOM: " + e);
- }
-}
-
-/**
- Returns theoriginal Window position for a given window element
- **/
-function findWindowPos(element)
-{
- for(var i = 0; i < o_el_regionA.length; i = i + 1)
- {
- currelement = o_el_regionA[i];
- if(element == currelement)
- {
- return i;
- }
- }
- for(var i = 0; i < o_el_regionB.length; i = i + 1)
- {
- currelement = o_el_regionB[i];
- if(element = currelement)
- {
- return i;
- }
- }
-}
-
-/**
- Returns the original region where a window resided.
- **/
-function findWindowRegion(element)
-{
- for(var i = 0; i < o_el_regionA.length; i = i + 1)
- {
- currelement = o_el_regionA[i];
- if(element == currelement)
- {
- return "regionA";
- }
- }
- for(var i = 0; i < o_el_regionB.length; i = i + 1)
- {
- currelement = o_el_regionB[i];
- if(element = currelement)
- {
- return "regionB";
- }
- }
-}
-
-/**
- Removes window from page and calls server-side
- **/
-function removeWindow(elementId)
-{
- var effectElement = document.getElementById(elementId)
- new Effect.BlindUp(effectElement);
-
- //removeElement(effectElement);
-
- sendData('windowremove', elementId);
-}
-
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/prototype.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/prototype.js 2007-03-31 14:21:37 UTC
(rev 6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/prototype.js 2007-03-31 14:25:31 UTC
(rev 6896)
@@ -1,5 +1,5 @@
-/* Prototype JavaScript framework, version 1.5.0_rc1
- * (c) 2005 Sam Stephenson <sam(a)conio.net>
+/* Prototype JavaScript framework, version 1.5.0
+ * (c) 2005-2007 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site:
http://prototype.conio.net/
@@ -7,11 +7,14 @@
/*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.5.0_rc1',
+ Version: '1.5.0',
+ BrowserFeatures: {
+ XPath: !!document.evaluate
+ },
+
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
-
emptyFunction: function() {},
- K: function(x) {return x}
+ K: function(x) { return x }
}
var Class = {
@@ -34,8 +37,8 @@
Object.extend(Object, {
inspect: function(object) {
try {
- if (object == undefined) return 'undefined';
- if (object == null) return 'null';
+ if (object === undefined) return 'undefined';
+ if (object === null) return 'null';
return object.inspect ? object.inspect() : object.toString();
} catch (e) {
if (e instanceof RangeError) return '...';
@@ -97,7 +100,7 @@
these: function() {
var returnValue;
- for (var i = 0; i < arguments.length; i++) {
+ for (var i = 0, length = arguments.length; i < length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
@@ -142,6 +145,10 @@
}
}
}
+String.interpret = function(value){
+ return value == null ? '' : String(value);
+}
+
Object.extend(String.prototype, {
gsub: function(pattern, replacement) {
var result = '', source = this, match;
@@ -150,7 +157,7 @@
while (source.length > 0) {
if (match = source.match(pattern)) {
result += source.slice(0, match.index);
- result += (replacement(match) || '').toString();
+ result += String.interpret(replacement(match));
source = source.slice(match.index + match[0].length);
} else {
result += source, source = '';
@@ -215,16 +222,28 @@
unescapeHTML: function() {
var div = document.createElement('div');
div.innerHTML = this.stripTags();
- return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
+ return div.childNodes[0] ? (div.childNodes.length > 1 ?
+ $A(div.childNodes).inject('',function(memo,node){ return
memo+node.nodeValue }) :
+ div.childNodes[0].nodeValue) : '';
},
- toQueryParams: function() {
- var pairs = this.match(/^\??(.*)$/)[1].split('&');
- return pairs.inject({}, function(params, pairString) {
- var pair = pairString.split('=');
- var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;
- params[decodeURIComponent(pair[0])] = value;
- return params;
+ toQueryParams: function(separator) {
+ var match = this.strip().match(/([^?#]*)(#.*)?$/);
+ if (!match) return {};
+
+ return match[1].split(separator || '&').inject({}, function(hash, pair)
{
+ if ((pair = pair.split('='))[0]) {
+ var name = decodeURIComponent(pair[0]);
+ var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;
+
+ if (hash[name] !== undefined) {
+ if (hash[name].constructor != Array)
+ hash[name] = [hash[name]];
+ if (value) hash[name].push(value);
+ }
+ else hash[name] = value;
+ }
+ return hash;
});
},
@@ -232,22 +251,37 @@
return this.split('');
},
+ succ: function() {
+ return this.slice(0, this.length - 1) +
+ String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
+ },
+
camelize: function() {
- var oStringList = this.split('-');
- if (oStringList.length == 1) return oStringList[0];
+ var parts = this.split('-'), len = parts.length;
+ if (len == 1) return parts[0];
- var camelizedString = this.indexOf('-') == 0
- ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
- : oStringList[0];
+ var camelized = this.charAt(0) == '-'
+ ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
+ : parts[0];
- for (var i = 1, len = oStringList.length; i < len; i++) {
- var s = oStringList[i];
- camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
- }
+ for (var i = 1; i < len; i++)
+ camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
- return camelizedString;
+ return camelized;
},
+ capitalize: function(){
+ return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
+ },
+
+ underscore: function() {
+ return this.gsub(/::/,
'/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
+ },
+
+ dasherize: function() {
+ return this.gsub(/_/,'-');
+ },
+
inspect: function(useDoubleQuotes) {
var escapedString = this.replace(/\\/g, '\\\\');
if (useDoubleQuotes)
@@ -277,7 +311,7 @@
return this.template.gsub(this.pattern, function(match) {
var before = match[1];
if (before == '\\') return match[2];
- return before + (object[match[3]] || '').toString();
+ return before + String.interpret(object[match[3]]);
});
}
}
@@ -299,8 +333,16 @@
} catch (e) {
if (e != $break) throw e;
}
+ return this;
},
+ eachSlice: function(number, iterator) {
+ var index = -number, slices = [], array = this.toArray();
+ while ((index += number) < array.length)
+ slices.push(array.slice(index, index+number));
+ return slices.map(iterator);
+ },
+
all: function(iterator) {
var result = true;
this.each(function(value, index) {
@@ -322,12 +364,12 @@
collect: function(iterator) {
var results = [];
this.each(function(value, index) {
- results.push(iterator(value, index));
+ results.push((iterator || Prototype.K)(value, index));
});
return results;
},
- detect: function (iterator) {
+ detect: function(iterator) {
var result;
this.each(function(value, index) {
if (iterator(value, index)) {
@@ -368,6 +410,14 @@
return found;
},
+ inGroupsOf: function(number, fillWith) {
+ fillWith = fillWith === undefined ? null : fillWith;
+ return this.eachSlice(number, function(slice) {
+ while(slice.length < number) slice.push(fillWith);
+ return slice;
+ });
+ },
+
inject: function(memo, iterator) {
this.each(function(value, index) {
memo = iterator(memo, value, index);
@@ -377,7 +427,7 @@
invoke: function(method) {
var args = $A(arguments).slice(1);
- return this.collect(function(value) {
+ return this.map(function(value) {
return value[method].apply(value, args);
});
},
@@ -429,7 +479,7 @@
},
sortBy: function(iterator) {
- return this.collect(function(value, index) {
+ return this.map(function(value, index) {
return {value: value, criteria: iterator(value, index)};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
@@ -438,7 +488,7 @@
},
toArray: function() {
- return this.collect(Prototype.K);
+ return this.map();
},
zip: function() {
@@ -452,6 +502,10 @@
});
},
+ size: function() {
+ return this.toArray().length;
+ },
+
inspect: function() {
return '#<Enumerable:' + this.toArray().inspect() + '>';
}
@@ -470,7 +524,7 @@
return iterable.toArray();
} else {
var results = [];
- for (var i = 0; i < iterable.length; i++)
+ for (var i = 0, length = iterable.length; i < length; i++)
results.push(iterable[i]);
return results;
}
@@ -483,7 +537,7 @@
Object.extend(Array.prototype, {
_each: function(iterator) {
- for (var i = 0; i < this.length; i++)
+ for (var i = 0, length = this.length; i < length; i++)
iterator(this[i]);
},
@@ -502,7 +556,7 @@
compact: function() {
return this.select(function(value) {
- return value != undefined || value != null;
+ return value != null;
});
},
@@ -521,7 +575,7 @@
},
indexOf: function(object) {
- for (var i = 0; i < this.length; i++)
+ for (var i = 0, length = this.length; i < length; i++)
if (this[i] == object) return i;
return -1;
},
@@ -540,15 +594,78 @@
});
},
+ clone: function() {
+ return [].concat(this);
+ },
+
+ size: function() {
+ return this.length;
+ },
+
inspect: function() {
return '[' + this.map(Object.inspect).join(', ') + ']';
}
});
-var Hash = {
+
+Array.prototype.toArray = Array.prototype.clone;
+
+function $w(string){
+ string = string.strip();
+ return string ? string.split(/\s+/) : [];
+}
+
+if(window.opera){
+ Array.prototype.concat = function(){
+ var array = [];
+ for(var i = 0, length = this.length; i < length; i++) array.push(this[i]);
+ for(var i = 0, length = arguments.length; i < length; i++) {
+ if(arguments[i].constructor == Array) {
+ for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
+ array.push(arguments[i][j]);
+ } else {
+ array.push(arguments[i]);
+ }
+ }
+ return array;
+ }
+}
+var Hash = function(obj) {
+ Object.extend(this, obj || {});
+};
+
+Object.extend(Hash, {
+ toQueryString: function(obj) {
+ var parts = [];
+
+ this.prototype._each.call(obj, function(pair) {
+ if (!pair.key) return;
+
+ if (pair.value && pair.value.constructor == Array) {
+ var values = pair.value.compact();
+ if (values.length < 2) pair.value = values.reduce();
+ else {
+ key = encodeURIComponent(pair.key);
+ values.each(function(value) {
+ value = value != undefined ? encodeURIComponent(value) : '';
+ parts.push(key + '=' + encodeURIComponent(value));
+ });
+ return;
+ }
+ }
+ if (pair.value == undefined) pair[1] = '';
+ parts.push(pair.map(encodeURIComponent).join('='));
+ });
+
+ return parts.join('&');
+ }
+});
+
+Object.extend(Hash.prototype, Enumerable);
+Object.extend(Hash.prototype, {
_each: function(iterator) {
for (var key in this) {
var value = this[key];
- if (typeof value == 'function') continue;
+ if (value && value == Hash.prototype[key]) continue;
var pair = [key, value];
pair.key = key;
@@ -566,16 +683,30 @@
},
merge: function(hash) {
- return $H(hash).inject($H(this), function(mergedHash, pair) {
+ return $H(hash).inject(this, function(mergedHash, pair) {
mergedHash[pair.key] = pair.value;
return mergedHash;
});
},
+ 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 (result.constructor != Array) result = [result];
+ result.push(value)
+ }
+ }
+ delete this[arguments[i]];
+ }
+ return result;
+ },
+
toQueryString: function() {
- return this.map(function(pair) {
- return pair.map(encodeURIComponent).join('=');
- }).join('&');
+ return Hash.toQueryString(this);
},
inspect: function() {
@@ -583,14 +714,12 @@
return pair.map(Object.inspect).join(': ');
}).join(', ') + '}>';
}
-}
+});
function $H(object) {
- var hash = Object.extend({}, object || {});
- Object.extend(hash, Enumerable);
- Object.extend(hash, Hash);
- return hash;
-}
+ if (object && object.constructor == Hash) return object;
+ return new Hash(object);
+};
ObjectRange = Class.create();
Object.extend(ObjectRange.prototype, Enumerable);
Object.extend(ObjectRange.prototype, {
@@ -640,18 +769,18 @@
this.responders._each(iterator);
},
- register: function(responderToAdd) {
- if (!this.include(responderToAdd))
- this.responders.push(responderToAdd);
+ register: function(responder) {
+ if (!this.include(responder))
+ this.responders.push(responder);
},
- unregister: function(responderToRemove) {
- this.responders = this.responders.without(responderToRemove);
+ unregister: function(responder) {
+ this.responders = this.responders.without(responder);
},
dispatch: function(callback, request, transport, json) {
this.each(function(responder) {
- if (responder[callback] && typeof responder[callback] ==
'function') {
+ if (typeof responder[callback] == 'function') {
try {
responder[callback].apply(responder, [request, transport, json]);
} catch (e) {}
@@ -666,7 +795,6 @@
onCreate: function() {
Ajax.activeRequestCount++;
},
-
onComplete: function() {
Ajax.activeRequestCount--;
}
@@ -679,19 +807,14 @@
method: 'post',
asynchronous: true,
contentType: 'application/x-www-form-urlencoded',
+ encoding: 'UTF-8',
parameters: ''
}
Object.extend(this.options, options || {});
- },
- responseIsSuccess: function() {
- return this.transport.status == undefined
- || this.transport.status == 0
- || (this.transport.status >= 200 && this.transport.status < 300);
- },
-
- responseIsFailure: function() {
- return !this.responseIsSuccess();
+ this.options.method = this.options.method.toLowerCase();
+ if (typeof this.options.parameters == 'string')
+ this.options.parameters = this.options.parameters.toQueryParams();
}
}
@@ -700,6 +823,8 @@
['Uninitialized', 'Loading', 'Loaded', 'Interactive',
'Complete'];
Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
+ _complete: false,
+
initialize: function(url, options) {
this.transport = Ajax.getTransport();
this.setOptions(options);
@@ -707,23 +832,27 @@
},
request: function(url) {
- var parameters = this.options.parameters || '';
- if (parameters.length > 0) parameters += '&_=';
+ this.url = url;
+ this.method = this.options.method;
+ var params = this.options.parameters;
- /* Simulate other verbs over post */
- if (this.options.method != 'get' && this.options.method !=
'post') {
- parameters += (parameters.length > 0 ? '&' : '') +
'_method=' + this.options.method;
- this.options.method = 'post';
+ if (!['get', 'post'].include(this.method)) {
+ // simulate other verbs over post
+ params['_method'] = this.method;
+ this.method = 'post';
}
+ params = Hash.toQueryString(params);
+ if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params +=
'&_='
+
+ // when GET, append parameters to URL
+ if (this.method == 'get' && params)
+ this.url += (this.url.indexOf('?') > -1 ? '&' : '?')
+ params;
+
try {
- this.url = url;
- if (this.options.method == 'get' && parameters.length > 0)
- this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
-
Ajax.Responders.dispatch('onCreate', this, this.transport);
- this.transport.open(this.options.method, this.url,
+ this.transport.open(this.method.toUpperCase(), this.url,
this.options.asynchronous);
if (this.options.asynchronous)
@@ -732,97 +861,119 @@
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();
- var body = this.options.postBody ? this.options.postBody : parameters;
- this.transport.send(this.options.method == 'post' ? body : null);
+ var body = this.method == 'post' ? (this.options.postBody || params) :
null;
+ this.transport.send(body);
+
/* Force Firefox to handle ready state 4 for synchronous requests */
if (!this.options.asynchronous && this.transport.overrideMimeType)
this.onStateChange();
- } catch (e) {
+ }
+ catch (e) {
this.dispatchException(e);
}
},
+ onStateChange: function() {
+ var readyState = this.transport.readyState;
+ if (readyState > 1 && !((readyState == 4) && this._complete))
+ this.respondToReadyState(this.transport.readyState);
+ },
+
setRequestHeaders: function() {
- var requestHeaders =
- ['X-Requested-With', 'XMLHttpRequest',
- 'X-Prototype-Version', Prototype.Version,
- 'Accept', 'text/javascript, text/html, application/xml, text/xml,
*/*'];
+ var headers = {
+ 'X-Requested-With': 'XMLHttpRequest',
+ 'X-Prototype-Version': Prototype.Version,
+ 'Accept': 'text/javascript, text/html, application/xml, text/xml,
*/*'
+ };
- if (this.options.method == 'post') {
- requestHeaders.push('Content-type', this.options.contentType);
+ if (this.method == 'post') {
+ headers['Content-type'] = this.options.contentType +
+ (this.options.encoding ? '; charset=' + this.options.encoding :
'');
- /* Force "Connection: close" for Mozilla browsers to work around
- * a bug where XMLHttpReqeuest sends an incorrect Content-length
- * header. See Mozilla Bugzilla #246651.
+ /* Force "Connection: close" for older Mozilla browsers to work
+ * around a bug where XMLHttpRequest sends an incorrect
+ * Content-length header. See Mozilla Bugzilla #246651.
*/
- if (this.transport.overrideMimeType)
- requestHeaders.push('Connection', 'close');
+ if (this.transport.overrideMimeType &&
+ (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
+ headers['Connection'] = 'close';
}
- if (this.options.requestHeaders)
- requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
+ // user-defined headers
+ if (typeof this.options.requestHeaders == 'object') {
+ var extras = this.options.requestHeaders;
- for (var i = 0; i < requestHeaders.length; i += 2)
- this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
- },
+ if (typeof extras.push == 'function')
+ for (var i = 0, length = extras.length; i < length; i += 2)
+ headers[extras[i]] = extras[i+1];
+ else
+ $H(extras).each(function(pair) { headers[pair.key] = pair.value });
+ }
- onStateChange: function() {
- var readyState = this.transport.readyState;
- if (readyState != 1)
- this.respondToReadyState(this.transport.readyState);
+ for (var name in headers)
+ this.transport.setRequestHeader(name, headers[name]);
},
- header: function(name) {
- try {
- return this.transport.getResponseHeader(name);
- } catch (e) {}
+ success: function() {
+ return !this.transport.status
+ || (this.transport.status >= 200 && this.transport.status < 300);
},
- evalJSON: function() {
- try {
- return eval('(' + this.header('X-JSON') + ')');
- } catch (e) {}
- },
-
- evalResponse: function() {
- try {
- return eval(this.transport.responseText);
- } catch (e) {
- this.dispatchException(e);
- }
- },
-
respondToReadyState: function(readyState) {
- var event = Ajax.Request.Events[readyState];
+ var state = Ajax.Request.Events[readyState];
var transport = this.transport, json = this.evalJSON();
- if (event == 'Complete') {
+ if (state == 'Complete') {
try {
+ this._complete = true;
(this.options['on' + this.transport.status]
- || this.options['on' + (this.responseIsSuccess() ? 'Success' :
'Failure')]
+ || this.options['on' + (this.success() ? 'Success' :
'Failure')]
|| Prototype.emptyFunction)(transport, json);
} catch (e) {
this.dispatchException(e);
}
- if ((this.header('Content-type') ||
'').match(/^text\/javascript/i))
- this.evalResponse();
+ if ((this.getHeader('Content-type') || 'text/javascript').strip().
+ match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
+ this.evalResponse();
}
try {
- (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
- Ajax.Responders.dispatch('on' + event, this, transport, json);
+ (this.options['on' + state] || Prototype.emptyFunction)(transport, json);
+ Ajax.Responders.dispatch('on' + state, this, transport, json);
} catch (e) {
this.dispatchException(e);
}
- /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
- if (event == 'Complete')
+ if (state == 'Complete') {
+ // avoid memory leak in MSIE: clean up
this.transport.onreadystatechange = Prototype.emptyFunction;
+ }
},
+ getHeader: function(name) {
+ try {
+ return this.transport.getResponseHeader(name);
+ } catch (e) { return null }
+ },
+
+ evalJSON: function() {
+ try {
+ var json = this.getHeader('X-JSON');
+ return json ? eval('(' + json + ')') : null;
+ } catch (e) { return null }
+ },
+
+ evalResponse: function() {
+ try {
+ return eval(this.transport.responseText);
+ } catch (e) {
+ this.dispatchException(e);
+ }
+ },
+
dispatchException: function(exception) {
(this.options.onException || Prototype.emptyFunction)(this, exception);
Ajax.Responders.dispatch('onException', this, exception);
@@ -833,41 +984,37 @@
Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
initialize: function(container, url, options) {
- this.containers = {
- success: container.success ? $(container.success) : $(container),
- failure: container.failure ? $(container.failure) :
- (container.success ? null : $(container))
+ this.container = {
+ success: (container.success || container),
+ failure: (container.failure || (container.success ? null : container))
}
this.transport = Ajax.getTransport();
this.setOptions(options);
var onComplete = this.options.onComplete || Prototype.emptyFunction;
- this.options.onComplete = (function(transport, object) {
+ this.options.onComplete = (function(transport, param) {
this.updateContent();
- onComplete(transport, object);
+ onComplete(transport, param);
}).bind(this);
this.request(url);
},
updateContent: function() {
- var receiver = this.responseIsSuccess() ?
- this.containers.success : this.containers.failure;
+ var receiver = this.container[this.success() ? 'success' :
'failure'];
var response = this.transport.responseText;
- if (!this.options.evalScripts)
- response = response.stripScripts();
+ if (!this.options.evalScripts) response = response.stripScripts();
- if (receiver) {
- if (this.options.insertion) {
+ if (receiver = $(receiver)) {
+ if (this.options.insertion)
new this.options.insertion(receiver, response);
- } else {
- Element.update(receiver, response);
- }
+ else
+ receiver.update(response);
}
- if (this.responseIsSuccess()) {
+ if (this.success()) {
if (this.onComplete)
setTimeout(this.onComplete.bind(this), 10);
}
@@ -916,25 +1063,43 @@
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));
+function $(element) {
+ if (arguments.length > 1) {
+ for (var i = 0, elements = [], length = arguments.length; i < length; i++)
+ elements.push($(arguments[i]));
+ return elements;
}
- return results.reduce();
+ if (typeof element == 'string')
+ element = document.getElementById(element);
+ return Element.extend(element);
}
+if (Prototype.BrowserFeatures.XPath) {
+ document._getElementsByXPath = function(expression, parentElement) {
+ var results = [];
+ var query = document.evaluate(expression, $(parentElement) || document,
+ null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+ for (var i = 0, length = query.snapshotLength; i < length; i++)
+ results.push(query.snapshotItem(i));
+ return 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(Element.extend(child));
+ if (Prototype.BrowserFeatures.XPath) {
+ var q = ".//*[contains(concat(' ', @class, ' '), ' " +
className + " ')]";
+ return document._getElementsByXPath(q, parentElement);
+ } else {
+ var children = ($(parentElement) ||
document.body).getElementsByTagName('*');
+ var elements = [], child;
+ for (var i = 0, length = children.length; i < length; i++) {
+ child = children[i];
+ if (Element.hasClassName(child, className))
+ elements.push(Element.extend(child));
+ }
return elements;
- });
-}
+ }
+};
/*--------------------------------------------------------------------------*/
@@ -942,8 +1107,7 @@
var Element = new Object();
Element.extend = function(element) {
- if (!element) return;
- if (_nativeExtensions || element.nodeType == 3) return element;
+ if (!element || _nativeExtensions || element.nodeType == 3) return element;
if (!element._extended && element.tagName && element != window) {
var methods = Object.clone(Element.Methods), cache = Element.extend.cache;
@@ -953,16 +1117,18 @@
if (['INPUT', 'TEXTAREA',
'SELECT'].include(element.tagName))
Object.extend(methods, Form.Element.Methods);
+ Object.extend(methods, Element.Methods.Simulated);
+
for (var property in methods) {
var value = methods[property];
- if (typeof value == 'function')
+ if (typeof value == 'function' && !(property in element))
element[property] = cache.findOrStore(value);
}
}
element._extended = true;
return element;
-}
+};
Element.extend.cache = {
findOrStore: function(value) {
@@ -970,7 +1136,7 @@
return value.apply(null, [this].concat($A(arguments)));
}
}
-}
+};
Element.Methods = {
visible: function(element) {
@@ -1000,6 +1166,7 @@
},
update: function(element, html) {
+ html = typeof html == 'undefined' ? '' : html.toString();
$(element).innerHTML = html.stripScripts();
setTimeout(function() {html.evalScripts()}, 10);
return element;
@@ -1007,6 +1174,7 @@
replace: function(element, html) {
element = $(element);
+ html = typeof html == 'undefined' ? '' : html.toString();
if (element.outerHTML) {
element.outerHTML = html.stripScripts();
} else {
@@ -1044,10 +1212,16 @@
},
descendants: function(element) {
- element = $(element);
- return $A(element.getElementsByTagName('*'));
+ return $A($(element).getElementsByTagName('*'));
},
+ immediateDescendants: function(element) {
+ if (!(element = $(element).firstChild)) return [];
+ while (element && element.nodeType != 1) element = element.nextSibling;
+ if (element) return [element].concat($(element).nextSiblings());
+ return [];
+ },
+
previousSiblings: function(element) {
return $(element).recursivelyCollect('previousSibling');
},
@@ -1062,10 +1236,9 @@
},
match: function(element, selector) {
- element = $(element);
if (typeof selector == 'string')
selector = new Selector(selector);
- return selector.match(element);
+ return selector.match($(element));
},
up: function(element, expression, index) {
@@ -1090,22 +1263,41 @@
},
getElementsByClassName: function(element, className) {
- element = $(element);
return document.getElementsByClassName(className, element);
},
- getHeight: function(element) {
+ readAttribute: function(element, name) {
element = $(element);
- return element.offsetHeight;
+ if (document.all && !window.opera) {
+ var t = Element._attributeTranslations;
+ if (t.values[name]) return t.values[name](element, name);
+ if (t.names[name]) name = t.names[name];
+ var attribute = element.attributes[name];
+ if(attribute) return attribute.nodeValue;
+ }
+ return element.getAttribute(name);
},
+ getHeight: function(element) {
+ return $(element).getDimensions().height;
+ },
+
+ getWidth: function(element) {
+ return $(element).getDimensions().width;
+ },
+
classNames: function(element) {
return new Element.ClassNames(element);
},
hasClassName: function(element, className) {
if (!(element = $(element))) return;
- return Element.classNames(element).include(className);
+ var elementClassName = element.className;
+ if (elementClassName.length == 0) return false;
+ if (elementClassName == className ||
+ elementClassName.match(new RegExp("(^|\\s)" + className +
"(\\s|$)")))
+ return true;
+ return false;
},
addClassName: function(element, className) {
@@ -1120,6 +1312,12 @@
return element;
},
+ toggleClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ Element.classNames(element)[element.hasClassName(className) ? 'remove' :
'add'](className);
+ return element;
+ },
+
observe: function() {
Event.observe.apply(Event, arguments);
return $A(arguments).first();
@@ -1147,7 +1345,7 @@
return $(element).innerHTML.match(/^\s*$/);
},
- childOf: function(element, ancestor) {
+ descendantOf: function(element, ancestor) {
element = $(element), ancestor = $(ancestor);
while (element = element.parentNode)
if (element == ancestor) return true;
@@ -1156,40 +1354,69 @@
scrollTo: function(element) {
element = $(element);
- var x = element.x ? element.x : element.offsetLeft,
- y = element.y ? element.y : element.offsetTop;
- window.scrollTo(x, y);
+ var pos = Position.cumulativeOffset(element);
+ window.scrollTo(pos[0], pos[1]);
return element;
},
getStyle: function(element, style) {
element = $(element);
- var value = element.style[style.camelize()];
+ if (['float','cssFloat'].include(style))
+ style = (typeof element.style.styleFloat != 'undefined' ?
'styleFloat' : 'cssFloat');
+ style = style.camelize();
+ var value = element.style[style];
if (!value) {
if (document.defaultView && document.defaultView.getComputedStyle) {
var css = document.defaultView.getComputedStyle(element, null);
- value = css ? css.getPropertyValue(style) : null;
+ value = css ? css[style] : null;
} else if (element.currentStyle) {
- value = element.currentStyle[style.camelize()];
+ value = element.currentStyle[style];
}
}
+ if((value == 'auto') &&
['width','height'].include(style) &&
(element.getStyle('display') != 'none'))
+ value = element['offset'+style.capitalize()] + 'px';
+
if (window.opera && ['left', 'top', 'right',
'bottom'].include(style))
if (Element.getStyle(element, 'position') == 'static') value =
'auto';
-
+ if(style == 'opacity') {
+ if(value) return parseFloat(value);
+ if(value = (element.getStyle('filter') ||
'').match(/alpha\(opacity=(.*)\)/))
+ if(value[1]) return parseFloat(value[1]) / 100;
+ return 1.0;
+ }
return value == 'auto' ? null : value;
},
setStyle: function(element, style) {
element = $(element);
- for (var name in style)
- element.style[name.camelize()] = style[name];
+ for (var name in style) {
+ var value = style[name];
+ if(name == 'opacity') {
+ if (value == 1) {
+ value = (/Gecko/.test(navigator.userAgent) &&
+ !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0;
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter =
element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
+ } else if(value === '') {
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter =
element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
+ } else {
+ if(value < 0.00001) value = 0;
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter =
element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
+ 'alpha(opacity='+value*100+')';
+ }
+ } else if(['float','cssFloat'].include(name)) name = (typeof
element.style.styleFloat != 'undefined') ? 'styleFloat' :
'cssFloat';
+ element.style[name.camelize()] = value;
+ }
return element;
},
getDimensions: function(element) {
element = $(element);
- if (Element.getStyle(element, 'display') != 'none')
+ var display = $(element).getStyle('display');
+ if (display != 'none' && display != null) // Safari bug
return {width: element.offsetWidth, height: element.offsetHeight};
// All *Width and *Height properties give 0 on elements with display none,
@@ -1197,12 +1424,13 @@
var els = element.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
+ var originalDisplay = els.display;
els.visibility = 'hidden';
els.position = 'absolute';
- els.display = '';
+ els.display = 'block';
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
- els.display = 'none';
+ els.display = originalDisplay;
els.position = originalPosition;
els.visibility = originalVisibility;
return {width: originalWidth, height: originalHeight};
@@ -1239,7 +1467,7 @@
makeClipping: function(element) {
element = $(element);
- if (element._overflow) return;
+ if (element._overflow) return element;
element._overflow = element.style.overflow || 'auto';
if ((Element.getStyle(element, 'overflow') || 'visible') !=
'hidden')
element.style.overflow = 'hidden';
@@ -1248,19 +1476,73 @@
undoClipping: function(element) {
element = $(element);
- if (!element._overflow) return;
+ if (!element._overflow) return element;
element.style.overflow = element._overflow == 'auto' ? '' :
element._overflow;
element._overflow = null;
return element;
}
-}
+};
+Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf});
+
+Element._attributeTranslations = {};
+
+Element._attributeTranslations.names = {
+ colspan: "colSpan",
+ rowspan: "rowSpan",
+ valign: "vAlign",
+ datetime: "dateTime",
+ accesskey: "accessKey",
+ tabindex: "tabIndex",
+ enctype: "encType",
+ maxlength: "maxLength",
+ readonly: "readOnly",
+ longdesc: "longDesc"
+};
+
+Element._attributeTranslations.values = {
+ _getAttr: function(element, attribute) {
+ return element.getAttribute(attribute, 2);
+ },
+
+ _flag: function(element, attribute) {
+ return $(element).hasAttribute(attribute) ? attribute : null;
+ },
+
+ style: function(element) {
+ return element.style.cssText.toLowerCase();
+ },
+
+ title: function(element) {
+ var node = element.getAttributeNode('title');
+ return node.specified ? node.nodeValue : null;
+ }
+};
+
+Object.extend(Element._attributeTranslations.values, {
+ href: Element._attributeTranslations.values._getAttr,
+ src: Element._attributeTranslations.values._getAttr,
+ disabled: Element._attributeTranslations.values._flag,
+ checked: Element._attributeTranslations.values._flag,
+ readonly: Element._attributeTranslations.values._flag,
+ multiple: Element._attributeTranslations.values._flag
+});
+
+Element.Methods.Simulated = {
+ hasAttribute: function(element, attribute) {
+ var t = Element._attributeTranslations;
+ attribute = t.names[attribute] || attribute;
+ return $(element).getAttributeNode(attribute).specified;
+ }
+};
+
// IE is missing .innerHTML support for TABLE-related elements
-if(document.all){
+if (document.all && !window.opera){
Element.Methods.update = function(element, html) {
element = $(element);
+ html = typeof html == 'undefined' ? '' : html.toString();
var tagName = element.tagName.toUpperCase();
- if (['THEAD','TBODY','TR','TD'].indexOf(tagName) >
-1) {
+ if (['THEAD','TBODY','TR','TD'].include(tagName)) {
var div = document.createElement('div');
switch (tagName) {
case 'THEAD':
@@ -1289,34 +1571,36 @@
setTimeout(function() {html.evalScripts()}, 10);
return element;
}
-}
+};
Object.extend(Element, Element.Methods);
var _nativeExtensions = false;
-if (!window.HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
- /* Emulate HTMLElement, HTMLFormElement, HTMLInputElement, HTMLTextAreaElement,
- and HTMLSelectElement in Safari */
+if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))
['', 'Form', 'Input', 'TextArea',
'Select'].each(function(tag) {
- var klass = window['HTML' + tag + 'Element'] = {};
+ var className = 'HTML' + tag + 'Element';
+ if(window[className]) return;
+ var klass = window[className] = {};
klass.prototype = document.createElement(tag ? tag.toLowerCase() :
'div').__proto__;
});
-}
Element.addMethods = function(methods) {
Object.extend(Element.Methods, methods || {});
- function copy(methods, destination) {
+ function copy(methods, destination, onlyIfAbsent) {
+ onlyIfAbsent = onlyIfAbsent || false;
var cache = Element.extend.cache;
for (var property in methods) {
var value = methods[property];
- destination[property] = cache.findOrStore(value);
+ if (!onlyIfAbsent || !(property in destination))
+ destination[property] = cache.findOrStore(value);
}
}
if (typeof HTMLElement != 'undefined') {
copy(Element.Methods, HTMLElement.prototype);
+ copy(Element.Methods.Simulated, HTMLElement.prototype, true);
copy(Form.Methods, HTMLFormElement.prototype);
[HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) {
copy(Form.Element.Methods, klass.prototype);
@@ -1343,8 +1627,8 @@
try {
this.element.insertAdjacentHTML(this.adjacency, this.content);
} catch (e) {
- var tagName = this.element.tagName.toLowerCase();
- if (tagName == 'tbody' || tagName == 'tr') {
+ var tagName = this.element.tagName.toUpperCase();
+ if (['TBODY', 'TR'].include(tagName)) {
this.insertContent(this.contentFromAnonymousTable());
} else {
throw e;
@@ -1443,20 +1727,18 @@
add: function(classNameToAdd) {
if (this.include(classNameToAdd)) return;
- this.set(this.toArray().concat(classNameToAdd).join(' '));
+ this.set($A(this).concat(classNameToAdd).join(' '));
},
remove: function(classNameToRemove) {
if (!this.include(classNameToRemove)) return;
- this.set(this.select(function(className) {
- return className != classNameToRemove;
- }).join(' '));
+ this.set($A(this).without(classNameToRemove).join(' '));
},
toString: function() {
- return this.toArray().join(' ');
+ return $A(this).join(' ');
}
-}
+};
Object.extend(Element.ClassNames.prototype, Enumerable);
var Selector = Class.create();
@@ -1503,15 +1785,15 @@
if (params.wildcard)
conditions.push('true');
if (clause = params.id)
- conditions.push('element.id == ' + clause.inspect());
+ conditions.push('element.readAttribute("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() +
')');
+ for (var i = 0, length = clause.length; i < length; i++)
+ conditions.push('element.hasClassName(' + clause[i].inspect() +
')');
if (clause = params.attributes) {
clause.each(function(attribute) {
- var value = 'element.getAttribute(' + attribute.name.inspect() +
')';
+ var value = 'element.readAttribute(' + attribute.name.inspect() +
')';
var splitValueBy = function(delimiter) {
return value + ' && ' + value + '.split(' +
delimiter.inspect() + ')';
}
@@ -1524,7 +1806,7 @@
); break;
case '!=': conditions.push(value + ' != ' +
attribute.value.inspect()); break;
case '':
- case undefined: conditions.push(value + ' != null'); break;
+ case undefined: conditions.push('element.hasAttribute(' +
attribute.name.inspect() + ')'); break;
default: throw 'Unknown operator ' + attribute.operator + '
in selector';
}
});
@@ -1535,6 +1817,7 @@
compileMatcher: function() {
this.match = new Function('element', 'if (!element.tagName) return false;
\
+ element = $(element); \
return ' + this.buildMatchExpression());
},
@@ -1549,7 +1832,7 @@
scope = (scope || document).getElementsByTagName(this.params.tagName ||
'*');
var results = [];
- for (var i = 0; i < scope.length; i++)
+ for (var i = 0, length = scope.length; i < length; i++)
if (this.match(element = scope[i]))
results.push(Element.extend(element));
@@ -1564,7 +1847,7 @@
Object.extend(Selector, {
matchElements: function(elements, expression) {
var selector = new Selector(expression);
- return elements.select(selector.match.bind(selector));
+ return elements.select(selector.match.bind(selector)).map(Element.extend);
},
findElement: function(elements, expression, index) {
@@ -1574,7 +1857,7 @@
findChildElements: function(element, expressions) {
return expressions.map(function(expression) {
- return expression.strip().split(/\s+/).inject([null], function(results, expr) {
+ return
expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null],
function(results, expr) {
var selector = new Selector(expr);
return results.inject([], function(elements, result) {
return elements.concat(selector.findElements(result || element));
@@ -1591,49 +1874,53 @@
reset: function(form) {
$(form).reset();
return form;
+ },
+
+ serializeElements: function(elements, getHash) {
+ var data = elements.inject({}, function(result, element) {
+ if (!element.disabled && element.name) {
+ var key = element.name, value = $(element).getValue();
+ if (value != undefined) {
+ if (result[key]) {
+ if (result[key].constructor != Array) result[key] = [result[key]];
+ result[key].push(value);
+ }
+ else result[key] = value;
+ }
+ }
+ return result;
+ });
+
+ return getHash ? data : Hash.toQueryString(data);
}
};
Form.Methods = {
- serialize: function(form) {
- var elements = Form.getElements($(form));
- var queryComponents = new Array();
-
- for (var i = 0; i < elements.length; i++) {
- var queryComponent = Form.Element.serialize(elements[i]);
- if (queryComponent)
- queryComponents.push(queryComponent);
- }
-
- return queryComponents.join('&');
+ serialize: function(form, getHash) {
+ return Form.serializeElements(Form.getElements(form), getHash);
},
getElements: function(form) {
- form = $(form);
- var elements = new Array();
-
- for (var tagName in Form.Element.Serializers) {
- var tagElements = form.getElementsByTagName(tagName);
- for (var j = 0; j < tagElements.length; j++)
- elements.push(tagElements[j]);
- }
- return elements;
+ return $A($(form).getElementsByTagName('*')).inject([],
+ function(elements, child) {
+ if (Form.Element.Serializers[child.tagName.toLowerCase()])
+ elements.push(Element.extend(child));
+ return elements;
+ }
+ );
},
getInputs: function(form, typeName, name) {
form = $(form);
var inputs = form.getElementsByTagName('input');
- if (!typeName && !name)
- return inputs;
+ if (!typeName && !name) return $A(inputs).map(Element.extend);
- var matchingInputs = new Array();
- for (var i = 0; i < inputs.length; i++) {
+ for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
var input = inputs[i];
- if ((typeName && input.type != typeName) ||
- (name && input.name != name))
+ if ((typeName && input.type != typeName) || (name && input.name !=
name))
continue;
- matchingInputs.push(input);
+ matchingInputs.push(Element.extend(input));
}
return matchingInputs;
@@ -1641,27 +1928,23 @@
disable: function(form) {
form = $(form);
- var elements = Form.getElements(form);
- for (var i = 0; i < elements.length; i++) {
- var element = elements[i];
+ form.getElements().each(function(element) {
element.blur();
element.disabled = 'true';
- }
+ });
return form;
},
enable: function(form) {
form = $(form);
- var elements = Form.getElements(form);
- for (var i = 0; i < elements.length; i++) {
- var element = elements[i];
+ form.getElements().each(function(element) {
element.disabled = '';
- }
+ });
return form;
},
findFirstElement: function(form) {
- return Form.getElements(form).find(function(element) {
+ return $(form).getElements().find(function(element) {
return element.type != 'hidden' && !element.disabled &&
['input', 'select',
'textarea'].include(element.tagName.toLowerCase());
});
@@ -1669,7 +1952,7 @@
focusFirstElement: function(form) {
form = $(form);
- Field.activate(Form.findFirstElement(form));
+ form.findFirstElement().activate();
return form;
}
}
@@ -1693,29 +1976,21 @@
Form.Element.Methods = {
serialize: function(element) {
element = $(element);
- var method = element.tagName.toLowerCase();
- var parameter = Form.Element.Serializers[method](element);
-
- if (parameter) {
- var key = encodeURIComponent(parameter[0]);
- if (key.length == 0) return;
-
- if (parameter[1].constructor != Array)
- parameter[1] = [parameter[1]];
-
- return parameter[1].map(function(value) {
- return key + '=' + encodeURIComponent(value);
- }).join('&');
+ if (!element.disabled && element.name) {
+ var value = element.getValue();
+ if (value != undefined) {
+ var pair = {};
+ pair[element.name] = value;
+ return Hash.toQueryString(pair);
+ }
}
+ return '';
},
getValue: function(element) {
element = $(element);
var method = element.tagName.toLowerCase();
- var parameter = Form.Element.Serializers[method](element);
-
- if (parameter)
- return parameter[1];
+ return Form.Element.Serializers[method](element);
},
clear: function(element) {
@@ -1730,27 +2005,29 @@
activate: function(element) {
element = $(element);
element.focus();
- if (element.select)
+ if (element.select && ( element.tagName.toLowerCase() != 'input' ||
+ !['button', 'reset', 'submit'].include(element.type) ) )
element.select();
return element;
},
disable: function(element) {
element = $(element);
- element.disabled = '';
+ element.disabled = true;
return element;
},
enable: function(element) {
element = $(element);
element.blur();
- element.disabled = 'true';
+ element.disabled = false;
return element;
}
}
Object.extend(Form.Element, Form.Element.Methods);
var Field = Form.Element;
+var $F = Form.Element.getValue;
/*--------------------------------------------------------------------------*/
@@ -1763,49 +2040,45 @@
default:
return Form.Element.Serializers.textarea(element);
}
- return false;
},
inputSelector: function(element) {
- if (element.checked)
- return [element.name, element.value];
+ return element.checked ? element.value : null;
},
textarea: function(element) {
- return [element.name, element.value];
+ return element.value;
},
select: function(element) {
- return Form.Element.Serializers[element.type == 'select-one' ?
+ return this[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element);
},
selectOne: function(element) {
- var value = '', opt, index = element.selectedIndex;
- if (index >= 0) {
- opt = element.options[index];
- value = opt.value || opt.text;
- }
- return [element.name, value];
+ var index = element.selectedIndex;
+ return index >= 0 ? this.optionValue(element.options[index]) : null;
},
selectMany: function(element) {
- var value = [];
- for (var i = 0; i < element.length; i++) {
+ var values, length = element.length;
+ if (!length) return null;
+
+ for (var i = 0, values = []; i < length; i++) {
var opt = element.options[i];
- if (opt.selected)
- value.push(opt.value || opt.text);
+ if (opt.selected) values.push(this.optionValue(opt));
}
- return [element.name, value];
+ return values;
+ },
+
+ optionValue: function(opt) {
+ // extend element because hasAttribute may not be native
+ return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
}
}
/*--------------------------------------------------------------------------*/
-var $F = Form.Element.getValue;
-
-/*--------------------------------------------------------------------------*/
-
Abstract.TimedObserver = function() {}
Abstract.TimedObserver.prototype = {
initialize: function(element, frequency, callback) {
@@ -1823,7 +2096,9 @@
onTimerEvent: function() {
var value = this.getValue();
- if (this.lastValue != value) {
+ var changed = ('string' == typeof this.lastValue && 'string'
== typeof value
+ ? this.lastValue != value : String(this.lastValue) != String(value));
+ if (changed) {
this.callback(this.element, value);
this.lastValue = value;
}
@@ -1868,9 +2143,7 @@
},
registerFormCallbacks: function() {
- var elements = Form.getElements(this.element);
- for (var i = 0; i < elements.length; i++)
- this.registerCallback(elements[i]);
+ Form.getElements(this.element).each(this.registerCallback.bind(this));
},
registerCallback: function(element) {
@@ -1974,7 +2247,7 @@
unloadCache: function() {
if (!Event.observers) return;
- for (var i = 0; i < Event.observers.length; i++) {
+ for (var i = 0, length = Event.observers.length; i < length; i++) {
Event.stopObserving.apply(this, Event.observers[i]);
Event.observers[i][0] = null;
}
@@ -2061,7 +2334,8 @@
valueL += element.offsetLeft || 0;
element = element.offsetParent;
if (element) {
- p = Element.getStyle(element, 'position');
+ if(element.tagName=='BODY') break;
+ var p = Element.getStyle(element, 'position');
if (p == 'relative' || p == 'absolute') break;
}
} while (element);
@@ -2197,10 +2471,10 @@
element._originalHeight = element.style.height;
element.style.position = 'absolute';
- element.style.top = top + 'px';;
- element.style.left = left + 'px';;
- element.style.width = width + 'px';;
- element.style.height = height + 'px';;
+ element.style.top = top + 'px';
+ element.style.left = left + 'px';
+ element.style.width = width + 'px';
+ element.style.height = height + 'px';
},
relativize: function(element) {
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/scriptaculous.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/scriptaculous.js 2007-03-31 14:21:37 UTC
(rev 6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/scriptaculous.js 2007-03-31 14:25:31 UTC
(rev 6896)
@@ -1,6 +1,6 @@
-// script.aculo.us scriptaculous.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+// script.aculo.us scriptaculous.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
+// Copyright (c) 2005, 2006 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
@@ -20,9 +20,11 @@
// 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.
+//
+// For details, see the script.aculo.us web site:
http://script.aculo.us/
var Scriptaculous = {
- Version: '1.6.4',
+ Version: '1.7.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>');
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/slider.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/slider.js 2007-03-31 14:21:37 UTC (rev
6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/slider.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -1,27 +1,9 @@
-// script.aculo.us slider.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
+// script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
-// Copyright (c) 2005 Marty Haught, Thomas Fuchs
+// Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs
//
-// See
http://script.aculo.us for more info
-//
-// 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.
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site:
http://script.aculo.us/
if(!Control) var Control = {};
Control.Slider = Class.create();
@@ -241,14 +223,16 @@
// find the handle (prevents issues with Safari)
while((this.handles.indexOf(handle) == -1) && handle.parentNode)
handle = handle.parentNode;
-
- this.activeHandle = handle;
- this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
- this.updateStyles();
-
- var offsets = Position.cumulativeOffset(this.activeHandle);
- this.offsetX = (pointer[0] - offsets[0]);
- this.offsetY = (pointer[1] - offsets[1]);
+
+ if(this.handles.indexOf(handle)!=-1) {
+ this.activeHandle = handle;
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+ this.updateStyles();
+
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ }
}
}
Event.stop(event);
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/unittest.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/unittest.js 2007-03-31 14:21:37 UTC (rev
6895)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/unittest.js 2007-03-31 14:25:31 UTC (rev
6896)
@@ -1,552 +1,564 @@
-// script.aculo.us unittest.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006
-
-// Copyright (c) 2005 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
-// (c) 2005 Jon Tirsen (
http://www.tirsen.com)
-// (c) 2005 Michael Schuerig (
http://www.schuerig.de/michael/)
-//
-// 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({
- pointerX: 0,
- pointerY: 0,
- buttons: 0
- }, arguments[2] || {});
- var oEvent = document.createEvent("MouseEvents");
- oEvent.initMouseEvent(eventName, true, true, document.defaultView,
- options.buttons, options.pointerX, options.pointerY, options.pointerX,
options.pointerY,
- false, false, false, false, 0, $(element));
-
- if(this.mark) Element.remove(this.mark);
- this.mark = document.createElement('div');
- this.mark.appendChild(document.createTextNode(" "));
- document.body.appendChild(this.mark);
- this.mark.style.position = 'absolute';
- this.mark.style.top = options.pointerY + "px";
- this.mark.style.left = options.pointerX + "px";
- this.mark.style.width = "5px";
- this.mark.style.height = "5px;";
- this.mark.style.borderTop = "1px solid red;"
- this.mark.style.borderLeft = "1px solid red;"
-
- if(this.step)
- alert('['+new Date().getTime().toString()+']
'+eventName+'/'+Test.Unit.inspect(options));
-
- $(element).dispatchEvent(oEvent);
-};
-
-// Note: Due to a fix in Firefox 1.0.5/6 that probably fixed "too much", this
doesn't work in 1.0.6 or DP2.
-// You need to downgrade to 1.0.4 for now to get this working
-// See
https://bugzilla.mozilla.org/show_bug.cgi?id=289940 for the fix that fixed too
much
-Event.simulateKey = function(element, eventName) {
- var options = Object.extend({
- ctrlKey: false,
- altKey: false,
- shiftKey: false,
- metaKey: false,
- keyCode: 0,
- charCode: 0
- }, arguments[2] || {});
-
- var oEvent = document.createEvent("KeyEvents");
- oEvent.initKeyEvent(eventName, true, true, window,
- options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
- options.keyCode, options.charCode );
- $(element).dispatchEvent(oEvent);
-};
-
-Event.simulateKeys = function(element, command) {
- for(var i=0; i<command.length; i++) {
- Event.simulateKey(element,'keypress',{charCode:command.charCodeAt(i)});
- }
-};
-
-var Test = {}
-Test.Unit = {};
-
-// security exception workaround
-Test.Unit.inspect = Object.inspect;
-
-Test.Unit.Logger = Class.create();
-Test.Unit.Logger.prototype = {
- initialize: function(log) {
- this.log = $(log);
- if (this.log) {
- this._createLogTable();
- }
- },
- start: function(testName) {
- if (!this.log) return;
- this.testName = testName;
- this.lastLogLine = document.createElement('tr');
- this.statusCell = document.createElement('td');
- this.nameCell = document.createElement('td');
- this.nameCell.appendChild(document.createTextNode(testName));
- this.messageCell = document.createElement('td');
- this.lastLogLine.appendChild(this.statusCell);
- this.lastLogLine.appendChild(this.nameCell);
- this.lastLogLine.appendChild(this.messageCell);
- this.loglines.appendChild(this.lastLogLine);
- },
- finish: function(status, summary) {
- if (!this.log) return;
- this.lastLogLine.className = status;
- this.statusCell.innerHTML = status;
- this.messageCell.innerHTML = this._toHTML(summary);
- },
- message: function(message) {
- if (!this.log) return;
- this.messageCell.innerHTML = this._toHTML(message);
- },
- summary: function(summary) {
- if (!this.log) return;
- this.logsummary.innerHTML = this._toHTML(summary);
- },
- _createLogTable: function() {
- this.log.innerHTML =
- '<div id="logsummary"></div>' +
- '<table id="logtable">' +
-
'<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>'
+
- '<tbody id="loglines"></tbody>' +
- '</table>';
- this.logsummary = $('logsummary')
- this.loglines = $('loglines');
- },
- _toHTML: function(txt) {
- return txt.escapeHTML().replace(/\n/g,"<br/>");
- }
-}
-
-Test.Unit.Runner = Class.create();
-Test.Unit.Runner.prototype = {
- initialize: function(testcases) {
- this.options = Object.extend({
- testLog: 'testlog'
- }, arguments[1] || {});
- this.options.resultsURL = this.parseResultsURLQueryParameter();
- if (this.options.testLog) {
- this.options.testLog = $(this.options.testLog) || null;
- }
- if(this.options.tests) {
- this.tests = [];
- for(var i = 0; i < this.options.tests.length; i++) {
- if(/^test/.test(this.options.tests[i])) {
- this.tests.push(new Test.Unit.Testcase(this.options.tests[i],
testcases[this.options.tests[i]], testcases["setup"],
testcases["teardown"]));
- }
- }
- } else {
- if (this.options.test) {
- this.tests = [new Test.Unit.Testcase(this.options.test,
testcases[this.options.test], testcases["setup"],
testcases["teardown"])];
- } else {
- this.tests = [];
- for(var testcase in testcases) {
- if(/^test/.test(testcase)) {
- this.tests.push(
- new Test.Unit.Testcase(
- this.options.context ? ' -> ' + this.options.titles[testcase]
: testcase,
- testcases[testcase], testcases["setup"],
testcases["teardown"]
- ));
- }
- }
- }
- }
- this.currentTest = 0;
- this.logger = new Test.Unit.Logger(this.options.testLog);
- setTimeout(this.runTests.bind(this), 1000);
- },
- parseResultsURLQueryParameter: function() {
- return window.location.search.parseQuery()["resultsURL"];
- },
- // Returns:
- // "ERROR" if there was an error,
- // "FAILURE" if there was a failure, or
- // "SUCCESS" if there was neither
- getResult: function() {
- var hasFailure = false;
- for(var i=0;i<this.tests.length;i++) {
- if (this.tests[i].errors > 0) {
- return "ERROR";
- }
- if (this.tests[i].failures > 0) {
- hasFailure = true;
- }
- }
- if (hasFailure) {
- return "FAILURE";
- } else {
- return "SUCCESS";
- }
- },
- postResults: function() {
- if (this.options.resultsURL) {
- new Ajax.Request(this.options.resultsURL,
- { method: 'get', parameters: 'result=' + this.getResult(),
asynchronous: false });
- }
- },
- runTests: function() {
- var test = this.tests[this.currentTest];
- if (!test) {
- // finished!
- this.postResults();
- this.logger.summary(this.summary());
- return;
- }
- if(!test.isWaiting) {
- this.logger.start(test.name);
- }
- test.run();
- if(test.isWaiting) {
- this.logger.message("Waiting for " + test.timeToWait + "ms");
- setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
- } else {
- this.logger.finish(test.status(), test.summary());
- this.currentTest++;
- // tail recursive, hopefully the browser will skip the stackframe
- this.runTests();
- }
- },
- summary: function() {
- var assertions = 0;
- var failures = 0;
- var errors = 0;
- var messages = [];
- for(var i=0;i<this.tests.length;i++) {
- assertions += this.tests[i].assertions;
- failures += this.tests[i].failures;
- errors += this.tests[i].errors;
- }
- return (
- (this.options.context ? this.options.context + ': ': '') +
- this.tests.length + " tests, " +
- assertions + " assertions, " +
- failures + " failures, " +
- errors + " errors");
- }
-}
-
-Test.Unit.Assertions = Class.create();
-Test.Unit.Assertions.prototype = {
- initialize: function() {
- this.assertions = 0;
- this.failures = 0;
- this.errors = 0;
- this.messages = [];
- },
- summary: function() {
- return (
- this.assertions + " assertions, " +
- this.failures + " failures, " +
- this.errors + " errors" + "\n" +
- this.messages.join("\n"));
- },
- pass: function() {
- this.assertions++;
- },
- fail: function(message) {
- this.failures++;
- this.messages.push("Failure: " + message);
- },
- info: function(message) {
- this.messages.push("Info: " + message);
- },
- error: function(error) {
- this.errors++;
- this.messages.push(error.name + ": "+ error.message + "(" +
Test.Unit.inspect(error) +")");
- },
- status: function() {
- if (this.failures > 0) return 'failed';
- if (this.errors > 0) return 'error';
- return 'passed';
- },
- assert: function(expression) {
- var message = arguments[1] || 'assert: got "' +
Test.Unit.inspect(expression) + '"';
- try { expression ? this.pass() :
- this.fail(message); }
- catch(e) { this.error(e); }
- },
- assertEqual: function(expected, actual) {
- var message = arguments[2] || "assertEqual";
- try { (expected == actual) ? this.pass() :
- this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
- '", 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() :
- this.fail(message + ': got "' + Test.Unit.inspect(actual) +
'"'); }
- catch(e) { this.error(e); }
- },
- assertIdentical: function(expected, actual) {
- var message = arguments[2] || "assertIdentical";
- try { (expected === actual) ? this.pass() :
- this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
- '", actual "' + Test.Unit.inspect(actual) + '"');
}
- catch(e) { this.error(e); }
- },
- assertNotIdentical: function(expected, actual) {
- var message = arguments[2] || "assertNotIdentical";
- try { !(expected === actual) ? this.pass() :
- this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
- '", actual "' + Test.Unit.inspect(actual) + '"');
}
- catch(e) { this.error(e); }
- },
- assertNull: function(obj) {
- var message = arguments[1] || 'assertNull'
- try { (obj==null) ? this.pass() :
- this.fail(message + ': got "' + Test.Unit.inspect(obj) +
'"'); }
- catch(e) { this.error(e); }
- },
- assertMatch: function(expected, actual) {
- var message = arguments[2] || 'assertMatch';
- var regex = new RegExp(expected);
- try { (regex.exec(actual)) ? this.pass() :
- this.fail(message + ' : regex: "' + Test.Unit.inspect(expected) +
' did not match: ' + Test.Unit.inspect(actual) + '"'); }
- catch(e) { this.error(e); }
- },
- assertHidden: function(element) {
- var message = arguments[1] || 'assertHidden';
- this.assertEqual("none", element.style.display, message);
- },
- assertNotNull: function(object) {
- var message = arguments[1] || 'assertNotNull';
- this.assert(object != null, message);
- },
- assertType: function(expected, actual) {
- var message = arguments[2] || 'assertType';
- try {
- (actual.constructor == expected) ? this.pass() :
- this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
- '", actual "' + (actual.constructor) + '"'); }
- catch(e) { this.error(e); }
- },
- assertNotOfType: function(expected, actual) {
- var message = arguments[2] || 'assertNotOfType';
- try {
- (actual.constructor != expected) ? this.pass() :
- this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
- '", actual "' + (actual.constructor) + '"'); }
- catch(e) { this.error(e); }
- },
- assertInstanceOf: function(expected, actual) {
- var message = arguments[2] || 'assertInstanceOf';
- try {
- (actual instanceof expected) ? this.pass() :
- this.fail(message + ": object was not an instance of the expected type");
}
- catch(e) { this.error(e); }
- },
- assertNotInstanceOf: function(expected, actual) {
- var message = arguments[2] || 'assertNotInstanceOf';
- try {
- !(actual instanceof expected) ? this.pass() :
- this.fail(message + ": object was an instance of the not expected type");
}
- catch(e) { this.error(e); }
- },
- assertRespondsTo: function(method, obj) {
- var message = arguments[2] || 'assertRespondsTo';
- try {
- (obj[method] && typeof obj[method] == 'function') ? this.pass() :
- this.fail(message + ": object doesn't respond to [" + method +
"]"); }
- catch(e) { this.error(e); }
- },
- assertReturnsTrue: function(method, obj) {
- var message = arguments[2] || 'assertReturnsTrue';
- try {
- var m = obj[method];
- if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
- m() ? this.pass() :
- this.fail(message + ": method returned false"); }
- catch(e) { this.error(e); }
- },
- assertReturnsFalse: function(method, obj) {
- var message = arguments[2] || 'assertReturnsFalse';
- try {
- var m = obj[method];
- if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
- !m() ? this.pass() :
- this.fail(message + ": method returned true"); }
- catch(e) { this.error(e); }
- },
- assertRaise: function(exceptionName, method) {
- var message = arguments[2] || 'assertRaise';
- try {
- method();
- this.fail(message + ": exception expected but none was raised"); }
- catch(e) {
- (e.name==exceptionName) ? this.pass() : this.error(e);
- }
- },
- assertElementsMatch: function() {
- var expressions = $A(arguments), elements = $A(expressions.shift());
- if (elements.length != expressions.length) {
- this.fail('assertElementsMatch: size mismatch: ' + elements.length + '
elements, ' + expressions.length + ' expressions');
- return false;
- }
- elements.zip(expressions).all(function(pair, index) {
- var element = $(pair.first()), expression = pair.last();
- if (element.match(expression)) return true;
- this.fail('assertElementsMatch: (in index ' + index + ') expected '
+ expression.inspect() + ' but got ' + element.inspect());
- }.bind(this)) && this.pass();
- },
- assertElementMatches: function(element, expression) {
- this.assertElementsMatch([element], expression);
- },
- benchmark: function(operation, iterations) {
- var startAt = new Date();
- (iterations || 1).times(operation);
- var timeTaken = ((new Date())-startAt);
- this.info((arguments[2] || 'Operation') + ' finished ' +
- iterations + ' iterations in ' + (timeTaken/1000)+'s' );
- return timeTaken;
- },
- _isVisible: function(element) {
- element = $(element);
- if(!element.parentNode) return true;
- this.assertNotNull(element);
- if(element.style && Element.getStyle(element, 'display') ==
'none')
- return false;
-
- return this._isVisible(element.parentNode);
- },
- assertNotVisible: function(element) {
- this.assert(!this._isVisible(element), Test.Unit.inspect(element) + " was not
hidden and didn't have a hidden parent either. " + ("" ||
arguments[1]));
- },
- assertVisible: function(element) {
- this.assert(this._isVisible(element), Test.Unit.inspect(element) + " was not
visible. " + ("" || arguments[1]));
- },
- benchmark: function(operation, iterations) {
- var startAt = new Date();
- (iterations || 1).times(operation);
- var timeTaken = ((new Date())-startAt);
- this.info((arguments[2] || 'Operation') + ' finished ' +
- iterations + ' iterations in ' + (timeTaken/1000)+'s' );
- return timeTaken;
- }
-}
-
-Test.Unit.Testcase = Class.create();
-Object.extend(Object.extend(Test.Unit.Testcase.prototype,
Test.Unit.Assertions.prototype), {
- initialize: function(name, test, setup, teardown) {
- Test.Unit.Assertions.prototype.initialize.bind(this)();
- this.name = name;
-
- if(typeof test == 'string') {
- test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,');
- test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)');
- this.test = function() {
- eval('with(this){'+test+'}');
- }
- } else {
- this.test = test || function() {};
- }
-
- this.setup = setup || function() {};
- this.teardown = teardown || function() {};
- this.isWaiting = false;
- this.timeToWait = 1000;
- },
- wait: function(time, nextPart) {
- this.isWaiting = true;
- this.test = nextPart;
- this.timeToWait = time;
- },
- run: function() {
- try {
- try {
- if (!this.isWaiting) this.setup.bind(this)();
- this.isWaiting = false;
- this.test.bind(this)();
- } finally {
- if(!this.isWaiting) {
- this.teardown.bind(this)();
- }
- }
- }
- catch(e) { this.error(e); }
- }
-});
-
-// *EXPERIMENTAL* BDD-style testing to please non-technical folk
-// This draws many ideas from RSpec
http://rspec.rubyforge.org/
-
-Test.setupBDDExtensionMethods = function(){
- var METHODMAP = {
- shouldEqual: 'assertEqual',
- shouldNotEqual: 'assertNotEqual',
- shouldEqualEnum: 'assertEnumEqual',
- shouldBeA: 'assertType',
- shouldNotBeA: 'assertNotOfType',
- shouldBeAn: 'assertType',
- shouldNotBeAn: 'assertNotOfType',
- shouldBeNull: 'assertNull',
- shouldNotBeNull: 'assertNotNull',
-
- shouldBe: 'assertReturnsTrue',
- shouldNotBe: 'assertReturnsFalse',
- shouldRespondTo: 'assertRespondsTo'
- };
- Test.BDDMethods = {};
- for(m in METHODMAP) {
- Test.BDDMethods[m] = eval(
- 'function(){'+
- 'var args = $A(arguments);'+
- 'var scope = args.shift();'+
- 'scope.'+METHODMAP[m]+'.apply(scope,(args || []).concat([this]));
}');
- }
- [Array.prototype, String.prototype, Number.prototype].each(
- function(p){ Object.extend(p, Test.BDDMethods) }
- );
-}
-
-Test.context = function(name, spec, log){
- Test.setupBDDExtensionMethods();
-
- var compiledSpec = {};
- var titles = {};
- for(specName in spec) {
- switch(specName){
- case "setup":
- case "teardown":
- compiledSpec[specName] = spec[specName];
- break;
- default:
- var testName = 'test'+specName.gsub(/\s+/,'-').camelize();
- var body = spec[specName].toString().split('\n').slice(1);
- if(/^\{/.test(body[0])) body = body.slice(1);
- body.pop();
- body = body.map(function(statement){
- return statement.strip()
- });
- compiledSpec[testName] = body.join('\n');
- titles[testName] = specName;
- }
- }
- new Test.Unit.Runner(compiledSpec, { titles: titles, testLog: log || 'testlog',
context: name });
+// script.aculo.us unittest.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
+
+// Copyright (c) 2005, 2006 Thomas Fuchs (
http://script.aculo.us,
http://mir.aculo.us)
+// (c) 2005, 2006 Jon Tirsen (
http://www.tirsen.com)
+// (c) 2005, 2006 Michael Schuerig (
http://www.schuerig.de/michael/)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site:
http://script.aculo.us/
+
+// experimental, Firefox-only
+Event.simulateMouse = function(element, eventName) {
+ var options = Object.extend({
+ pointerX: 0,
+ pointerY: 0,
+ buttons: 0,
+ ctrlKey: false,
+ altKey: false,
+ shiftKey: false,
+ metaKey: false
+ }, arguments[2] || {});
+ var oEvent = document.createEvent("MouseEvents");
+ oEvent.initMouseEvent(eventName, true, true, document.defaultView,
+ options.buttons, options.pointerX, options.pointerY, options.pointerX,
options.pointerY,
+ options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, 0, $(element));
+
+ if(this.mark) Element.remove(this.mark);
+ this.mark = document.createElement('div');
+ this.mark.appendChild(document.createTextNode(" "));
+ document.body.appendChild(this.mark);
+ this.mark.style.position = 'absolute';
+ this.mark.style.top = options.pointerY + "px";
+ this.mark.style.left = options.pointerX + "px";
+ this.mark.style.width = "5px";
+ this.mark.style.height = "5px;";
+ this.mark.style.borderTop = "1px solid red;"
+ this.mark.style.borderLeft = "1px solid red;"
+
+ if(this.step)
+ alert('['+new Date().getTime().toString()+']
'+eventName+'/'+Test.Unit.inspect(options));
+
+ $(element).dispatchEvent(oEvent);
+};
+
+// Note: Due to a fix in Firefox 1.0.5/6 that probably fixed "too much", this
doesn't work in 1.0.6 or DP2.
+// You need to downgrade to 1.0.4 for now to get this working
+// See
https://bugzilla.mozilla.org/show_bug.cgi?id=289940 for the fix that fixed too
much
+Event.simulateKey = function(element, eventName) {
+ var options = Object.extend({
+ ctrlKey: false,
+ altKey: false,
+ shiftKey: false,
+ metaKey: false,
+ keyCode: 0,
+ charCode: 0
+ }, arguments[2] || {});
+
+ var oEvent = document.createEvent("KeyEvents");
+ oEvent.initKeyEvent(eventName, true, true, window,
+ options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
+ options.keyCode, options.charCode );
+ $(element).dispatchEvent(oEvent);
+};
+
+Event.simulateKeys = function(element, command) {
+ for(var i=0; i<command.length; i++) {
+ Event.simulateKey(element,'keypress',{charCode:command.charCodeAt(i)});
+ }
+};
+
+var Test = {}
+Test.Unit = {};
+
+// security exception workaround
+Test.Unit.inspect = Object.inspect;
+
+Test.Unit.Logger = Class.create();
+Test.Unit.Logger.prototype = {
+ initialize: function(log) {
+ this.log = $(log);
+ if (this.log) {
+ this._createLogTable();
+ }
+ },
+ start: function(testName) {
+ if (!this.log) return;
+ this.testName = testName;
+ this.lastLogLine = document.createElement('tr');
+ this.statusCell = document.createElement('td');
+ this.nameCell = document.createElement('td');
+ this.nameCell.className = "nameCell";
+ this.nameCell.appendChild(document.createTextNode(testName));
+ this.messageCell = document.createElement('td');
+ this.lastLogLine.appendChild(this.statusCell);
+ this.lastLogLine.appendChild(this.nameCell);
+ this.lastLogLine.appendChild(this.messageCell);
+ this.loglines.appendChild(this.lastLogLine);
+ },
+ finish: function(status, summary) {
+ if (!this.log) return;
+ this.lastLogLine.className = status;
+ this.statusCell.innerHTML = status;
+ this.messageCell.innerHTML = this._toHTML(summary);
+ this.addLinksToResults();
+ },
+ message: function(message) {
+ if (!this.log) return;
+ this.messageCell.innerHTML = this._toHTML(message);
+ },
+ summary: function(summary) {
+ if (!this.log) return;
+ this.logsummary.innerHTML = this._toHTML(summary);
+ },
+ _createLogTable: function() {
+ this.log.innerHTML =
+ '<div id="logsummary"></div>' +
+ '<table id="logtable">' +
+
'<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>'
+
+ '<tbody id="loglines"></tbody>' +
+ '</table>';
+ this.logsummary = $('logsummary')
+ this.loglines = $('loglines');
+ },
+ _toHTML: function(txt) {
+ return txt.escapeHTML().replace(/\n/g,"<br/>");
+ },
+ addLinksToResults: function(){
+ $$("tr.failed .nameCell").each( function(td){ // todo: limit to children of
this.log
+ td.title = "Run only this test"
+ Event.observe(td, 'click', function(){ window.location.search =
"?tests=" + td.innerHTML;});
+ });
+ $$("tr.passed .nameCell").each( function(td){ // todo: limit to children of
this.log
+ td.title = "Run all tests"
+ Event.observe(td, 'click', function(){ window.location.search =
"";});
+ });
+ }
+}
+
+Test.Unit.Runner = Class.create();
+Test.Unit.Runner.prototype = {
+ initialize: function(testcases) {
+ this.options = Object.extend({
+ testLog: 'testlog'
+ }, arguments[1] || {});
+ this.options.resultsURL = this.parseResultsURLQueryParameter();
+ this.options.tests = this.parseTestsQueryParameter();
+ if (this.options.testLog) {
+ this.options.testLog = $(this.options.testLog) || null;
+ }
+ if(this.options.tests) {
+ this.tests = [];
+ for(var i = 0; i < this.options.tests.length; i++) {
+ if(/^test/.test(this.options.tests[i])) {
+ this.tests.push(new Test.Unit.Testcase(this.options.tests[i],
testcases[this.options.tests[i]], testcases["setup"],
testcases["teardown"]));
+ }
+ }
+ } else {
+ if (this.options.test) {
+ this.tests = [new Test.Unit.Testcase(this.options.test,
testcases[this.options.test], testcases["setup"],
testcases["teardown"])];
+ } else {
+ this.tests = [];
+ for(var testcase in testcases) {
+ if(/^test/.test(testcase)) {
+ this.tests.push(
+ new Test.Unit.Testcase(
+ this.options.context ? ' -> ' + this.options.titles[testcase]
: testcase,
+ testcases[testcase], testcases["setup"],
testcases["teardown"]
+ ));
+ }
+ }
+ }
+ }
+ this.currentTest = 0;
+ this.logger = new Test.Unit.Logger(this.options.testLog);
+ setTimeout(this.runTests.bind(this), 1000);
+ },
+ parseResultsURLQueryParameter: function() {
+ return window.location.search.parseQuery()["resultsURL"];
+ },
+ parseTestsQueryParameter: function(){
+ if (window.location.search.parseQuery()["tests"]){
+ return
window.location.search.parseQuery()["tests"].split(',');
+ };
+ },
+ // Returns:
+ // "ERROR" if there was an error,
+ // "FAILURE" if there was a failure, or
+ // "SUCCESS" if there was neither
+ getResult: function() {
+ var hasFailure = false;
+ for(var i=0;i<this.tests.length;i++) {
+ if (this.tests[i].errors > 0) {
+ return "ERROR";
+ }
+ if (this.tests[i].failures > 0) {
+ hasFailure = true;
+ }
+ }
+ if (hasFailure) {
+ return "FAILURE";
+ } else {
+ return "SUCCESS";
+ }
+ },
+ postResults: function() {
+ if (this.options.resultsURL) {
+ new Ajax.Request(this.options.resultsURL,
+ { method: 'get', parameters: 'result=' + this.getResult(),
asynchronous: false });
+ }
+ },
+ runTests: function() {
+ var test = this.tests[this.currentTest];
+ if (!test) {
+ // finished!
+ this.postResults();
+ this.logger.summary(this.summary());
+ return;
+ }
+ if(!test.isWaiting) {
+ this.logger.start(test.name);
+ }
+ test.run();
+ if(test.isWaiting) {
+ this.logger.message("Waiting for " + test.timeToWait + "ms");
+ setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
+ } else {
+ this.logger.finish(test.status(), test.summary());
+ this.currentTest++;
+ // tail recursive, hopefully the browser will skip the stackframe
+ this.runTests();
+ }
+ },
+ summary: function() {
+ var assertions = 0;
+ var failures = 0;
+ var errors = 0;
+ var messages = [];
+ for(var i=0;i<this.tests.length;i++) {
+ assertions += this.tests[i].assertions;
+ failures += this.tests[i].failures;
+ errors += this.tests[i].errors;
+ }
+ return (
+ (this.options.context ? this.options.context + ': ': '') +
+ this.tests.length + " tests, " +
+ assertions + " assertions, " +
+ failures + " failures, " +
+ errors + " errors");
+ }
+}
+
+Test.Unit.Assertions = Class.create();
+Test.Unit.Assertions.prototype = {
+ initialize: function() {
+ this.assertions = 0;
+ this.failures = 0;
+ this.errors = 0;
+ this.messages = [];
+ },
+ summary: function() {
+ return (
+ this.assertions + " assertions, " +
+ this.failures + " failures, " +
+ this.errors + " errors" + "\n" +
+ this.messages.join("\n"));
+ },
+ pass: function() {
+ this.assertions++;
+ },
+ fail: function(message) {
+ this.failures++;
+ this.messages.push("Failure: " + message);
+ },
+ info: function(message) {
+ this.messages.push("Info: " + message);
+ },
+ error: function(error) {
+ this.errors++;
+ this.messages.push(error.name + ": "+ error.message + "(" +
Test.Unit.inspect(error) +")");
+ },
+ status: function() {
+ if (this.failures > 0) return 'failed';
+ if (this.errors > 0) return 'error';
+ return 'passed';
+ },
+ assert: function(expression) {
+ var message = arguments[1] || 'assert: got "' +
Test.Unit.inspect(expression) + '"';
+ try { expression ? this.pass() :
+ this.fail(message); }
+ catch(e) { this.error(e); }
+ },
+ assertEqual: function(expected, actual) {
+ var message = arguments[2] || "assertEqual";
+ try { (expected == actual) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + Test.Unit.inspect(actual) + '"');
}
+ catch(e) { this.error(e); }
+ },
+ assertInspect: function(expected, actual) {
+ var message = arguments[2] || "assertInspect";
+ try { (expected == actual.inspect()) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", 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() :
+ this.fail(message + ': got "' + Test.Unit.inspect(actual) +
'"'); }
+ catch(e) { this.error(e); }
+ },
+ assertIdentical: function(expected, actual) {
+ var message = arguments[2] || "assertIdentical";
+ try { (expected === actual) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + Test.Unit.inspect(actual) + '"');
}
+ catch(e) { this.error(e); }
+ },
+ assertNotIdentical: function(expected, actual) {
+ var message = arguments[2] || "assertNotIdentical";
+ try { !(expected === actual) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + Test.Unit.inspect(actual) + '"');
}
+ catch(e) { this.error(e); }
+ },
+ assertNull: function(obj) {
+ var message = arguments[1] || 'assertNull'
+ try { (obj==null) ? this.pass() :
+ this.fail(message + ': got "' + Test.Unit.inspect(obj) +
'"'); }
+ catch(e) { this.error(e); }
+ },
+ assertMatch: function(expected, actual) {
+ var message = arguments[2] || 'assertMatch';
+ var regex = new RegExp(expected);
+ try { (regex.exec(actual)) ? this.pass() :
+ this.fail(message + ' : regex: "' + Test.Unit.inspect(expected) +
' did not match: ' + Test.Unit.inspect(actual) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertHidden: function(element) {
+ var message = arguments[1] || 'assertHidden';
+ this.assertEqual("none", element.style.display, message);
+ },
+ assertNotNull: function(object) {
+ var message = arguments[1] || 'assertNotNull';
+ this.assert(object != null, message);
+ },
+ assertType: function(expected, actual) {
+ var message = arguments[2] || 'assertType';
+ try {
+ (actual.constructor == expected) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + (actual.constructor) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertNotOfType: function(expected, actual) {
+ var message = arguments[2] || 'assertNotOfType';
+ try {
+ (actual.constructor != expected) ? this.pass() :
+ this.fail(message + ': expected "' + Test.Unit.inspect(expected) +
+ '", actual "' + (actual.constructor) + '"'); }
+ catch(e) { this.error(e); }
+ },
+ assertInstanceOf: function(expected, actual) {
+ var message = arguments[2] || 'assertInstanceOf';
+ try {
+ (actual instanceof expected) ? this.pass() :
+ this.fail(message + ": object was not an instance of the expected type");
}
+ catch(e) { this.error(e); }
+ },
+ assertNotInstanceOf: function(expected, actual) {
+ var message = arguments[2] || 'assertNotInstanceOf';
+ try {
+ !(actual instanceof expected) ? this.pass() :
+ this.fail(message + ": object was an instance of the not expected type");
}
+ catch(e) { this.error(e); }
+ },
+ assertRespondsTo: function(method, obj) {
+ var message = arguments[2] || 'assertRespondsTo';
+ try {
+ (obj[method] && typeof obj[method] == 'function') ? this.pass() :
+ this.fail(message + ": object doesn't respond to [" + method +
"]"); }
+ catch(e) { this.error(e); }
+ },
+ assertReturnsTrue: function(method, obj) {
+ var message = arguments[2] || 'assertReturnsTrue';
+ try {
+ var m = obj[method];
+ if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
+ m() ? this.pass() :
+ this.fail(message + ": method returned false"); }
+ catch(e) { this.error(e); }
+ },
+ assertReturnsFalse: function(method, obj) {
+ var message = arguments[2] || 'assertReturnsFalse';
+ try {
+ var m = obj[method];
+ if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
+ !m() ? this.pass() :
+ this.fail(message + ": method returned true"); }
+ catch(e) { this.error(e); }
+ },
+ assertRaise: function(exceptionName, method) {
+ var message = arguments[2] || 'assertRaise';
+ try {
+ method();
+ this.fail(message + ": exception expected but none was raised"); }
+ catch(e) {
+ ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e);
+ }
+ },
+ assertElementsMatch: function() {
+ var expressions = $A(arguments), elements = $A(expressions.shift());
+ if (elements.length != expressions.length) {
+ this.fail('assertElementsMatch: size mismatch: ' + elements.length + '
elements, ' + expressions.length + ' expressions');
+ return false;
+ }
+ elements.zip(expressions).all(function(pair, index) {
+ var element = $(pair.first()), expression = pair.last();
+ if (element.match(expression)) return true;
+ this.fail('assertElementsMatch: (in index ' + index + ') expected '
+ expression.inspect() + ' but got ' + element.inspect());
+ }.bind(this)) && this.pass();
+ },
+ assertElementMatches: function(element, expression) {
+ this.assertElementsMatch([element], expression);
+ },
+ benchmark: function(operation, iterations) {
+ var startAt = new Date();
+ (iterations || 1).times(operation);
+ var timeTaken = ((new Date())-startAt);
+ this.info((arguments[2] || 'Operation') + ' finished ' +
+ iterations + ' iterations in ' + (timeTaken/1000)+'s' );
+ return timeTaken;
+ },
+ _isVisible: function(element) {
+ element = $(element);
+ if(!element.parentNode) return true;
+ this.assertNotNull(element);
+ if(element.style && Element.getStyle(element, 'display') ==
'none')
+ return false;
+
+ return this._isVisible(element.parentNode);
+ },
+ assertNotVisible: function(element) {
+ this.assert(!this._isVisible(element), Test.Unit.inspect(element) + " was not
hidden and didn't have a hidden parent either. " + ("" ||
arguments[1]));
+ },
+ assertVisible: function(element) {
+ this.assert(this._isVisible(element), Test.Unit.inspect(element) + " was not
visible. " + ("" || arguments[1]));
+ },
+ benchmark: function(operation, iterations) {
+ var startAt = new Date();
+ (iterations || 1).times(operation);
+ var timeTaken = ((new Date())-startAt);
+ this.info((arguments[2] || 'Operation') + ' finished ' +
+ iterations + ' iterations in ' + (timeTaken/1000)+'s' );
+ return timeTaken;
+ }
+}
+
+Test.Unit.Testcase = Class.create();
+Object.extend(Object.extend(Test.Unit.Testcase.prototype,
Test.Unit.Assertions.prototype), {
+ initialize: function(name, test, setup, teardown) {
+ Test.Unit.Assertions.prototype.initialize.bind(this)();
+ this.name = name;
+
+ if(typeof test == 'string') {
+ test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,');
+ test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)');
+ this.test = function() {
+ eval('with(this){'+test+'}');
+ }
+ } else {
+ this.test = test || function() {};
+ }
+
+ this.setup = setup || function() {};
+ this.teardown = teardown || function() {};
+ this.isWaiting = false;
+ this.timeToWait = 1000;
+ },
+ wait: function(time, nextPart) {
+ this.isWaiting = true;
+ this.test = nextPart;
+ this.timeToWait = time;
+ },
+ run: function() {
+ try {
+ try {
+ if (!this.isWaiting) this.setup.bind(this)();
+ this.isWaiting = false;
+ this.test.bind(this)();
+ } finally {
+ if(!this.isWaiting) {
+ this.teardown.bind(this)();
+ }
+ }
+ }
+ catch(e) { this.error(e); }
+ }
+});
+
+// *EXPERIMENTAL* BDD-style testing to please non-technical folk
+// This draws many ideas from RSpec
http://rspec.rubyforge.org/
+
+Test.setupBDDExtensionMethods = function(){
+ var METHODMAP = {
+ shouldEqual: 'assertEqual',
+ shouldNotEqual: 'assertNotEqual',
+ shouldEqualEnum: 'assertEnumEqual',
+ shouldBeA: 'assertType',
+ shouldNotBeA: 'assertNotOfType',
+ shouldBeAn: 'assertType',
+ shouldNotBeAn: 'assertNotOfType',
+ shouldBeNull: 'assertNull',
+ shouldNotBeNull: 'assertNotNull',
+
+ shouldBe: 'assertReturnsTrue',
+ shouldNotBe: 'assertReturnsFalse',
+ shouldRespondTo: 'assertRespondsTo'
+ };
+ Test.BDDMethods = {};
+ for(m in METHODMAP) {
+ Test.BDDMethods[m] = eval(
+ 'function(){'+
+ 'var args = $A(arguments);'+
+ 'var scope = args.shift();'+
+ 'scope.'+METHODMAP[m]+'.apply(scope,(args || []).concat([this]));
}');
+ }
+ [Array.prototype, String.prototype, Number.prototype].each(
+ function(p){ Object.extend(p, Test.BDDMethods) }
+ );
+}
+
+Test.context = function(name, spec, log){
+ Test.setupBDDExtensionMethods();
+
+ var compiledSpec = {};
+ var titles = {};
+ for(specName in spec) {
+ switch(specName){
+ case "setup":
+ case "teardown":
+ compiledSpec[specName] = spec[specName];
+ break;
+ default:
+ var testName = 'test'+specName.gsub(/\s+/,'-').camelize();
+ var body = spec[specName].toString().split('\n').slice(1);
+ if(/^\{/.test(body[0])) body = body.slice(1);
+ body.pop();
+ body = body.map(function(statement){
+ return statement.strip()
+ });
+ compiledSpec[testName] = body.join('\n');
+ titles[testName] = specName;
+ }
+ }
+ new Test.Unit.Runner(compiledSpec, { titles: titles, testLog: log || 'testlog',
context: name });
};
\ No newline at end of file
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-31
14:21:37 UTC (rev 6895)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-31
14:25:31 UTC (rev 6896)
@@ -61,14 +61,10 @@
public class DynaRegionRenderer implements RegionRenderer
{
- /**
- * .
- */
+ /** . */
private static final ThreadLocal enabledLocal = new ThreadLocal();
- /**
- * .
- */
+ /** . */
private RegionRenderer delegate;
public static boolean isEnabled()
@@ -107,147 +103,16 @@
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/scriptaculous.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/effects.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/dragdrop.js'></script>\n");
+ markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/dyna.js'></script>\n");
markup.append("<script type='text/javascript'>\n");
markup.append("async_server_url=\"").append(asyncServerURL).append(";\"\n");
markup.append("classic_server_url=\"").append(classicServerURL).append("\";\n");
-
- String sendData = "" +
- "function sendData(action, windowId, fromPos, fromRegionId, toPos,
toRegionId) {\n" +
- " var options = {\n" +
- " method: 'post',\n" +
- " postBody: 'action=' + action +
'&windowId=' + windowId + '&fromPos=' + fromPos +
'&fromRegion=' + fromRegionId + '&toPos=' + toPos +
'&toRegion=' + toRegionId,\n" +
- " onSuccess: function(t)\n" +
- " {\n" +
- " },\n" +
- " onSuccess: function(t)\n" +
- " {\n" +
- " },\n" +
- " on404: function(t)\n" +
- " {\n" +
- " alert('Error 404: location \"' + t.statusText
+ '\" was not found.');\n" +
- " },\n" +
- " onFailure: function(t)\n" +
- " {\n" +
- " alert('Error ' + t.status + ' -- ' +
t.statusText);\n" +
- " },\n" +
- " onLoading: function(t)\n" +
- " {\n" +
- " }\n" +
- " }\n" +
- " new Ajax.Request(async_server_url, options);\n" +
- "}";
- markup.append(sendData);
-
- //
- String t = "" +
- "function snapshot() {\n" +
-
- // Find draggable regions
- " var regions_on_page =
document.getElementsByClassName(\"dyna-region\");\n" +
-
- // Save current state in the DOM itself
- " for(var i = 0;i < regions_on_page.length;i++) {\n" +
- " var regionDiv = regions_on_page[i]\n" +
- " for (var j = 0;j < regionDiv.childNodes.length;j++)
{\n" +
- " var child = regionDiv.childNodes[j];\n" +
- " child['regionId'] = regionDiv.id;\n" +
- " child['pos'] = j;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- markup.append(t);
-
- String s = "" +
- "var WindowMoveObserver = Class.create();\n" +
- "WindowMoveObserver.prototype =\n" +
- "{\n" +
- " initialize: function(element)\n" +
- " {\n" +
- " this.element = $(element);\n" +
- " },\n" +
- " onStart: function()\n" +
- " {\n" +
- " },\n" +
- " onEnd: function()\n" +
- " {\n" +
- " var elt = Draggables.activeDraggable.element;\n" +
- " var fromRegionId = elt['regionId'];\n" +
- " var fromPos = elt['pos'];\n" +
- " snapshot();\n" +
- " var toRegionId = elt['regionId'];\n" +
- " var toPos = elt['pos'];\n" +
- " sendData('windowmove', elt.id, fromPos, fromRegionId,
toPos, toRegionId);\n" +
- " }\n" +
- "};\n";
- markup.append(s);
-
- String u = "" +
- "function removeWindow(elementId)\n" +
- "{\n" +
- " var effectElement = document.getElementById(elementId)\n" +
- " new Effect.BlindUp(effectElement);\n" +
- "\n" +
- " //removeElement(effectElement);\n" +
- "\n" +
- " sendData('windowremove', elementId);\n" +
- "}\n";
- markup.append(u);
-
- String v = "" +
- "function bilto(event)\n" +
- "{\n" +
-// " var source = Event.element(event);\n" +
-// " if (source.nodeName == \"A\") {;\n" +
-// " var url = source.href;\n" +
-// " var parameters = \"\";\n" +
-// " var pos = url.indexOf(\"?\");\n" +
-// " if (pos != -1) {\n" +
-// " parameters = url.substring(pos + 1);\n" +
-// " url = url.substring(0, pos);\n" +
-// " }\n" +
-// " Event.stop(event);\n" +
-// " var options = {\n" +
-// " parameters:parameters,\n" +
-// " asynchronous:true,\n" +
-// " method:\"get\",\n" +
-// "
requestHeaders:[\"ajax\",\"true\"],\n" +
-// " };" +
-// " new Ajax.Request(url, options);\n" +
-// " }\n" +
- "}\n";
- markup.append(v);
-
markup.append("</script>\n");
markup.append("\n\n\n");
}
else if ("AJAXFooter".equals(rrc.getId()))
{
- markup.append("<script>\n" +
-
- // Find the draggable regions
- "var regions_on_page =
document.getElementsByClassName(\"dyna-region\");\n" +
-
- // Create draggable regions
- "for(var i = 0;i < regions_on_page.length;i++) {\n" +
- " var region = regions_on_page[i];\n" +
- " Sortable.create(region,
{dropOnEmpty:true,handle:'handle',tag:'div',containment:regions_on_page,constraint:false});\n"
+
- "}\n" +
-
- //
- "Draggables.addObserver(new WindowMoveObserver());\n" +
- "snapshot();\n" +
-
- // Find the dyna portlets
- "var portlets_on_page =
document.getElementsByClassName(\"dyna-portlet\");\n" +
-
- // Add listener for teh dyna portlets
- "for(var i = 0;i < portlets_on_page.length;i++) {\n" +
- " var portlet = portlets_on_page[i];\n" +
- " Event.observe(portlet, 'click', bilto);\n" +
- "}\n" +
-
- "</script>\n");
+ markup.append("<script
type='text/javascript'>footer()</script>\n");
}
else
{