dojox/widget/rotator/Controller.js

  • Provides:

    • dojox.widget.rotator.Controller
  • dojox.widget.rotator.Controller

    • type
      Function
    • summary
      Initializes the pager and connect to the rotator.
    • 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
    • parameters:
      • params: (typeof Object)
      • node: (typeof DomNode|string)
    • source: [view]
         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: '' + label + '',
             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        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");
         }
    • chains:
      • r.control: (call)
  • dojox.widget.rotator.Controller.rotator

    • type
      dojox.widget.Rotator
    • summary
      An instance of a Rotator widget.
  • dojox.widget.rotator.Controller.commands

    • type
      string
    • summary
      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 &quot;1 / 4&quot;)
      #				Displays a number button for each pane. (ie &quot;1 2 3 4&quot;)
      titles		Displays each pane's title as a tab. (ie &quot;Home Services Contact Blog&quot;)
  • dojox.widget.rotator.Controller.destroy

    • type
      Function
    • source: [view]
         d.disconnect(this._con);
         d.destroy(this._domNode);
    • summary
      Disconnect from the rotator.
  • dojox.widget.rotator.Controller._togglePlay

    • type
      Function
    • parameters:
      • playing: (typeof boolean)
    • source: [view]
         var p = this.rotator.playing;
         d.query('.'+_play, this._domNode).style("display", p ? "none" : "");
         d.query('.'+_pause, this._domNode).style("display", p ? "" : "none");
    • summary
      Toggles the play/pause button, if it exists.
  • dojox.widget.rotator.Controller._buildInfo

    • type
      Function
    • parameters:
      • r: (typeof dojox.widget.Rotator)
    • source: [view]
         return '' + (r.idx+1) + ' / ' + r.panes.length + ''; /*string*/
    • summary
      Return a string containing the current pane number and the total number of panes.
    • returns
      string
  • dojox.widget.rotator.Controller._onUpdate

    • type
      Function
    • parameters:
      • type: (typeof string)
    • source: [view]
         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;
         }
    • summary
      Updates various pager controls when the rotator updates.
  • dojox.widget.rotator.Controller._info.innerHTML

    • summary
  • dojox.widget.rotator.Controller._domNode

    • summary
  • dojox.widget.rotator.Controller._info

    • summary
  • dojox.widget.rotator.Controller._con

    • summary
  • _play

    • summary
  • _pause

    • summary
  • _number

    • summary
  • _tab

    • summary
  • _selected

    • summary
  • dojox.widget.rotator

    • type
      Object
    • summary
  • dojox.widget

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary