123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- define("dojox/layout/RotatorContainer", ["dojo/_base/declare","dojo/_base/html","dojo/_base/connect","dojo/_base/lang","dojo/_base/array",
- "dojo/_base/fx","dojo/fx","dijit/_base/manager","dijit/layout/StackContainer","dijit/layout/StackController","dijit/_Widget",
- "dijit/_Templated","dijit/_Contained"
- ],function(declare,html,connect,lang,array,baseFx,coreFx,manager,
- StackContainer,StackController,Widget,Templated,Contained){
- var RotatorContainer = declare("dojox.layout.RotatorContainer",[StackContainer, Templated], {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- templateString: '<div class="dojoxRotatorContainer"><div dojoAttachPoint="tabNode"></div><div class="dojoxRotatorPager" dojoAttachPoint="pagerNode"></div><div class="dojoxRotatorContent" dojoAttachPoint="containerNode"></div></div>',
-
-
-
- showTabs: true,
-
-
- transitionDelay: 5000,
-
-
-
- transition: "fade",
-
-
- transitionDuration: 1000,
-
-
- autoStart: true,
-
-
- suspendOnHover: false,
-
-
-
- pauseOnManualChange: null,
-
-
- reverse: false,
-
-
- pagerId: "",
-
-
- cycles: -1,
-
-
- pagerClass: "dojox.layout.RotatorPager",
- postCreate: function(){
-
- this.inherited(arguments);
-
- html.style(this.domNode, "position", "relative");
-
- if(this.cycles-0 == this.cycles && this.cycles != -1){
-
- this.cycles++;
- }else{
- this.cycles = -1;
- }
-
-
- if(this.pauseOnManualChange === null){
- this.pauseOnManualChange = !this.suspendOnHover;
- }
-
- var id = this.id || "rotator"+(new Date()).getTime(),
- sc = new StackController({ containerId:id }, this.tabNode);
- this.tabNode = sc.domNode;
- this._stackController = sc;
- html.style(this.tabNode, "display", this.showTabs ? "" : "none");
-
- this.connect(sc, "onButtonClick","_manualChange");
-
- this._subscriptions = [
- connect.subscribe(this.id+"-cycle", this, "_cycle"),
- connect.subscribe(this.id+"-state", this, "_state")
- ];
-
- var d = Math.round(this.transitionDelay * 0.75);
- if(d < this.transitionDuration){
- this.transitionDuration = d;
- }
-
- if(this.suspendOnHover){
- this.connect(this.domNode, "onmouseover", "_onMouseOver");
- this.connect(this.domNode, "onmouseout", "_onMouseOut");
- }
- },
- startup: function(){
-
- if(this._started){ return; }
-
- var c = this.getChildren();
- for(var i=0, len=c.length; i<len; i++){
- if(c[i].declaredClass == this.pagerClass){
- this.pagerNode.appendChild(c[i].domNode);
- break;
- }
- }
-
- this.inherited(arguments);
-
- if(this.autoStart){
-
- setTimeout(lang.hitch(this, "_play"), 10);
- }else{
-
- this._updatePager();
- }
- },
- destroy: function(){
-
- array.forEach(this._subscriptions, connect.unsubscribe);
- this.inherited(arguments);
- },
- _setShowTabsAttr: function(/*anything*/value){
- this.showTabs = value;
- html.style(this.tabNode, "display", value ? "" : "none");
- },
- _updatePager: function(){
-
- var c = this.getChildren();
- connect.publish(this.id+"-update", [this._playing, array.indexOf(c, this.selectedChildWidget)+1, c.length]);
- },
- _onMouseOver: function(){
-
-
- this._resetTimer();
- this._over = true;
- },
- _onMouseOut: function(){
-
- this._over = false;
-
-
- if(this._playing){
- clearTimeout(this._timer);
- this._timer = setTimeout(lang.hitch(this, "_play", true), 200);
- }
- },
- _resetTimer: function(){
-
- clearTimeout(this._timer);
- this._timer = null;
- },
- _cycle: function(/*boolean or int*/next){
-
-
-
- if(next instanceof Boolean || typeof next == "boolean"){
- this._manualChange();
- }
- var c = this.getChildren(),
- len = c.length,
- i = array.indexOf(c, this.selectedChildWidget) + (next === false || (next !== true && this.reverse) ? -1 : 1);
- this.selectChild(c[(i < len ? (i < 0 ? len-1 : i) : 0)]);
- this._updatePager();
- },
- _manualChange: function(){
-
-
- if(this.pauseOnManualChange){
- this._playing = false;
- }
- this.cycles = -1;
- },
- _play: function(skip){
-
- this._playing = true;
- this._resetTimer();
- if(skip !== true && this.cycles>0){
- this.cycles--;
- }
- if(this.cycles==0){
- this._pause();
- }else if((!this.suspendOnHover || !this._over) && this.transitionDelay){
-
- this._timer = setTimeout(lang.hitch(this, "_cycle"), this.selectedChildWidget.domNode.getAttribute("transitionDelay") || this.transitionDelay);
- }
- this._updatePager();
- },
- _pause: function(){
-
- this._playing = false;
- this._resetTimer();
- },
- _state: function(playing){
-
- if(playing){
-
- this.cycles = -1;
- this._play();
- }else{
- this._pause();
- }
- },
- _transition: function(/*dijit._Widget*/ next, /*dijit._Widget*/ prev){
-
- this._resetTimer();
-
- if(prev && this.transitionDuration){
- switch(this.transition){
- case "fade": this._fade(next, prev); return;
- }
- }
- this._transitionEnd();
- this.inherited(arguments);
- },
- _transitionEnd: function(){
- if(this._playing){
- this._play();
- }else{
- this._updatePager();
- }
- },
- _fade: function(/*dijit._Widget*/ next, /*dijit._Widget*/ prev){
-
- this._styleNode(prev.domNode, 1, 1);
- this._styleNode(next.domNode, 0, 2);
-
- this._showChild(next);
- if(this.doLayout && next.resize){
- next.resize(this._containerContentBox || this._contentBox);
- }
-
- var args = { duration:this.transitionDuration },
- anim = coreFx.combine([
- baseFx["fadeOut"](lang.mixin({node:prev.domNode}, args)),
- baseFx["fadeIn"](lang.mixin({node:next.domNode}, args))
- ]);
- this.connect(anim, "onEnd", lang.hitch(this,function(){
- this._hideChild(prev);
- this._transitionEnd();
- }));
- anim.play();
- },
- _styleNode: function(/*DOMnode*/node, /*number*/opacity, /*int*/zIndex){
-
- html.style(node, "opacity", opacity);
- html.style(node, "zIndex", zIndex);
- html.style(node, "position", "absolute");
- }
- });
- declare("dojox.layout.RotatorPager", [Widget, Templated, Contained], {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- widgetsInTemplate: true,
-
-
-
- rotatorId: "",
- postMixInProperties: function(){
- this.templateString = "<div>" + this.srcNodeRef.innerHTML + "</div>";
- },
- postCreate: function(){
- var p = manager.byId(this.rotatorId) || this.getParent();
- if(p && p.declaredClass == "dojox.layout.RotatorContainer"){
- if(this.previous){
- connect.connect(this.previous, "onClick", function(){
- connect.publish(p.id+"-cycle", [false]);
- });
- }
- if(this.next){
- connect.connect(this.next, "onClick", function(){
- connect.publish(p.id+"-cycle", [true]);
- });
- }
- if(this.playPause){
- connect.connect(this.playPause, "onClick", function(){
- this.set('label', this.checked ? "Pause" : "Play");
- connect.publish(p.id+"-state", [this.checked]);
- });
- }
- this._subscriptions = [
- connect.subscribe(p.id+"-state", this, "_state"),
- connect.subscribe(p.id+"-update", this, "_update")
- ];
- }
- },
- destroy: function(){
-
- array.forEach(this._subscriptions, connect.unsubscribe);
- this.inherited(arguments);
- },
- _state: function(/*boolean*/playing){
-
- if(this.playPause && this.playPause.checked != playing){
- this.playPause.set("label", playing ? "Pause" : "Play");
- this.playPause.set("checked", playing);
- }
- },
- _update: function(/*boolean*/playing, /*int*/current, /*int*/total){
-
- this._state(playing);
- if(this.current && current){
- this.current.innerHTML = current;
- }
- if(this.total && total){
- this.total.innerHTML = total;
- }
- }
- });
- return RotatorContainer;
- });
|