📄 _base.js
字号:
if(!dojo._hasResource["dojox.presentation._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dojox.presentation._base"] = true;dojo.provide("dojox.presentation._base");dojo.experimental("dojox.presentation"); dojo.require("dijit._Widget");dojo.require("dijit._Container"); dojo.require("dijit._Templated");dojo.require("dijit.layout.StackContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("dojo.fx"); dojo.declare("dojox.presentation.Deck", [ dijit.layout.StackContainer, dijit._Templated ], { // summary: // dojox.presentation class // basic powerpoint esque engine for handling transitons and control // in a page-by-page and part-by-part way // // FIXME: parsing part(s)/widget(s) in href="" Slides not working // TODO: make auto actions progress. // FIXME: Safari keydown/press/up listener not working. // noClick=true prevents progression of slides in that broweser // // fullScreen: Boolean // unsupported (that i know of) just yet. Default it to take control // of window. Would be nice to be able to contain presentation in a // styled container, like StackContainer ... theoretically possible. // [and may not need this variable?] fullScreen: true, // useNav: Boolean // true to allow navigation popup, false to disallow useNav: true, // navDuration: Integer // time in MS fadein/out of popup nav [default: 250] navDuration: 250, // noClick: Boolean // if true, prevents _any_ click events to propagate actions // (limiting control to keyboard and/or action.on="auto" or action.delay="" // actions. noClick: false, // setHash: Boolean // if true, window location bar will get a #link to slide for direct // access to a particular slide number. setHash: true, // just to over-ride: templateString: null, templateString:"<div class=\"dojoShow\" dojoAttachPoint=\"showHolder\">\n\t<div class=\"dojoShowNav\" dojoAttachPoint=\"showNav\" dojoAttachEvent=\"onmouseover: _showNav, onmouseout: _hideNav\">\n\t<div class=\"dojoShowNavToggler\" dojoAttachPoint=\"showToggler\">\n\t\t<img dojoAttachPoint=\"prevNode\" src=\"${prevIcon}\" dojoAttachEvent=\"onclick:previousSlide\">\n\t\t<select dojoAttachEvent=\"onchange:_onEvent\" dojoAttachPoint=\"select\">\n\t\t\t<option dojoAttachPoint=\"_option\">Title</option>\n\t\t</select>\n\t\t<img dojoAttachPoint=\"nextNode\" src=\"${nextIcon}\" dojoAttachEvent=\"onclick:nextSlide\">\n\t</div>\n\t</div>\n\t<div dojoAttachPoint=\"containerNode\"></div>\n</div>\n", // nextIcon: String // icon for navigation "next" button nextIcon: dojo.moduleUrl('dojox.presentation','resources/icons/next.png'), // prevIcon: String // icon for navigation "previous" button prevIcon: dojo.moduleUrl('dojox.presentation','resources/icons/prev.png'), _navOpacMin: 0, _navOpacMax: 0.85, _slideIndex: 0, // Private: _slides: [], _navShowing: true, _inNav: false, startup: function(){ // summary: connect to the various handlers and controls for this presention this.inherited(arguments); if(this.useNav){ this._hideNav(); }else{ this.showNav.style.display = "none"; } this.connect(document,'onclick', '_onEvent'); this.connect(document,'onkeypress', '_onEvent'); // only if this.fullScreen == true? this.connect(window, 'onresize', '_resizeWindow'); this._resizeWindow(); this._updateSlides(); this._readHash(); this._setHash(); }, moveTo: function(/* Integer */ number){ // summary: jump to slide based on param var slideIndex = number - 1; if(slideIndex < 0) slideIndex = 0; if(slideIndex > this._slides.length - 1) slideIndex = this._slides.length - 1; this._gotoSlide(slideIndex); }, onMove: function (number){ // summary: stub function? TODOC: ? }, nextSlide: function(/*Event*/ evt){ // summary: transition to the next slide. if (!this.selectedChildWidget.isLastChild) { this._gotoSlide(this._slideIndex+1); } if (evt) { evt.stopPropagation(); } }, previousSlide: function(/*Event*/ evt){ // summary: transition to the previous slide if (!this.selectedChildWidget.isFirstChild) { this._gotoSlide(this._slideIndex-1); } else { this.selectedChildWidget._reset(); } if (evt) { evt.stopPropagation();} }, getHash: function(id){ // summary: get the current hash to set in localtion return this.id+"_SlideNo_"+id; }, _hideNav: function(evt){ // summary: hides navigation if(this._navAnim){ this._navAnim.stop(); } this._navAnim = dojo.animateProperty({ node:this.showNav, duration:this.navDuration, properties: { opacity: { end:this._navOpacMin } } }).play(); }, _showNav: function(evt){ // summary: shows navigation if(this._navAnim){ this._navAnim.stop(); } this._navAnim = dojo.animateProperty({ node:this.showNav, duration:this.navDuration, properties: { opacity: { end:this._navOpacMax } } }).play(); }, _handleNav: function(evt){ // summary: does nothing? _that_ seems useful. evt.stopPropagation(); }, _updateSlides: function(){ // summary: // populate navigation select list with refs to slides call this // if you add a node to your presentation dynamically. this._slides = this.getChildren(); if(this.useNav){ // populate the select box with top-level slides var i=0; dojo.forEach(this._slides,dojo.hitch(this,function(slide){ i++; var tmp = this._option.cloneNode(true); tmp.text = slide.title+" ("+i+") "; this._option.parentNode.insertBefore(tmp,this._option); })); if(this._option.parentNode){ this._option.parentNode.removeChild(this._option); } // dojo._destroyElement(this._option); } }, _onEvent: function(/* Event */ evt){ // summary: // main presentation function, determines next 'best action' for a // specified event. var _node = evt.target; var _type = evt.type; if(_type == "click" || _type == "change"){ if(_node.index && _node.parentNode == this.select){ this._gotoSlide(_node.index); }else if(_node == this.select){ this._gotoSlide(_node.selectedIndex); }else{ if (this.noClick || this.selectedChildWidget.noClick || this._isUnclickable(evt)) return; this.selectedChildWidget._nextAction(evt); } }else if(_type=="keydown" || _type == "keypress"){ // FIXME: safari doesn't report keydown/keypress? var key = (evt.charCode == dojo.keys.SPACE ? dojo.keys.SPACE : evt.keyCode); switch(key){ case dojo.keys.DELETE: case dojo.keys.BACKSPACE: case dojo.keys.LEFT_ARROW: case dojo.keys.UP_ARROW: case dojo.keys.PAGE_UP: case 80: // key 'p' this.previousSlide(evt); break; case dojo.keys.ENTER: case dojo.keys.SPACE: case dojo.keys.RIGHT_ARROW: case dojo.keys.DOWN_ARROW: case dojo.keys.PAGE_DOWN: case 78: // key 'n' this.selectedChildWidget._nextAction(evt); break; case dojo.keys.HOME: this._gotoSlide(0); } } this._resizeWindow(); evt.stopPropagation(); }, _gotoSlide: function(/* Integer */ slideIndex){ // summary: goes to slide this.selectChild(this._slides[slideIndex]); this.selectedChildWidget._reset(); this._slideIndex = slideIndex; if(this.useNav){ this.select.selectedIndex = slideIndex; } if(this.setHash){ this._setHash(); } this.onMove(this._slideIndex+1); }, _isUnclickable: function(/* Event */ evt){ // summary: returns true||false base of a nodes click-ability var nodeName = evt.target.nodeName.toLowerCase(); // TODO: check for noClick='true' in target attrs & return true // TODO: check for relayClick='true' in target attrs & return false switch(nodeName){ case 'a' : case 'input' : case 'textarea' : return true; break; } return false; }, _readHash: function(){ var th = window.location.hash; if (th.length && this.setHash) { var parts = (""+window.location).split(this.getHash('')); if(parts.length>1){ this._gotoSlide(parseInt(parts[1])-1); } } }, _setHash: function(){ // summary: sets url #mark to direct slide access if(this.setHash){ var slideNo = this._slideIndex+1; window.location.href = "#"+this.getHash(slideNo); } }, _resizeWindow: function(/*Event*/ evt){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -