📄 dialog.js
字号:
}), dojo.fadeOut({ node: this._underlay.domNode, duration: this.duration, onEnd: dojo.hitch(this._underlay, "hide") }) ] ); }, uninitialize: function(){ if(this._fadeIn && this._fadeIn.status() == "playing"){ this._fadeIn.stop(); } if(this._fadeOut && this._fadeOut.status() == "playing"){ this._fadeOut.stop(); } if(this._underlay){ this._underlay.destroy(); } }, _position: function(){ // summary: position modal dialog in center of screen if(dojo.hasClass(dojo.body(),"dojoMove")){ return; } var viewport = dijit.getViewport(); var mb = dojo.marginBox(this.domNode); var style = this.domNode.style; style.left = Math.floor((viewport.l + (viewport.w - mb.w)/2)) + "px"; style.top = Math.floor((viewport.t + (viewport.h - mb.h)/2)) + "px"; }, _onKey: function(/*Event*/ evt){ // summary: handles the keyboard events for accessibility reasons if(evt.keyCode){ var node = evt.target; if (evt.keyCode == dojo.keys.TAB){ this._getFocusItems(this.domNode); } var singleFocusItem = (this._firstFocusItem == this._lastFocusItem); // see if we are shift-tabbing from first focusable item on dialog if(node == this._firstFocusItem && evt.shiftKey && evt.keyCode == dojo.keys.TAB){ if(!singleFocusItem){ dijit.focus(this._lastFocusItem); // send focus to last item in dialog } dojo.stopEvent(evt); }else if(node == this._lastFocusItem && evt.keyCode == dojo.keys.TAB && !evt.shiftKey){ if (!singleFocusItem){ dijit.focus(this._firstFocusItem); // send focus to first item in dialog } dojo.stopEvent(evt); }else{ // see if the key is for the dialog while(node){ if(node == this.domNode){ if(evt.keyCode == dojo.keys.ESCAPE){ this.hide(); }else{ return; // just let it go } } node = node.parentNode; } // this key is for the disabled document window if(evt.keyCode != dojo.keys.TAB){ // allow tabbing into the dialog for a11y dojo.stopEvent(evt); // opera won't tab to a div }else if(!dojo.isOpera){ try{ this._firstFocusItem.focus(); }catch(e){ /*squelch*/ } } } } }, show: function(){ // summary: display the dialog if(this.open){ return; } // first time we show the dialog, there's some initialization stuff to do if(!this._alreadyInitialized){ this._setup(); this._alreadyInitialized=true; } if(this._fadeOut.status() == "playing"){ this._fadeOut.stop(); } this._modalconnects.push(dojo.connect(window, "onscroll", this, "layout")); this._modalconnects.push(dojo.connect(dojo.doc.documentElement, "onkeypress", this, "_onKey")); dojo.style(this.domNode, "opacity", 0); this.domNode.style.visibility=""; this.open = true; this._loadCheck(); // lazy load trigger this._position(); this._fadeIn.play(); this._savedFocus = dijit.getFocus(this); // find focusable Items each time dialog is shown since if dialog contains a widget the // first focusable items can change this._getFocusItems(this.domNode); // set timeout to allow the browser to render dialog setTimeout(dojo.hitch(this, function(){ dijit.focus(this._firstFocusItem); }), 50); }, hide: function(){ // summary: Hide the dialog // if we haven't been initialized yet then we aren't showing and we can just return if(!this._alreadyInitialized){ return; } if(this._fadeIn.status() == "playing"){ this._fadeIn.stop(); } this._fadeOut.play(); if (this._scrollConnected){ this._scrollConnected = false; } dojo.forEach(this._modalconnects, dojo.disconnect); this._modalconnects = []; if(this.refocus){ this.connect(this._fadeOut,"onEnd",dojo.hitch(dijit,"focus",this._savedFocus)); } this.open = false; }, layout: function() { // summary: position the Dialog and the underlay if(this.domNode.style.visibility != "hidden"){ this._underlay.layout(); this._position(); } }, destroy: function(){ dojo.forEach(this._modalconnects, dojo.disconnect); if(this.refocus && this.open){ var fo = this._savedFocus; setTimeout(dojo.hitch(dijit,"focus",fo),25); } this.inherited(arguments); } });dojo.declare( "dijit.TooltipDialog", [dijit.layout.ContentPane, dijit._Templated, dijit.form._FormMixin, dijit._DialogMixin], { // summary: // Pops up a dialog that appears like a Tooltip // // title: String // Description of tooltip dialog (required for a11Y) title: "", // doLayout: Boolean // Don't change this parameter from the default value. // This ContentPane parameter doesn't make sense for TooltipDialog, since TooltipDialog // is never a child of a layout container, nor can you specify the size of // TooltipDialog in order to control the size of an inner widget. doLayout: false, // _firstFocusItem: DomNode // The pointer to the first focusable node in the dialog _firstFocusItem:null, // _lastFocusItem: DomNode // The domNode that had focus before we took it. _lastFocusItem: null, templateString: null, templateString:"<div class=\"dijitTooltipDialog\" waiRole=\"presentation\">\n\t<div class=\"dijitTooltipContainer\" waiRole=\"presentation\">\n\t\t<div class =\"dijitTooltipContents dijitTooltipFocusNode\" dojoAttachPoint=\"containerNode\" tabindex=\"-1\" waiRole=\"dialog\"></div>\n\t</div>\n\t<div class=\"dijitTooltipConnector\" waiRole=\"presenation\"></div>\n</div>\n", postCreate: function(){ this.inherited(arguments); this.connect(this.containerNode, "onkeypress", "_onKey"); this.containerNode.title = this.title; }, orient: function(/*DomNode*/ node, /*String*/ aroundCorner, /*String*/ corner){ // summary: configure widget to be displayed in given position relative to the button this.domNode.className="dijitTooltipDialog " +" dijitTooltipAB"+(corner.charAt(1)=='L'?"Left":"Right")+" dijitTooltip"+(corner.charAt(0)=='T' ? "Below" : "Above"); }, onOpen: function(/*Object*/ pos){ // summary: called when dialog is displayed this._getFocusItems(this.containerNode); this.orient(this.domNode,pos.aroundCorner, pos.corner); this._loadCheck(); // lazy load trigger dijit.focus(this._firstFocusItem); }, _onKey: function(/*Event*/ evt){ // summary: keep keyboard focus in dialog; close dialog on escape key var node = evt.target; if (evt.keyCode == dojo.keys.TAB){ this._getFocusItems(this.containerNode); } var singleFocusItem = (this._firstFocusItem == this._lastFocusItem); if(evt.keyCode == dojo.keys.ESCAPE){ this.onCancel(); }else if(node == this._firstFocusItem && evt.shiftKey && evt.keyCode == dojo.keys.TAB){ if(!singleFocusItem){ dijit.focus(this._lastFocusItem); // send focus to last item in dialog } dojo.stopEvent(evt); }else if(node == this._lastFocusItem && evt.keyCode == dojo.keys.TAB && !evt.shiftKey){ if(!singleFocusItem){ dijit.focus(this._firstFocusItem); // send focus to first item in dialog } dojo.stopEvent(evt); }else if(evt.keyCode == dojo.keys.TAB){ // we want the browser's default tab handling to move focus // but we don't want the tab to propagate upwards evt.stopPropagation(); } } } );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -