diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /js/dojo/dojox/widget/rotator | |
Diffstat (limited to 'js/dojo/dojox/widget/rotator')
| -rw-r--r-- | js/dojo/dojox/widget/rotator/Controller.js | 196 | ||||
| -rw-r--r-- | js/dojo/dojox/widget/rotator/Fade.js | 44 | ||||
| -rw-r--r-- | js/dojo/dojox/widget/rotator/Pan.js | 212 | ||||
| -rw-r--r-- | js/dojo/dojox/widget/rotator/PanFade.js | 216 | ||||
| -rw-r--r-- | js/dojo/dojox/widget/rotator/Slide.js | 66 | ||||
| -rw-r--r-- | js/dojo/dojox/widget/rotator/ThumbnailController.js | 100 | ||||
| -rw-r--r-- | js/dojo/dojox/widget/rotator/Wipe.js | 92 |
7 files changed, 926 insertions, 0 deletions
diff --git a/js/dojo/dojox/widget/rotator/Controller.js b/js/dojo/dojox/widget/rotator/Controller.js new file mode 100644 index 0000000..8fc5aed --- /dev/null +++ b/js/dojo/dojox/widget/rotator/Controller.js @@ -0,0 +1,196 @@ +//>>built +// wrapped by build app +define("dojox/widget/rotator/Controller", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){ +dojo.provide("dojox.widget.rotator.Controller"); + +(function(d){ + + var _dojoxRotator = "dojoxRotator", + _play = _dojoxRotator + "Play", + _pause = _dojoxRotator + "Pause", + _number = _dojoxRotator + "Number", + _tab = _dojoxRotator + "Tab", + _selected = _dojoxRotator + "Selected"; + + d.declare("dojox.widget.rotator.Controller", null, { + // summary: + // A controller that manipulates a Rotator or AutoRotator. + // + // description: + // Displays a series of controls that send actions to a Rotator or + // AutoRotator. The Controller supports the following controls: + // + // * Next pane + // * Previous pane + // * Play/Pause toggler + // * Numbered tabs + // * Titled tabs + // * Information + // + // You may specify any of these controls in any order. You may also + // have multiple Controllers tied to a single Rotator instance. + // + // The Controller's DOM node may also be styled for positioning or + // other styled preferences. + // + // example: + // | <div dojoType="dojox.widget.rotator.Controller" + // | rotator="myRotator" + // | ></div> + // + // example: + // | <div dojoType="dojox.widget.rotator.Controller" + // | rotator="myRotator" + // | controls="prev,#,next" + // | class="myCtrl" + // | ></div> + // + // example: + // | <div dojoType="dojox.widget.rotator.Controller" + // | rotator="myRotator" + // | controls="titles" + // | class="myCtrl" + // | ></div>s + + // rotator: dojox.widget.Rotator + // An instance of a Rotator widget. + rotator: null, + + // commands: string + // A comma-separated list of commands. Valid commands are: + // prev An icon button to go to the previous pane. + // next An icon button to go to the next pane. + // play/pause A play and pause toggle icon button. + // info Displays the current and total panes. (ie "1 / 4") + // # Displays a number button for each pane. (ie "1 2 3 4") + // titles Displays each pane's title as a tab. (ie "Home Services Contact Blog") + commands: "prev,play/pause,info,next", + + constructor: function(/*Object*/params, /*DomNode|string*/node){ + // summary: + // Initializes the pager and connect to the rotator. + + d.mixin(this, params); + + // check if we have a valid rotator + var r = this.rotator; + if(r){ + // remove all of the controller's child nodes just in case + while(node.firstChild){ + node.removeChild(node.firstChild); + } + + var ul = this._domNode = d.create("ul", null, node), + icon = " " + _dojoxRotator + "Icon", + + // helper function for creating a button + cb = function(/*string*/label, /*string*/css, /*array*/action){ + d.create("li", { + className: css, + innerHTML: '<a href="#"><span>' + label + '</span></a>', + onclick: function(/*event*/e){ + d.stopEvent(e); + if(r){ + r.control.apply(r, action); + } + } + }, ul); + }; + + // build out the commands + d.forEach(this.commands.split(','), function(b, i){ + switch(b){ + case "prev": + cb("Prev", _dojoxRotator + "Prev" + icon, ["prev"]); + break; + case "play/pause": + cb("Play", _play + icon, ["play"]); + cb("Pause", _pause + icon, ["pause"]); + break; + case "info": + this._info = d.create("li", { + className: _dojoxRotator + "Info", + innerHTML: this._buildInfo(r) + }, ul); + break; + case "next": + cb("Next", _dojoxRotator + "Next" + icon, ["next"]); + break; + case "#": + case "titles": + for(var j=0; j<r.panes.length; j++){ + cb( + /*label*/ b == '#' ? j+1 : r.panes[j].title || "Tab " + (j+1), + /*css*/ (b == '#' ? _number : _tab) + ' ' + (j == r.idx ? _selected : "") + ' ' + _dojoxRotator + "Pane" + j, + /*action*/ ["go", j] + ); + } + break; + } + }, this); + + // add the first/last classes for styling + d.query("li:first-child", ul).addClass(_dojoxRotator + "First"); + d.query("li:last-child", ul).addClass(_dojoxRotator + "Last"); + + // set the initial state of the play/pause toggle button + this._togglePlay(); + + this._con = d.connect(r, "onUpdate", this, "_onUpdate"); + } + }, + + destroy: function(){ + // summary: + // Disconnect from the rotator. + d.disconnect(this._con); + d.destroy(this._domNode); + }, + + _togglePlay: function(/*boolean*/playing){ + // summary: + // Toggles the play/pause button, if it exists. + + var p = this.rotator.playing; + d.query('.'+_play, this._domNode).style("display", p ? "none" : ""); + d.query('.'+_pause, this._domNode).style("display", p ? "" : "none"); + }, + + _buildInfo: function(/*dojox.widget.Rotator*/r){ + // summary: + // Return a string containing the current pane number and the total number of panes. + return '<span>' + (r.idx+1) + ' / ' + r.panes.length + '</span>'; /*string*/ + }, + + _onUpdate: function(/*string*/type){ + // summary: + // Updates various pager controls when the rotator updates. + + var r = this.rotator; // no need to test if this is null since _onUpdate is only fired by the rotator + + switch(type){ + case "play": + case "pause": + this._togglePlay(); + break; + case "onAfterTransition": + if(this._info){ + this._info.innerHTML = this._buildInfo(r); + } + + // helper function for selecting the current tab + var s = function(/*NodeList*/n){ + if(r.idx < n.length){ + d.addClass(n[r.idx], _selected); + } + }; + + s(d.query('.' + _number, this._domNode).removeClass(_selected)); + s(d.query('.' + _tab, this._domNode).removeClass(_selected)); + break; + } + } + }); + +})(dojo); +}); diff --git a/js/dojo/dojox/widget/rotator/Fade.js b/js/dojo/dojox/widget/rotator/Fade.js new file mode 100644 index 0000000..26a9c03 --- /dev/null +++ b/js/dojo/dojox/widget/rotator/Fade.js @@ -0,0 +1,44 @@ +//>>built +// wrapped by build app +define("dojox/widget/rotator/Fade", ["dijit","dojo","dojox","dojo/require!dojo/fx"], function(dijit,dojo,dojox){ +dojo.provide("dojox.widget.rotator.Fade"); +dojo.require("dojo.fx"); + +(function(d){ + + function _fade(/*Object*/args, /*string*/action){ + // summary: + // Returns an animation of a fade out and fade in of the current and next + // panes. It will either chain (fade) or combine (crossFade) the fade + // animations. + var n = args.next.node; + d.style(n, { + display: "", + opacity: 0 + }); + + args.node = args.current.node; + + return d.fx[action]([ /*dojo.Animation*/ + d.fadeOut(args), + d.fadeIn(d.mixin(args, { node: n })) + ]); + } + + d.mixin(dojox.widget.rotator, { + fade: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that fades out the current pane, then fades in + // the next pane. + return _fade(args, "chain"); /*dojo.Animation*/ + }, + + crossFade: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that cross fades two rotator panes. + return _fade(args, "combine"); /*dojo.Animation*/ + } + }); + +})(dojo); +}); diff --git a/js/dojo/dojox/widget/rotator/Pan.js b/js/dojo/dojox/widget/rotator/Pan.js new file mode 100644 index 0000000..92723b8 --- /dev/null +++ b/js/dojo/dojox/widget/rotator/Pan.js @@ -0,0 +1,212 @@ +//>>built +// wrapped by build app +define("dojox/widget/rotator/Pan", ["dijit","dojo","dojox","dojo/require!dojo/fx"], function(dijit,dojo,dojox){ +dojo.provide("dojox.widget.rotator.Pan"); +dojo.require("dojo.fx"); + +(function(d){ + + // Constants used to identify which edge the pane pans in from. + var DOWN = 0, + RIGHT = 1, + UP = 2, + LEFT = 3; + + function _pan(/*int*/type, /*Object*/args){ + // summary: + // Handles the preparation of the dom node and creates the dojo.Animation object. + var n = args.next.node, + r = args.rotatorBox, + m = type % 2, + a = m ? "left" : "top", + s = (m ? r.w : r.h) * (type < 2 ? -1 : 1), + p = {}, + q = {}; + + d.style(n, "display", ""); + + p[a] = { + start: 0, + end: -s + }; + + q[a] = { + start: s, + end: 0 + }; + + return d.fx.combine([ /*dojo.Animation*/ + d.animateProperty({ + node: args.current.node, + duration: args.duration, + properties: p, + easing: args.easing + }), + d.animateProperty({ + node: n, + duration: args.duration, + properties: q, + easing: args.easing + }) + ]); + } + + function _setZindex(/*DomNode*/n, /*int*/z){ + // summary: + // Helper function for continuously panning. + d.style(n, "zIndex", z); + } + + d.mixin(dojox.widget.rotator, { + pan: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that either pans left or right to the next pane. + // The actual direction depends on the order of the panes. + // + // If panning forward from index 1 to 3, it will perform a pan left. If panning + // backwards from 5 to 1, then it will perform a pan right. + // + // If the parameter "continuous" is set to true, it will return an animation + // chain of several pan animations of each intermediate pane panning. For + // example, if you pan forward from 1 to 3, it will return an animation panning + // left from 1 to 2 and then 2 to 3. + // + // If an easing is specified, it will be applied to each pan transition. For + // example, if you are panning from pane 1 to pane 5 and you set the easing to + // "dojo.fx.easing.elasticInOut", then it will "wobble" 5 times, once for each + // pan transition. + // + // If the parameter "wrap" is set to true, it will pan to the next pane using + // the shortest distance in the array of panes. For example, if there are 6 + // panes, then panning from 5 to 1 will pan forward (left) from pane 5 to 6 and + // 6 to 1. If the distance is the same either going forward or backwards, then + // it will always pan forward (left). + // + // A continuous pan will use the target pane's duration to pan all intermediate + // panes. To use the target's pane duration for each intermediate pane, then + // set the "quick" parameter to "false". + + var w = args.wrap, + p = args.rotator.panes, + len = p.length, + z = len, + j = args.current.idx, + k = args.next.idx, + nw = Math.abs(k - j), + ww = Math.abs((len - Math.max(j, k)) + Math.min(j, k)) % len, + _forward = j < k, + _dir = LEFT, + _pans = [], + _nodes = [], + _duration = args.duration; + + // default to pan left, but check if we should pan right. + // need to take into account wrapping. + if((!w && !_forward) || (w && (_forward && nw > ww || !_forward && nw < ww))){ + _dir = RIGHT; + } + + if(args.continuous){ + // if continuous pans are quick, then divide the duration by the number of panes + if(args.quick){ + _duration = Math.round(_duration / (w ? Math.min(ww, nw) : nw)); + } + + // set the current pane's z-index + _setZindex(p[j].node, z--); + + var f = (_dir == LEFT); + + // loop and set z-indexes and get all pan animations + while(1){ + // set the current pane + var i = j; + + // increment/decrement the next pane's index + if(f){ + if(++j >= len){ + j = 0; + } + }else{ + if(--j < 0){ + j = len - 1; + } + } + + var x = p[i], + y = p[j]; + + // set next pane's z-index + _setZindex(y.node, z--); + + // build the pan animation + _pans.push(_pan(_dir, d.mixin({ + easing: function(m){ return m; } // continuous gets a linear easing by default + }, args, { + current: x, + next: y, + duration: _duration + }))); + + // if we're done, then break out of the loop + if((f && j == k) || (!f && j == k)){ + break; + } + + // this must come after the break... we don't want the last pane to get it's + // styles reset. + _nodes.push(y.node); + } + + // build the chained animation of all pan animations + var _anim = d.fx.chain(_pans), + + // clean up styles when the chained animation finishes + h = d.connect(_anim, "onEnd", function(){ + d.disconnect(h); + d.forEach(_nodes, function(q){ + d.style(q, { + display: "none", + left: 0, + opacity: 1, + top: 0, + zIndex: 0 + }); + }); + }); + + return _anim; + } + + // we're not continuous, so just return a normal pan animation + return _pan(_dir, args); /*dojo.Animation*/ + }, + + panDown: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the top. + return _pan(DOWN, args); /*dojo.Animation*/ + }, + + panRight: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the right. + return _pan(RIGHT, args); /*dojo.Animation*/ + }, + + panUp: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the bottom. + return _pan(UP, args); /*dojo.Animation*/ + }, + + panLeft: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the left. + return _pan(LEFT, args); /*dojo.Animation*/ + } + }); + +})(dojo); + +}); diff --git a/js/dojo/dojox/widget/rotator/PanFade.js b/js/dojo/dojox/widget/rotator/PanFade.js new file mode 100644 index 0000000..f84da21 --- /dev/null +++ b/js/dojo/dojox/widget/rotator/PanFade.js @@ -0,0 +1,216 @@ +//>>built +// wrapped by build app +define("dojox/widget/rotator/PanFade", ["dijit","dojo","dojox","dojo/require!dojo/fx"], function(dijit,dojo,dojox){ +dojo.provide("dojox.widget.rotator.PanFade"); +dojo.require("dojo.fx"); + +(function(d){ + + // Constants used to identify which edge the pane pans in from. + var DOWN = 0, + RIGHT = 1, + UP = 2, + LEFT = 3; + + function _pan(/*int*/type, /*Object*/args){ + // summary: + // Handles the preparation of the dom node and creates the dojo.Animation object. + var j = { + node: args.current.node, + duration: args.duration, + easing: args.easing + }, + k = { + node: args.next.node, + duration: args.duration, + easing: args.easing + }, + r = args.rotatorBox, + m = type % 2, + a = m ? "left" : "top", + s = (m ? r.w : r.h) * (type < 2 ? -1 : 1), + p = {}, + q = {}; + + d.style(k.node, { + display: "", + opacity: 0 + }); + + p[a] = { + start: 0, + end: -s + }; + + q[a] = { + start: s, + end: 0 + }; + + return d.fx.combine([ /*dojo.Animation*/ + d.animateProperty(d.mixin({ properties: p }, j)), + d.fadeOut(j), + d.animateProperty(d.mixin({ properties: q }, k)), + d.fadeIn(k) + ]); + } + + function _setZindex(/*DomNode*/n, /*int*/z){ + // summary: + // Helper function for continuously panning. + d.style(n, "zIndex", z); + } + + d.mixin(dojox.widget.rotator, { + panFade: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that either pans left or right to the next pane. + // The actual direction depends on the order of the panes. + // + // If panning forward from index 1 to 3, it will perform a pan left. If panning + // backwards from 5 to 1, then it will perform a pan right. + // + // If the parameter "continuous" is set to true, it will return an animation + // chain of several pan animations of each intermediate pane panning. For + // example, if you pan forward from 1 to 3, it will return an animation panning + // left from 1 to 2 and then 2 to 3. + // + // If an easing is specified, it will be applied to each pan transition. For + // example, if you are panning from pane 1 to pane 5 and you set the easing to + // "dojo.fx.easing.elasticInOut", then it will "wobble" 5 times, once for each + // pan transition. + // + // If the parameter "wrap" is set to true, it will pan to the next pane using + // the shortest distance in the array of panes. For example, if there are 6 + // panes, then panning from 5 to 1 will pan forward (left) from pane 5 to 6 and + // 6 to 1. If the distance is the same either going forward or backwards, then + // it will always pan forward (left). + // + // A continuous pan will use the target pane's duration to pan all intermediate + // panes. To use the target's pane duration for each intermediate pane, then + // set the "quick" parameter to "false". + + var w = args.wrap, + p = args.rotator.panes, + len = p.length, + z = len, + j = args.current.idx, + k = args.next.idx, + nw = Math.abs(k - j), + ww = Math.abs((len - Math.max(j, k)) + Math.min(j, k)) % len, + _forward = j < k, + _dir = LEFT, + _pans = [], + _nodes = [], + _duration = args.duration; + + // default to pan left, but check if we should pan right. + // need to take into account wrapping. + if((!w && !_forward) || (w && (_forward && nw > ww || !_forward && nw < ww))){ + _dir = RIGHT; + } + + if(args.continuous){ + // if continuous pans are quick, then divide the duration by the number of panes + if(args.quick){ + _duration = Math.round(_duration / (w ? Math.min(ww, nw) : nw)); + } + + // set the current pane's z-index + _setZindex(p[j].node, z--); + + var f = (_dir == LEFT); + + // loop and set z-indexes and get all pan animations + while(1){ + // set the current pane + var i = j; + + // increment/decrement the next pane's index + if(f){ + if(++j >= len){ + j = 0; + } + }else{ + if(--j < 0){ + j = len - 1; + } + } + + var x = p[i], + y = p[j]; + + // set next pane's z-index + _setZindex(y.node, z--); + + // build the pan animation + _pans.push(_pan(_dir, d.mixin({ + easing: function(m){ return m; } // continuous gets a linear easing by default + }, args, { + current: x, + next: y, + duration: _duration + }))); + + // if we're done, then break out of the loop + if((f && j == k) || (!f && j == k)){ + break; + } + + // this must come after the break... we don't want the last pane to get it's + // styles reset. + _nodes.push(y.node); + } + + // build the chained animation of all pan animations + var _anim = d.fx.chain(_pans), + + // clean up styles when the chained animation finishes + h = d.connect(_anim, "onEnd", function(){ + d.disconnect(h); + d.forEach(_nodes, function(q){ + d.style(q, { + display: "none", + left: 0, + opacity: 1, + top: 0, + zIndex: 0 + }); + }); + }); + + return _anim; + } + + // we're not continuous, so just return a normal pan animation + return _pan(_dir, args); /*dojo.Animation*/ + }, + + panFadeDown: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the top. + return _pan(DOWN, args); /*dojo.Animation*/ + }, + + panFadeRight: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the right. + return _pan(RIGHT, args); /*dojo.Animation*/ + }, + + panFadeUp: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the bottom. + return _pan(UP, args); /*dojo.Animation*/ + }, + + panFadeLeft: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that pans in the next rotator pane from the left. + return _pan(LEFT, args); /*dojo.Animation*/ + } + }); + +})(dojo); + +}); diff --git a/js/dojo/dojox/widget/rotator/Slide.js b/js/dojo/dojox/widget/rotator/Slide.js new file mode 100644 index 0000000..0f13b44 --- /dev/null +++ b/js/dojo/dojox/widget/rotator/Slide.js @@ -0,0 +1,66 @@ +//>>built +// wrapped by build app +define("dojox/widget/rotator/Slide", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){ +dojo.provide("dojox.widget.rotator.Slide"); + +(function(d){ + + // Constants used to identify which edge the pane slides in from. + var DOWN = 0, + RIGHT = 1, + UP = 2, + LEFT = 3; + + function _slide(/*int*/type, /*Object*/args){ + // summary: + // Handles the preparation of the dom node and creates the dojo.Animation object. + var node = args.node = args.next.node, + r = args.rotatorBox, + m = type % 2, + s = (m ? r.w : r.h) * (type < 2 ? -1 : 1); + + d.style(node, { + display: "", + zIndex: (d.style(args.current.node, "zIndex") || 1) + 1 + }); + + if(!args.properties){ + args.properties = {}; + } + args.properties[m ? "left" : "top"] = { + start: s, + end: 0 + }; + + return d.animateProperty(args); /*dojo.Animation*/ + } + + d.mixin(dojox.widget.rotator, { + slideDown: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that slides in the next rotator pane from the top. + return _slide(DOWN, args); /*dojo.Animation*/ + }, + + slideRight: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that slides in the next rotator pane from the right. + return _slide(RIGHT, args); /*dojo.Animation*/ + }, + + slideUp: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that slides in the next rotator pane from the bottom. + return _slide(UP, args); /*dojo.Animation*/ + }, + + slideLeft: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that slides in the next rotator pane from the left. + return _slide(LEFT, args); /*dojo.Animation*/ + } + }); + +})(dojo); + +}); diff --git a/js/dojo/dojox/widget/rotator/ThumbnailController.js b/js/dojo/dojox/widget/rotator/ThumbnailController.js new file mode 100644 index 0000000..d7f8d29 --- /dev/null +++ b/js/dojo/dojox/widget/rotator/ThumbnailController.js @@ -0,0 +1,100 @@ +//>>built +// wrapped by build app +define("dojox/widget/rotator/ThumbnailController", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){ +dojo.provide("dojox.widget.rotator.ThumbnailController"); + +(function(d){ + + var _css = "dojoxRotatorThumb", + _selected = _css + "Selected"; + + d.declare("dojox.widget.rotator.ThumbnailController", null, { + // summary: + // A rotator controller that displays thumbnails of each rotator pane. + // + // description: + // The ThumbnailController will look at each of the rotator's panes and + // only if the node is an <img> tag, then it will create an thumbnail of + // the pane's image using the <img> tag's "thumbsrc" or "src" attribute. + // + // The size of the thumbnails and the style of the selected thumbnail is + // controlled using CSS. + // + // example: + // | <div dojoType="dojox.widget.Rotator" jsId="myRotator"> + // | <img src="/path/to/image1.jpg" thumbsrc="/path/to/thumb1.jpg" alt="Image 1"/> + // | <img src="/path/to/image2.jpg" thumbsrc="/path/to/thumb2.jpg" alt="Image 2"/> + // | </div> + // | <div dojoType="dojox.widget.rotator.ThumbnailController" rotator="myRotator"></div> + + // rotator: dojox.widget.Rotator + // An instance of a Rotator widget. + rotator: null, + + constructor: function(/*Object*/params, /*DomNode|string*/node){ + // summary: + // Initializes the thumbnails and connect to the rotator. + + d.mixin(this, params); + + this._domNode = node; + + // check if we have a valid rotator + var r = this.rotator; + if(r){ + // remove all of the controller's child nodes just in case + while(node.firstChild){ + node.removeChild(node.firstChild); + } + + for(var i=0; i<r.panes.length; i++){ + var n = r.panes[i].node, + s = d.attr(n, "thumbsrc") || d.attr(n, "src"), + t = d.attr(n, "alt") || ""; + + if(/img/i.test(n.tagName)){ + (function(j){ + d.create("a", { + classname: _css + ' ' + _css + j + ' ' + (j == r.idx ? _selected : ""), + href: s, + onclick: function(e){ + d.stopEvent(e); + if(r){ + r.control.apply(r, ["go", j]); + } + }, + title: t, + innerHTML: '<img src="' + s + '" alt="' + t + '"/>' + }, node); + })(i); + } + } + + this._con = d.connect(r, "onUpdate", this, "_onUpdate"); + } + }, + + destroy: function(){ + // summary: + // Disconnect from the rotator. + + d.disconnect(this._con); + d.destroy(this._domNode); + }, + + _onUpdate: function(/*string*/type){ + // summary: + // Updates various pager controls when the rotator updates. + + var r = this.rotator; // no need to test if this is null since _onUpdate is only fired by the rotator + if(type == "onAfterTransition"){ + var n = d.query('.' + _css, this._domNode).removeClass(_selected); + if(r.idx < n.length){ + d.addClass(n[r.idx], _selected); + } + } + } + }); + +})(dojo); +}); diff --git a/js/dojo/dojox/widget/rotator/Wipe.js b/js/dojo/dojox/widget/rotator/Wipe.js new file mode 100644 index 0000000..9377ebf --- /dev/null +++ b/js/dojo/dojox/widget/rotator/Wipe.js @@ -0,0 +1,92 @@ +//>>built +// wrapped by build app +define("dojox/widget/rotator/Wipe", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){ +dojo.provide("dojox.widget.rotator.Wipe"); + +(function(d){ + + // Constants used to identify which clip edge is being wiped. The values are + // the index of the clip array that is changed during the animation. + var DOWN = 2, + RIGHT = 3, + UP = 0, + LEFT = 1; + + function _clipArray(/*int*/type, /*int*/w, /*int*/h, /*number*/x){ + // summary: + // Returns an array containing the down, right, up, and + // left clip region based on the type. If "x" is specified, + // then it is applied to the appropriate clipping edge. + var a = [0, w, 0, 0]; // default to the top edge + if(type == RIGHT){ + a = [0, w, h, w]; + }else if(type == UP){ + a = [h, w, h, 0]; + }else if(type == LEFT){ + a = [0, 0, h, 0]; + } + if(x != null){ + a[type] = type == DOWN || type == LEFT ? x : (type % 2 ? w : h) - x; + } + return a; /*Array*/ + } + + function _setClip(/*DomNode*/n, /*int*/type, /*int*/w, /*int*/h, /*number*/x){ + // summary: + // Sets the clip region of the node. If a type is passed in then we + // return a rect(), otherwise return "auto". + d.style(n, "clip", type == null ? "auto" : "rect(" + _clipArray(type, w, h, x).join("px,") + "px)"); + } + + function _wipe(/*int*/type, /*Object*/args){ + // summary: + // Handles the preparation of the dom node and creates the dojo.Animation object. + var node = args.next.node, + w = args.rotatorBox.w, + h = args.rotatorBox.h; + + d.style(node, { + display: "", + zIndex: (d.style(args.current.node, "zIndex") || 1) + 1 + }); + + _setClip(node, type, w, h); + + return new d.Animation(d.mixin({ /*dojo.Animation*/ + node: node, + curve: [0, type % 2 ? w : h], + onAnimate: function(x){ + _setClip(node, type, w, h, parseInt(x)); + } + }, args)); + } + + d.mixin(dojox.widget.rotator, { + wipeDown: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that wipes in the next rotator pane from the top. + return _wipe(DOWN, args); /*dojo.Animation*/ + }, + + wipeRight: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that wipes in the next rotator pane from the right. + return _wipe(RIGHT, args); /*dojo.Animation*/ + }, + + wipeUp: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that wipes in the next rotator pane from the bottom. + return _wipe(UP, args); /*dojo.Animation*/ + }, + + wipeLeft: function(/*Object*/args){ + // summary: + // Returns a dojo.Animation that wipes in the next rotator pane from the left. + return _wipe(LEFT, args); /*dojo.Animation*/ + } + }); + +})(dojo); + +}); |
