📄 _base.js
字号:
// summary: resize this and children to fix this window/container // only if this.fullScreen? dojo.body().style.height = "auto"; var wh = dijit.getViewport(); var h = Math.max( document.documentElement.scrollHeight || dojo.body().scrollHeight, wh.h); var w = wh.w; this.selectedChildWidget.domNode.style.height = h +'px'; this.selectedChildWidget.domNode.style.width = w +'px'; }, _transition: function(newWidget,oldWidget){ // summary: over-ride stackcontainers _transition method // but atm, i find it to be ugly with not way to call // _showChild() without over-riding it too. hopefull // basic toggles in superclass._transition will be available // in dijit, and this won't be necessary. var anims = []; if(oldWidget){ /* anims.push(dojo.fadeOut({ node: oldWidget.domNode, duration:250, onEnd: dojo.hitch(this,function(){ this._hideChild(oldWidget); }) })); */ this._hideChild(oldWidget); } if(newWidget){ /* anims.push(dojo.fadeIn({ node:newWidget.domNode, start:0, end:1, duration:300, onEnd: dojo.hitch(this,function(){ this._showChild(newWidget); newWidget._reset(); }) }) ); */ this._showChild(newWidget); newWidget._reset(); } //dojo.fx.combine(anims).play(); }});dojo.declare( "dojox.presentation.Slide", [dijit.layout.ContentPane,dijit._Contained,dijit._Container,dijit._Templated], { // summary: // a Comonent of a dojox.presentation, and container for each 'Slide' // made up of direct HTML (no part/action relationship), and dojox.presentation.Part(s), // and their attached Actions. // templatPath: String // make a ContentPane templated, and style the 'titleNode' templateString:"<div dojoAttachPoint=\"showSlide\" class=\"dojoShowPrint dojoShowSlide\">\n\t<h1 class=\"showTitle\" dojoAttachPoint=\"slideTitle\"><span class=\"dojoShowSlideTitle\" dojoAttachPoint=\"slideTitleText\">${title}</span></h1>\n\t<div class=\"dojoShowBody\" dojoAttachPoint=\"containerNode\"></div>\n</div>\n", // title: String // string to insert into titleNode, title of Slide title: "", // inherited from ContentPane FIXME: don't seem to work ATM? refreshOnShow: true, preLoad: false, doLayout: true, parseContent: true, // noClick: Boolean // true on slide tag prevents clicking, false allows // (can also be set on base presentation for global control) noClick: false, // private holders: _parts: [], _actions: [], _actionIndex: 0, _runningDelay: false, startup: function(){ // summary: setup this slide with actions and components (Parts) this.inherited(arguments); this.slideTitleText.innerHTML = this.title; var children = this.getChildren(); this._actions = []; dojo.forEach(children,function(child){ var tmpClass = child.declaredClass.toLowerCase(); switch(tmpClass){ case "dojox.presentation.part" : this._parts.push(child); break; case "dojox.presentation.action" : this._actions.push(child); break; } },this); }, _nextAction: function(evt){ // summary: gotoAndPlay current cached action var tmpAction = this._actions[this._actionIndex] || 0; if (tmpAction){ // is this action a delayed action? [auto? thoughts?] if(tmpAction.on == "delay"){ this._runningDelay = setTimeout( dojo.hitch(tmpAction,"_runAction"),tmpAction.delay ); console.debug('started delay action',this._runningDelay); }else{ tmpAction._runAction(); } // FIXME: it gets hairy here. maybe runAction should // call _actionIndex++ onEnd? if a delayed action is running, do // we want to prevent action++? var tmpNext = this._getNextAction(); this._actionIndex++; if(tmpNext.on == "delay"){ // FIXME: yeah it looks like _runAction() onend should report // _actionIndex++ console.debug('started delay action',this._runningDelay); setTimeout(dojo.hitch(tmpNext,"_runAction"),tmpNext.delay); } }else{ // no more actions in this slide this.getParent().nextSlide(evt); } }, _getNextAction: function(){ // summary: returns the _next action in this sequence return this._actions[this._actionIndex+1] || 0; }, _reset: function(){ // summary: set action chain back to 0 and re-init each Part this._actionIndex = [0]; dojo.forEach(this._parts,function(part){ part._reset(); },this); }});dojo.declare("dojox.presentation.Part", [dijit._Widget,dijit._Contained], { // summary: // a node in a presentation.Slide that inherits control from a // dojox.presentation.Action // can be any element type, and requires styling before parsing // // as: String // like an ID, attach to Action via (part) as="" / (action) forSlide="" tags // this should be unique identifier? as: "", // startVisible: boolean // true to leave in page on slide startup/reset // false to hide on slide startup/reset startVisible: false, // isShowing: Boolean, // private holder for _current_ state of Part _isShowing: false, postCreate: function(){ // summary: override and init() this component this._reset(); }, _reset: function(){ // summary: set part back to initial calculate state // these _seem_ backwards, but quickToggle flips it this._isShowing =! this.startVisible; this._quickToggle(); }, _quickToggle: function(){ // summary: ugly [unworking] fix to test setting state of component // before/after an animation. display:none prevents fadeIns? if(this._isShowing){ dojo.style(this.domNode,'display','none'); dojo.style(this.domNode,'visibility','hidden'); dojo.style(this.domNode,'opacity',0); }else{ dojo.style(this.domNode,'display',''); dojo.style(this.domNode,'visibility','visible'); dojo.style(this.domNode,'opacity',1); } this._isShowing =! this._isShowing; }});dojo.declare("dojox.presentation.Action", [dijit._Widget,dijit._Contained], { // summary: // a widget to attach to a dojox.presentation.Part to control // it's properties based on an inherited chain of events ... // // // on: String // FIXME: only 'click' supported ATM. plans include on="delay", // on="end" of="", and on="auto". those should make semantic sense // to you. on: 'click', // forSlide: String // attach this action to a dojox.presentation.Part with a matching 'as' attribute forSlide: "", // toggle: String // will toggle attached [matching] node(s) via forSlide/as relationship(s) toggle: 'fade', // delay: Integer // delay: 0, // duration: Integer // default time in MS to run this action effect on it's 'forSlide' node duration: 1000, // private holders: _attached: [], _nullAnim: false, _runAction: function(){ // summary: runs this action on attached node(s) var anims = []; // executes the action for each attached 'Part' dojo.forEach(this._attached,function(node){ // FIXME: this is ugly, and where is toggle class? :( var dir = (node._isShowing) ? "Out" : "In"; // node._isShowing =! node._isShowing; //var _anim = dojox.fx[ this.toggle ? this.toggle+dir : "fade"+dir]({ var _anim = dojo.fadeIn({ node:node.domNode, duration: this.duration, beforeBegin: dojo.hitch(node,"_quickToggle") }); anims.push(_anim); },this); var _anim = dojo.fx.combine(anims); if(_anim){ _anim.play(); } }, _getSiblingsByType: function(/* String */ declaredClass){ // summary: quick replacement for getChildrenByType("class"), but in // a child here ... so it's getSiblings. courtesy bill in #dojo // could be moved into parent, and just call this.getChildren(), // which makes more sense. var siblings = dojo.filter( this.getParent().getChildren(), function(widget){ return widget.declaredClass==declaredClass; } ); return siblings; // dijit._Widget }, postCreate: function(){ // summary: run this once, should this be startup: function()? this.inherited(arguments); // prevent actions from being visible, _always_ dojo.style(this.domNode,"display","none"); var parents = this._getSiblingsByType('dojox.presentation.Part'); // create a list of "parts" we are attached to via forSlide/as this._attached = []; dojo.forEach(parents,function(parentPart){ if(this.forSlide == parentPart.as){ this._attached.push(parentPart); } },this); } });}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -