diff options
Diffstat (limited to 'js/dojo-1.7.2/dojox/fx/ext-dojo')
| -rw-r--r-- | js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList-style.js | 62 | ||||
| -rw-r--r-- | js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList.js | 63 | ||||
| -rw-r--r-- | js/dojo-1.7.2/dojox/fx/ext-dojo/complex.js | 170 | ||||
| -rw-r--r-- | js/dojo-1.7.2/dojox/fx/ext-dojo/reverse.js | 104 |
4 files changed, 399 insertions, 0 deletions
diff --git a/js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList-style.js b/js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList-style.js new file mode 100644 index 0000000..10f4442 --- /dev/null +++ b/js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList-style.js @@ -0,0 +1,62 @@ +//>>built +define("dojox/fx/ext-dojo/NodeList-style", ["dojo/_base/lang", "dojo/_base/NodeList","dojo/NodeList-fx", "dojo/fx", "../style"], + function(lang, NodeList, NodeListFx, coreFx, styleX){ +// summary: +// Core extensions to `dojo.NodeList` providing additional fx to `dojo.NodeList-fx` +// from `dojox.fx.style` +// +// description: +// A Package to extend dojo base NodeList with fx provided by the `dojox.fx` project. +// These are experimental animations, in an experimental + + +lang.extend( NodeList, { + + addClassFx: function(cssClass, args){ + // summary: + // Animate the effects of adding a class to all nodes in this list. + // see `dojox.fx.addClass` + // + // tags: FX, NodeList + // + // example: + // | // fade all elements with class "bar" to to 50% opacity + // | dojo.query(".bar").addClassFx("bar").play(); + + return coreFx.combine(this.map(function(n){ // dojo.Animation + return styleX.addClass(n, cssClass, args); + })); + }, + + removeClassFx: function(cssClass, args){ + // summary: + // Animate the effect of removing a class to all nodes in this list. + // see `dojox.fx.removeClass` + // + // tags: FX, NodeList + // + // example: + // | dojo.query(".box").removeClassFx("bar").play(); + + return coreFx.combine(this.map(function(n){ // dojo.Animation + return styleX.removeClass(n, cssClass, args); + })); + }, + + toggleClassFx: function(cssClass, force, args){ + // summary: + // Animate the effect of adding or removing a class to all nodes in this list. + // see `dojox.fx.toggleClass` + // + // tags: FX, NodeList + // + // example: + // | dojo.query(".box").toggleClass("bar").play(); + + return coreFx.combine(this.map(function(n){ // dojo.Animation + return styleX.toggleClass(n, cssClass, force, args); + })); + } +}); +return NodeList; +}); diff --git a/js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList.js b/js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList.js new file mode 100644 index 0000000..7e4209c --- /dev/null +++ b/js/dojo-1.7.2/dojox/fx/ext-dojo/NodeList.js @@ -0,0 +1,63 @@ +//>>built +define("dojox/fx/ext-dojo/NodeList", ["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/fx", "dojox/fx","dojo/NodeList-fx"], + function(kernel, lang, baseFx, CoreFx, NodeList){ +kernel.experimental("dojox.fx.ext-dojo.NodeList"); +// summary: Core extensions to dojo.NodeList providing addtional fx to dojo.NodeList-fx +// description: +// A Package to extend dojo base NodeList with fx provided by the dojox.fx project. +// These are experimental animations, in an experimental + +lang.extend(NodeList, { + + sizeTo: function(args){ + // summary: + // size all elements of this NodeList. Returns an instance of dojo.Animation + // example: + // | // size all divs with class "blah" + // | dojo.query("div.blah").sizeTo({ + // | width:50, + // | height:50 + // | }).play(); + return this._anim(CoreFx, "sizeTo", args); // dojo.Animation + }, + + slideBy: function(args){ + // summary: + // slide all elements of this NodeList. Returns an instance of dojo.Animation + // + // example: + // | // slide all tables with class "blah" 10 px + // | dojo.query("table.blah").slideBy({ top:10, left:10 }).play(); + return this._anim(CoreFx, "slideBy", args); // dojo.Animation + }, + + highlight: function(args){ + // summary: + // highlight all elements of the node list. + // Returns an instance of dojo.Animation + // example: + // | // highlight all links with class "foo" + // | dojo.query("a.foo").hightlight().play(); + return this._anim(CoreFx, "highlight", args); // dojo.Animation + }, + + fadeTo: function(args){ + // summary: + // fade all elements of the node list to a specified opacity + // example: + // | // fade all elements with class "bar" to to 50% opacity + // | dojo.query(".bar").fadeTo({ end: 0.5 }).play(); + return this._anim(baseFx,"_fade",args); + }, + + wipeTo: function(args){ + // summary: + // Wipe all elements of the NodeList to a specified width: or height: + // example: + // | dojo.query(".box").wipeTo({ width: 300px }).play(); + return this._anim(CoreFx, "wipeTo", args); + } + +}); +return NodeList; +}); diff --git a/js/dojo-1.7.2/dojox/fx/ext-dojo/complex.js b/js/dojo-1.7.2/dojox/fx/ext-dojo/complex.js new file mode 100644 index 0000000..e7ab677 --- /dev/null +++ b/js/dojo-1.7.2/dojox/fx/ext-dojo/complex.js @@ -0,0 +1,170 @@ +//>>built +define("dojox/fx/ext-dojo/complex", ["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/array","dojo/_base/declare", "dojo/_base/connect", + "dojo/_base/Color", "dojo/_base/fx", "dojo/fx"], + function(dojo, lang, arrayUtil, declare, connectUtil, Color, baseFx, coreFx){ + lang.getObject("dojox.fx.ext-dojo.complex", true); + + var da = baseFx.animateProperty; + dojo.animateProperty = baseFx.animateProperty = function(options){ + // summary: + // An extension of dojo.animateProperty which adds functionality + // that animates a "complex property". The primary example is the + // clip style: rect(10px 30px 10px 50px). + // Note this can also be used with (and is actually intended for) + // CSS3 properties, such as transform: + // transform: rotate(10deg) translateX(0px) + // + // description: + // The standard animation doesn't know what to do with something like + // rect(...). This class identifies complex properties by they being a + // string and having parenthesis. If so, that property is made into a + // dojox.fx._Complex object and the getValue() is obtained from + // there. + // + // example: + // | var ani = dojo.animateProperty({ + // | node:dojo.byId("myDiv"), + // | duration:600, + // | properties:{ + // | clip:{start:'rect(0px 50px 50px 0px)', end:'rect(10px 30px 30px 10px)'} + // | } + // | }).play(); + // + var d = dojo; + var ani = da(options); + + connectUtil.connect(ani, "beforeBegin", function(){ + // dojo.Animate original still invokes and still + // works. We're appending this functionality to + // modify targeted properties. + ani.curve.getValue = function(r){ + // Overwriting dojo.Animate's curve.getValue + // This is mostly duplicate code, except it looks + // for an instance of dojox.fx._Complex. + var ret = {}; + for(var p in this._properties){ + var prop = this._properties[p], + start = prop.start; + if(start instanceof d.Color){ + ret[p] = d.blendColors(start, prop.end, r, prop.tempColor).toCss(); + }else if(start instanceof dojox.fx._Complex){ + ret[p] = start.getValue(r); + }else if(!d.isArray(start)){ + ret[p] = ((prop.end - start) * r) + start + (p != "opacity" ? prop.units || "px" : 0); + } + } + return ret; + }; + + // this.properties has already been set, as has this.curve._properties. + // We're fixing the props in curve which will have NaN attributes from + // our string property. + var pm = {}; + for(var p in this.properties){ + var o = this.properties[p]; + if(typeof(o.start) == "string" && /\(/.test(o.start)){ + this.curve._properties[p].start = new dojox.fx._Complex(o); + } + } + + }); + return ani; // dojo.Animation + } + + return declare("dojox.fx._Complex", null, { + // summary: + // A class that takes a complex property such as + // clip style: rect(10px 30px 10px 50px), and breaks it + // into seperate animatable units. The object has a getValue() + // that will return a string with the modified units. + // + PROP: /\([\w|,|+|\-|#|\.|\s]*\)/g, + constructor: function(options){ + var beg = options.start.match(this.PROP); + var end = options.end.match(this.PROP); + + var begProps = arrayUtil.map(beg, this.getProps, this); + var endProps = arrayUtil.map(end, this.getProps, this); + + this._properties = {}; + this.strProp = options.start; + arrayUtil.forEach(begProps, function(prop, i){ + arrayUtil.forEach(prop, function(p, j){ + this.strProp = this.strProp.replace(p, "PROP_"+i+""+j); + this._properties["PROP_"+i+""+j] = this.makePropObject(p, endProps[i][j]) + },this); + },this); + }, + + getValue: function(/*Float*/r){ + // summary: + // Returns a string with teh same integrity as the + // original star and end, but with the modified units. + var str = this.strProp, u; + for(var nm in this._properties){ + var v, o = this._properties[nm]; + if(o.units == "isColor"){ + v = Color.blendColors(o.beg, o.end, r).toCss(false); + u = ""; + }else{ + v = ((o.end - o.beg) * r) + o.beg; + u = o.units; + } + str = str.replace(nm, v + u); + } + + return str; // String + }, + + makePropObject: function(/* String */beg, /* String */end){ + // summary: + // Returns an object that stores the numeric value and + // units of the beggining and ending properties. + // + var b = this.getNumAndUnits(beg); + var e = this.getNumAndUnits(end); + return { + beg:b.num, + end:e.num, + units:b.units + }; // Object + }, + + getProps: function(/* String */str){ + // summary: + // Helper function that splits a stringified set of properties + // into individual units. + // + str = str.substring(1, str.length-1); + var s; + if(/,/.test(str)){ + str = str.replace(/\s/g, ""); + s = str.split(","); + }else{ + str = str.replace(/\s{2,}/g, " "); + s = str.split(" "); + } + return s; // String + }, + getNumAndUnits: function(prop){ + // summary: + // Helper function that returns the numeric verion of the string + // property (or dojo.Color object) and the unit in which it was + // defined. + // + if(!prop){ return {}; } + if(/#/.test(prop)){ + return { + num: new Color(prop), + units:"isColor" + }; // Object + } + var o = { + num:parseFloat(/-*[\d\.\d|\d]{1,}/.exec(prop).join("")) + }; + o.units = /[a-z]{1,}/.exec(prop);//.join(""); + o.units = o.units && o.units.length ? o.units.join("") : ""; + return o; // Object + } + }); +}); diff --git a/js/dojo-1.7.2/dojox/fx/ext-dojo/reverse.js b/js/dojo-1.7.2/dojox/fx/ext-dojo/reverse.js new file mode 100644 index 0000000..a3bb852 --- /dev/null +++ b/js/dojo-1.7.2/dojox/fx/ext-dojo/reverse.js @@ -0,0 +1,104 @@ +//>>built +define("dojox/fx/ext-dojo/reverse", ["dojo/_base/fx", + "dojo/fx", + "dojo/_base/lang", + "dojo/fx/easing", + "dojox/fx"], + function(baseFx, coreFx, lang, easingUtil, dojoxFx){ // +/*===== var dojox.fx.ext-dojo.=====*/ +var reverseApi = { + // summary: + // A dojo.Animation extension that enables an easy reversal. + // description: + // To use, simply require dojox.fx.ext-dojo.reverse and a reverse() + // method will be added to all dojo.Animations. + // It can be used at any time during the animation. It does not + // need to be called when it ends. It also reverses the easing - + // if dojo.fx.easing.quadIn is used, dojo.fx.easing.quadOut will + // be used when animating backwards. + // + _reversed: false, + reverse: function(/*Boolean*/keepPaused, /*Function ? */reverseEase){ + // summary: + // The key method added to an animation to enable reversal. + // keepPaused: Boolean + // By default, calling reverse() will play the animation if + // it was paused. Pass in true to keep it paused (will have + // no effect if reverse is called while animation is playing). + // reverseEase: Function + // A function to use for the reverse easing. This allows for + // the possibility of custom eases that are not in the dojo.fx + // library. + // + var playing = this.status() == "playing"; + this.pause(); + this._reversed = !this._reversed; + var d = this.duration, + sofar = d * this._percent, + togo = d - sofar, + curr = new Date().valueOf(), + cp = this.curve._properties, + p = this.properties, + nm + ; + this._endTime = curr + sofar; + this._startTime = curr - togo; + + if(playing){ + this.gotoPercent(togo / d) + } + for(nm in p){ + var tmp = p[nm].start; + p[nm].start = cp[nm].start = p[nm].end; + p[nm].end = cp[nm].end = tmp; + } + + if(this._reversed){ + if(!this.rEase){ + this.fEase = this.easing; + if(reverseEase){ + this.rEase = reverseEase; + }else{ + // loop through dojo.fx.easing to find the matching ease + var de = easingUtil, found, eName; + for(nm in de){ + if(this.easing == de[nm]){ + // get ease's name + found = nm; break; + } + } + + if(found){ + // find ease's opposite + if(/InOut/.test(nm) || !/In|Out/i.test(nm)){ + this.rEase = this.easing; + }else if(/In/.test(nm)){ + eName = nm.replace("In", "Out"); + }else{ + eName = nm.replace("Out", "In"); + } + if(eName){ + this.rEase = easingUtil[eName]; + } + }else{ + // default ease, and other's like linear do not have an opposite + console.info("ease function to reverse not found"); + this.rEase = this.easing; + } + } + + } + this.easing = this.rEase; + }else{ + this.easing = this.fEase; + } + if(!keepPaused && this.status() != "playing"){ + this.play(); + } + + return this; + } +}; +lang.extend( baseFx.Animation, reverseApi); +return baseFx.Animation; +});
\ No newline at end of file |
