From 81bea17aefb26859f825b9293c7c99192874806e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 8 Nov 2011 20:40:44 +0400 Subject: upgrade Dojo to 1.6.1 --- lib/dijit/TooltipDialog.js | 188 ++++++++++++++++++++++++++++++++------------- 1 file changed, 134 insertions(+), 54 deletions(-) (limited to 'lib/dijit/TooltipDialog.js') diff --git a/lib/dijit/TooltipDialog.js b/lib/dijit/TooltipDialog.js index 13f69dbd3..38d551048 100644 --- a/lib/dijit/TooltipDialog.js +++ b/lib/dijit/TooltipDialog.js @@ -1,66 +1,146 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ -if(!dojo._hasResource["dijit.TooltipDialog"]){ -dojo._hasResource["dijit.TooltipDialog"]=true; +if(!dojo._hasResource["dijit.TooltipDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.TooltipDialog"] = true; dojo.provide("dijit.TooltipDialog"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit._Templated"); dojo.require("dijit.form._FormMixin"); dojo.require("dijit._DialogMixin"); -dojo.declare("dijit.TooltipDialog",[dijit.layout.ContentPane,dijit._Templated,dijit.form._FormMixin,dijit._DialogMixin],{title:"",doLayout:false,autofocus:true,baseClass:"dijitTooltipDialog",_firstFocusItem:null,_lastFocusItem:null,templateString:dojo.cache("dijit","templates/TooltipDialog.html","
\n\t
\n\t\t
\n\t
\n\t
\n
\n"),postCreate:function(){ -this.inherited(arguments); -this.connect(this.containerNode,"onkeypress","_onKey"); -this.containerNode.title=this.title; -},orient:function(_1,_2,_3){ -var c=this._currentOrientClass; -if(c){ -dojo.removeClass(this.domNode,c); -} -c="dijitTooltipAB"+(_3.charAt(1)=="L"?"Left":"Right")+" dijitTooltip"+(_3.charAt(0)=="T"?"Below":"Above"); -dojo.addClass(this.domNode,c); -this._currentOrientClass=c; -},onOpen:function(_4){ -this.orient(this.domNode,_4.aroundCorner,_4.corner); -this._onShow(); -if(this.autofocus){ -this._getFocusItems(this.containerNode); -dijit.focus(this._firstFocusItem); -} -},onClose:function(){ -this.onHide(); -},_onKey:function(_5){ -var _6=_5.target; -var dk=dojo.keys; -if(_5.charOrCode===dk.TAB){ -this._getFocusItems(this.containerNode); -} -var _7=(this._firstFocusItem==this._lastFocusItem); -if(_5.charOrCode==dk.ESCAPE){ -setTimeout(dojo.hitch(this,"onCancel"),0); -dojo.stopEvent(_5); -}else{ -if(_6==this._firstFocusItem&&_5.shiftKey&&_5.charOrCode===dk.TAB){ -if(!_7){ -dijit.focus(this._lastFocusItem); -} -dojo.stopEvent(_5); -}else{ -if(_6==this._lastFocusItem&&_5.charOrCode===dk.TAB&&!_5.shiftKey){ -if(!_7){ -dijit.focus(this._firstFocusItem); -} -dojo.stopEvent(_5); -}else{ -if(_5.charOrCode===dk.TAB){ -_5.stopPropagation(); -} -} -} -} -}}); + + +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: [protected] 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, + + // autofocus: Boolean + // A Toggle to modify the default focus behavior of a Dialog, which + // is to focus on the first dialog element after opening the dialog. + // False will disable autofocusing. Default: true + autofocus: true, + + // baseClass: [protected] String + // The root className to use for the various states of this widget + baseClass: "dijitTooltipDialog", + + // _firstFocusItem: [private] [readonly] DomNode + // The pointer to the first focusable node in the dialog. + // Set by `dijit._DialogMixin._getFocusItems`. + _firstFocusItem: null, + + // _lastFocusItem: [private] [readonly] DomNode + // The pointer to which node has focus prior to our dialog. + // Set by `dijit._DialogMixin._getFocusItems`. + _lastFocusItem: null, + + templateString: dojo.cache("dijit", "templates/TooltipDialog.html", "
\n\t
\n\t\t
\n\t
\n\t
\n
\n"), + + _setTitleAttr: function(/*String*/ title){ + this.containerNode.title = title; + this._set("title", title) + }, + + postCreate: function(){ + this.inherited(arguments); + this.connect(this.containerNode, "onkeypress", "_onKey"); + }, + + orient: function(/*DomNode*/ node, /*String*/ aroundCorner, /*String*/ corner){ + // summary: + // Configure widget to be displayed in given position relative to the button. + // This is called from the dijit.popup code, and should not be called + // directly. + // tags: + // protected + var newC = "dijitTooltipAB" + (corner.charAt(1) == 'L' ? "Left" : "Right") + + " dijitTooltip" + + (corner.charAt(0) == 'T' ? "Below" : "Above"); + + dojo.replaceClass(this.domNode, newC, this._currentOrientClass || ""); + this._currentOrientClass = newC; + }, + + focus: function(){ + // summary: + // Focus on first field + this._getFocusItems(this.containerNode); + dijit.focus(this._firstFocusItem); + }, + + onOpen: function(/*Object*/ pos){ + // summary: + // Called when dialog is displayed. + // This is called from the dijit.popup code, and should not be called directly. + // tags: + // protected + + this.orient(this.domNode,pos.aroundCorner, pos.corner); + this._onShow(); // lazy load trigger + }, + + onClose: function(){ + // summary: + // Called when dialog is hidden. + // This is called from the dijit.popup code, and should not be called directly. + // tags: + // protected + this.onHide(); + }, + + _onKey: function(/*Event*/ evt){ + // summary: + // Handler for keyboard events + // description: + // Keep keyboard focus in dialog; close dialog on escape key + // tags: + // private + + var node = evt.target; + var dk = dojo.keys; + if(evt.charOrCode === dk.TAB){ + this._getFocusItems(this.containerNode); + } + var singleFocusItem = (this._firstFocusItem == this._lastFocusItem); + if(evt.charOrCode == dk.ESCAPE){ + // Use setTimeout to avoid crash on IE, see #10396. + setTimeout(dojo.hitch(this, "onCancel"), 0); + dojo.stopEvent(evt); + }else if(node == this._firstFocusItem && evt.shiftKey && evt.charOrCode === dk.TAB){ + if(!singleFocusItem){ + dijit.focus(this._lastFocusItem); // send focus to last item in dialog + } + dojo.stopEvent(evt); + }else if(node == this._lastFocusItem && evt.charOrCode === dk.TAB && !evt.shiftKey){ + if(!singleFocusItem){ + dijit.focus(this._firstFocusItem); // send focus to first item in dialog + } + dojo.stopEvent(evt); + }else if(evt.charOrCode === dk.TAB){ + // we want the browser's default tab handling to move focus + // but we don't want the tab to propagate upwards + evt.stopPropagation(); + } + } + } + ); + } -- cgit v1.2.3