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/_base/focus.js | 803 ++++++++++++++++++++++++++++--------------- lib/dijit/_base/manager.js | 718 +++++++++++++++++++++++++------------- lib/dijit/_base/place.js | 449 +++++++++++++++++++----- lib/dijit/_base/popup.js | 533 ++++++++++++++++++++-------- lib/dijit/_base/scroll.js | 17 +- lib/dijit/_base/sniff.js | 15 +- lib/dijit/_base/typematic.js | 262 +++++++++----- lib/dijit/_base/wai.js | 191 +++++++--- lib/dijit/_base/window.js | 13 +- 9 files changed, 2098 insertions(+), 903 deletions(-) (limited to 'lib/dijit/_base') diff --git a/lib/dijit/_base/focus.js b/lib/dijit/_base/focus.js index 32be06aa7..55c5b682d 100644 --- a/lib/dijit/_base/focus.js +++ b/lib/dijit/_base/focus.js @@ -1,299 +1,530 @@ /* - 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._base.focus"]){ -dojo._hasResource["dijit._base.focus"]=true; +if(!dojo._hasResource["dijit._base.focus"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit._base.focus"] = true; dojo.provide("dijit._base.focus"); dojo.require("dojo.window"); dojo.require("dijit._base.manager"); -dojo.mixin(dijit,{_curFocus:null,_prevFocus:null,isCollapsed:function(){ -return dijit.getBookmark().isCollapsed; -},getBookmark:function(){ -var bm,rg,tg,_1=dojo.doc.selection,cf=dijit._curFocus; -if(dojo.global.getSelection){ -_1=dojo.global.getSelection(); -if(_1){ -if(_1.isCollapsed){ -tg=cf?cf.tagName:""; -if(tg){ -tg=tg.toLowerCase(); -if(tg=="textarea"||(tg=="input"&&(!cf.type||cf.type.toLowerCase()=="text"))){ -_1={start:cf.selectionStart,end:cf.selectionEnd,node:cf,pRange:true}; -return {isCollapsed:(_1.end<=_1.start),mark:_1}; -} -} -bm={isCollapsed:true}; -}else{ -rg=_1.getRangeAt(0); -bm={isCollapsed:false,mark:rg.cloneRange()}; -} -} -}else{ -if(_1){ -tg=cf?cf.tagName:""; -tg=tg.toLowerCase(); -if(cf&&tg&&(tg=="button"||tg=="textarea"||tg=="input")){ -if(_1.type&&_1.type.toLowerCase()=="none"){ -return {isCollapsed:true,mark:null}; -}else{ -rg=_1.createRange(); -return {isCollapsed:rg.text&&rg.text.length?false:true,mark:{range:rg,pRange:true}}; -} -} -bm={}; -try{ -rg=_1.createRange(); -bm.isCollapsed=!(_1.type=="Text"?rg.htmlText.length:rg.length); -} -catch(e){ -bm.isCollapsed=true; -return bm; -} -if(_1.type.toUpperCase()=="CONTROL"){ -if(rg.length){ -bm.mark=[]; -var i=0,_2=rg.length; -while(i<_2){ -bm.mark.push(rg.item(i++)); -} -}else{ -bm.isCollapsed=true; -bm.mark=null; -} -}else{ -bm.mark=rg.getBookmark(); -} -}else{ -console.warn("No idea how to store the current selection for this browser!"); -} -} -return bm; -},moveToBookmark:function(_3){ -var _4=dojo.doc,_5=_3.mark; -if(_5){ -if(dojo.global.getSelection){ -var _6=dojo.global.getSelection(); -if(_6&&_6.removeAllRanges){ -if(_5.pRange){ -var r=_5; -var n=r.node; -n.selectionStart=r.start; -n.selectionEnd=r.end; -}else{ -_6.removeAllRanges(); -_6.addRange(_5); -} -}else{ -console.warn("No idea how to restore selection for this browser!"); -} -}else{ -if(_4.selection&&_5){ -var rg; -if(_5.pRange){ -rg=_5.range; -}else{ -if(dojo.isArray(_5)){ -rg=_4.body.createControlRange(); -dojo.forEach(_5,function(n){ -rg.addElement(n); + + +// summary: +// These functions are used to query or set the focus and selection. +// +// Also, they trace when widgets become activated/deactivated, +// so that the widget can fire _onFocus/_onBlur events. +// "Active" here means something similar to "focused", but +// "focus" isn't quite the right word because we keep track of +// a whole stack of "active" widgets. Example: ComboButton --> Menu --> +// MenuItem. The onBlur event for ComboButton doesn't fire due to focusing +// on the Menu or a MenuItem, since they are considered part of the +// ComboButton widget. It only happens when focus is shifted +// somewhere completely different. + +dojo.mixin(dijit, { + // _curFocus: DomNode + // Currently focused item on screen + _curFocus: null, + + // _prevFocus: DomNode + // Previously focused item on screen + _prevFocus: null, + + isCollapsed: function(){ + // summary: + // Returns true if there is no text selected + return dijit.getBookmark().isCollapsed; + }, + + getBookmark: function(){ + // summary: + // Retrieves a bookmark that can be used with moveToBookmark to return to the same range + var bm, rg, tg, sel = dojo.doc.selection, cf = dijit._curFocus; + + if(dojo.global.getSelection){ + //W3C Range API for selections. + sel = dojo.global.getSelection(); + if(sel){ + if(sel.isCollapsed){ + tg = cf? cf.tagName : ""; + if(tg){ + //Create a fake rangelike item to restore selections. + tg = tg.toLowerCase(); + if(tg == "textarea" || + (tg == "input" && (!cf.type || cf.type.toLowerCase() == "text"))){ + sel = { + start: cf.selectionStart, + end: cf.selectionEnd, + node: cf, + pRange: true + }; + return {isCollapsed: (sel.end <= sel.start), mark: sel}; //Object. + } + } + bm = {isCollapsed:true}; + if(sel.rangeCount){ + bm.mark = sel.getRangeAt(0).cloneRange(); + } + }else{ + rg = sel.getRangeAt(0); + bm = {isCollapsed: false, mark: rg.cloneRange()}; + } + } + }else if(sel){ + // If the current focus was a input of some sort and no selection, don't bother saving + // a native bookmark. This is because it causes issues with dialog/page selection restore. + // So, we need to create psuedo bookmarks to work with. + tg = cf ? cf.tagName : ""; + tg = tg.toLowerCase(); + if(cf && tg && (tg == "button" || tg == "textarea" || tg == "input")){ + if(sel.type && sel.type.toLowerCase() == "none"){ + return { + isCollapsed: true, + mark: null + } + }else{ + rg = sel.createRange(); + return { + isCollapsed: rg.text && rg.text.length?false:true, + mark: { + range: rg, + pRange: true + } + }; + } + } + bm = {}; + + //'IE' way for selections. + try{ + // createRange() throws exception when dojo in iframe + //and nothing selected, see #9632 + rg = sel.createRange(); + bm.isCollapsed = !(sel.type == 'Text' ? rg.htmlText.length : rg.length); + }catch(e){ + bm.isCollapsed = true; + return bm; + } + if(sel.type.toUpperCase() == 'CONTROL'){ + if(rg.length){ + bm.mark=[]; + var i=0,len=rg.length; + while(i to follow the parentNode chain, + // but we need to set focus to iframe.contentWindow + if(node){ + var focusNode = (node.tagName.toLowerCase() == "iframe") ? node.contentWindow : node; + if(focusNode && focusNode.focus){ + try{ + // Gecko throws sometimes if setting focus is impossible, + // node not displayed or something like that + focusNode.focus(); + }catch(e){/*quiet*/} + } + dijit._onFocusNode(node); + } + + // set the selection + // do not need to restore if current selection is not empty + // (use keyboard to select a menu item) or if previous selection was collapsed + // as it may cause focus shift (Esp in IE). + if(bookmark && dojo.withGlobal(openedForWindow || dojo.global, dijit.isCollapsed) && !collapsed){ + if(openedForWindow){ + openedForWindow.focus(); + } + try{ + dojo.withGlobal(openedForWindow || dojo.global, dijit.moveToBookmark, null, [bookmark]); + }catch(e2){ + /*squelch IE internal error, see http://trac.dojotoolkit.org/ticket/1984 */ + } + } + }, + + // _activeStack: dijit._Widget[] + // List of currently active widgets (focused widget and it's ancestors) + _activeStack: [], + + registerIframe: function(/*DomNode*/ iframe){ + // summary: + // Registers listeners on the specified iframe so that any click + // or focus event on that iframe (or anything in it) is reported + // as a focus/click event on the