Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 10290 invoked from network); 11 Nov 2006 16:46:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Nov 2006 16:46:52 -0000 Received: (qmail 30125 invoked by uid 500); 11 Nov 2006 16:47:02 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 30095 invoked by uid 500); 11 Nov 2006 16:47:02 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 30086 invoked by uid 99); 11 Nov 2006 16:47:02 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Nov 2006 08:47:02 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Nov 2006 08:46:40 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id B12281A9882; Sat, 11 Nov 2006 08:45:11 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r473755 [21/43] - in /jackrabbit/trunk/contrib/jcr-browser: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/browser/ src/main/resources/ ... Date: Sat, 11 Nov 2006 16:44:48 -0000 To: commits@jackrabbit.apache.org From: edgarpoce@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061111164511.B12281A9882@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/common.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/common.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/common.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/common.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1,220 @@ +dojo.provide("dojo.lang.common"); + +dojo.lang.inherits = function(/*Function*/ subclass, /*Function*/ superclass){ + // summary: Set up inheritance between two classes. + if(typeof superclass != 'function'){ + dojo.raise("dojo.inherits: superclass argument ["+superclass+"] must be a function (subclass: ["+subclass+"']"); + } + subclass.prototype = new superclass(); + subclass.prototype.constructor = subclass; + subclass.superclass = superclass.prototype; + // DEPRECATED: super is a reserved word, use 'superclass' + subclass['super'] = superclass.prototype; +} + +dojo.lang._mixin = function(/*Object*/ obj, /*Object*/ props){ + // summary: Adds all properties and methods of props to obj. + var tobj = {}; + for(var x in props){ + // the "tobj" condition avoid copying properties in "props" + // inherited from Object.prototype. For example, if obj has a custom + // toString() method, don't overwrite it with the toString() method + // that props inherited from Object.protoype + if((typeof tobj[x] == "undefined") || (tobj[x] != props[x])){ + obj[x] = props[x]; + } + } + // IE doesn't recognize custom toStrings in for..in + if(dojo.render.html.ie + && (typeof(props["toString"]) == "function") + && (props["toString"] != obj["toString"]) + && (props["toString"] != tobj["toString"])) + { + obj.toString = props.toString; + } + return obj; // Object +} + +dojo.lang.mixin = function(/*Object*/ obj, /*Object...*/props){ + // summary: Adds all properties and methods of props to obj. + for(var i=1, l=arguments.length; i -1; // boolean +} + +/** + * Partial implmentation of is* functions from + * http://www.crockford.com/javascript/recommend.html + * NOTE: some of these may not be the best thing to use in all situations + * as they aren't part of core JS and therefore can't work in every case. + * See WARNING messages inline for tips. + * + * The following is* functions are fairly "safe" + */ + +dojo.lang.isObject = function(/*anything*/ it){ + // summary: Return true if it is an Object, Array or Function. + if(typeof it == "undefined"){ return false; } + return (typeof it == "object" || it === null || dojo.lang.isArray(it) || dojo.lang.isFunction(it)); // Boolean +} + +dojo.lang.isArray = function(/*anything*/ it){ + // summary: Return true if it is an Array. + return (it && it instanceof Array || typeof it == "array"); // Boolean +} + +dojo.lang.isArrayLike = function(/*anything*/ it){ + // summary: Return true if it can be used as an array (i.e. is an object with an integer length property). + if((!it)||(dojo.lang.isUndefined(it))){ return false; } + if(dojo.lang.isString(it)){ return false; } + if(dojo.lang.isFunction(it)){ return false; } // keeps out built-in constructors (Number, String, ...) which have length properties + if(dojo.lang.isArray(it)){ return true; } + // form node itself is ArrayLike, but not always iterable. Use form.elements instead. + if((it.tagName)&&(it.tagName.toLowerCase()=='form')){ return false; } + if(dojo.lang.isNumber(it.length) && isFinite(it.length)){ return true; } + return false; // Boolean +} + +dojo.lang.isFunction = function(/*anything*/ it){ + // summary: Return true if it is a Function. + if(!it){ return false; } + // webkit treats NodeList as a function, which is bad + if((typeof(it) == "function") && (it == "[object NodeList]")) { return false; } + return (it instanceof Function || typeof it == "function"); // Boolean +} + +dojo.lang.isString = function(/*anything*/ it){ + // summary: Return true if it is a String. + return (typeof it == "string" || it instanceof String); +} + +dojo.lang.isAlien = function(/*anything*/ it){ + // summary: Return true if it is not a built-in function. + if(!it){ return false; } + return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean +} + +dojo.lang.isBoolean = function(/*anything*/ it){ + // summary: Return true if it is a Boolean. + return (it instanceof Boolean || typeof it == "boolean"); // Boolean +} + +/** + * The following is***() functions are somewhat "unsafe". Fortunately, + * there are workarounds the the language provides and are mentioned + * in the WARNING messages. + * + */ +dojo.lang.isNumber = function(/*anything*/ it){ + // summary: Return true if it is a number. + // description: + // WARNING - In most cases, isNaN(it) is sufficient to determine whether or not + // something is a number or can be used as such. For example, a number or string + // can be used interchangably when accessing array items (array["1"] is the same as + // array[1]) and isNaN will return false for both values ("1" and 1). However, + // isNumber("1") will return false, which is generally not too useful. + // Also, isNumber(NaN) returns true, again, this isn't generally useful, but there + // are corner cases (like when you want to make sure that two things are really + // the same type of thing). That is really where isNumber "shines". + // + // Recommendation - Use isNaN(it) when possible + + return (it instanceof Number || typeof it == "number"); // Boolean +} + +/* + * FIXME: Should isUndefined go away since it is error prone? + */ +dojo.lang.isUndefined = function(/*anything*/ it){ + // summary: Return true if it is not defined. + // description: + // WARNING - In some cases, isUndefined will not behave as you + // might expect. If you do isUndefined(foo) and there is no earlier + // reference to foo, an error will be thrown before isUndefined is + // called. It behaves correctly if you scope yor object first, i.e. + // isUndefined(foo.bar) where foo is an object and bar isn't a + // property of the object. + // + // Recommendation - Use typeof foo == "undefined" when possible + + return ((typeof(it) == "undefined")&&(it == undefined)); // Boolean +} + +// end Crockford functions Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/common.js ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/declare.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/declare.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/declare.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/declare.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1,151 @@ +dojo.provide("dojo.lang.declare"); + +dojo.require("dojo.lang.common"); +dojo.require("dojo.lang.extras"); + +dojo.lang.declare = function(/*String*/ className, /*Function|Array*/ superclass, /*Function?*/ init, /*Object|Array*/ props){ +/* + * summary: Create a feature-rich constructor with a compact notation + * + * className: the name of the constructor (loosely, a "class") + * + * superclass: may be a Function, or an Array of Functions. + * If "superclass" is an array, the first element is used + * as the prototypical ancestor and any following Functions + * become mixin ancestors. + * + * init: an initializer function + * + * props: an object (or array of objects) whose properties are copied to the created prototype + * + * description: Create a constructor using a compact notation for inheritance and prototype extension. + * + * "superclass" argument may be a Function, or an array of + * Functions. + * + * If "superclass" is an array, the first element is used + * as the prototypical ancestor and any following Functions + * become mixin ancestors. + * + * All "superclass(es)" must be Functions (not mere Objects). + * + * Using mixin ancestors provides a type of multiple + * inheritance. Mixin ancestors prototypical + * properties are copied to the subclass, and any + * inializater/constructor is invoked. + * + * Properties of object "props" are copied to the constructor + * prototype. If "props" is an array, properties of each + * object in the array are copied to the constructor prototype. + * + * name of the class ("className" argument) is stored in + * "declaredClass" property + * + * Initializer functions are called when an object + * is instantiated from this constructor. + * + * Aliased as "dojo.declare" + * + * Usage: + * + * dojo.declare("my.classes.bar", my.classes.foo, + * function() { + * // initialization function + * this.myComplicatedObject = new ReallyComplicatedObject(); + * },{ + * someValue: 2, + * someMethod: function() { + * doStuff(); + * } + * }); + * + */ + if((dojo.lang.isFunction(props))||((!props)&&(!dojo.lang.isFunction(init)))){ + // parameter juggling to support omitting init param (also allows reordering init and props arguments) + var temp = props; + props = init; + init = temp; + } + var mixins = [ ]; + if(dojo.lang.isArray(superclass)){ + mixins = superclass; + superclass = mixins.shift(); + } + if(!init){ + init = dojo.evalObjPath(className, false); + if((init)&&(!dojo.lang.isFunction(init))){ init = null }; + } + var ctor = dojo.lang.declare._makeConstructor(); + var scp = (superclass ? superclass.prototype : null); + if(scp){ + scp.prototyping = true; + ctor.prototype = new superclass(); + scp.prototyping = false; + } + ctor.superclass = scp; + ctor.mixins = mixins; + for(var i=0,l=mixins.length; i 0){ + obj = queue.shift(); + } + + // check to see if the input function needs to be fired + // stop before firing the output function + // TODO: relegate this to the output function? + if(typeof(obj) == "undefined"){ + self.stop(); + return; + } + + // call the output function. + self.outputFunction(obj); + }; + + this.setInterval = function(/* int */ms){ + // summary + // sets the interval in milliseconds of the internal timer + this.interval = ms; + timer.setInterval(ms); + }; + + this.onTick = function(/* dojo.lang.timing.Streamer */obj){ }; + // wrap the timer functions so that we can connect to them if needed. + this.start = function(){ + // summary + // starts the Streamer + if(typeof(this.inputFunction) == "function" && typeof(this.outputFunction) == "function"){ + timer.start(); + return; + } + dojo.raise("You cannot start a Streamer without an input and an output function."); + }; + this.onStart = function(){ }; + this.stop = function(){ + // summary + // stops the Streamer + timer.stop(); + }; + this.onStop = function(){ }; + + // finish initialization + timer.onTick = this.tick; + timer.onStart = this.onStart; + timer.onStop = this.onStop; + if(initialData){ + queue.concat(initialData); + } +}; Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/Streamer.js ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/Timer.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/Timer.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/Timer.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/Timer.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1,54 @@ +dojo.provide("dojo.lang.timing.Timer"); +dojo.require("dojo.lang.func"); + +dojo.lang.timing.Timer = function(/*int*/ interval){ + // summary: Timer object executes an "onTick()" method repeatedly at a specified interval. + // repeatedly at a given interval. + // interval: Interval between function calls, in milliseconds. + this.timer = null; + this.isRunning = false; + this.interval = interval; + + this.onStart = null; + this.onStop = null; +}; + +dojo.extend(dojo.lang.timing.Timer, { + onTick : function(){ + // summary: Method called every time the interval passes. Override to do something useful. + }, + + setInterval : function(interval){ + // summary: Reset the interval of a timer, whether running or not. + // interval: New interval, in milliseconds. + if (this.isRunning){ + dj_global.clearInterval(this.timer); + } + this.interval = interval; + if (this.isRunning){ + this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); + } + }, + + start : function(){ + // summary: Start the timer ticking. + // description: Calls the "onStart()" handler, if defined. + // Note that the onTick() function is not called right away, + // only after first interval passes. + if (typeof this.onStart == "function"){ + this.onStart(); + } + this.isRunning = true; + this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); + }, + + stop : function(){ + // summary: Stop the timer. + // description: Calls the "onStop()" handler, if defined. + if (typeof this.onStop == "function"){ + this.onStop(); + } + this.isRunning = false; + dj_global.clearInterval(this.timer); + } +}); Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/Timer.js ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/__package__.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/__package__.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/__package__.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/__package__.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1 @@ +dojo.provide("dojo.lang.timing.*"); Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/timing/__package__.js ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/type.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/type.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/type.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lang/type.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1,241 @@ +dojo.provide("dojo.lang.type"); +dojo.require("dojo.lang.common"); + +dojo.lang.whatAmI = function(value) { + dojo.deprecated("dojo.lang.whatAmI", "use dojo.lang.getType instead", "0.5"); + return dojo.lang.getType(value); +} +dojo.lang.whatAmI.custom = {}; + +dojo.lang.getType = function(/* anything */ value){ + /* summary: + * Attempts to determine what type value is. + * value: Any literal value or object instance. + */ + try { + if(dojo.lang.isArray(value)) { + return "array"; // string + } + if(dojo.lang.isFunction(value)) { + return "function"; // string + } + if(dojo.lang.isString(value)) { + return "string"; // string + } + if(dojo.lang.isNumber(value)) { + return "number"; // string + } + if(dojo.lang.isBoolean(value)) { + return "boolean"; // string + } + if(dojo.lang.isAlien(value)) { + return "alien"; // string + } + if(dojo.lang.isUndefined(value)) { + return "undefined"; // string + } + // FIXME: should this go first? + for(var name in dojo.lang.whatAmI.custom) { + if(dojo.lang.whatAmI.custom[name](value)) { + return name; // string + } + } + if(dojo.lang.isObject(value)) { + return "object"; // string + } + } catch(e) {} + return "unknown"; // string +} + +dojo.lang.isNumeric = function(/* anything */ value){ + /* summary: + * Returns true if value can be interpreted as a number + * value: Any literal value or object instance. + */ + + /* examples: + * dojo.lang.isNumeric(3); // returns true + * dojo.lang.isNumeric("3"); // returns true + * dojo.lang.isNumeric(new Number(3)); // returns true + * dojo.lang.isNumeric(new String("3")); // returns true + * + * dojo.lang.isNumeric(3/0); // returns false + * dojo.lang.isNumeric("foo"); // returns false + * dojo.lang.isNumeric(new Number("foo")); // returns false + * dojo.lang.isNumeric(false); // returns false + * dojo.lang.isNumeric(true); // returns false + */ + return (!isNaN(value) + && isFinite(value) + && (value != null) + && !dojo.lang.isBoolean(value) + && !dojo.lang.isArray(value) + && !/^\s*$/.test(value) + ); // boolean +} + +dojo.lang.isBuiltIn = function(/* anything */ value){ + /* summary: + * Returns true if value is of a type provided by core JavaScript + * description: + * Returns true for any literal, and for any object that is an + * instance of a built-in type like String, Number, Boolean, + * Array, Function, or Error. + * value: Any literal value or object instance. + */ + return (dojo.lang.isArray(value) + || dojo.lang.isFunction(value) + || dojo.lang.isString(value) + || dojo.lang.isNumber(value) + || dojo.lang.isBoolean(value) + || (value == null) + || (value instanceof Error) + || (typeof value == "error") + ); // boolean +} + +dojo.lang.isPureObject = function(/* anything */ value){ + /* summary: + * Returns true for any value where the value of value.constructor == Object + * description: + * Returns true for any literal, and for any object that is an + * instance of a built-in type like String, Number, Boolean, + * Array, Function, or Error. + * value: Any literal value or object instance. + */ + + /* examples: + * dojo.lang.isPureObject(new Object()); // returns true + * dojo.lang.isPureObject({a: 1, b: 2}); // returns true + * + * dojo.lang.isPureObject(new Date()); // returns false + * dojo.lang.isPureObject([11, 2, 3]); // returns false + */ + return ((value != null) + && dojo.lang.isObject(value) + && value.constructor == Object + ); // boolean +} + +dojo.lang.isOfType = function(/* anything */ value, /* function */ type, /* object? */ keywordParameters) { + /* summary: + * Returns true if 'value' is of type 'type' + * description: + * Given a value and a datatype, this method returns true if the + * type of the value matches the datatype. The datatype parameter + * can be an array of datatypes, in which case the method returns + * true if the type of the value matches any of the datatypes. + * value: Any literal value or object instance. + * type: A class of object, or a literal type, or the string name of a type, or an array with a list of types. + * keywordParameters: {optional: boolean} + */ + + /* examples: + * dojo.lang.isOfType("foo", String); // returns true + * dojo.lang.isOfType(12345, Number); // returns true + * dojo.lang.isOfType(false, Boolean); // returns true + * dojo.lang.isOfType([6, 8], Array); // returns true + * dojo.lang.isOfType(dojo.lang.isOfType, Function); // returns true + * dojo.lang.isOfType({foo: "bar"}, Object); // returns true + * dojo.lang.isOfType(new Date(), Date); // returns true + * + * dojo.lang.isOfType("foo", "string"); // returns true + * dojo.lang.isOfType(12345, "number"); // returns true + * dojo.lang.isOfType(false, "boolean"); // returns true + * dojo.lang.isOfType([6, 8], "array"); // returns true + * dojo.lang.isOfType(dojo.lang.isOfType, "function"); // returns true + * dojo.lang.isOfType({foo: "bar"}, "object"); // returns true + * dojo.lang.isOfType(xxxxx, "undefined"); // returns true + * dojo.lang.isOfType(null, "null"); // returns true + * + * dojo.lang.isOfType("foo", [Number, String, Boolean]); // returns true + * dojo.lang.isOfType(12345, [Number, String, Boolean]); // returns true + * dojo.lang.isOfType(false, [Number, String, Boolean]); // returns true + * + * dojo.lang.isOfType(null, Date, {optional: true} ); // returns true // description: + */ + var optional = false; + if (keywordParameters) { + optional = keywordParameters["optional"]; + } + if (optional && ((value === null) || dojo.lang.isUndefined(value))) { + return true; // boolean + } + if(dojo.lang.isArray(type)){ + var arrayOfTypes = type; + for(var i in arrayOfTypes){ + var aType = arrayOfTypes[i]; + if(dojo.lang.isOfType(value, aType)) { + return true; // boolean + } + } + return false; // boolean + }else{ + if(dojo.lang.isString(type)){ + type = type.toLowerCase(); + } + switch (type) { + case Array: + case "array": + return dojo.lang.isArray(value); // boolean + case Function: + case "function": + return dojo.lang.isFunction(value); // boolean + case String: + case "string": + return dojo.lang.isString(value); // boolean + case Number: + case "number": + return dojo.lang.isNumber(value); // boolean + case "numeric": + return dojo.lang.isNumeric(value); // boolean + case Boolean: + case "boolean": + return dojo.lang.isBoolean(value); // boolean + case Object: + case "object": + return dojo.lang.isObject(value); // boolean + case "pureobject": + return dojo.lang.isPureObject(value); // boolean + case "builtin": + return dojo.lang.isBuiltIn(value); // boolean + case "alien": + return dojo.lang.isAlien(value); // boolean + case "undefined": + return dojo.lang.isUndefined(value); // boolean + case null: + case "null": + return (value === null); // boolean + case "optional": + dojo.deprecated('dojo.lang.isOfType(value, [type, "optional"])', 'use dojo.lang.isOfType(value, type, {optional: true} ) instead', "0.5"); + return ((value === null) || dojo.lang.isUndefined(value)); // boolean + default: + if (dojo.lang.isFunction(type)) { + return (value instanceof type); // boolean + } else { + dojo.raise("dojo.lang.isOfType() was passed an invalid type"); + } + } + } + dojo.raise("If we get here, it means a bug was introduced above."); +} + +dojo.lang.getObject=function(/* String */ str){ + // summary: + // Will return an object, if it exists, based on the name in the passed string. + var parts=str.split("."), i=0, obj=dj_global; + do{ + obj=obj[parts[i++]]; + }while(i 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 +} Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/Animation.js ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/__package__.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/__package__.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/__package__.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/__package__.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1,5 @@ +dojo.kwCompoundRequire({ + browser: ["dojo.lfx.html"], + dashboard: ["dojo.lfx.html"] +}); +dojo.provide("dojo.lfx.*"); \ No newline at end of file Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/__package__.js ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/extras.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/extras.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/extras.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/extras.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1,138 @@ +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); Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/extras.js ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/html.js URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/html.js?view=auto&rev=473755 ============================================================================== --- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/html.js (added) +++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/html.js Sat Nov 11 08:44:22 2006 @@ -0,0 +1,724 @@ +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){ + if(s == "opacity"){ + dojo.html.setOpacity(n, style[s]); + }else{ + n.style[s] = style[s]; + } + } + } + + 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) + dojo.html.show(node); + var height = dojo.html.getBorderBox(node).height; + dojo.html.hide(node); + + 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"; + } + 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); Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/lfx/html.js ------------------------------------------------------------------------------ svn:eol-style = native