Ticket #4063: presentation.patch

File presentation.patch, 18.8 kB (added by guest, 16 months ago)
  • dijit/_Widget.js

     
    5252 
    5353        this.buildRendering(); 
    5454        if(this.domNode){ 
     55                this.domNode.setAttribute("id", this.id); 
    5556                this.domNode.setAttribute("widgetId", this.id); 
    5657                if(this.srcNodeRef && this.srcNodeRef.dir){ 
    5758                        this.domNode.dir = this.srcNodeRef.dir; 
  • dojox/presentation/_base.js

     
    6868        // _navOpacMin: 0.15, 
    6969        _navOpacMin: 0, 
    7070        _navOpacMax: 0.85, 
    71  
     71        _slideIndex: 0, 
     72         
    7273        // Private: 
    7374        _slides: [],  
    7475        _navShowing: true, 
     
    7677         
    7778        startup: function(){ 
    7879                // summary: connect to the various handlers and controls for this presention 
    79                 console.log('fooooo');  
    8080                dojox.presentation.Deck.superclass.startup.call(this); 
    8181 
    8282                if(this.useNav){  
     
    8585                        this.showNav.style.display = "none";  
    8686                }  
    8787 
    88                 this.connect(document,'onclick', 'gotoSlideByEvent'); 
     88                this.connect(document,'onclick', '_onEvent'); 
    8989                /* 
    9090                var tmp = (dojo.isIE)   ? dojo.connect(document,'onkeydown',this,'gotoSlideByEvent')  
    9191                                        : dojo.connect(document,'onkeypress',this,'gotoSlideByEvent'); 
    9292                */ 
    93                 this.connect(document,'onkeypress', 'gotoSlideByEvent'); 
    94  
     93                this.connect(document,'onkeypress', '_onEvent'); 
     94                 
    9595                // only if this.fullScreen == true? 
    9696                this.connect(window, 'onresize', '_resizeWindow'); 
    9797                this._resizeWindow(); 
    9898                 
    9999                this._updateSlides();  
    100100                 
    101                 var th = window.location.hash; 
    102                 if(th.length && this.setHash){ 
    103                         var parts = (""+window.location).split(this.id+"_SlideNo_"); 
    104                         if(parts.length>1){ 
    105                                 this._gotoSlide(parseInt(parts[1])); 
    106                         }        
     101                this._readHash(); 
     102                this._setHash(); 
     103        }, 
     104 
     105        moveTo: function(/* Integer */ number) { 
     106                var slideIndex = number - 1;  
     107                 
     108                if(slideIndex < 0) 
     109                        slideIndex = 0; 
     110                 
     111                if(slideIndex > this._slides.length - 1) 
     112                        slideIndex = this._slides.length - 1;  
     113                 
     114                this._gotoSlide(slideIndex); 
     115        }, 
     116 
     117        onMove: function (number) { 
     118        }, 
     119         
     120        nextSlide: function(/*Event*/ evt) { 
     121                // summary: transition to the next slide. 
     122                if (!this.selectedChildWidget.isLastChild) { 
     123                        this._gotoSlide(this._slideIndex+1); 
    107124                } 
     125                if (evt) { evt.stopPropagation(); } 
     126        }, 
    108127 
     128        previousSlide: function(/*Event*/ evt){ 
     129                // summary: transition to the previous slide 
     130                if (!this.selectedChildWidget.isFirstChild) { 
     131                         
     132                        this._gotoSlide(this._slideIndex-1); 
     133                         
     134                } else { this.selectedChildWidget._reset(); }  
     135                if (evt) { evt.stopPropagation();} 
    109136        }, 
    110137 
    111  
     138        getHash: function(id){ 
     139                return this.id+"_SlideNo_"+id; 
     140        }, 
     141         
    112142        _hideNav: function(evt){ 
    113143                // summary: hides navigation 
    114144                if(this._navAnim){ this._navAnim.stop(); } 
     
    159189                } 
    160190        }, 
    161191 
    162         gotoSlideByEvent: function(/* Event */ evt){ 
     192        _onEvent: function(/* Event */ evt){ 
    163193                // summary:  
    164194                //              main presentation function, determines next 'best action' for a 
    165195                //              specified event. 
     
    168198 
    169199                if(_type == "click" || _type == "change"){ 
    170200                        if(_node.index && _node.parentNode == this.select){  
    171                                 this.selectChild(this._slides[_node.index]);  
     201                                this._gotoSlide(_node.index); 
    172202                        }else if(_node == this.select){ 
    173                                 this.selectChild(this._slides[_node.selectedIndex]); 
     203                                this._gotoSlide(_node.selectedIndex); 
    174204                        }else{ 
    175205                                if (this.noClick || this.selectedChildWidget.noClick || this._isUnclickable(evt)) return;  
    176206                                this.selectedChildWidget._nextAction(evt); 
    177207                        } 
    178208                }else if(_type=="keydown" || _type == "keypress"){ 
    179                         // TODO: match these again dojo.keys.* 
     209                         
    180210                        // FIXME: safari doesn't report keydown/keypress? 
    181                         var key = evt.keyCode; 
    182                         var ch = evt.charCode; 
    183                         if(key == 63234 || key == 37){ 
    184                                 this.previousSlide(evt); 
    185                         }else if(key == 63235 || key == 39 || ch == 32) { 
    186                                 this.selectedChildWidget._nextAction(evt);  
     211                         
     212                        var key = (evt.charCode == dojo.keys.SPACE ? dojo.keys.SPACE : evt.keyCode); 
     213                        switch(key){ 
     214                                case dojo.keys.DELETE: 
     215                                case dojo.keys.BACKSPACE: 
     216                                case dojo.keys.LEFT_ARROW: 
     217                                case dojo.keys.UP_ARROW: 
     218                                case dojo.keys.PAGE_UP: 
     219                                case 80:        // key 'p' 
     220                                                                                this.previousSlide(evt); 
     221                                                                                break; 
     222                                case dojo.keys.ENTER: 
     223                                case dojo.keys.SPACE: 
     224                                case dojo.keys.RIGHT_ARROW: 
     225                                case dojo.keys.DOWN_ARROW: 
     226                                case dojo.keys.PAGE_DOWN: 
     227                                case 78:        // key 'n' 
     228                                                                                this.selectedChildWidget._nextAction(evt);  
     229                                                                                break; 
     230 
     231                                case dojo.keys.HOME:    this._gotoSlide(0); 
     232                                                                                 
    187233                        } 
    188234                } 
    189235                this._resizeWindow(); 
    190236                evt.stopPropagation();  
    191237        }, 
    192238                 
    193         _gotoSlide: function(/* Integer */ slideNo) { 
    194                 slideNo -= 1;  
    195                 this.selectChild(this._slides[slideNo]); 
    196                 this._slides[slideNo]._reset(); 
    197                 this.select.selectedIndex = slideNo;  
    198                 if(this.setHash){ this._setHash(); } 
     239        _gotoSlide: function(/* Integer */ slideIndex) { 
     240 
     241                this.selectChild(this._slides[slideIndex]); 
     242                this.selectedChildWidget._reset(); 
     243 
     244                this._slideIndex = slideIndex; 
     245                 
     246                if(this.useNav) { 
     247                        this.select.selectedIndex = slideIndex;  
     248                } 
     249                 
     250                if(this.setHash){  
     251                        this._setHash();  
     252                } 
     253                this.onMove(this._slideIndex+1); 
    199254        }, 
    200255 
    201256        _isUnclickable: function(/* Event */ evt){ 
     
    210265                } 
    211266                return false;  
    212267        }, 
    213         nextSlide: function(/*Event*/ evt){ 
    214                 // summary: transition to the next slide. 
    215                 if(!this.selectedChildWidget.isLastChild){ 
    216                         this.forward(); 
    217                         this.select.selectedIndex += 1;  
     268 
     269        _readHash: function(){ 
     270                var th = window.location.hash; 
     271                if (th.length && this.setHash) { 
     272                        var parts = (""+window.location).split(this.getHash('')); 
     273                        if (parts.length>1) { 
     274                                this._gotoSlide(parseInt(parts[1])-1); 
     275                        } 
    218276                } 
    219                 if(this.setHash){ this._setHash(); } 
    220                 if(evt){ evt.stopPropagation(); } 
    221277        }, 
    222278 
    223         previousSlide: function(/*Event*/ evt){ 
    224                 // summary: transition to the previous slide 
    225                 if(!this.selectedChildWidget.isFirstChild){ 
    226                         this.back(); 
    227                         this.select.selectedIndex -= 1;  
    228                 }else{ 
    229                         this.selectedChildWidget._reset(); 
    230                 }  
    231                 if(this.setHash){ this._setHash(); } 
    232                 if(evt){ evt.stopPropagation();} 
    233         }, 
    234  
    235279        _setHash: function(){ 
    236                 // summary: sets url #mark to direct slide access 
    237                 var slideNo = this.select.selectedIndex+1; 
    238                 window.location.href = "#"+this.id+"_SlideNo_"+slideNo; 
    239  
     280                if (this.setHash) { 
     281                        // summary: sets url #mark to direct slide access 
     282                        var slideNo = this._slideIndex+1; 
     283                        window.location.href = "#"+this.getHash(slideNo);        
     284                } 
    240285        }, 
    241286 
    242287        _resizeWindow: function(/*Event*/ evt){ 
     
    253298                this.selectedChildWidget.domNode.style.width = w +'px'; 
    254299        }, 
    255300 
    256  
    257301        _transition: function(newWidget,oldWidget){  
    258302                // summary: over-ride stackcontainers _transition method 
    259303                //      but atm, i find it to be ugly with not way to call 
  • dojox/presentation/resources/Show.html

     
    22        <div class="dojoShowNav" dojoAttachPoint="showNav" dojoAttachEvent="onmouseover: _showNav, onmouseout: _hideNav"> 
    33        <div class="dojoShowNavToggler" dojoAttachPoint="showToggler"> 
    44                <img dojoAttachPoint="prevNode" src="${prevIcon}" dojoAttachEvent="onclick:previousSlide"> 
    5                 <select dojoAttachEvent="onclick:gotoSlideByEvent, onchange:gotoSlideByEvent" dojoAttachPoint="select"> 
     5                <select dojoAttachEvent="onchange:_onEvent" dojoAttachPoint="select"> 
    66                        <option dojoAttachPoint="_option">Title</option> 
    77                </select> 
    88                <img dojoAttachPoint="nextNode" src="${nextIcon}" dojoAttachEvent="onclick:nextSlide"> 
  • dojox/presentation/tests/test_presentation.html

     
    55 
    66        <script type="text/javascript"> djConfig = { isDebug: true, parseOnLoad: true }; </script> 
    77        <script type="text/javascript" src="../../../dojo/dojo.js"></script> 
    8         <script type="text/javascript" src="../_base.js"></script> 
     8         
    99                 
    1010        <script type="text/javascript"> 
    11                 // dojo.require("dojox.presentation"); 
     11                dojo.require("dojox.presentation"); 
    1212                dojo.require("dijit._Calendar");  
    1313                dojo.require("dijit.TitlePane");  
    1414                dojo.require("dojo.parser");  
     
    129129                <div dojoType="dojox.presentation.Slide" title="Click Blocking" id="animated"> 
    130130                        <p>You cannot click on this page</p> 
    131131                        <p dojoType="dojox.presentation.Part" as="1">I told you that you can't click ...</p> 
    132                         <a href="#" onclick="playIt()">click here to move the title</a> 
     132                        <a href="#" onClick="playIt()">click here to move the title</a> 
    133133                        <input dojoType="dojox.presentation.Action" forSlide="1" toggle="wipe"> 
    134134                        <input dojoType="dojox.presentation.Action" forSlide="2"> 
    135135                        <input dojoType="dojox.presentation.Action" forSlide="1" toggle="fade"> 
  • dojox/timing/_base.js

     
     1dojo.provide("dojox.timing._base"); 
     2 
     3dojox.timing.Timer = function(/*int*/ interval){ 
     4        // summary: Timer object executes an "onTick()" method repeatedly at a specified interval.  
     5        //                      repeatedly at a given interval. 
     6        // interval: Interval between function calls, in milliseconds. 
     7        this.timer = null; 
     8        this.isRunning = false; 
     9        this.interval = interval; 
     10 
     11        this.onStart = null; 
     12        this.onStop = null; 
     13}; 
     14 
     15dojo.extend(dojox.timing.Timer, { 
     16        onTick : function(){ 
     17                // summary: Method called every time the interval passes.  Override to do something useful. 
     18        }, 
     19                 
     20        setInterval : function(interval){ 
     21                // summary: Reset the interval of a timer, whether running or not. 
     22                // interval: New interval, in milliseconds. 
     23                if (this.isRunning){ 
     24                        window.clearInterval(this.timer); 
     25                } 
     26                this.interval = interval; 
     27                if (this.isRunning){ 
     28                        this.timer = window.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); 
     29                } 
     30        }, 
     31         
     32        start : function(){ 
     33                // summary: Start the timer ticking. 
     34                // description: Calls the "onStart()" handler, if defined. 
     35                //                              Note that the onTick() function is not called right away,  
     36                //                              only after first interval passes. 
     37                if (typeof this.onStart == "function"){ 
     38                        this.onStart(); 
     39                } 
     40                this.isRunning = true; 
     41                this.timer = window.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); 
     42        }, 
     43         
     44        stop : function(){ 
     45                // summary: Stop the timer. 
     46                // description: Calls the "onStop()" handler, if defined. 
     47                if (typeof this.onStop == "function"){ 
     48                        this.onStop(); 
     49                } 
     50                this.isRunning = false; 
     51                window.clearInterval(this.timer); 
     52        } 
     53}); 
  • dojox/timing/Streamer.js

    Property changes on: dojox\timing\_base.js
    ___________________________________________________________________
    Name: svn:keywords
       + Author Date Id HeadURL Revision
    
     
     1dojo.provide("dojox.timing.Streamer"); 
     2 
     3dojo.require("dojox.timing._base"); 
     4 
     5dojox.timing.Streamer = function( 
     6        /* function */input,  
     7        /* function */output,  
     8        /* int */interval,  
     9        /* int */minimum, 
     10        /* array */initialData 
     11){ 
     12        //      summary 
     13        //      Streamer will take an input function that pushes N datapoints into a 
     14        //              queue, and will pass the next point in that queue out to an 
     15        //              output function at the passed interval; this way you can emulate 
     16        //              a constant buffered stream of data. 
     17        //      input: the function executed when the internal queue reaches minimumSize 
     18        //      output: the function executed on internal tick 
     19        //      interval: the interval in ms at which the output function is fired. 
     20        //      minimum: the minimum number of elements in the internal queue. 
     21 
     22        var self = this; 
     23        var queue = []; 
     24 
     25        //      public properties 
     26        this.interval = interval || 1000; 
     27        this.minimumSize = minimum || 10;       //      latency usually == interval * minimumSize 
     28        this.inputFunction = input || function(q){ }; 
     29        this.outputFunction = output || function(point){ }; 
     30 
     31        //      more setup 
     32        var timer = new dojox.timing.Timer(this.interval); 
     33        var tick = function(){ 
     34                self.onTick(self); 
     35 
     36                if(queue.length < self.minimumSize){ 
     37                        self.inputFunction(queue); 
     38                } 
     39 
     40                var obj = queue.shift(); 
     41                while(typeof(obj) == "undefined" && queue.length > 0){ 
     42                        obj = queue.shift(); 
     43                } 
     44                 
     45                //      check to see if the input function needs to be fired 
     46                //      stop before firing the output function 
     47                //      TODO: relegate this to the output function? 
     48                if(typeof(obj) == "undefined"){ 
     49                        self.stop(); 
     50                        return; 
     51                } 
     52 
     53                //      call the output function. 
     54                self.outputFunction(obj); 
     55        }; 
     56 
     57        this.setInterval = function(/* int */ms){ 
     58                //      summary 
     59                //      sets the interval in milliseconds of the internal timer 
     60                this.interval = ms; 
     61                timer.setInterval(ms); 
     62        }; 
     63 
     64        this.onTick = function(/* dojox.timing.Streamer */obj){ }; 
     65        // wrap the timer functions so that we can connect to them if needed. 
     66        this.start = function(){ 
     67                //      summary 
     68                //      starts the Streamer 
     69                if(typeof(this.inputFunction) == "function" && typeof(this.outputFunction) == "function"){ 
     70                        timer.start(); 
     71                        return; 
     72                } 
     73                dojo.raise("You cannot start a Streamer without an input and an output function."); 
     74        }; 
     75        this.onStart = function(){ }; 
     76        this.stop = function(){ 
     77                //      summary 
     78                //      stops the Streamer 
     79                timer.stop(); 
     80        }; 
     81        this.onStop = function(){ }; 
     82 
     83        //      finish initialization 
     84        timer.onTick = this.tick; 
     85        timer.onStart = this.onStart; 
     86        timer.onStop = this.onStop; 
     87        if(initialData){ 
     88                queue.concat(initialData); 
     89        } 
     90}; 
  • dojox/timing/_base.js

    Property changes on: dojox\timing\Streamer.js
    ___________________________________________________________________
    Name: svn:keywords
       + Author Date Id HeadURL Revision
    
     
     1dojo.provide("dojox.timing._base"); 
     2 
     3dojox.timing.Timer = function(/*int*/ interval){ 
     4        // summary: Timer object executes an "onTick()" method repeatedly at a specified interval.  
     5        //                      repeatedly at a given interval. 
     6        // interval: Interval between function calls, in milliseconds. 
     7        this.timer = null; 
     8        this.isRunning = false; 
     9        this.interval = interval; 
     10 
     11        this.onStart = null; 
     12        this.onStop = null; 
     13}; 
     14 
     15dojo.extend(dojox.timing.Timer, { 
     16        onTick : function(){ 
     17                // summary: Method called every time the interval passes.  Override to do something useful. 
     18        }, 
     19                 
     20        setInterval : function(interval){ 
     21                // summary: Reset the interval of a timer, whether running or not. 
     22                // interval: New interval, in milliseconds. 
     23                if (this.isRunning){ 
     24                        window.clearInterval(this.timer); 
     25                } 
     26                this.interval = interval; 
     27                if (this.isRunning){ 
     28                        this.timer = window.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); 
     29                } 
     30        }, 
     31         
     32        start : function(){ 
     33                // summary: Start the timer ticking. 
     34                // description: Calls the "onStart()" handler, if defined. 
     35                //                              Note that the onTick() function is not called right away,  
     36                //                              only after first interval passes. 
     37                if (typeof this.onStart == "function"){ 
     38                        this.onStart(); 
     39                } 
     40                this.isRunning = true; 
     41                this.timer = window.setInterval(dojo.lang.hitch(this, "onTick"), this.interval); 
     42        }, 
     43         
     44        stop : function(){ 
     45                // summary: Stop the timer. 
     46                // description: Calls the "onStop()" handler, if defined. 
     47                if (typeof this.onStop == "function"){ 
     48                        this.onStop(); 
     49                } 
     50                this.isRunning = false; 
     51                window.clearInterval(this.timer); 
     52        } 
     53}); 
  • dojox/timing/Streamer.js

    Property changes on: dojox\timing\_base.js
    ___________________________________________________________________
    Name: svn:keywords
       + Author Date Id HeadURL Revision
    
     
     1dojo.provide("dojox.timing.Streamer"); 
     2 
     3dojo.require("dojox.timing._base"); 
     4 
     5dojox.timing.Streamer = function( 
     6        /* function */input,  
     7        /* function */output,  
     8        /* int */interval,  
     9        /* int */minimum, 
     10        /* array */initialData 
     11){ 
     12        //      summary 
     13        //      Streamer will take an input function that pushes N datapoints into a 
     14        //              queue, and will pass the next point in that queue out to an 
     15        //              output function at the passed interval; this way you can emulate 
     16        //              a constant buffered stream of data. 
     17        //      input: the function executed when the internal queue reaches minimumSize 
     18        //      output: the function executed on internal tick 
     19        //      interval: the interval in ms at which the output function is fired. 
     20        //      minimum: the minimum number of elements in the internal queue. 
     21 
     22        var self = this; 
     23        var queue = []; 
     24 
     25        //      public properties 
     26        this.interval = interval || 1000; 
     27        this.minimumSize = minimum || 10;       //      latency usually == interval * minimumSize 
     28        this.inputFunction = input || function(q){ }; 
     29        this.outputFunction = output || function(point){ }; 
     30 
     31        //      more setup 
     32        var timer = new dojox.timing.Timer(this.interval); 
     33        var tick = function(){ 
     34                self.onTick(self); 
     35 
     36                if(queue.length < self.minimumSize){ 
     37                        self.inputFunction(queue); 
     38                } 
     39 
     40                var obj = queue.shift(); 
     41                while(typeof(obj) == "undefined" && queue.length > 0){ 
     42                        obj = queue.shift(); 
     43                } 
     44                 
     45                //      check to see if the input function needs to be fired 
     46                //      stop before firing the output function 
     47                //      TODO: relegate this to the output function? 
     48                if(typeof(obj) == "undefined"){ 
     49                        self.stop(); 
     50                        return; 
     51                } 
     52 
     53                //      call the output function. 
     54                self.outputFunction(obj); 
     55        }; 
     56 
     57        this.setInterval = function(/* int */ms){ 
     58                //      summary 
     59                //      sets the interval in milliseconds of the internal timer 
     60                this.interval = ms; 
     61                timer.setInterval(ms); 
     62        }; 
     63 
     64        this.onTick = function(/* dojox.timing.Streamer */obj){ }; 
     65        // wrap the timer functions so that we can connect to them if needed. 
     66        this.start = function(){ 
     67                //      summary 
     68                //      starts the Streamer 
     69                if(typeof(this.inputFunction) == "function" && typeof(this.outputFunction) == "function"){ 
     70                        timer.start(); 
     71                        return; 
     72                } 
     73                dojo.raise("You cannot start a Streamer without an input and an output function."); 
     74        }; 
     75        this.onStart = function(){ }; 
     76        this.stop = function(){ 
     77                //      summary 
     78                //      stops the Streamer 
     79                timer.stop(); 
     80        }; 
     81        this.onStop = function(){ }; 
     82 
     83        //      finish initialization 
     84        timer.onTick = this.tick; 
     85        timer.onStart = this.onStart; 
     86        timer.onStop = this.onStop; 
     87        if(initialData){ 
     88                queue.concat(initialData); 
     89        } 
     90};