mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
New build scripts
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5282 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
575
source/web/scripts/ajax/dojo/src/lfx/Animation.js
Normal file
575
source/web/scripts/ajax/dojo/src/lfx/Animation.js
Normal file
@@ -0,0 +1,575 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.lfx.Animation");
|
||||
|
||||
dojo.require("dojo.lang.func");
|
||||
|
||||
/*
|
||||
Animation package based on Dan Pupius' work: http://pupius.co.uk/js/Toolkit.Drawing.js
|
||||
*/
|
||||
dojo.lfx.Line = function(/*int*/ start, /*int*/ end){
|
||||
// summary: dojo.lfx.Line is the object used to generate values
|
||||
// from a start value to an end value
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
if(dojo.lang.isArray(start)){
|
||||
/* start: Array
|
||||
end: Array
|
||||
pId: a */
|
||||
var diff = [];
|
||||
dojo.lang.forEach(this.start, function(s,i){
|
||||
diff[i] = this.end[i] - s;
|
||||
}, this);
|
||||
|
||||
this.getValue = function(/*float*/ n){
|
||||
var res = [];
|
||||
dojo.lang.forEach(this.start, function(s, i){
|
||||
res[i] = (diff[i] * n) + s;
|
||||
}, this);
|
||||
return res; // Array
|
||||
}
|
||||
}else{
|
||||
var diff = end - start;
|
||||
|
||||
this.getValue = function(/*float*/ n){
|
||||
// summary: returns the point on the line
|
||||
// n: a floating point number greater than 0 and less than 1
|
||||
return (diff * n) + this.start; // Decimal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dojo.lfx.easeDefault = function(/*Decimal?*/ n){
|
||||
// summary: Returns the point for point n on a sin wave.
|
||||
if(dojo.render.html.khtml){
|
||||
// the cool kids are obviously not using konqueror...
|
||||
// found a very wierd bug in floats constants, 1.5 evals as 1
|
||||
// seems somebody mixed up ints and floats in 3.5.4 ??
|
||||
// FIXME: investigate more and post a KDE bug (Fredrik)
|
||||
return (parseFloat("0.5")+((Math.sin( (n+parseFloat("1.5")) * Math.PI))/2));
|
||||
}else{
|
||||
return (0.5+((Math.sin( (n+1.5) * Math.PI))/2));
|
||||
}
|
||||
}
|
||||
|
||||
dojo.lfx.easeIn = function(/*Decimal?*/ n){
|
||||
// summary: returns the point on an easing curve
|
||||
// n: a floating point number greater than 0 and less than 1
|
||||
return Math.pow(n, 3);
|
||||
}
|
||||
|
||||
dojo.lfx.easeOut = function(/*Decimal?*/ n){
|
||||
// summary: returns the point on the line
|
||||
// n: a floating point number greater than 0 and less than 1
|
||||
return ( 1 - Math.pow(1 - n, 3) );
|
||||
}
|
||||
|
||||
dojo.lfx.easeInOut = function(/*Decimal?*/ n){
|
||||
// summary: returns the point on the line
|
||||
// n: a floating point number greater than 0 and less than 1
|
||||
return ( (3 * Math.pow(n, 2)) - (2 * Math.pow(n, 3)) );
|
||||
}
|
||||
|
||||
dojo.lfx.IAnimation = function(){
|
||||
// summary: dojo.lfx.IAnimation is an interface that implements
|
||||
// commonly used functions of animation objects
|
||||
}
|
||||
dojo.lang.extend(dojo.lfx.IAnimation, {
|
||||
// public properties
|
||||
curve: null,
|
||||
duration: 1000,
|
||||
easing: null,
|
||||
repeatCount: 0,
|
||||
rate: 25,
|
||||
|
||||
// events
|
||||
handler: null,
|
||||
beforeBegin: null,
|
||||
onBegin: null,
|
||||
onAnimate: null,
|
||||
onEnd: null,
|
||||
onPlay: null,
|
||||
onPause: null,
|
||||
onStop: null,
|
||||
|
||||
// public methods
|
||||
play: null,
|
||||
pause: null,
|
||||
stop: null,
|
||||
|
||||
connect: function(/*Event*/ evt, /*Object*/ scope, /*Function*/ newFunc){
|
||||
// summary: Convenience function. Quickly connect to an event
|
||||
// of this object and save the old functions connected to it.
|
||||
// evt: The name of the event to connect to.
|
||||
// scope: the scope in which to run newFunc.
|
||||
// newFunc: the function to run when evt is fired.
|
||||
if(!newFunc){
|
||||
/* scope: Function
|
||||
newFunc: null
|
||||
pId: f */
|
||||
newFunc = scope;
|
||||
scope = this;
|
||||
}
|
||||
newFunc = dojo.lang.hitch(scope, newFunc);
|
||||
var oldFunc = this[evt]||function(){};
|
||||
this[evt] = function(){
|
||||
var ret = oldFunc.apply(this, arguments);
|
||||
newFunc.apply(this, arguments);
|
||||
return ret;
|
||||
}
|
||||
return this; // dojo.lfx.IAnimation
|
||||
},
|
||||
|
||||
fire: function(/*Event*/ evt, /*Array*/ args){
|
||||
// summary: Convenience function. Fire event "evt" and pass it
|
||||
// the arguments specified in "args".
|
||||
// evt: The event to fire.
|
||||
// args: The arguments to pass to the event.
|
||||
if(this[evt]){
|
||||
this[evt].apply(this, (args||[]));
|
||||
}
|
||||
return this; // dojo.lfx.IAnimation
|
||||
},
|
||||
|
||||
repeat: function(/*int*/ count){
|
||||
// summary: Set the repeat count of this object.
|
||||
// count: How many times to repeat the animation.
|
||||
this.repeatCount = count;
|
||||
return this; // dojo.lfx.IAnimation
|
||||
},
|
||||
|
||||
// private properties
|
||||
_active: false,
|
||||
_paused: false
|
||||
});
|
||||
|
||||
dojo.lfx.Animation = function( /*Object*/ handlers,
|
||||
/*int*/ duration,
|
||||
/*dojo.lfx.Line*/ curve,
|
||||
/*function*/ easing,
|
||||
/*int*/ repeatCount,
|
||||
/*int*/ rate){
|
||||
// summary
|
||||
// a generic animation object that fires callbacks into it's handlers
|
||||
// object at various states
|
||||
// handlers: { handler: Function?, onstart: Function?, onstop: Function?, onanimate: Function? }
|
||||
dojo.lfx.IAnimation.call(this);
|
||||
if(dojo.lang.isNumber(handlers)||(!handlers && duration.getValue)){
|
||||
// no handlers argument:
|
||||
rate = repeatCount;
|
||||
repeatCount = easing;
|
||||
easing = curve;
|
||||
curve = duration;
|
||||
duration = handlers;
|
||||
handlers = null;
|
||||
}else if(handlers.getValue||dojo.lang.isArray(handlers)){
|
||||
// no handlers or duration:
|
||||
rate = easing;
|
||||
repeatCount = curve;
|
||||
easing = duration;
|
||||
curve = handlers;
|
||||
duration = null;
|
||||
handlers = null;
|
||||
}
|
||||
if(dojo.lang.isArray(curve)){
|
||||
/* curve: Array
|
||||
pId: a */
|
||||
this.curve = new dojo.lfx.Line(curve[0], curve[1]);
|
||||
}else{
|
||||
this.curve = curve;
|
||||
}
|
||||
if(duration != null && duration > 0){ this.duration = duration; }
|
||||
if(repeatCount){ this.repeatCount = repeatCount; }
|
||||
if(rate){ this.rate = rate; }
|
||||
if(handlers){
|
||||
dojo.lang.forEach([
|
||||
"handler", "beforeBegin", "onBegin",
|
||||
"onEnd", "onPlay", "onStop", "onAnimate"
|
||||
], function(item){
|
||||
if(handlers[item]){
|
||||
this.connect(item, handlers[item]);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
if(easing && dojo.lang.isFunction(easing)){
|
||||
this.easing=easing;
|
||||
}
|
||||
}
|
||||
dojo.inherits(dojo.lfx.Animation, dojo.lfx.IAnimation);
|
||||
dojo.lang.extend(dojo.lfx.Animation, {
|
||||
// "private" properties
|
||||
_startTime: null,
|
||||
_endTime: null,
|
||||
_timer: null,
|
||||
_percent: 0,
|
||||
_startRepeatCount: 0,
|
||||
|
||||
// public methods
|
||||
play: function(/*int?*/ delay, /*bool?*/ gotoStart){
|
||||
// summary: Start the animation.
|
||||
// delay: How many milliseconds to delay before starting.
|
||||
// gotoStart: If true, starts the animation from the beginning; otherwise,
|
||||
// starts it from its current position.
|
||||
if(gotoStart){
|
||||
clearTimeout(this._timer);
|
||||
this._active = false;
|
||||
this._paused = false;
|
||||
this._percent = 0;
|
||||
}else if(this._active && !this._paused){
|
||||
return this; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
this.fire("handler", ["beforeBegin"]);
|
||||
this.fire("beforeBegin");
|
||||
|
||||
if(delay > 0){
|
||||
setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
|
||||
return this; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
this._startTime = new Date().valueOf();
|
||||
if(this._paused){
|
||||
this._startTime -= (this.duration * this._percent / 100);
|
||||
}
|
||||
this._endTime = this._startTime + this.duration;
|
||||
|
||||
this._active = true;
|
||||
this._paused = false;
|
||||
|
||||
var step = this._percent / 100;
|
||||
var value = this.curve.getValue(step);
|
||||
if(this._percent == 0 ){
|
||||
if(!this._startRepeatCount){
|
||||
this._startRepeatCount = this.repeatCount;
|
||||
}
|
||||
this.fire("handler", ["begin", value]);
|
||||
this.fire("onBegin", [value]);
|
||||
}
|
||||
|
||||
this.fire("handler", ["play", value]);
|
||||
this.fire("onPlay", [value]);
|
||||
|
||||
this._cycle();
|
||||
return this; // dojo.lfx.Animation
|
||||
},
|
||||
|
||||
pause: function(){
|
||||
// summary: Pauses a running animation.
|
||||
clearTimeout(this._timer);
|
||||
if(!this._active){ return this; /*dojo.lfx.Animation*/}
|
||||
this._paused = true;
|
||||
var value = this.curve.getValue(this._percent / 100);
|
||||
this.fire("handler", ["pause", value]);
|
||||
this.fire("onPause", [value]);
|
||||
return this; // dojo.lfx.Animation
|
||||
},
|
||||
|
||||
gotoPercent: function(/*Decimal*/ pct, /*bool?*/ andPlay){
|
||||
// summary: Sets the progress of the animation.
|
||||
// pct: A percentage in decimal notation (between and including 0.0 and 1.0).
|
||||
// andPlay: If true, play the animation after setting the progress.
|
||||
clearTimeout(this._timer);
|
||||
this._active = true;
|
||||
this._paused = true;
|
||||
this._percent = pct;
|
||||
if(andPlay){ this.play(); }
|
||||
return this; // dojo.lfx.Animation
|
||||
},
|
||||
|
||||
stop: function(/*bool?*/ gotoEnd){
|
||||
// summary: Stops a running animation.
|
||||
// gotoEnd: If true, the animation will end.
|
||||
clearTimeout(this._timer);
|
||||
var step = this._percent / 100;
|
||||
if(gotoEnd){
|
||||
step = 1;
|
||||
}
|
||||
var value = this.curve.getValue(step);
|
||||
this.fire("handler", ["stop", value]);
|
||||
this.fire("onStop", [value]);
|
||||
this._active = false;
|
||||
this._paused = false;
|
||||
return this; // dojo.lfx.Animation
|
||||
},
|
||||
|
||||
status: function(){
|
||||
// summary: Returns a string representation of the status of
|
||||
// the animation.
|
||||
if(this._active){
|
||||
return this._paused ? "paused" : "playing"; // String
|
||||
}else{
|
||||
return "stopped"; // String
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// "private" methods
|
||||
_cycle: function(){
|
||||
clearTimeout(this._timer);
|
||||
if(this._active){
|
||||
var curr = new Date().valueOf();
|
||||
var step = (curr - this._startTime) / (this._endTime - this._startTime);
|
||||
|
||||
if(step >= 1){
|
||||
step = 1;
|
||||
this._percent = 100;
|
||||
}else{
|
||||
this._percent = step * 100;
|
||||
}
|
||||
|
||||
// Perform easing
|
||||
if((this.easing)&&(dojo.lang.isFunction(this.easing))){
|
||||
step = this.easing(step);
|
||||
}
|
||||
|
||||
var value = this.curve.getValue(step);
|
||||
this.fire("handler", ["animate", value]);
|
||||
this.fire("onAnimate", [value]);
|
||||
|
||||
if( step < 1 ){
|
||||
this._timer = setTimeout(dojo.lang.hitch(this, "_cycle"), this.rate);
|
||||
}else{
|
||||
this._active = false;
|
||||
this.fire("handler", ["end"]);
|
||||
this.fire("onEnd");
|
||||
|
||||
if(this.repeatCount > 0){
|
||||
this.repeatCount--;
|
||||
this.play(null, true);
|
||||
}else if(this.repeatCount == -1){
|
||||
this.play(null, true);
|
||||
}else{
|
||||
if(this._startRepeatCount){
|
||||
this.repeatCount = this._startRepeatCount;
|
||||
this._startRepeatCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this; // dojo.lfx.Animation
|
||||
}
|
||||
});
|
||||
|
||||
dojo.lfx.Combine = function(/*dojo.lfx.IAnimation...*/ animations){
|
||||
// summary: An animation object to play animations passed to it at the same time.
|
||||
dojo.lfx.IAnimation.call(this);
|
||||
this._anims = [];
|
||||
this._animsEnded = 0;
|
||||
|
||||
var anims = arguments;
|
||||
if(anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))){
|
||||
/* animations: dojo.lfx.IAnimation[]
|
||||
pId: a */
|
||||
anims = anims[0];
|
||||
}
|
||||
|
||||
dojo.lang.forEach(anims, function(anim){
|
||||
this._anims.push(anim);
|
||||
anim.connect("onEnd", dojo.lang.hitch(this, "_onAnimsEnded"));
|
||||
}, this);
|
||||
}
|
||||
dojo.inherits(dojo.lfx.Combine, dojo.lfx.IAnimation);
|
||||
dojo.lang.extend(dojo.lfx.Combine, {
|
||||
// private members
|
||||
_animsEnded: 0,
|
||||
|
||||
// public methods
|
||||
play: function(/*int?*/ delay, /*bool?*/ gotoStart){
|
||||
// summary: Start the animations.
|
||||
// delay: How many milliseconds to delay before starting.
|
||||
// gotoStart: If true, starts the animations from the beginning; otherwise,
|
||||
// starts them from their current position.
|
||||
if( !this._anims.length ){ return this; /*dojo.lfx.Combine*/}
|
||||
|
||||
this.fire("beforeBegin");
|
||||
|
||||
if(delay > 0){
|
||||
setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
|
||||
return this; // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
if(gotoStart || this._anims[0].percent == 0){
|
||||
this.fire("onBegin");
|
||||
}
|
||||
this.fire("onPlay");
|
||||
this._animsCall("play", null, gotoStart);
|
||||
return this; // dojo.lfx.Combine
|
||||
},
|
||||
|
||||
pause: function(){
|
||||
// summary: Pauses the running animations.
|
||||
this.fire("onPause");
|
||||
this._animsCall("pause");
|
||||
return this; // dojo.lfx.Combine
|
||||
},
|
||||
|
||||
stop: function(/*bool?*/ gotoEnd){
|
||||
// summary: Stops the running animations.
|
||||
// gotoEnd: If true, the animations will end.
|
||||
this.fire("onStop");
|
||||
this._animsCall("stop", gotoEnd);
|
||||
return this; // dojo.lfx.Combine
|
||||
},
|
||||
|
||||
// private methods
|
||||
_onAnimsEnded: function(){
|
||||
this._animsEnded++;
|
||||
if(this._animsEnded >= this._anims.length){
|
||||
this.fire("onEnd");
|
||||
}
|
||||
return this; // dojo.lfx.Combine
|
||||
},
|
||||
|
||||
_animsCall: function(/*String*/ funcName){
|
||||
var args = [];
|
||||
if(arguments.length > 1){
|
||||
for(var i = 1 ; i < arguments.length ; i++){
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
var _this = this;
|
||||
dojo.lang.forEach(this._anims, function(anim){
|
||||
anim[funcName](args);
|
||||
}, _this);
|
||||
return this; // dojo.lfx.Combine
|
||||
}
|
||||
});
|
||||
|
||||
dojo.lfx.Chain = function(/*dojo.lfx.IAnimation...*/ animations) {
|
||||
// summary: An animation object to play animations passed to it
|
||||
// one after another.
|
||||
dojo.lfx.IAnimation.call(this);
|
||||
this._anims = [];
|
||||
this._currAnim = -1;
|
||||
|
||||
var anims = arguments;
|
||||
if(anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))){
|
||||
/* animations: dojo.lfx.IAnimation[]
|
||||
pId: a */
|
||||
anims = anims[0];
|
||||
}
|
||||
|
||||
var _this = this;
|
||||
dojo.lang.forEach(anims, function(anim, i, anims_arr){
|
||||
this._anims.push(anim);
|
||||
if(i < anims_arr.length - 1){
|
||||
anim.connect("onEnd", dojo.lang.hitch(this, "_playNext") );
|
||||
}else{
|
||||
anim.connect("onEnd", dojo.lang.hitch(this, function(){ this.fire("onEnd"); }) );
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
dojo.inherits(dojo.lfx.Chain, dojo.lfx.IAnimation);
|
||||
dojo.lang.extend(dojo.lfx.Chain, {
|
||||
// private members
|
||||
_currAnim: -1,
|
||||
|
||||
// public methods
|
||||
play: function(/*int?*/ delay, /*bool?*/ gotoStart){
|
||||
// summary: Start the animation sequence.
|
||||
// delay: How many milliseconds to delay before starting.
|
||||
// gotoStart: If true, starts the sequence from the beginning; otherwise,
|
||||
// starts it from its current position.
|
||||
if( !this._anims.length ) { return this; /*dojo.lfx.Chain*/}
|
||||
if( gotoStart || !this._anims[this._currAnim] ) {
|
||||
this._currAnim = 0;
|
||||
}
|
||||
|
||||
var currentAnimation = this._anims[this._currAnim];
|
||||
|
||||
this.fire("beforeBegin");
|
||||
if(delay > 0){
|
||||
setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
|
||||
return this; // dojo.lfx.Chain
|
||||
}
|
||||
|
||||
if(currentAnimation){
|
||||
if(this._currAnim == 0){
|
||||
this.fire("handler", ["begin", this._currAnim]);
|
||||
this.fire("onBegin", [this._currAnim]);
|
||||
}
|
||||
this.fire("onPlay", [this._currAnim]);
|
||||
currentAnimation.play(null, gotoStart);
|
||||
}
|
||||
return this; // dojo.lfx.Chain
|
||||
},
|
||||
|
||||
pause: function(){
|
||||
// summary: Pauses the running animation sequence.
|
||||
if( this._anims[this._currAnim] ) {
|
||||
this._anims[this._currAnim].pause();
|
||||
this.fire("onPause", [this._currAnim]);
|
||||
}
|
||||
return this; // dojo.lfx.Chain
|
||||
},
|
||||
|
||||
playPause: function(){
|
||||
// summary: If the animation sequence is playing, pause it; otherwise,
|
||||
// play it.
|
||||
if(this._anims.length == 0){ return this; }
|
||||
if(this._currAnim == -1){ this._currAnim = 0; }
|
||||
var currAnim = this._anims[this._currAnim];
|
||||
if( currAnim ) {
|
||||
if( !currAnim._active || currAnim._paused ) {
|
||||
this.play();
|
||||
} else {
|
||||
this.pause();
|
||||
}
|
||||
}
|
||||
return this; // dojo.lfx.Chain
|
||||
},
|
||||
|
||||
stop: function(){
|
||||
// summary: Stops the running animations.
|
||||
var currAnim = this._anims[this._currAnim];
|
||||
if(currAnim){
|
||||
currAnim.stop();
|
||||
this.fire("onStop", [this._currAnim]);
|
||||
}
|
||||
return currAnim; // dojo.lfx.IAnimation
|
||||
},
|
||||
|
||||
// private methods
|
||||
_playNext: function(){
|
||||
if( this._currAnim == -1 || this._anims.length == 0 ) { return this; }
|
||||
this._currAnim++;
|
||||
if( this._anims[this._currAnim] ){
|
||||
this._anims[this._currAnim].play(null, true);
|
||||
}
|
||||
return this; // dojo.lfx.Chain
|
||||
}
|
||||
});
|
||||
|
||||
dojo.lfx.combine = function(/*dojo.lfx.IAnimation...*/ animations){
|
||||
// summary: Convenience function. Returns a dojo.lfx.Combine created
|
||||
// using the animations passed in.
|
||||
var anims = arguments;
|
||||
if(dojo.lang.isArray(arguments[0])){
|
||||
/* animations: dojo.lfx.IAnimation[]
|
||||
pId: a */
|
||||
anims = arguments[0];
|
||||
}
|
||||
if(anims.length == 1){ return anims[0]; }
|
||||
return new dojo.lfx.Combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.chain = function(/*dojo.lfx.IAnimation...*/ animations){
|
||||
// summary: Convenience function. Returns a dojo.lfx.Chain created
|
||||
// using the animations passed in.
|
||||
var anims = arguments;
|
||||
if(dojo.lang.isArray(arguments[0])){
|
||||
/* animations: dojo.lfx.IAnimation[]
|
||||
pId: a */
|
||||
anims = arguments[0];
|
||||
}
|
||||
if(anims.length == 1){ return anims[0]; }
|
||||
return new dojo.lfx.Chain(anims); // dojo.lfx.Combine
|
||||
}
|
15
source/web/scripts/ajax/dojo/src/lfx/__package__.js
Normal file
15
source/web/scripts/ajax/dojo/src/lfx/__package__.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.kwCompoundRequire({
|
||||
browser: ["dojo.lfx.html"],
|
||||
dashboard: ["dojo.lfx.html"]
|
||||
});
|
||||
dojo.provide("dojo.lfx.*");
|
148
source/web/scripts/ajax/dojo/src/lfx/extras.js
Normal file
148
source/web/scripts/ajax/dojo/src/lfx/extras.js
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.lfx.extras");
|
||||
|
||||
dojo.require("dojo.lfx.html");
|
||||
dojo.require("dojo.lfx.Animation");
|
||||
|
||||
dojo.lfx.html.fadeWipeIn = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will fade "nodes" from its current
|
||||
// opacity to fully opaque while wiping it in.
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anim = dojo.lfx.combine(
|
||||
dojo.lfx.fadeIn(nodes, duration, easing),
|
||||
dojo.lfx.wipeIn(nodes, duration, easing)
|
||||
);
|
||||
|
||||
if(callback){
|
||||
anim.connect("onEnd", function(){
|
||||
callback(nodes, anim);
|
||||
});
|
||||
}
|
||||
|
||||
return anim; // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.html.fadeWipeOut = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will fade "nodes" from its current
|
||||
// opacity to fully transparent while wiping it out.
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anim = dojo.lfx.combine(
|
||||
dojo.lfx.fadeOut(nodes, duration, easing),
|
||||
dojo.lfx.wipeOut(nodes, duration, easing)
|
||||
);
|
||||
|
||||
if(callback){
|
||||
/* callback: Function
|
||||
pId: f */
|
||||
anim.connect("onEnd", function(){
|
||||
callback(nodes, anim);
|
||||
});
|
||||
}
|
||||
|
||||
return anim; // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.html.scale = function(/*DOMNode[]*/nodes,
|
||||
/*int*/ percentage,
|
||||
/*bool?*/ scaleContent,
|
||||
/*bool?*/ fromCenter,
|
||||
/*int?*/ duration,
|
||||
/*Function?*/ easing,
|
||||
/*Function?*/ callback){
|
||||
// summary: Returns an animation that will scale "nodes" by "percentage".
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// percentage: A whole number representing the percentage to scale "nodes".
|
||||
// scaleContent: If true, will scale the contents of "nodes".
|
||||
// fromCenter: If true, will scale "nodes" from its center rather than the
|
||||
// lower right corner.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anims = [];
|
||||
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
var outer = dojo.html.getMarginBox(node);
|
||||
|
||||
var actualPct = percentage/100.0;
|
||||
var props = [
|
||||
{ property: "width",
|
||||
start: outer.width,
|
||||
end: outer.width * actualPct
|
||||
},
|
||||
{ property: "height",
|
||||
start: outer.height,
|
||||
end: outer.height * actualPct
|
||||
}];
|
||||
|
||||
if(scaleContent){
|
||||
var fontSize = dojo.html.getStyle(node, 'font-size');
|
||||
var fontSizeType = null;
|
||||
if(!fontSize){
|
||||
fontSize = parseFloat('100%');
|
||||
fontSizeType = '%';
|
||||
}else{
|
||||
dojo.lang.some(['em','px','%'], function(item, index, arr){
|
||||
if(fontSize.indexOf(item)>0){
|
||||
fontSize = parseFloat(fontSize);
|
||||
fontSizeType = item;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
props.push({
|
||||
property: "font-size",
|
||||
start: fontSize,
|
||||
end: fontSize * actualPct,
|
||||
units: fontSizeType });
|
||||
}
|
||||
|
||||
if(fromCenter){
|
||||
var positioning = dojo.html.getStyle(node, "position");
|
||||
var originalTop = node.offsetTop;
|
||||
var originalLeft = node.offsetLeft;
|
||||
var endTop = ((outer.height * actualPct) - outer.height)/2;
|
||||
var endLeft = ((outer.width * actualPct) - outer.width)/2;
|
||||
props.push({
|
||||
property: "top",
|
||||
start: originalTop,
|
||||
end: (positioning == "absolute" ? originalTop - endTop : (-1*endTop))
|
||||
});
|
||||
props.push({
|
||||
property: "left",
|
||||
start: originalLeft,
|
||||
end: (positioning == "absolute" ? originalLeft - endLeft : (-1*endLeft))
|
||||
});
|
||||
}
|
||||
|
||||
var anim = dojo.lfx.propertyAnimation(node, props, duration, easing);
|
||||
if(callback){
|
||||
anim.connect("onEnd", function(){
|
||||
callback(node, anim);
|
||||
});
|
||||
}
|
||||
|
||||
anims.push(anim);
|
||||
});
|
||||
|
||||
return dojo.lfx.combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
|
748
source/web/scripts/ajax/dojo/src/lfx/html.js
Normal file
748
source/web/scripts/ajax/dojo/src/lfx/html.js
Normal file
@@ -0,0 +1,748 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.lfx.html");
|
||||
|
||||
dojo.require("dojo.gfx.color");
|
||||
dojo.require("dojo.lfx.Animation");
|
||||
dojo.require("dojo.lang.array");
|
||||
dojo.require("dojo.html.display");
|
||||
dojo.require("dojo.html.color");
|
||||
dojo.require("dojo.html.layout");
|
||||
|
||||
dojo.lfx.html._byId = function(nodes){
|
||||
if(!nodes){ return []; }
|
||||
if(dojo.lang.isArrayLike(nodes)){
|
||||
if(!nodes.alreadyChecked){
|
||||
var n = [];
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
n.push(dojo.byId(node));
|
||||
});
|
||||
n.alreadyChecked = true;
|
||||
return n;
|
||||
}else{
|
||||
return nodes;
|
||||
}
|
||||
}else{
|
||||
var n = [];
|
||||
n.push(dojo.byId(nodes));
|
||||
n.alreadyChecked = true;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
dojo.lfx.html.propertyAnimation = function( /*DOMNode[]*/ nodes,
|
||||
/*Object[]*/ propertyMap,
|
||||
/*int*/ duration,
|
||||
/*function*/ easing,
|
||||
/*Object*/ handlers){
|
||||
// summary: Returns an animation that will transition the properties of "nodes"
|
||||
// depending how they are defined in "propertyMap".
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// propertyMap: { property: String, start: Decimal?, end: Decimal?, units: String? }
|
||||
// An array of objects defining properties to change.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// handlers: { handler: Function?, onstart: Function?, onstop: Function?, onanimate: Function? }
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
|
||||
var targs = {
|
||||
"propertyMap": propertyMap,
|
||||
"nodes": nodes,
|
||||
"duration": duration,
|
||||
"easing": easing||dojo.lfx.easeDefault
|
||||
};
|
||||
|
||||
var setEmUp = function(args){
|
||||
if(args.nodes.length==1){
|
||||
// FIXME: we're only supporting start-value filling when one node is
|
||||
// passed
|
||||
|
||||
var pm = args.propertyMap;
|
||||
if(!dojo.lang.isArray(args.propertyMap)){
|
||||
// it's stupid to have to pack an array with a set of objects
|
||||
// when you can just pass in an object list
|
||||
var parr = [];
|
||||
for(var pname in pm){
|
||||
pm[pname].property = pname;
|
||||
parr.push(pm[pname]);
|
||||
}
|
||||
pm = args.propertyMap = parr;
|
||||
}
|
||||
dojo.lang.forEach(pm, function(prop){
|
||||
if(dj_undef("start", prop)){
|
||||
if(prop.property != "opacity"){
|
||||
prop.start = parseInt(dojo.html.getComputedStyle(args.nodes[0], prop.property));
|
||||
}else{
|
||||
prop.start = dojo.html.getOpacity(args.nodes[0]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var coordsAsInts = function(coords){
|
||||
var cints = [];
|
||||
dojo.lang.forEach(coords, function(c){
|
||||
cints.push(Math.round(c));
|
||||
});
|
||||
return cints;
|
||||
}
|
||||
|
||||
var setStyle = function(n, style){
|
||||
n = dojo.byId(n);
|
||||
if(!n || !n.style){ return; }
|
||||
for(var s in style){
|
||||
try{
|
||||
if(s == "opacity"){
|
||||
dojo.html.setOpacity(n, style[s]);
|
||||
}else{
|
||||
n.style[s] = style[s];
|
||||
}
|
||||
}catch(e){ dojo.debug(e); }
|
||||
}
|
||||
}
|
||||
|
||||
var propLine = function(properties){
|
||||
this._properties = properties;
|
||||
this.diffs = new Array(properties.length);
|
||||
dojo.lang.forEach(properties, function(prop, i){
|
||||
// calculate the end - start to optimize a bit
|
||||
if(dojo.lang.isFunction(prop.start)){
|
||||
prop.start = prop.start(prop, i);
|
||||
}
|
||||
if(dojo.lang.isFunction(prop.end)){
|
||||
prop.end = prop.end(prop, i);
|
||||
}
|
||||
if(dojo.lang.isArray(prop.start)){
|
||||
// don't loop through the arrays
|
||||
this.diffs[i] = null;
|
||||
}else if(prop.start instanceof dojo.gfx.color.Color){
|
||||
// save these so we don't have to call toRgb() every getValue() call
|
||||
prop.startRgb = prop.start.toRgb();
|
||||
prop.endRgb = prop.end.toRgb();
|
||||
}else{
|
||||
this.diffs[i] = prop.end - prop.start;
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.getValue = function(n){
|
||||
var ret = {};
|
||||
dojo.lang.forEach(this._properties, function(prop, i){
|
||||
var value = null;
|
||||
if(dojo.lang.isArray(prop.start)){
|
||||
// FIXME: what to do here?
|
||||
}else if(prop.start instanceof dojo.gfx.color.Color){
|
||||
value = (prop.units||"rgb") + "(";
|
||||
for(var j = 0 ; j < prop.startRgb.length ; j++){
|
||||
value += Math.round(((prop.endRgb[j] - prop.startRgb[j]) * n) + prop.startRgb[j]) + (j < prop.startRgb.length - 1 ? "," : "");
|
||||
}
|
||||
value += ")";
|
||||
}else{
|
||||
value = ((this.diffs[i]) * n) + prop.start + (prop.property != "opacity" ? prop.units||"px" : "");
|
||||
}
|
||||
ret[dojo.html.toCamelCase(prop.property)] = value;
|
||||
}, this);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
var anim = new dojo.lfx.Animation({
|
||||
beforeBegin: function(){
|
||||
setEmUp(targs);
|
||||
anim.curve = new propLine(targs.propertyMap);
|
||||
},
|
||||
onAnimate: function(propValues){
|
||||
dojo.lang.forEach(targs.nodes, function(node){
|
||||
setStyle(node, propValues);
|
||||
});
|
||||
}
|
||||
},
|
||||
targs.duration,
|
||||
null,
|
||||
targs.easing
|
||||
);
|
||||
if(handlers){
|
||||
for(var x in handlers){
|
||||
if(dojo.lang.isFunction(handlers[x])){
|
||||
anim.connect(x, anim, handlers[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return anim; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html._makeFadeable = function(nodes){
|
||||
var makeFade = function(node){
|
||||
if(dojo.render.html.ie){
|
||||
// only set the zoom if the "tickle" value would be the same as the
|
||||
// default
|
||||
if( (node.style.zoom.length == 0) &&
|
||||
(dojo.html.getStyle(node, "zoom") == "normal") ){
|
||||
// make sure the node "hasLayout"
|
||||
// NOTE: this has been tested with larger and smaller user-set text
|
||||
// sizes and works fine
|
||||
node.style.zoom = "1";
|
||||
// node.style.zoom = "normal";
|
||||
}
|
||||
// don't set the width to auto if it didn't already cascade that way.
|
||||
// We don't want to f anyones designs
|
||||
if( (node.style.width.length == 0) &&
|
||||
(dojo.html.getStyle(node, "width") == "auto") ){
|
||||
node.style.width = "auto";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(dojo.lang.isArrayLike(nodes)){
|
||||
dojo.lang.forEach(nodes, makeFade);
|
||||
}else{
|
||||
makeFade(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
dojo.lfx.html.fade = function(/*DOMNode[]*/ nodes,
|
||||
/*Object*/values,
|
||||
/*int?*/ duration,
|
||||
/*Function?*/ easing,
|
||||
/*Function?*/ callback){
|
||||
// summary:Returns an animation that will fade the "nodes" from the start to end values passed.
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// values: { start: Decimal?, end: Decimal? }
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var props = { property: "opacity" };
|
||||
if(!dj_undef("start", values)){
|
||||
props.start = values.start;
|
||||
}else{
|
||||
props.start = function(){ return dojo.html.getOpacity(nodes[0]); };
|
||||
}
|
||||
|
||||
if(!dj_undef("end", values)){
|
||||
props.end = values.end;
|
||||
}else{
|
||||
dojo.raise("dojo.lfx.html.fade needs an end value");
|
||||
}
|
||||
|
||||
var anim = dojo.lfx.propertyAnimation(nodes, [ props ], duration, easing);
|
||||
anim.connect("beforeBegin", function(){
|
||||
dojo.lfx.html._makeFadeable(nodes);
|
||||
});
|
||||
if(callback){
|
||||
anim.connect("onEnd", function(){ callback(nodes, anim); });
|
||||
}
|
||||
|
||||
return anim; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html.fadeIn = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will fade "nodes" from its current opacity to fully opaque.
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
return dojo.lfx.html.fade(nodes, { end: 1 }, duration, easing, callback); // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html.fadeOut = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will fade "nodes" from its current opacity to fully transparent.
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
return dojo.lfx.html.fade(nodes, { end: 0 }, duration, easing, callback); // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html.fadeShow = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will fade "nodes" from transparent to opaque and shows
|
||||
// "nodes" at the end if it is hidden.
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes=dojo.lfx.html._byId(nodes);
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
dojo.html.setOpacity(node, 0.0);
|
||||
});
|
||||
|
||||
var anim = dojo.lfx.html.fadeIn(nodes, duration, easing, callback);
|
||||
anim.connect("beforeBegin", function(){
|
||||
if(dojo.lang.isArrayLike(nodes)){
|
||||
dojo.lang.forEach(nodes, dojo.html.show);
|
||||
}else{
|
||||
dojo.html.show(nodes);
|
||||
}
|
||||
});
|
||||
|
||||
return anim; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html.fadeHide = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will fade "nodes" from its current opacity to opaque and hides
|
||||
// "nodes" at the end.
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
var anim = dojo.lfx.html.fadeOut(nodes, duration, easing, function(){
|
||||
if(dojo.lang.isArrayLike(nodes)){
|
||||
dojo.lang.forEach(nodes, dojo.html.hide);
|
||||
}else{
|
||||
dojo.html.hide(nodes);
|
||||
}
|
||||
if(callback){ callback(nodes, anim); }
|
||||
});
|
||||
|
||||
return anim; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html.wipeIn = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will show and wipe in "nodes".
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anims = [];
|
||||
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
var oprop = { }; // old properties of node (before we mucked w/them)
|
||||
|
||||
// get node height, either it's natural height or it's height specified via style or class attributes
|
||||
// (for FF, the node has to be (temporarily) rendered to measure height)
|
||||
// TODO: should this offscreen code be part of dojo.html, so that getBorderBox() works on hidden nodes?
|
||||
var origTop, origLeft, origPosition;
|
||||
with(node.style){
|
||||
origTop=top; origLeft=left; origPosition=position;
|
||||
top="-9999px"; left="-9999px"; position="absolute";
|
||||
display="";
|
||||
}
|
||||
var height = dojo.html.getBorderBox(node).height;
|
||||
with(node.style){
|
||||
top=origTop; left=origLeft; position=origPosition;
|
||||
display="none";
|
||||
}
|
||||
|
||||
var anim = dojo.lfx.propertyAnimation(node,
|
||||
{ "height": {
|
||||
start: 1, // 0 causes IE to display the whole panel
|
||||
end: function(){ return height; }
|
||||
}
|
||||
},
|
||||
duration,
|
||||
easing);
|
||||
|
||||
anim.connect("beforeBegin", function(){
|
||||
oprop.overflow = node.style.overflow;
|
||||
oprop.height = node.style.height;
|
||||
with(node.style){
|
||||
overflow = "hidden";
|
||||
height = "1px"; // 0 causes IE to display the whole panel
|
||||
}
|
||||
dojo.html.show(node);
|
||||
});
|
||||
|
||||
anim.connect("onEnd", function(){
|
||||
with(node.style){
|
||||
overflow = oprop.overflow;
|
||||
height = oprop.height;
|
||||
}
|
||||
if(callback){ callback(node, anim); }
|
||||
});
|
||||
anims.push(anim);
|
||||
});
|
||||
|
||||
return dojo.lfx.combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.html.wipeOut = function(/*DOMNode[]*/ nodes, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will wipe out and hide "nodes".
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anims = [];
|
||||
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
var oprop = { }; // old properties of node (before we mucked w/them)
|
||||
var anim = dojo.lfx.propertyAnimation(node,
|
||||
{ "height": {
|
||||
start: function(){ return dojo.html.getContentBox(node).height; },
|
||||
end: 1 // 0 causes IE to display the whole panel
|
||||
}
|
||||
},
|
||||
duration,
|
||||
easing,
|
||||
{
|
||||
"beforeBegin": function(){
|
||||
oprop.overflow = node.style.overflow;
|
||||
oprop.height = node.style.height;
|
||||
with(node.style){
|
||||
overflow = "hidden";
|
||||
}
|
||||
dojo.html.show(node);
|
||||
},
|
||||
|
||||
"onEnd": function(){
|
||||
dojo.html.hide(node);
|
||||
with(node.style){
|
||||
overflow = oprop.overflow;
|
||||
height = oprop.height;
|
||||
}
|
||||
if(callback){ callback(node, anim); }
|
||||
}
|
||||
}
|
||||
);
|
||||
anims.push(anim);
|
||||
});
|
||||
|
||||
return dojo.lfx.combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.html.slideTo = function(/*DOMNode*/ nodes,
|
||||
/*Object*/ coords,
|
||||
/*int?*/ duration,
|
||||
/*Function?*/ easing,
|
||||
/*Function?*/ callback){
|
||||
// summary: Returns an animation that will slide "nodes" from its current position to
|
||||
// the position defined in "coords".
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// coords: { top: Decimal?, left: Decimal? }
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anims = [];
|
||||
var compute = dojo.html.getComputedStyle;
|
||||
|
||||
if(dojo.lang.isArray(coords)){
|
||||
/* coords: Array
|
||||
pId: a */
|
||||
dojo.deprecated('dojo.lfx.html.slideTo(node, array)', 'use dojo.lfx.html.slideTo(node, {top: value, left: value});', '0.5');
|
||||
coords = { top: coords[0], left: coords[1] };
|
||||
}
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
var top = null;
|
||||
var left = null;
|
||||
|
||||
var init = (function(){
|
||||
var innerNode = node;
|
||||
return function(){
|
||||
var pos = compute(innerNode, 'position');
|
||||
top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node, 'top')) || 0);
|
||||
left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node, 'left')) || 0);
|
||||
|
||||
if (!dojo.lang.inArray(['absolute', 'relative'], pos)) {
|
||||
var ret = dojo.html.abs(innerNode, true);
|
||||
dojo.html.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;");
|
||||
top = ret.y;
|
||||
left = ret.x;
|
||||
}
|
||||
}
|
||||
})();
|
||||
init();
|
||||
|
||||
var anim = dojo.lfx.propertyAnimation(node,
|
||||
{ "top": { start: top, end: (coords.top||0) },
|
||||
"left": { start: left, end: (coords.left||0) }
|
||||
},
|
||||
duration,
|
||||
easing,
|
||||
{ "beforeBegin": init }
|
||||
);
|
||||
|
||||
if(callback){
|
||||
anim.connect("onEnd", function(){ callback(nodes, anim); });
|
||||
}
|
||||
|
||||
anims.push(anim);
|
||||
});
|
||||
|
||||
return dojo.lfx.combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.html.slideBy = function(/*DOMNode*/ nodes, /*Object*/ coords, /*int?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
|
||||
// summary: Returns an animation that will slide "nodes" from its current position
|
||||
// to its current position plus the numbers defined in "coords".
|
||||
// nodes: An array of DOMNodes or one DOMNode.
|
||||
// coords: { top: Decimal?, left: Decimal? }
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anims = [];
|
||||
var compute = dojo.html.getComputedStyle;
|
||||
|
||||
if(dojo.lang.isArray(coords)){
|
||||
/* coords: Array
|
||||
pId: a */
|
||||
dojo.deprecated('dojo.lfx.html.slideBy(node, array)', 'use dojo.lfx.html.slideBy(node, {top: value, left: value});', '0.5');
|
||||
coords = { top: coords[0], left: coords[1] };
|
||||
}
|
||||
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
var top = null;
|
||||
var left = null;
|
||||
|
||||
var init = (function(){
|
||||
var innerNode = node;
|
||||
return function(){
|
||||
var pos = compute(innerNode, 'position');
|
||||
top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node, 'top')) || 0);
|
||||
left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node, 'left')) || 0);
|
||||
|
||||
if (!dojo.lang.inArray(['absolute', 'relative'], pos)) {
|
||||
var ret = dojo.html.abs(innerNode, true);
|
||||
dojo.html.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;");
|
||||
top = ret.y;
|
||||
left = ret.x;
|
||||
}
|
||||
}
|
||||
})();
|
||||
init();
|
||||
|
||||
var anim = dojo.lfx.propertyAnimation(node,
|
||||
{
|
||||
"top": { start: top, end: top+(coords.top||0) },
|
||||
"left": { start: left, end: left+(coords.left||0) }
|
||||
},
|
||||
duration,
|
||||
easing).connect("beforeBegin", init);
|
||||
|
||||
if(callback){
|
||||
anim.connect("onEnd", function(){ callback(nodes, anim); });
|
||||
}
|
||||
|
||||
anims.push(anim);
|
||||
});
|
||||
|
||||
return dojo.lfx.combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.html.explode = function(/*DOMNode*/ start,
|
||||
/*DOMNode*/ endNode,
|
||||
/*int?*/ duration,
|
||||
/*Function?*/ easing,
|
||||
/*Function?*/ callback){
|
||||
// summary: Returns an animation that will
|
||||
// start:
|
||||
// endNode:
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
var h = dojo.html;
|
||||
start = dojo.byId(start);
|
||||
endNode = dojo.byId(endNode);
|
||||
var startCoords = h.toCoordinateObject(start, true);
|
||||
var outline = document.createElement("div");
|
||||
h.copyStyle(outline, endNode);
|
||||
if(endNode.explodeClassName){ outline.className = endNode.explodeClassName; }
|
||||
with(outline.style){
|
||||
position = "absolute";
|
||||
display = "none";
|
||||
// border = "1px solid black";
|
||||
var backgroundStyle = h.getStyle(start, "background-color");
|
||||
backgroundColor = backgroundStyle ? backgroundStyle.toLowerCase() : "transparent";
|
||||
backgroundColor = (backgroundColor == "transparent") ? "rgb(221, 221, 221)" : backgroundColor;
|
||||
}
|
||||
dojo.body().appendChild(outline);
|
||||
|
||||
with(endNode.style){
|
||||
visibility = "hidden";
|
||||
display = "block";
|
||||
}
|
||||
var endCoords = h.toCoordinateObject(endNode, true);
|
||||
with(endNode.style){
|
||||
display = "none";
|
||||
visibility = "visible";
|
||||
}
|
||||
|
||||
var props = { opacity: { start: 0.5, end: 1.0 } };
|
||||
dojo.lang.forEach(["height", "width", "top", "left"], function(type){
|
||||
props[type] = { start: startCoords[type], end: endCoords[type] }
|
||||
});
|
||||
|
||||
var anim = new dojo.lfx.propertyAnimation(outline,
|
||||
props,
|
||||
duration,
|
||||
easing,
|
||||
{
|
||||
"beforeBegin": function(){
|
||||
h.setDisplay(outline, "block");
|
||||
},
|
||||
"onEnd": function(){
|
||||
h.setDisplay(endNode, "block");
|
||||
outline.parentNode.removeChild(outline);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if(callback){
|
||||
anim.connect("onEnd", function(){ callback(endNode, anim); });
|
||||
}
|
||||
return anim; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html.implode = function(/*DOMNode*/ startNode,
|
||||
/*DOMNode*/ end,
|
||||
/*int?*/ duration,
|
||||
/*Function?*/ easing,
|
||||
/*Function?*/ callback){
|
||||
// summary: Returns an animation that will
|
||||
// startNode:
|
||||
// end:
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
var h = dojo.html;
|
||||
startNode = dojo.byId(startNode);
|
||||
end = dojo.byId(end);
|
||||
var startCoords = dojo.html.toCoordinateObject(startNode, true);
|
||||
var endCoords = dojo.html.toCoordinateObject(end, true);
|
||||
|
||||
var outline = document.createElement("div");
|
||||
dojo.html.copyStyle(outline, startNode);
|
||||
if (startNode.explodeClassName) { outline.className = startNode.explodeClassName; }
|
||||
dojo.html.setOpacity(outline, 0.3);
|
||||
with(outline.style){
|
||||
position = "absolute";
|
||||
display = "none";
|
||||
backgroundColor = h.getStyle(startNode, "background-color").toLowerCase();
|
||||
}
|
||||
dojo.body().appendChild(outline);
|
||||
|
||||
var props = { opacity: { start: 1.0, end: 0.5 } };
|
||||
dojo.lang.forEach(["height", "width", "top", "left"], function(type){
|
||||
props[type] = { start: startCoords[type], end: endCoords[type] }
|
||||
});
|
||||
|
||||
var anim = new dojo.lfx.propertyAnimation(outline,
|
||||
props,
|
||||
duration,
|
||||
easing,
|
||||
{
|
||||
"beforeBegin": function(){
|
||||
dojo.html.hide(startNode);
|
||||
dojo.html.show(outline);
|
||||
},
|
||||
"onEnd": function(){
|
||||
outline.parentNode.removeChild(outline);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if(callback){
|
||||
anim.connect("onEnd", function(){ callback(startNode, anim); });
|
||||
}
|
||||
return anim; // dojo.lfx.Animation
|
||||
}
|
||||
|
||||
dojo.lfx.html.highlight = function(/*DOMNode[]*/ nodes,
|
||||
/*dojo.gfx.color.Color*/ startColor,
|
||||
/*int?*/ duration,
|
||||
/*Function?*/ easing,
|
||||
/*Function?*/ callback){
|
||||
// summary: Returns an animation that will set the background color
|
||||
// of "nodes" to startColor and transition it to "nodes"
|
||||
// original color.
|
||||
// startColor: Color to transition from.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anims = [];
|
||||
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
var color = dojo.html.getBackgroundColor(node);
|
||||
var bg = dojo.html.getStyle(node, "background-color").toLowerCase();
|
||||
var bgImage = dojo.html.getStyle(node, "background-image");
|
||||
var wasTransparent = (bg == "transparent" || bg == "rgba(0, 0, 0, 0)");
|
||||
while(color.length > 3) { color.pop(); }
|
||||
|
||||
var rgb = new dojo.gfx.color.Color(startColor);
|
||||
var endRgb = new dojo.gfx.color.Color(color);
|
||||
|
||||
var anim = dojo.lfx.propertyAnimation(node,
|
||||
{ "background-color": { start: rgb, end: endRgb } },
|
||||
duration,
|
||||
easing,
|
||||
{
|
||||
"beforeBegin": function(){
|
||||
if(bgImage){
|
||||
node.style.backgroundImage = "none";
|
||||
}
|
||||
node.style.backgroundColor = "rgb(" + rgb.toRgb().join(",") + ")";
|
||||
},
|
||||
"onEnd": function(){
|
||||
if(bgImage){
|
||||
node.style.backgroundImage = bgImage;
|
||||
}
|
||||
if(wasTransparent){
|
||||
node.style.backgroundColor = "transparent";
|
||||
}
|
||||
if(callback){
|
||||
callback(node, anim);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
anims.push(anim);
|
||||
});
|
||||
return dojo.lfx.combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lfx.html.unhighlight = function(/*DOMNode[]*/ nodes,
|
||||
/*dojo.gfx.color.Color*/ endColor,
|
||||
/*int?*/ duration,
|
||||
/*Function?*/ easing,
|
||||
/*Function?*/ callback){
|
||||
// summary: Returns an animation that will transition "nodes" background color
|
||||
// from its current color to "endColor".
|
||||
// endColor: Color to transition to.
|
||||
// duration: Duration of the animation in milliseconds.
|
||||
// easing: An easing function.
|
||||
// callback: Function to run at the end of the animation.
|
||||
nodes = dojo.lfx.html._byId(nodes);
|
||||
var anims = [];
|
||||
|
||||
dojo.lang.forEach(nodes, function(node){
|
||||
var color = new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node));
|
||||
var rgb = new dojo.gfx.color.Color(endColor);
|
||||
|
||||
var bgImage = dojo.html.getStyle(node, "background-image");
|
||||
|
||||
var anim = dojo.lfx.propertyAnimation(node,
|
||||
{ "background-color": { start: color, end: rgb } },
|
||||
duration,
|
||||
easing,
|
||||
{
|
||||
"beforeBegin": function(){
|
||||
if(bgImage){
|
||||
node.style.backgroundImage = "none";
|
||||
}
|
||||
node.style.backgroundColor = "rgb(" + color.toRgb().join(",") + ")";
|
||||
},
|
||||
"onEnd": function(){
|
||||
if(callback){
|
||||
callback(node, anim);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
anims.push(anim);
|
||||
});
|
||||
return dojo.lfx.combine(anims); // dojo.lfx.Combine
|
||||
}
|
||||
|
||||
dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
|
512
source/web/scripts/ajax/dojo/src/lfx/rounded.js
Normal file
512
source/web/scripts/ajax/dojo/src/lfx/rounded.js
Normal file
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.lfx.rounded");
|
||||
|
||||
dojo.require("dojo.lang.common");
|
||||
dojo.require("dojo.html.common");
|
||||
dojo.require("dojo.html.style");
|
||||
dojo.require("dojo.html.display");
|
||||
dojo.require("dojo.html.layout");
|
||||
|
||||
/* Port of curvyCorners, by Cameron Cooke and Tim Hutchison.
|
||||
* Original port done by Brian Lucas.
|
||||
* Refactor and function by trt.
|
||||
*/
|
||||
dojo.lfx.rounded = function(/* object */settings /* ... */){
|
||||
// summary
|
||||
// Creates a set of rounded corners based on settings.
|
||||
var options={
|
||||
validTags:settings.validTags || ["div"], // tags we can apply this to
|
||||
autoPad:settings.autoPad!=null ? settings.autoPad : true, // automatically pad
|
||||
antiAlias:settings.antiAlias!=null ? settings.antiAlias : true, // anti-alias corners
|
||||
radii:{ // corner radii
|
||||
tl:(settings.tl && settings.tl.radius!=null) ? settings.tl.radius:5,
|
||||
tr:(settings.tr && settings.tr.radius!=null) ? settings.tr.radius:5,
|
||||
bl:(settings.bl && settings.bl.radius!=null) ? settings.bl.radius:5,
|
||||
br:(settings.br && settings.br.radius!=null) ? settings.br.radius:5
|
||||
}
|
||||
};
|
||||
|
||||
// get the node list to operate on.
|
||||
var nodes;
|
||||
if(typeof(arguments[1]) == "string"){
|
||||
// a CSS classname was passed, grab a node list.
|
||||
nodes=dojo.html.getElementsByClass(arguments[1]);
|
||||
} else if(dojo.lang.isArrayLike(arguments[1])){
|
||||
// we assume that the second argument is an array of nodes to apply this to.
|
||||
nodes=arguments[1];
|
||||
for(var i=0; i<nodes.length; i++){ nodes[i]=dojo.byId(nodes[i]); }
|
||||
}
|
||||
if(nodes.length == 0) return; // don't bother.
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
for(var i=0; i<nodes.length; i++){
|
||||
dojo.lfx.rounded.applyCorners(options, nodes[i]);
|
||||
}
|
||||
};
|
||||
|
||||
// can call this directly if one wants.
|
||||
dojo.lfx.rounded.applyCorners = function(/* object */options, /* HTMLElement */node){
|
||||
// summary
|
||||
// Rounds corners based on options to passed node.
|
||||
var top = null;
|
||||
var bottom = null;
|
||||
var contentNode = null;
|
||||
var fns=dojo.lfx.rounded._fns;
|
||||
|
||||
// node details
|
||||
var width = node.offsetWidth;
|
||||
var height = node.offsetHeight;
|
||||
var borderWidth = parseInt(dojo.html.getComputedStyle(node, "border-top-width"));
|
||||
var borderColor = dojo.html.getComputedStyle(node, "border-top-color");
|
||||
var color = dojo.html.getComputedStyle(node, "background-color");
|
||||
var bgImage = dojo.html.getComputedStyle(node, "background-image");
|
||||
var position = dojo.html.getComputedStyle(node, "position");
|
||||
var padding = parseInt(dojo.html.getComputedStyle(node, "padding-top"));
|
||||
|
||||
// formatting details
|
||||
// TODO: use Dojo equivilents for these if exists.
|
||||
var format={
|
||||
height : height,
|
||||
width : width,
|
||||
borderWidth : borderWidth,
|
||||
color : fns.getRGB(color),
|
||||
padding : padding,
|
||||
borderColor : fns.getRGB(borderColor),
|
||||
borderString : borderWidth + "px" + " solid " + fns.getRGB(borderColor),
|
||||
bgImage : ((bgImage != "none")? bgImage : ""),
|
||||
content : node.innerHTML
|
||||
};
|
||||
|
||||
if(!dojo.html.isPositionAbsolute(node)){ node.style.position="relative"; }
|
||||
node.style.padding="0px";
|
||||
if(dojo.render.html.ie && width=="auto" && height=="auto"){ node.style.width="100%"; }
|
||||
if(options.autoPad && format.padding>0){
|
||||
node.innerHTML="";
|
||||
}
|
||||
|
||||
var topHeight=Math.max(options.radii.tl, options.radii.tr);
|
||||
var bottomHeight=Math.max(options.radii.bl, options.radii.br);
|
||||
|
||||
// build the containers.
|
||||
if(options.radii.tl || options.radii.tr){
|
||||
top = document.createElement("div");
|
||||
top.style.width="100%";
|
||||
top.style.fontSize="1px";
|
||||
top.style.overflow="hidden";
|
||||
top.style.position="absolute";
|
||||
top.style.paddingLeft=format.borderWidth+"px";
|
||||
top.style.paddingRight=format.borderWidth+"px";
|
||||
top.style.height=topHeight+"px";
|
||||
top.style.top=(0-topHeight)+"px";
|
||||
top.style.left=(0-format.borderWidth)+"px";
|
||||
node.appendChild(top);
|
||||
}
|
||||
if(options.radii.bl || options.radii.br){ // bottom
|
||||
bottom = document.createElement("div");
|
||||
bottom.style.width="100%";
|
||||
bottom.style.fontSize="1px";
|
||||
bottom.style.overflow="hidden";
|
||||
bottom.style.position="absolute";
|
||||
bottom.style.paddingLeft=format.borderWidth+"px";
|
||||
bottom.style.paddingRight=format.borderWidth+"px";
|
||||
bottom.style.height=bottomHeight+"px";
|
||||
bottom.style.bottom=(0-bottomHeight)+"px";
|
||||
bottom.style.left=(0-format.borderWidth)+"px";
|
||||
node.appendChild(bottom);
|
||||
}
|
||||
|
||||
// turn off the borders
|
||||
if(top){ node.style.borderTopWidth = "0px"; }
|
||||
if(bottom){ node.style.borderBottomWidth = "0px"; }
|
||||
|
||||
// do the corners
|
||||
var corners = ["tr", "tl", "br", "bl"];
|
||||
for(var i=0; i<corners.length; i++){
|
||||
var cc=corners[i];
|
||||
if(options.radii[cc]==0){
|
||||
// fill up the space with a div.
|
||||
if((cc.charAt(0)=="t"&&top) || (cc.charAt(0)=="b"&&bottom)){
|
||||
var corner=document.createElement("div");
|
||||
corner.style.position="relative";
|
||||
corner.style.fontSize="1px;";
|
||||
corner.style.overflow="hidden";
|
||||
if(format.bgImage==""){
|
||||
corner.style.backgroundColor=format.color;
|
||||
} else {
|
||||
corner.style.backgroundImage=format.bgImage;
|
||||
}
|
||||
switch(cc){
|
||||
case "tl":{
|
||||
corner.style.height=topHeight-format.borderWidth+"px";
|
||||
corner.style.marginRight=options.radii[cc]-(format.borderWidth*2)+"px";
|
||||
corner.style.borderLeft=format.borderString;
|
||||
corner.style.borderTop=format.borderString;
|
||||
corner.style.left=-format.borderWidth+"px";
|
||||
break;
|
||||
}
|
||||
case "tr":{
|
||||
corner.style.height=topHeight-format.borderWidth+"px";
|
||||
corner.style.marginLeft=options.radii[cc]-(format.borderWidth*2)+"px";
|
||||
corner.style.borderRight=format.borderString;
|
||||
corner.style.borderTop=format.borderString;
|
||||
corner.style.backgroundPosition="-"+(topHeight-format.borderWidth)+"px 0px";
|
||||
corner.style.left=format.borderWidth+"px";
|
||||
break;
|
||||
}
|
||||
case "bl":{
|
||||
corner.style.height=bottomHeight-format.borderWidth+"px";
|
||||
corner.style.marginRight=options.radii[cc]-(format.borderWidth*2)+"px";
|
||||
corner.style.borderLeft=format.borderString;
|
||||
corner.style.borderBottom=format.borderString;
|
||||
corner.style.left=format.borderWidth+"px";
|
||||
corner.style.backgroundPosition="-"+format.borderWidth+"px -"+(format.height+(bottomHeight+format.borderWidth))+"px";
|
||||
break;
|
||||
}
|
||||
case "br":{
|
||||
corner.style.height=bottomHeight-format.borderWidth+"px";
|
||||
corner.style.marginLeft=options.radii[cc]-(format.borderWidth*2)+"px";
|
||||
corner.style.borderRight=format.borderString;
|
||||
corner.style.borderBottom=format.borderString;
|
||||
corner.style.left=format.borderWidth+"px";
|
||||
corner.style.backgroundPosition="-"+(bottomHeight+format.borderWidth)+"px -"+(format.height+(bottomHeight+format.borderWidth))+"px";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// NB: this version will not do the caching they built into the
|
||||
// current version of curvyCorners.
|
||||
var corner=document.createElement("div");
|
||||
corner.style.height=options.radii[cc]+"px";
|
||||
corner.style.width=options.radii[cc]+"px";
|
||||
corner.style.position="absolute";
|
||||
corner.style.fontSize="1px";
|
||||
corner.style.overflow="hidden";
|
||||
|
||||
var borderRadius=Math.floor(options.radii[cc] - format.borderWidth);
|
||||
for(var x=0, j=options.radii[cc]; x<j; x++){
|
||||
// figure out y coords
|
||||
var y1=Math.floor(Math.sqrt(Math.pow(borderRadius,2)-Math.pow((x+1),2)))-1;
|
||||
if((x+1) >= borderRadius){ var y1=-1; }
|
||||
var y2=Math.ceil(Math.sqrt(Math.pow(borderRadius,2)-Math.pow(x,2)));
|
||||
if(x >= borderRadius){ y2=-1; }
|
||||
var y3=Math.floor(Math.sqrt(Math.pow(j,2)-Math.pow((x+1),2)))-1;
|
||||
if((x+1) >= j){ y3=-1; }
|
||||
var y4=Math.ceil(Math.sqrt(Math.pow(j, 2)-Math.pow(x, 2)));
|
||||
if(x >= j){ y4=-1; }
|
||||
|
||||
// start drawing
|
||||
if(y1 > -1){
|
||||
fns.draw(x, 0, format.color, 100, (y1+1), corner, -1, j, topHeight, format);
|
||||
}
|
||||
|
||||
// cycle the y-axis
|
||||
for(var y=(y1+1); y<y2; y++){
|
||||
if(options.antiAlias){
|
||||
if(format.bgImage != ""){
|
||||
var fract=fns.fraction(x, y, borderRadius)*100;
|
||||
if(fract < 30){
|
||||
fns.draw(x, y, format.borderColor, 100, 1, corner, 0, options.radii[cc], topHeight, format);
|
||||
} else {
|
||||
fns.draw(x, y, format.borderColor, 100, 1, corner, -1, options.radii[cc], topHeight, format);
|
||||
}
|
||||
} else {
|
||||
var clr=fns.blend(format.color, format.borderColor, fns.fraction(x, y, borderRadius));
|
||||
fns.draw(x, y, clr, 100, 1, corner, 0, options.radii[cc], topHeight, format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bar for the border
|
||||
if(options.antiAlias){
|
||||
if(y3 >= y2){
|
||||
if(y2 == -1){ y2 = 0; }
|
||||
fns.draw(x, y2, format.borderColor, 100, (y3-y2+1), corner, 0, 0, topHeight, format)
|
||||
} else {
|
||||
if(y3 >= y1){
|
||||
fns.draw(x, (y1+1), format.borderColor, 100, (y3-y1), corner, 0, 0, topHeight, format);
|
||||
}
|
||||
}
|
||||
for(var y=(y3+1); y<y4; y++){
|
||||
fns.draw(x, y, format.borderColor, (fns.fraction(x, y, j)*100), 1, corner, (format.borderWidth>0 ? 0:-1), options.radii[cc], topHeight, format);
|
||||
}
|
||||
} else {
|
||||
y3=y1;
|
||||
}
|
||||
}
|
||||
|
||||
// reposition pixels if not the bottom right.
|
||||
if(cc != "br"){
|
||||
for(var t=0, k=corner.childNodes.length; t<k; t++){
|
||||
var bar=corner.childNodes[t];
|
||||
var barTop = parseInt(dojo.html.getComputedStyle(bar, "top"));
|
||||
var barLeft = parseInt(dojo.html.getComputedStyle(bar, "left"));
|
||||
var barHeight = parseInt(dojo.html.getComputedStyle(bar, "height"));
|
||||
|
||||
// reposition.
|
||||
if(cc.charAt(1)=="l"){
|
||||
bar.style.left = (options.radii[cc]-barLeft-1)+"px";
|
||||
}
|
||||
if(cc=="tr"){
|
||||
bar.style.top = (options.radii[cc]-barHeight-barTop)+"px";
|
||||
bar.style.backgroundPosition="-"+Math.abs((format.width-options.radii[cc]+format.borderWidth)+barLeft)
|
||||
+"px -"+Math.abs(options.radii[cc]-barHeight-barTop-format.borderWidth)+"px";
|
||||
} else if (cc=="tl"){
|
||||
bar.style.top = (options.radii[cc]-barHeight-barTop)+"px";
|
||||
bar.style.backgroundPosition="-"+Math.abs((options.radii[cc]-barLeft-1)-format.borderWidth)
|
||||
+"px -"+Math.abs(options.radii[cc]-barHeight-barTop-format.borderWidth)+"px";
|
||||
} else {
|
||||
bar.style.backgroundPosition="-"+Math.abs((options.radii[cc]+barLeft)+format.borderWidth)
|
||||
+"px -"+Math.abs((format.height+options.radii[cc]+barTop)-format.borderWidth)+"px";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(corner){
|
||||
// position the container.
|
||||
var psn=[];
|
||||
if(cc.charAt(0)=="t"){ psn.push("top"); }
|
||||
else { psn.push("bottom"); }
|
||||
if(cc.charAt(1)=="l"){ psn.push("left"); }
|
||||
else { psn.push("right"); }
|
||||
|
||||
if(corner.style.position=="absolute"){
|
||||
for(var z=0; z<psn.length; z++){ corner.style[psn[z]]="0px"; }
|
||||
}
|
||||
|
||||
if(psn[0]=="top"){
|
||||
if(top){ top.appendChild(corner); }
|
||||
} else {
|
||||
if(bottom){ bottom.appendChild(corner); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw fillers.
|
||||
var diff={
|
||||
t: Math.abs(options.radii.tl - options.radii.tr),
|
||||
b: Math.abs(options.radii.bl - options.radii.br)
|
||||
};
|
||||
for(var z in diff){
|
||||
var smaller=(options.radii[z+"l"]<options.radii[z+"r"] ? z+"l":z+"r");
|
||||
var filler=document.createElement("div");
|
||||
filler.style.height=diff[z]+"px";
|
||||
filler.style.width=options.radii[smaller]+"px";
|
||||
filler.style.position="absolute";
|
||||
filler.style.fontSize="1px";
|
||||
filler.style.overflow="hidden";
|
||||
filler.style.backgroundColor=format.color;
|
||||
switch(smaller){
|
||||
case "tl":{
|
||||
filler.style.bottom="0px";
|
||||
filler.style.left="0px";
|
||||
filler.style.borderLeft=format.borderString;
|
||||
top.appendChild(filler);
|
||||
break;
|
||||
}
|
||||
case "tr":{
|
||||
filler.style.bottom="0px";
|
||||
filler.style.right="0px";
|
||||
filler.style.borderRight=format.borderString;
|
||||
top.appendChild(filler);
|
||||
break;
|
||||
}
|
||||
case "bl":{
|
||||
filler.style.top="0px";
|
||||
filler.style.left="0px";
|
||||
filler.style.borderLeft=format.borderString;
|
||||
bottom.appendChild(filler);
|
||||
break;
|
||||
}
|
||||
case "br":{
|
||||
filler.style.top="0px";
|
||||
filler.style.right="0px";
|
||||
filler.style.borderRight=format.borderString;
|
||||
bottom.appendChild(filler);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var fillBar=document.createElement("div");
|
||||
fillBar.style.position="relative";
|
||||
fillBar.style.fontSize="1px";
|
||||
fillBar.style.overflow="hidden";
|
||||
fillBar.style.backgroundColor=format.color;
|
||||
fillBar.style.backgroundImage=format.bgImage;
|
||||
if(z=="t"){
|
||||
if(top){
|
||||
if(options.radii.tl && options.radii.tr){
|
||||
fillBar.style.height=(topHeight-format.borderWidth) + "px";
|
||||
fillBar.style.marginLeft=(options.radii.tl-format.borderWidth)+"px";
|
||||
fillBar.style.marginRight=(options.radii.tr-format.borderWidth)+"px";
|
||||
fillBar.style.borderTop=format.borderString;
|
||||
if(format.bgImage!=""){
|
||||
fillBar.style.backgroundPosition="-"+(topHeight+format.borderWidth)+"px 0px";
|
||||
}
|
||||
}
|
||||
top.appendChild(fillBar);
|
||||
}
|
||||
} else {
|
||||
if(bottom){
|
||||
if(options.radii.bl && options.radii.br){
|
||||
fillBar.style.height=(bottomHeight-format.borderWidth) + "px";
|
||||
fillBar.style.marginLeft=(options.radii.bl-format.borderWidth)+"px";
|
||||
fillBar.style.marginRight=(options.radii.br-format.borderWidth)+"px";
|
||||
fillBar.style.borderBottom=format.borderString;
|
||||
if(format.bgImage!=""){
|
||||
fillBar.style.backgroundPosition="-"+(bottomHeight+format.borderWidth)+"px -"
|
||||
+ (format.height + (topHeight+format.borderWidth))+"px";
|
||||
}
|
||||
}
|
||||
bottom.appendChild(fillBar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finally, set up the padding.
|
||||
if(options.autoPad && format.padding>0){
|
||||
var content=document.createElement("div");
|
||||
content.style.position="relative";
|
||||
content.innerHTML=format.content;
|
||||
content.className="autoPadDiv";
|
||||
if(topHeight < format.padding){
|
||||
content.style.paddingTop = Math.abs(topHeight-format.padding)+"px";
|
||||
}
|
||||
if(bottomHeight < format.padding){
|
||||
content.style.paddingBottom = Math.abs(bottomHeight-format.padding)+"px";
|
||||
}
|
||||
content.style.paddingLeft=format.padding+"px";
|
||||
content.style.paddingRight=format.padding+"px";
|
||||
node.appendChild(content);
|
||||
}
|
||||
};
|
||||
|
||||
var count=0;
|
||||
|
||||
// helper methods.
|
||||
dojo.lfx.rounded._fns={
|
||||
blend:function(clr1, clr2, frac){
|
||||
var c1={
|
||||
r:parseInt(clr1.substr(1,2),16),
|
||||
g:parseInt(clr1.substr(3,2),16),
|
||||
b:parseInt(clr1.substr(5,2),16)
|
||||
};
|
||||
var c2={
|
||||
r:parseInt(clr2.substr(1,2),16),
|
||||
g:parseInt(clr2.substr(3,2),16),
|
||||
b:parseInt(clr2.substr(5,2),16)
|
||||
};
|
||||
if(frac>1||frac<0){ frac=1; }
|
||||
var ret=[
|
||||
Math.min(Math.max(Math.round((c1.r*frac)+(c2.r*(1-frac))),0),255),
|
||||
Math.min(Math.max(Math.round((c1.g*frac)+(c2.g*(1-frac))),0),255),
|
||||
Math.min(Math.max(Math.round((c1.b*frac)+(c2.b*(1-frac))),0),255)
|
||||
];
|
||||
for(var i=0; i<ret.length; i++){
|
||||
var n=ret[i].toString(16);
|
||||
if(n.length<2){ n="0"+n; }
|
||||
ret[i]=n;
|
||||
}
|
||||
return "#"+ret.join("");
|
||||
},
|
||||
fraction:function(x, y, r){
|
||||
var frac=0;
|
||||
var xval=[];
|
||||
var yval=[];
|
||||
var point=0;
|
||||
var whatsides="";
|
||||
|
||||
var intersect=Math.sqrt((Math.pow(r,2)-Math.pow(x,2)));
|
||||
if(intersect >=y && intersect < (y+1)){
|
||||
whatsides="Left";
|
||||
xval[point]=0;
|
||||
yval[point++]=intersect-y;
|
||||
}
|
||||
|
||||
intersect=Math.sqrt((Math.pow(r,2)-Math.pow(y+1,2)));
|
||||
if(intersect >=x && intersect < (x+1)){
|
||||
whatsides += "Top";
|
||||
xval[point]=intersect-x;
|
||||
yval[point++]=1;
|
||||
}
|
||||
|
||||
intersect=Math.sqrt((Math.pow(r,2)-Math.pow(x+1,2)));
|
||||
if(intersect >= y && intersect < (y+1)){
|
||||
whatsides += "Right";
|
||||
xval[point]=1;
|
||||
yval[point++] = intersect-y;
|
||||
}
|
||||
|
||||
intersect=Math.sqrt((Math.pow(r,2)-Math.pow(y,2)));
|
||||
if(intersect >=x && intersect < (x+1)){
|
||||
whatsides += "Bottom";
|
||||
xval[point]=intersect-x;
|
||||
yval[point]=1;
|
||||
}
|
||||
|
||||
switch(whatsides){
|
||||
case "LeftRight":
|
||||
return Math.min(yval[0],yval[1]) + ((Math.max(yval[0],yval[1])-Math.min(yval[0],yval[1]))/2);
|
||||
case "TopRight":
|
||||
return 1-(((1-xval[0])*(1-yval[1]))/2);
|
||||
case "TopBottom":
|
||||
return Math.min(xval[0],xval[1]) + ((Math.max(xval[0],xval[1])-Math.min(xval[0],xval[1]))/2);
|
||||
case "LeftBottom":
|
||||
return (yval[0]*xval[1])/2;
|
||||
default: return 1;
|
||||
}
|
||||
},
|
||||
draw:function(x, y, color, opac, height, corner, image, radius, top, format){
|
||||
var px=document.createElement("div");
|
||||
px.style.height=height+"px"
|
||||
px.style.width="1px";
|
||||
px.style.position="absolute";
|
||||
px.style.fontSize="1px";
|
||||
px.style.overflow="hidden";
|
||||
if(image==-1 && format.bgImage!=""){
|
||||
px.style.backgroundImage=format.bgImage;
|
||||
px.style.backgroundPosition="-"+(format.width-(radius-x)+format.borderWidth)
|
||||
+"px -"+((format.height+top+y)-format.borderWidth)+"px";
|
||||
} else {
|
||||
px.style.backgroundColor=color;
|
||||
}
|
||||
if(opac!=100){ dojo.html.setOpacity(px, (opac/100)); }
|
||||
px.style.top=y+"px";
|
||||
px.style.left=x+"px";
|
||||
corner.appendChild(px);
|
||||
},
|
||||
getRGB:function(clr){
|
||||
var ret="#ffffff";
|
||||
if(clr!="" && clr!="transparent"){
|
||||
if(clr.substr(0,3)=="rgb"){
|
||||
var t=clr.substring(4, clr.indexOf(")"));
|
||||
t=t.split(",");
|
||||
for(var i=0; i<t.length; i++){
|
||||
var n=parseInt(t[i]).toString(16);
|
||||
if(n.length<2){ n = "0"+n; }
|
||||
t[i]=n;
|
||||
}
|
||||
ret = "#"+t.join("");
|
||||
}
|
||||
else if(clr.length==4){
|
||||
ret = "#"+clr.substring(1,2)+clr.substring(1,2)
|
||||
+ clr.substring(2,3)+clr.substring(2,3)
|
||||
+ clr.substring(3,4)+clr.substring(3,4);
|
||||
}
|
||||
else {
|
||||
ret = clr;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
86
source/web/scripts/ajax/dojo/src/lfx/shadow.js
Normal file
86
source/web/scripts/ajax/dojo/src/lfx/shadow.js
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.lfx.shadow");
|
||||
|
||||
dojo.require("dojo.lang.common");
|
||||
dojo.require("dojo.uri.Uri");
|
||||
|
||||
dojo.lfx.shadow = function(/* HTMLElement */node) {
|
||||
// summary
|
||||
// creates a shadow underneath node.
|
||||
this.shadowPng = dojo.uri.dojoUri("src/html/images/shadow");
|
||||
this.shadowThickness = 8;
|
||||
this.shadowOffset = 15;
|
||||
this.init(node);
|
||||
}
|
||||
|
||||
dojo.extend(dojo.lfx.shadow, {
|
||||
init: function(/* HTMLElement */node){
|
||||
// summary
|
||||
// Initializes the shadow.
|
||||
this.node=node;
|
||||
|
||||
// make all the pieces of the shadow, and position/size them as much
|
||||
// as possible (but a lot of the coordinates are set in sizeShadow
|
||||
this.pieces={};
|
||||
var x1 = -1 * this.shadowThickness;
|
||||
var y0 = this.shadowOffset;
|
||||
var y1 = this.shadowOffset + this.shadowThickness;
|
||||
this._makePiece("tl", "top", y0, "left", x1);
|
||||
this._makePiece("l", "top", y1, "left", x1, "scale");
|
||||
this._makePiece("tr", "top", y0, "left", 0);
|
||||
this._makePiece("r", "top", y1, "left", 0, "scale");
|
||||
this._makePiece("bl", "top", 0, "left", x1);
|
||||
this._makePiece("b", "top", 0, "left", 0, "crop");
|
||||
this._makePiece("br", "top", 0, "left", 0);
|
||||
},
|
||||
|
||||
_makePiece: function(name, vertAttach, vertCoord, horzAttach, horzCoord, sizing){
|
||||
var img;
|
||||
var url = this.shadowPng + name.toUpperCase() + ".png";
|
||||
if(dojo.render.html.ie55 || dojo.render.html.ie60){
|
||||
img=dojo.doc().createElement("div");
|
||||
img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"'"+
|
||||
(sizing?", sizingMethod='"+sizing+"'":"") + ")";
|
||||
}else{
|
||||
img=dojo.doc().createElement("img");
|
||||
img.src=url;
|
||||
}
|
||||
img.style.position="absolute";
|
||||
img.style[vertAttach]=vertCoord+"px";
|
||||
img.style[horzAttach]=horzCoord+"px";
|
||||
img.style.width=this.shadowThickness+"px";
|
||||
img.style.height=this.shadowThickness+"px";
|
||||
this.pieces[name]=img;
|
||||
this.node.appendChild(img);
|
||||
},
|
||||
|
||||
size: function(/* int */width, /* int */height){
|
||||
// summary
|
||||
// Resizes the shadow based on width and height.
|
||||
var sideHeight = height - (this.shadowOffset+this.shadowThickness+1);
|
||||
if (sideHeight < 0) { sideHeight = 0; }
|
||||
if (height < 1) { height = 1; }
|
||||
if (width < 1) { width = 1; }
|
||||
with(this.pieces){
|
||||
l.style.height = sideHeight+"px";
|
||||
r.style.height = sideHeight+"px";
|
||||
b.style.width = (width-1)+"px";
|
||||
bl.style.top = (height-1)+"px";
|
||||
b.style.top = (height-1)+"px";
|
||||
br.style.top = (height-1)+"px";
|
||||
tr.style.left = (width-1)+"px";
|
||||
r.style.left = (width-1)+"px";
|
||||
br.style.left = (width-1)+"px";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
54
source/web/scripts/ajax/dojo/src/lfx/toggle.js
Normal file
54
source/web/scripts/ajax/dojo/src/lfx/toggle.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.lfx.toggle");
|
||||
dojo.require("dojo.lfx.*");
|
||||
|
||||
dojo.lfx.toggle.plain = {
|
||||
show: function(node, duration, easing, callback){
|
||||
dojo.html.show(node);
|
||||
if(dojo.lang.isFunction(callback)){ callback(); }
|
||||
},
|
||||
|
||||
hide: function(node, duration, easing, callback){
|
||||
dojo.html.hide(node);
|
||||
if(dojo.lang.isFunction(callback)){ callback(); }
|
||||
}
|
||||
}
|
||||
|
||||
dojo.lfx.toggle.fade = {
|
||||
show: function(node, duration, easing, callback){
|
||||
dojo.lfx.fadeShow(node, duration, easing, callback).play();
|
||||
},
|
||||
|
||||
hide: function(node, duration, easing, callback){
|
||||
dojo.lfx.fadeHide(node, duration, easing, callback).play();
|
||||
}
|
||||
}
|
||||
|
||||
dojo.lfx.toggle.wipe = {
|
||||
show: function(node, duration, easing, callback){
|
||||
dojo.lfx.wipeIn(node, duration, easing, callback).play();
|
||||
},
|
||||
|
||||
hide: function(node, duration, easing, callback){
|
||||
dojo.lfx.wipeOut(node, duration, easing, callback).play();
|
||||
}
|
||||
}
|
||||
|
||||
dojo.lfx.toggle.explode = {
|
||||
show: function(node, duration, easing, callback, explodeSrc){
|
||||
dojo.lfx.explode(explodeSrc||{x:0,y:0,width:0,height:0}, node, duration, easing, callback).play();
|
||||
},
|
||||
|
||||
hide: function(node, duration, easing, callback, explodeSrc){
|
||||
dojo.lfx.implode(node, explodeSrc||{x:0,y:0,width:0,height:0}, duration, easing, callback).play();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user