Ticket #4063: presentation.patch
| File presentation.patch, 18.8 kB (added by guest, 16 months ago) |
|---|
-
dijit/_Widget.js
52 52 53 53 this.buildRendering(); 54 54 if(this.domNode){ 55 this.domNode.setAttribute("id", this.id); 55 56 this.domNode.setAttribute("widgetId", this.id); 56 57 if(this.srcNodeRef && this.srcNodeRef.dir){ 57 58 this.domNode.dir = this.srcNodeRef.dir; -
dojox/presentation/_base.js
68 68 // _navOpacMin: 0.15, 69 69 _navOpacMin: 0, 70 70 _navOpacMax: 0.85, 71 71 _slideIndex: 0, 72 72 73 // Private: 73 74 _slides: [], 74 75 _navShowing: true, … … 76 77 77 78 startup: function(){ 78 79 // summary: connect to the various handlers and controls for this presention 79 console.log('fooooo');80 80 dojox.presentation.Deck.superclass.startup.call(this); 81 81 82 82 if(this.useNav){ … … 85 85 this.showNav.style.display = "none"; 86 86 } 87 87 88 this.connect(document,'onclick', ' gotoSlideByEvent');88 this.connect(document,'onclick', '_onEvent'); 89 89 /* 90 90 var tmp = (dojo.isIE) ? dojo.connect(document,'onkeydown',this,'gotoSlideByEvent') 91 91 : dojo.connect(document,'onkeypress',this,'gotoSlideByEvent'); 92 92 */ 93 this.connect(document,'onkeypress', ' gotoSlideByEvent');94 93 this.connect(document,'onkeypress', '_onEvent'); 94 95 95 // only if this.fullScreen == true? 96 96 this.connect(window, 'onresize', '_resizeWindow'); 97 97 this._resizeWindow(); 98 98 99 99 this._updateSlides(); 100 100 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); 107 124 } 125 if (evt) { evt.stopPropagation(); } 126 }, 108 127 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();} 109 136 }, 110 137 111 138 getHash: function(id){ 139 return this.id+"_SlideNo_"+id; 140 }, 141 112 142 _hideNav: function(evt){ 113 143 // summary: hides navigation 114 144 if(this._navAnim){ this._navAnim.stop(); } … … 159 189 } 160 190 }, 161 191 162 gotoSlideByEvent: function(/* Event */ evt){192 _onEvent: function(/* Event */ evt){ 163 193 // summary: 164 194 // main presentation function, determines next 'best action' for a 165 195 // specified event. … … 168 198 169 199 if(_type == "click" || _type == "change"){ 170 200 if(_node.index && _node.parentNode == this.select){ 171 this. selectChild(this._slides[_node.index]);201 this._gotoSlide(_node.index); 172 202 }else if(_node == this.select){ 173 this. selectChild(this._slides[_node.selectedIndex]);203 this._gotoSlide(_node.selectedIndex); 174 204 }else{ 175 205 if (this.noClick || this.selectedChildWidget.noClick || this._isUnclickable(evt)) return; 176 206 this.selectedChildWidget._nextAction(evt); 177 207 } 178 208 }else if(_type=="keydown" || _type == "keypress"){ 179 // TODO: match these again dojo.keys.*209 180 210 // 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 187 233 } 188 234 } 189 235 this._resizeWindow(); 190 236 evt.stopPropagation(); 191 237 }, 192 238 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); 199 254 }, 200 255 201 256 _isUnclickable: function(/* Event */ evt){ … … 210 265 } 211 266 return false; 212 267 }, 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 } 218 276 } 219 if(this.setHash){ this._setHash(); }220 if(evt){ evt.stopPropagation(); }221 277 }, 222 278 223 previousSlide: function(/*Event*/ evt){224 // summary: transition to the previous slide225 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 235 279 _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 } 240 285 }, 241 286 242 287 _resizeWindow: function(/*Event*/ evt){ … … 253 298 this.selectedChildWidget.domNode.style.width = w +'px'; 254 299 }, 255 300 256 257 301 _transition: function(newWidget,oldWidget){ 258 302 // summary: over-ride stackcontainers _transition method 259 303 // but atm, i find it to be ugly with not way to call -
dojox/presentation/resources/Show.html
2 2 <div class="dojoShowNav" dojoAttachPoint="showNav" dojoAttachEvent="onmouseover: _showNav, onmouseout: _hideNav"> 3 3 <div class="dojoShowNavToggler" dojoAttachPoint="showToggler"> 4 4 <img dojoAttachPoint="prevNode" src="${prevIcon}" dojoAttachEvent="onclick:previousSlide"> 5 <select dojoAttachEvent="onc lick:gotoSlideByEvent, onchange:gotoSlideByEvent" dojoAttachPoint="select">5 <select dojoAttachEvent="onchange:_onEvent" dojoAttachPoint="select"> 6 6 <option dojoAttachPoint="_option">Title</option> 7 7 </select> 8 8 <img dojoAttachPoint="nextNode" src="${nextIcon}" dojoAttachEvent="onclick:nextSlide"> -
dojox/presentation/tests/test_presentation.html
5 5 6 6 <script type="text/javascript"> djConfig = { isDebug: true, parseOnLoad: true }; </script> 7 7 <script type="text/javascript" src="../../../dojo/dojo.js"></script> 8 <script type="text/javascript" src="../_base.js"></script>8 9 9 10 10 <script type="text/javascript"> 11 //dojo.require("dojox.presentation");11 dojo.require("dojox.presentation"); 12 12 dojo.require("dijit._Calendar"); 13 13 dojo.require("dijit.TitlePane"); 14 14 dojo.require("dojo.parser"); … … 129 129 <div dojoType="dojox.presentation.Slide" title="Click Blocking" id="animated"> 130 130 <p>You cannot click on this page</p> 131 131 <p dojoType="dojox.presentation.Part" as="1">I told you that you can't click ...</p> 132 <a href="#" on click="playIt()">click here to move the title</a>132 <a href="#" onClick="playIt()">click here to move the title</a> 133 133 <input dojoType="dojox.presentation.Action" forSlide="1" toggle="wipe"> 134 134 <input dojoType="dojox.presentation.Action" forSlide="2"> 135 135 <input dojoType="dojox.presentation.Action" forSlide="1" toggle="fade"> -
dojox/timing/_base.js
1 dojo.provide("dojox.timing._base"); 2 3 dojox.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 15 dojo.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
1 dojo.provide("dojox.timing.Streamer"); 2 3 dojo.require("dojox.timing._base"); 4 5 dojox.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
1 dojo.provide("dojox.timing._base"); 2 3 dojox.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 15 dojo.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
1 dojo.provide("dojox.timing.Streamer"); 2 3 dojo.require("dojox.timing._base"); 4 5 dojox.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 };