mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 15:45:56 +00:00
update dojo to 1.7.3
This commit is contained in:
@@ -1,530 +1,2 @@
|
||||
/*
|
||||
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"]){ //_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");
|
||||
|
||||
|
||||
// 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<len){
|
||||
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; // Object
|
||||
},
|
||||
|
||||
moveToBookmark: function(/*Object*/bookmark){
|
||||
// summary:
|
||||
// Moves current selection to a bookmark
|
||||
// bookmark:
|
||||
// This should be a returned object from dijit.getBookmark()
|
||||
|
||||
var _doc = dojo.doc,
|
||||
mark = bookmark.mark;
|
||||
if(mark){
|
||||
if(dojo.global.getSelection){
|
||||
//W3C Rangi API (FF, WebKit, Opera, etc)
|
||||
var sel = dojo.global.getSelection();
|
||||
if(sel && sel.removeAllRanges){
|
||||
if(mark.pRange){
|
||||
var r = mark;
|
||||
var n = r.node;
|
||||
n.selectionStart = r.start;
|
||||
n.selectionEnd = r.end;
|
||||
}else{
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(mark);
|
||||
}
|
||||
}else{
|
||||
console.warn("No idea how to restore selection for this browser!");
|
||||
}
|
||||
}else if(_doc.selection && mark){
|
||||
//'IE' way.
|
||||
var rg;
|
||||
if(mark.pRange){
|
||||
rg = mark.range;
|
||||
}else if(dojo.isArray(mark)){
|
||||
rg = _doc.body.createControlRange();
|
||||
//rg.addElement does not have call/apply method, so can not call it directly
|
||||
//rg is not available in "range.addElement(item)", so can't use that either
|
||||
dojo.forEach(mark, function(n){
|
||||
rg.addElement(n);
|
||||
});
|
||||
}else{
|
||||
rg = _doc.body.createTextRange();
|
||||
rg.moveToBookmark(mark);
|
||||
}
|
||||
rg.select();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getFocus: function(/*Widget?*/ menu, /*Window?*/ openedForWindow){
|
||||
// summary:
|
||||
// Called as getFocus(), this returns an Object showing the current focus
|
||||
// and selected text.
|
||||
//
|
||||
// Called as getFocus(widget), where widget is a (widget representing) a button
|
||||
// that was just pressed, it returns where focus was before that button
|
||||
// was pressed. (Pressing the button may have either shifted focus to the button,
|
||||
// or removed focus altogether.) In this case the selected text is not returned,
|
||||
// since it can't be accurately determined.
|
||||
//
|
||||
// menu: dijit._Widget or {domNode: DomNode} structure
|
||||
// The button that was just pressed. If focus has disappeared or moved
|
||||
// to this button, returns the previous focus. In this case the bookmark
|
||||
// information is already lost, and null is returned.
|
||||
//
|
||||
// openedForWindow:
|
||||
// iframe in which menu was opened
|
||||
//
|
||||
// returns:
|
||||
// A handle to restore focus/selection, to be passed to `dijit.focus`
|
||||
var node = !dijit._curFocus || (menu && dojo.isDescendant(dijit._curFocus, menu.domNode)) ? dijit._prevFocus : dijit._curFocus;
|
||||
return {
|
||||
node: node,
|
||||
bookmark: (node == dijit._curFocus) && dojo.withGlobal(openedForWindow || dojo.global, dijit.getBookmark),
|
||||
openedForWindow: openedForWindow
|
||||
}; // Object
|
||||
},
|
||||
|
||||
focus: function(/*Object || DomNode */ handle){
|
||||
// summary:
|
||||
// Sets the focused node and the selection according to argument.
|
||||
// To set focus to an iframe's content, pass in the iframe itself.
|
||||
// handle:
|
||||
// object returned by get(), or a DomNode
|
||||
|
||||
if(!handle){ return; }
|
||||
|
||||
var node = "node" in handle ? handle.node : handle, // because handle is either DomNode or a composite object
|
||||
bookmark = handle.bookmark,
|
||||
openedForWindow = handle.openedForWindow,
|
||||
collapsed = bookmark ? bookmark.isCollapsed : false;
|
||||
|
||||
// Set the focus
|
||||
// Note that for iframe's we need to use the <iframe> 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 <iframe> itself.
|
||||
// description:
|
||||
// Currently only used by editor.
|
||||
// returns:
|
||||
// Handle to pass to unregisterIframe()
|
||||
return dijit.registerWin(iframe.contentWindow, iframe);
|
||||
},
|
||||
|
||||
unregisterIframe: function(/*Object*/ handle){
|
||||
// summary:
|
||||
// Unregisters listeners on the specified iframe created by registerIframe.
|
||||
// After calling be sure to delete or null out the handle itself.
|
||||
// handle:
|
||||
// Handle returned by registerIframe()
|
||||
|
||||
dijit.unregisterWin(handle);
|
||||
},
|
||||
|
||||
registerWin: function(/*Window?*/targetWindow, /*DomNode?*/ effectiveNode){
|
||||
// summary:
|
||||
// Registers listeners on the specified window (either the main
|
||||
// window or an iframe's window) to detect when the user has clicked somewhere
|
||||
// or focused somewhere.
|
||||
// description:
|
||||
// Users should call registerIframe() instead of this method.
|
||||
// targetWindow:
|
||||
// If specified this is the window associated with the iframe,
|
||||
// i.e. iframe.contentWindow.
|
||||
// effectiveNode:
|
||||
// If specified, report any focus events inside targetWindow as
|
||||
// an event on effectiveNode, rather than on evt.target.
|
||||
// returns:
|
||||
// Handle to pass to unregisterWin()
|
||||
|
||||
// TODO: make this function private in 2.0; Editor/users should call registerIframe(),
|
||||
|
||||
var mousedownListener = function(evt){
|
||||
dijit._justMouseDowned = true;
|
||||
setTimeout(function(){ dijit._justMouseDowned = false; }, 0);
|
||||
|
||||
// workaround weird IE bug where the click is on an orphaned node
|
||||
// (first time clicking a Select/DropDownButton inside a TooltipDialog)
|
||||
if(dojo.isIE && evt && evt.srcElement && evt.srcElement.parentNode == null){
|
||||
return;
|
||||
}
|
||||
|
||||
dijit._onTouchNode(effectiveNode || evt.target || evt.srcElement, "mouse");
|
||||
};
|
||||
//dojo.connect(targetWindow, "onscroll", ???);
|
||||
|
||||
// Listen for blur and focus events on targetWindow's document.
|
||||
// IIRC, I'm using attachEvent() rather than dojo.connect() because focus/blur events don't bubble
|
||||
// through dojo.connect(), and also maybe to catch the focus events early, before onfocus handlers
|
||||
// fire.
|
||||
// Connect to <html> (rather than document) on IE to avoid memory leaks, but document on other browsers because
|
||||
// (at least for FF) the focus event doesn't fire on <html> or <body>.
|
||||
var doc = dojo.isIE ? targetWindow.document.documentElement : targetWindow.document;
|
||||
if(doc){
|
||||
if(dojo.isIE){
|
||||
targetWindow.document.body.attachEvent('onmousedown', mousedownListener);
|
||||
var activateListener = function(evt){
|
||||
// IE reports that nodes like <body> have gotten focus, even though they have tabIndex=-1,
|
||||
// Should consider those more like a mouse-click than a focus....
|
||||
if(evt.srcElement.tagName.toLowerCase() != "#document" &&
|
||||
dijit.isTabNavigable(evt.srcElement)){
|
||||
dijit._onFocusNode(effectiveNode || evt.srcElement);
|
||||
}else{
|
||||
dijit._onTouchNode(effectiveNode || evt.srcElement);
|
||||
}
|
||||
};
|
||||
doc.attachEvent('onactivate', activateListener);
|
||||
var deactivateListener = function(evt){
|
||||
dijit._onBlurNode(effectiveNode || evt.srcElement);
|
||||
};
|
||||
doc.attachEvent('ondeactivate', deactivateListener);
|
||||
|
||||
return function(){
|
||||
targetWindow.document.detachEvent('onmousedown', mousedownListener);
|
||||
doc.detachEvent('onactivate', activateListener);
|
||||
doc.detachEvent('ondeactivate', deactivateListener);
|
||||
doc = null; // prevent memory leak (apparent circular reference via closure)
|
||||
};
|
||||
}else{
|
||||
doc.body.addEventListener('mousedown', mousedownListener, true);
|
||||
var focusListener = function(evt){
|
||||
dijit._onFocusNode(effectiveNode || evt.target);
|
||||
};
|
||||
doc.addEventListener('focus', focusListener, true);
|
||||
var blurListener = function(evt){
|
||||
dijit._onBlurNode(effectiveNode || evt.target);
|
||||
};
|
||||
doc.addEventListener('blur', blurListener, true);
|
||||
|
||||
return function(){
|
||||
doc.body.removeEventListener('mousedown', mousedownListener, true);
|
||||
doc.removeEventListener('focus', focusListener, true);
|
||||
doc.removeEventListener('blur', blurListener, true);
|
||||
doc = null; // prevent memory leak (apparent circular reference via closure)
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
unregisterWin: function(/*Handle*/ handle){
|
||||
// summary:
|
||||
// Unregisters listeners on the specified window (either the main
|
||||
// window or an iframe's window) according to handle returned from registerWin().
|
||||
// After calling be sure to delete or null out the handle itself.
|
||||
|
||||
// Currently our handle is actually a function
|
||||
handle && handle();
|
||||
},
|
||||
|
||||
_onBlurNode: function(/*DomNode*/ node){
|
||||
// summary:
|
||||
// Called when focus leaves a node.
|
||||
// Usually ignored, _unless_ it *isn't* follwed by touching another node,
|
||||
// which indicates that we tabbed off the last field on the page,
|
||||
// in which case every widget is marked inactive
|
||||
dijit._prevFocus = dijit._curFocus;
|
||||
dijit._curFocus = null;
|
||||
|
||||
if(dijit._justMouseDowned){
|
||||
// the mouse down caused a new widget to be marked as active; this blur event
|
||||
// is coming late, so ignore it.
|
||||
return;
|
||||
}
|
||||
|
||||
// if the blur event isn't followed by a focus event then mark all widgets as inactive.
|
||||
if(dijit._clearActiveWidgetsTimer){
|
||||
clearTimeout(dijit._clearActiveWidgetsTimer);
|
||||
}
|
||||
dijit._clearActiveWidgetsTimer = setTimeout(function(){
|
||||
delete dijit._clearActiveWidgetsTimer;
|
||||
dijit._setStack([]);
|
||||
dijit._prevFocus = null;
|
||||
}, 100);
|
||||
},
|
||||
|
||||
_onTouchNode: function(/*DomNode*/ node, /*String*/ by){
|
||||
// summary:
|
||||
// Callback when node is focused or mouse-downed
|
||||
// node:
|
||||
// The node that was touched.
|
||||
// by:
|
||||
// "mouse" if the focus/touch was caused by a mouse down event
|
||||
|
||||
// ignore the recent blurNode event
|
||||
if(dijit._clearActiveWidgetsTimer){
|
||||
clearTimeout(dijit._clearActiveWidgetsTimer);
|
||||
delete dijit._clearActiveWidgetsTimer;
|
||||
}
|
||||
|
||||
// compute stack of active widgets (ex: ComboButton --> Menu --> MenuItem)
|
||||
var newStack=[];
|
||||
try{
|
||||
while(node){
|
||||
var popupParent = dojo.attr(node, "dijitPopupParent");
|
||||
if(popupParent){
|
||||
node=dijit.byId(popupParent).domNode;
|
||||
}else if(node.tagName && node.tagName.toLowerCase() == "body"){
|
||||
// is this the root of the document or just the root of an iframe?
|
||||
if(node === dojo.body()){
|
||||
// node is the root of the main document
|
||||
break;
|
||||
}
|
||||
// otherwise, find the iframe this node refers to (can't access it via parentNode,
|
||||
// need to do this trick instead). window.frameElement is supported in IE/FF/Webkit
|
||||
node=dojo.window.get(node.ownerDocument).frameElement;
|
||||
}else{
|
||||
// if this node is the root node of a widget, then add widget id to stack,
|
||||
// except ignore clicks on disabled widgets (actually focusing a disabled widget still works,
|
||||
// to support MenuItem)
|
||||
var id = node.getAttribute && node.getAttribute("widgetId"),
|
||||
widget = id && dijit.byId(id);
|
||||
if(widget && !(by == "mouse" && widget.get("disabled"))){
|
||||
newStack.unshift(id);
|
||||
}
|
||||
node=node.parentNode;
|
||||
}
|
||||
}
|
||||
}catch(e){ /* squelch */ }
|
||||
|
||||
dijit._setStack(newStack, by);
|
||||
},
|
||||
|
||||
_onFocusNode: function(/*DomNode*/ node){
|
||||
// summary:
|
||||
// Callback when node is focused
|
||||
|
||||
if(!node){
|
||||
return;
|
||||
}
|
||||
|
||||
if(node.nodeType == 9){
|
||||
// Ignore focus events on the document itself. This is here so that
|
||||
// (for example) clicking the up/down arrows of a spinner
|
||||
// (which don't get focus) won't cause that widget to blur. (FF issue)
|
||||
return;
|
||||
}
|
||||
|
||||
dijit._onTouchNode(node);
|
||||
|
||||
if(node == dijit._curFocus){ return; }
|
||||
if(dijit._curFocus){
|
||||
dijit._prevFocus = dijit._curFocus;
|
||||
}
|
||||
dijit._curFocus = node;
|
||||
dojo.publish("focusNode", [node]);
|
||||
},
|
||||
|
||||
_setStack: function(/*String[]*/ newStack, /*String*/ by){
|
||||
// summary:
|
||||
// The stack of active widgets has changed. Send out appropriate events and records new stack.
|
||||
// newStack:
|
||||
// array of widget id's, starting from the top (outermost) widget
|
||||
// by:
|
||||
// "mouse" if the focus/touch was caused by a mouse down event
|
||||
|
||||
var oldStack = dijit._activeStack;
|
||||
dijit._activeStack = newStack;
|
||||
|
||||
// compare old stack to new stack to see how many elements they have in common
|
||||
for(var nCommon=0; nCommon<Math.min(oldStack.length, newStack.length); nCommon++){
|
||||
if(oldStack[nCommon] != newStack[nCommon]){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var widget;
|
||||
// for all elements that have gone out of focus, send blur event
|
||||
for(var i=oldStack.length-1; i>=nCommon; i--){
|
||||
widget = dijit.byId(oldStack[i]);
|
||||
if(widget){
|
||||
widget._focused = false;
|
||||
widget.set("focused", false);
|
||||
widget._hasBeenBlurred = true;
|
||||
if(widget._onBlur){
|
||||
widget._onBlur(by);
|
||||
}
|
||||
dojo.publish("widgetBlur", [widget, by]);
|
||||
}
|
||||
}
|
||||
|
||||
// for all element that have come into focus, send focus event
|
||||
for(i=nCommon; i<newStack.length; i++){
|
||||
widget = dijit.byId(newStack[i]);
|
||||
if(widget){
|
||||
widget._focused = true;
|
||||
widget.set("focused", true);
|
||||
if(widget._onFocus){
|
||||
widget._onFocus(by);
|
||||
}
|
||||
dojo.publish("widgetFocus", [widget, by]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// register top window and all the iframes it contains
|
||||
dojo.addOnLoad(function(){
|
||||
var handle = dijit.registerWin(window);
|
||||
if(dojo.isIE){
|
||||
dojo.addOnWindowUnload(function(){
|
||||
dijit.unregisterWin(handle);
|
||||
handle = null;
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/focus",["dojo/_base/array","dojo/dom","dojo/_base/lang","dojo/topic","dojo/_base/window","../focus",".."],function(_1,_2,_3,_4,_5,_6,_7){_3.mixin(_7,{_curFocus:null,_prevFocus:null,isCollapsed:function(){return _7.getBookmark().isCollapsed;},getBookmark:function(){var bm,rg,tg,_8=_5.doc.selection,cf=_6.curNode;if(_5.global.getSelection){_8=_5.global.getSelection();if(_8){if(_8.isCollapsed){tg=cf?cf.tagName:"";if(tg){tg=tg.toLowerCase();if(tg=="textarea"||(tg=="input"&&(!cf.type||cf.type.toLowerCase()=="text"))){_8={start:cf.selectionStart,end:cf.selectionEnd,node:cf,pRange:true};return {isCollapsed:(_8.end<=_8.start),mark:_8};}}bm={isCollapsed:true};if(_8.rangeCount){bm.mark=_8.getRangeAt(0).cloneRange();}}else{rg=_8.getRangeAt(0);bm={isCollapsed:false,mark:rg.cloneRange()};}}}else{if(_8){tg=cf?cf.tagName:"";tg=tg.toLowerCase();if(cf&&tg&&(tg=="button"||tg=="textarea"||tg=="input")){if(_8.type&&_8.type.toLowerCase()=="none"){return {isCollapsed:true,mark:null};}else{rg=_8.createRange();return {isCollapsed:rg.text&&rg.text.length?false:true,mark:{range:rg,pRange:true}};}}bm={};try{rg=_8.createRange();bm.isCollapsed=!(_8.type=="Text"?rg.htmlText.length:rg.length);}catch(e){bm.isCollapsed=true;return bm;}if(_8.type.toUpperCase()=="CONTROL"){if(rg.length){bm.mark=[];var i=0,_9=rg.length;while(i<_9){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(_a){var _b=_5.doc,_c=_a.mark;if(_c){if(_5.global.getSelection){var _d=_5.global.getSelection();if(_d&&_d.removeAllRanges){if(_c.pRange){var n=_c.node;n.selectionStart=_c.start;n.selectionEnd=_c.end;}else{_d.removeAllRanges();_d.addRange(_c);}}else{console.warn("No idea how to restore selection for this browser!");}}else{if(_b.selection&&_c){var rg;if(_c.pRange){rg=_c.range;}else{if(_3.isArray(_c)){rg=_b.body.createControlRange();_1.forEach(_c,function(n){rg.addElement(n);});}else{rg=_b.body.createTextRange();rg.moveToBookmark(_c);}}rg.select();}}}},getFocus:function(_e,_f){var _10=!_6.curNode||(_e&&_2.isDescendant(_6.curNode,_e.domNode))?_7._prevFocus:_6.curNode;return {node:_10,bookmark:_10&&(_10==_6.curNode)&&_5.withGlobal(_f||_5.global,_7.getBookmark),openedForWindow:_f};},_activeStack:[],registerIframe:function(_11){return _6.registerIframe(_11);},unregisterIframe:function(_12){_12&&_12.remove();},registerWin:function(_13,_14){return _6.registerWin(_13,_14);},unregisterWin:function(_15){_15&&_15.remove();}});_6.focus=function(_16){if(!_16){return;}var _17="node" in _16?_16.node:_16,_18=_16.bookmark,_19=_16.openedForWindow,_1a=_18?_18.isCollapsed:false;if(_17){var _1b=(_17.tagName.toLowerCase()=="iframe")?_17.contentWindow:_17;if(_1b&&_1b.focus){try{_1b.focus();}catch(e){}}_6._onFocusNode(_17);}if(_18&&_5.withGlobal(_19||_5.global,_7.isCollapsed)&&!_1a){if(_19){_19.focus();}try{_5.withGlobal(_19||_5.global,_7.moveToBookmark,null,[_18]);}catch(e2){}}};_6.watch("curNode",function(_1c,_1d,_1e){_7._curFocus=_1e;_7._prevFocus=_1d;if(_1e){_4.publish("focusNode",_1e);}});_6.watch("activeStack",function(_1f,_20,_21){_7._activeStack=_21;});_6.on("widget-blur",function(_22,by){_4.publish("widgetBlur",_22,by);});_6.on("widget-focus",function(_23,by){_4.publish("widgetFocus",_23,by);});return _7;});
|
||||
319
lib/dijit/_base/focus.js.uncompressed.js
Normal file
319
lib/dijit/_base/focus.js.uncompressed.js
Normal file
@@ -0,0 +1,319 @@
|
||||
define("dijit/_base/focus", [
|
||||
"dojo/_base/array", // array.forEach
|
||||
"dojo/dom", // dom.isDescendant
|
||||
"dojo/_base/lang", // lang.isArray
|
||||
"dojo/topic", // publish
|
||||
"dojo/_base/window", // win.doc win.doc.selection win.global win.global.getSelection win.withGlobal
|
||||
"../focus",
|
||||
".." // for exporting symbols to dijit
|
||||
], function(array, dom, lang, topic, win, focus, dijit){
|
||||
|
||||
// module:
|
||||
// dijit/_base/focus
|
||||
// summary:
|
||||
// Deprecated module to monitor currently focused node and stack of currently focused widgets.
|
||||
// New code should access dijit/focus directly.
|
||||
|
||||
lang.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 = win.doc.selection, cf = focus.curNode;
|
||||
|
||||
if(win.global.getSelection){
|
||||
//W3C Range API for selections.
|
||||
sel = win.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<len){
|
||||
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; // Object
|
||||
},
|
||||
|
||||
moveToBookmark: function(/*Object*/ bookmark){
|
||||
// summary:
|
||||
// Moves current selection to a bookmark
|
||||
// bookmark:
|
||||
// This should be a returned object from dijit.getBookmark()
|
||||
|
||||
var _doc = win.doc,
|
||||
mark = bookmark.mark;
|
||||
if(mark){
|
||||
if(win.global.getSelection){
|
||||
//W3C Rangi API (FF, WebKit, Opera, etc)
|
||||
var sel = win.global.getSelection();
|
||||
if(sel && sel.removeAllRanges){
|
||||
if(mark.pRange){
|
||||
var n = mark.node;
|
||||
n.selectionStart = mark.start;
|
||||
n.selectionEnd = mark.end;
|
||||
}else{
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(mark);
|
||||
}
|
||||
}else{
|
||||
console.warn("No idea how to restore selection for this browser!");
|
||||
}
|
||||
}else if(_doc.selection && mark){
|
||||
//'IE' way.
|
||||
var rg;
|
||||
if(mark.pRange){
|
||||
rg = mark.range;
|
||||
}else if(lang.isArray(mark)){
|
||||
rg = _doc.body.createControlRange();
|
||||
//rg.addElement does not have call/apply method, so can not call it directly
|
||||
//rg is not available in "range.addElement(item)", so can't use that either
|
||||
array.forEach(mark, function(n){
|
||||
rg.addElement(n);
|
||||
});
|
||||
}else{
|
||||
rg = _doc.body.createTextRange();
|
||||
rg.moveToBookmark(mark);
|
||||
}
|
||||
rg.select();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getFocus: function(/*Widget?*/ menu, /*Window?*/ openedForWindow){
|
||||
// summary:
|
||||
// Called as getFocus(), this returns an Object showing the current focus
|
||||
// and selected text.
|
||||
//
|
||||
// Called as getFocus(widget), where widget is a (widget representing) a button
|
||||
// that was just pressed, it returns where focus was before that button
|
||||
// was pressed. (Pressing the button may have either shifted focus to the button,
|
||||
// or removed focus altogether.) In this case the selected text is not returned,
|
||||
// since it can't be accurately determined.
|
||||
//
|
||||
// menu: dijit._Widget or {domNode: DomNode} structure
|
||||
// The button that was just pressed. If focus has disappeared or moved
|
||||
// to this button, returns the previous focus. In this case the bookmark
|
||||
// information is already lost, and null is returned.
|
||||
//
|
||||
// openedForWindow:
|
||||
// iframe in which menu was opened
|
||||
//
|
||||
// returns:
|
||||
// A handle to restore focus/selection, to be passed to `dijit.focus`
|
||||
var node = !focus.curNode || (menu && dom.isDescendant(focus.curNode, menu.domNode)) ? dijit._prevFocus : focus.curNode;
|
||||
return {
|
||||
node: node,
|
||||
bookmark: node && (node == focus.curNode) && win.withGlobal(openedForWindow || win.global, dijit.getBookmark),
|
||||
openedForWindow: openedForWindow
|
||||
}; // Object
|
||||
},
|
||||
|
||||
// _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 <iframe> itself.
|
||||
// description:
|
||||
// Currently only used by editor.
|
||||
// returns:
|
||||
// Handle to pass to unregisterIframe()
|
||||
return focus.registerIframe(iframe);
|
||||
},
|
||||
|
||||
unregisterIframe: function(/*Object*/ handle){
|
||||
// summary:
|
||||
// Unregisters listeners on the specified iframe created by registerIframe.
|
||||
// After calling be sure to delete or null out the handle itself.
|
||||
// handle:
|
||||
// Handle returned by registerIframe()
|
||||
|
||||
handle && handle.remove();
|
||||
},
|
||||
|
||||
registerWin: function(/*Window?*/targetWindow, /*DomNode?*/ effectiveNode){
|
||||
// summary:
|
||||
// Registers listeners on the specified window (either the main
|
||||
// window or an iframe's window) to detect when the user has clicked somewhere
|
||||
// or focused somewhere.
|
||||
// description:
|
||||
// Users should call registerIframe() instead of this method.
|
||||
// targetWindow:
|
||||
// If specified this is the window associated with the iframe,
|
||||
// i.e. iframe.contentWindow.
|
||||
// effectiveNode:
|
||||
// If specified, report any focus events inside targetWindow as
|
||||
// an event on effectiveNode, rather than on evt.target.
|
||||
// returns:
|
||||
// Handle to pass to unregisterWin()
|
||||
|
||||
return focus.registerWin(targetWindow, effectiveNode);
|
||||
},
|
||||
|
||||
unregisterWin: function(/*Handle*/ handle){
|
||||
// summary:
|
||||
// Unregisters listeners on the specified window (either the main
|
||||
// window or an iframe's window) according to handle returned from registerWin().
|
||||
// After calling be sure to delete or null out the handle itself.
|
||||
|
||||
handle && handle.remove();
|
||||
}
|
||||
});
|
||||
|
||||
// Override focus singleton's focus function so that dijit.focus()
|
||||
// has backwards compatible behavior of restoring selection (although
|
||||
// probably no one is using that).
|
||||
focus.focus = function(/*Object || DomNode */ handle){
|
||||
// summary:
|
||||
// Sets the focused node and the selection according to argument.
|
||||
// To set focus to an iframe's content, pass in the iframe itself.
|
||||
// handle:
|
||||
// object returned by get(), or a DomNode
|
||||
|
||||
if(!handle){ return; }
|
||||
|
||||
var node = "node" in handle ? handle.node : handle, // because handle is either DomNode or a composite object
|
||||
bookmark = handle.bookmark,
|
||||
openedForWindow = handle.openedForWindow,
|
||||
collapsed = bookmark ? bookmark.isCollapsed : false;
|
||||
|
||||
// Set the focus
|
||||
// Note that for iframe's we need to use the <iframe> 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*/}
|
||||
}
|
||||
focus._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 && win.withGlobal(openedForWindow || win.global, dijit.isCollapsed) && !collapsed){
|
||||
if(openedForWindow){
|
||||
openedForWindow.focus();
|
||||
}
|
||||
try{
|
||||
win.withGlobal(openedForWindow || win.global, dijit.moveToBookmark, null, [bookmark]);
|
||||
}catch(e2){
|
||||
/*squelch IE internal error, see http://trac.dojotoolkit.org/ticket/1984 */
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// For back compatibility, monitor changes to focused node and active widget stack,
|
||||
// publishing events and copying changes from focus manager variables into dijit (top level) variables
|
||||
focus.watch("curNode", function(name, oldVal, newVal){
|
||||
dijit._curFocus = newVal;
|
||||
dijit._prevFocus = oldVal;
|
||||
if(newVal){
|
||||
topic.publish("focusNode", newVal); // publish
|
||||
}
|
||||
});
|
||||
focus.watch("activeStack", function(name, oldVal, newVal){
|
||||
dijit._activeStack = newVal;
|
||||
});
|
||||
|
||||
focus.on("widget-blur", function(widget, by){
|
||||
topic.publish("widgetBlur", widget, by); // publish
|
||||
});
|
||||
focus.on("widget-focus", function(widget, by){
|
||||
topic.publish("widgetFocus", widget, by); // publish
|
||||
});
|
||||
|
||||
return dijit;
|
||||
});
|
||||
@@ -1,493 +1,2 @@
|
||||
/*
|
||||
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.manager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.manager"] = true;
|
||||
dojo.provide("dijit._base.manager");
|
||||
|
||||
|
||||
dojo.declare("dijit.WidgetSet", null, {
|
||||
// summary:
|
||||
// A set of widgets indexed by id. A default instance of this class is
|
||||
// available as `dijit.registry`
|
||||
//
|
||||
// example:
|
||||
// Create a small list of widgets:
|
||||
// | var ws = new dijit.WidgetSet();
|
||||
// | ws.add(dijit.byId("one"));
|
||||
// | ws.add(dijit.byId("two"));
|
||||
// | // destroy both:
|
||||
// | ws.forEach(function(w){ w.destroy(); });
|
||||
//
|
||||
// example:
|
||||
// Using dijit.registry:
|
||||
// | dijit.registry.forEach(function(w){ /* do something */ });
|
||||
|
||||
constructor: function(){
|
||||
this._hash = {};
|
||||
this.length = 0;
|
||||
},
|
||||
|
||||
add: function(/*dijit._Widget*/ widget){
|
||||
// summary:
|
||||
// Add a widget to this list. If a duplicate ID is detected, a error is thrown.
|
||||
//
|
||||
// widget: dijit._Widget
|
||||
// Any dijit._Widget subclass.
|
||||
if(this._hash[widget.id]){
|
||||
throw new Error("Tried to register widget with id==" + widget.id + " but that id is already registered");
|
||||
}
|
||||
this._hash[widget.id] = widget;
|
||||
this.length++;
|
||||
},
|
||||
|
||||
remove: function(/*String*/ id){
|
||||
// summary:
|
||||
// Remove a widget from this WidgetSet. Does not destroy the widget; simply
|
||||
// removes the reference.
|
||||
if(this._hash[id]){
|
||||
delete this._hash[id];
|
||||
this.length--;
|
||||
}
|
||||
},
|
||||
|
||||
forEach: function(/*Function*/ func, /* Object? */thisObj){
|
||||
// summary:
|
||||
// Call specified function for each widget in this set.
|
||||
//
|
||||
// func:
|
||||
// A callback function to run for each item. Is passed the widget, the index
|
||||
// in the iteration, and the full hash, similar to `dojo.forEach`.
|
||||
//
|
||||
// thisObj:
|
||||
// An optional scope parameter
|
||||
//
|
||||
// example:
|
||||
// Using the default `dijit.registry` instance:
|
||||
// | dijit.registry.forEach(function(widget){
|
||||
// | console.log(widget.declaredClass);
|
||||
// | });
|
||||
//
|
||||
// returns:
|
||||
// Returns self, in order to allow for further chaining.
|
||||
|
||||
thisObj = thisObj || dojo.global;
|
||||
var i = 0, id;
|
||||
for(id in this._hash){
|
||||
func.call(thisObj, this._hash[id], i++, this._hash);
|
||||
}
|
||||
return this; // dijit.WidgetSet
|
||||
},
|
||||
|
||||
filter: function(/*Function*/ filter, /* Object? */thisObj){
|
||||
// summary:
|
||||
// Filter down this WidgetSet to a smaller new WidgetSet
|
||||
// Works the same as `dojo.filter` and `dojo.NodeList.filter`
|
||||
//
|
||||
// filter:
|
||||
// Callback function to test truthiness. Is passed the widget
|
||||
// reference and the pseudo-index in the object.
|
||||
//
|
||||
// thisObj: Object?
|
||||
// Option scope to use for the filter function.
|
||||
//
|
||||
// example:
|
||||
// Arbitrary: select the odd widgets in this list
|
||||
// | dijit.registry.filter(function(w, i){
|
||||
// | return i % 2 == 0;
|
||||
// | }).forEach(function(w){ /* odd ones */ });
|
||||
|
||||
thisObj = thisObj || dojo.global;
|
||||
var res = new dijit.WidgetSet(), i = 0, id;
|
||||
for(id in this._hash){
|
||||
var w = this._hash[id];
|
||||
if(filter.call(thisObj, w, i++, this._hash)){
|
||||
res.add(w);
|
||||
}
|
||||
}
|
||||
return res; // dijit.WidgetSet
|
||||
},
|
||||
|
||||
byId: function(/*String*/ id){
|
||||
// summary:
|
||||
// Find a widget in this list by it's id.
|
||||
// example:
|
||||
// Test if an id is in a particular WidgetSet
|
||||
// | var ws = new dijit.WidgetSet();
|
||||
// | ws.add(dijit.byId("bar"));
|
||||
// | var t = ws.byId("bar") // returns a widget
|
||||
// | var x = ws.byId("foo"); // returns undefined
|
||||
|
||||
return this._hash[id]; // dijit._Widget
|
||||
},
|
||||
|
||||
byClass: function(/*String*/ cls){
|
||||
// summary:
|
||||
// Reduce this widgetset to a new WidgetSet of a particular `declaredClass`
|
||||
//
|
||||
// cls: String
|
||||
// The Class to scan for. Full dot-notated string.
|
||||
//
|
||||
// example:
|
||||
// Find all `dijit.TitlePane`s in a page:
|
||||
// | dijit.registry.byClass("dijit.TitlePane").forEach(function(tp){ tp.close(); });
|
||||
|
||||
var res = new dijit.WidgetSet(), id, widget;
|
||||
for(id in this._hash){
|
||||
widget = this._hash[id];
|
||||
if(widget.declaredClass == cls){
|
||||
res.add(widget);
|
||||
}
|
||||
}
|
||||
return res; // dijit.WidgetSet
|
||||
},
|
||||
|
||||
toArray: function(){
|
||||
// summary:
|
||||
// Convert this WidgetSet into a true Array
|
||||
//
|
||||
// example:
|
||||
// Work with the widget .domNodes in a real Array
|
||||
// | dojo.map(dijit.registry.toArray(), function(w){ return w.domNode; });
|
||||
|
||||
var ar = [];
|
||||
for(var id in this._hash){
|
||||
ar.push(this._hash[id]);
|
||||
}
|
||||
return ar; // dijit._Widget[]
|
||||
},
|
||||
|
||||
map: function(/* Function */func, /* Object? */thisObj){
|
||||
// summary:
|
||||
// Create a new Array from this WidgetSet, following the same rules as `dojo.map`
|
||||
// example:
|
||||
// | var nodes = dijit.registry.map(function(w){ return w.domNode; });
|
||||
//
|
||||
// returns:
|
||||
// A new array of the returned values.
|
||||
return dojo.map(this.toArray(), func, thisObj); // Array
|
||||
},
|
||||
|
||||
every: function(func, thisObj){
|
||||
// summary:
|
||||
// A synthetic clone of `dojo.every` acting explicitly on this WidgetSet
|
||||
//
|
||||
// func: Function
|
||||
// A callback function run for every widget in this list. Exits loop
|
||||
// when the first false return is encountered.
|
||||
//
|
||||
// thisObj: Object?
|
||||
// Optional scope parameter to use for the callback
|
||||
|
||||
thisObj = thisObj || dojo.global;
|
||||
var x = 0, i;
|
||||
for(i in this._hash){
|
||||
if(!func.call(thisObj, this._hash[i], x++, this._hash)){
|
||||
return false; // Boolean
|
||||
}
|
||||
}
|
||||
return true; // Boolean
|
||||
},
|
||||
|
||||
some: function(func, thisObj){
|
||||
// summary:
|
||||
// A synthetic clone of `dojo.some` acting explictly on this WidgetSet
|
||||
//
|
||||
// func: Function
|
||||
// A callback function run for every widget in this list. Exits loop
|
||||
// when the first true return is encountered.
|
||||
//
|
||||
// thisObj: Object?
|
||||
// Optional scope parameter to use for the callback
|
||||
|
||||
thisObj = thisObj || dojo.global;
|
||||
var x = 0, i;
|
||||
for(i in this._hash){
|
||||
if(func.call(thisObj, this._hash[i], x++, this._hash)){
|
||||
return true; // Boolean
|
||||
}
|
||||
}
|
||||
return false; // Boolean
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
(function(){
|
||||
|
||||
/*=====
|
||||
dijit.registry = {
|
||||
// summary:
|
||||
// A list of widgets on a page.
|
||||
// description:
|
||||
// Is an instance of `dijit.WidgetSet`
|
||||
};
|
||||
=====*/
|
||||
dijit.registry = new dijit.WidgetSet();
|
||||
|
||||
var hash = dijit.registry._hash,
|
||||
attr = dojo.attr,
|
||||
hasAttr = dojo.hasAttr,
|
||||
style = dojo.style;
|
||||
|
||||
dijit.byId = function(/*String|dijit._Widget*/ id){
|
||||
// summary:
|
||||
// Returns a widget by it's id, or if passed a widget, no-op (like dojo.byId())
|
||||
return typeof id == "string" ? hash[id] : id; // dijit._Widget
|
||||
};
|
||||
|
||||
var _widgetTypeCtr = {};
|
||||
dijit.getUniqueId = function(/*String*/widgetType){
|
||||
// summary:
|
||||
// Generates a unique id for a given widgetType
|
||||
|
||||
var id;
|
||||
do{
|
||||
id = widgetType + "_" +
|
||||
(widgetType in _widgetTypeCtr ?
|
||||
++_widgetTypeCtr[widgetType] : _widgetTypeCtr[widgetType] = 0);
|
||||
}while(hash[id]);
|
||||
return dijit._scopeName == "dijit" ? id : dijit._scopeName + "_" + id; // String
|
||||
};
|
||||
|
||||
dijit.findWidgets = function(/*DomNode*/ root){
|
||||
// summary:
|
||||
// Search subtree under root returning widgets found.
|
||||
// Doesn't search for nested widgets (ie, widgets inside other widgets).
|
||||
|
||||
var outAry = [];
|
||||
|
||||
function getChildrenHelper(root){
|
||||
for(var node = root.firstChild; node; node = node.nextSibling){
|
||||
if(node.nodeType == 1){
|
||||
var widgetId = node.getAttribute("widgetId");
|
||||
if(widgetId){
|
||||
var widget = hash[widgetId];
|
||||
if(widget){ // may be null on page w/multiple dojo's loaded
|
||||
outAry.push(widget);
|
||||
}
|
||||
}else{
|
||||
getChildrenHelper(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getChildrenHelper(root);
|
||||
return outAry;
|
||||
};
|
||||
|
||||
dijit._destroyAll = function(){
|
||||
// summary:
|
||||
// Code to destroy all widgets and do other cleanup on page unload
|
||||
|
||||
// Clean up focus manager lingering references to widgets and nodes
|
||||
dijit._curFocus = null;
|
||||
dijit._prevFocus = null;
|
||||
dijit._activeStack = [];
|
||||
|
||||
// Destroy all the widgets, top down
|
||||
dojo.forEach(dijit.findWidgets(dojo.body()), function(widget){
|
||||
// Avoid double destroy of widgets like Menu that are attached to <body>
|
||||
// even though they are logically children of other widgets.
|
||||
if(!widget._destroyed){
|
||||
if(widget.destroyRecursive){
|
||||
widget.destroyRecursive();
|
||||
}else if(widget.destroy){
|
||||
widget.destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if(dojo.isIE){
|
||||
// Only run _destroyAll() for IE because we think it's only necessary in that case,
|
||||
// and because it causes problems on FF. See bug #3531 for details.
|
||||
dojo.addOnWindowUnload(function(){
|
||||
dijit._destroyAll();
|
||||
});
|
||||
}
|
||||
|
||||
dijit.byNode = function(/*DOMNode*/ node){
|
||||
// summary:
|
||||
// Returns the widget corresponding to the given DOMNode
|
||||
return hash[node.getAttribute("widgetId")]; // dijit._Widget
|
||||
};
|
||||
|
||||
dijit.getEnclosingWidget = function(/*DOMNode*/ node){
|
||||
// summary:
|
||||
// Returns the widget whose DOM tree contains the specified DOMNode, or null if
|
||||
// the node is not contained within the DOM tree of any widget
|
||||
while(node){
|
||||
var id = node.getAttribute && node.getAttribute("widgetId");
|
||||
if(id){
|
||||
return hash[id];
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
var shown = (dijit._isElementShown = function(/*Element*/ elem){
|
||||
var s = style(elem);
|
||||
return (s.visibility != "hidden")
|
||||
&& (s.visibility != "collapsed")
|
||||
&& (s.display != "none")
|
||||
&& (attr(elem, "type") != "hidden");
|
||||
});
|
||||
|
||||
dijit.hasDefaultTabStop = function(/*Element*/ elem){
|
||||
// summary:
|
||||
// Tests if element is tab-navigable even without an explicit tabIndex setting
|
||||
|
||||
// No explicit tabIndex setting, need to investigate node type
|
||||
switch(elem.nodeName.toLowerCase()){
|
||||
case "a":
|
||||
// An <a> w/out a tabindex is only navigable if it has an href
|
||||
return hasAttr(elem, "href");
|
||||
case "area":
|
||||
case "button":
|
||||
case "input":
|
||||
case "object":
|
||||
case "select":
|
||||
case "textarea":
|
||||
// These are navigable by default
|
||||
return true;
|
||||
case "iframe":
|
||||
// If it's an editor <iframe> then it's tab navigable.
|
||||
var body;
|
||||
try{
|
||||
// non-IE
|
||||
var contentDocument = elem.contentDocument;
|
||||
if("designMode" in contentDocument && contentDocument.designMode == "on"){
|
||||
return true;
|
||||
}
|
||||
body = contentDocument.body;
|
||||
}catch(e1){
|
||||
// contentWindow.document isn't accessible within IE7/8
|
||||
// if the iframe.src points to a foreign url and this
|
||||
// page contains an element, that could get focus
|
||||
try{
|
||||
body = elem.contentWindow.document.body;
|
||||
}catch(e2){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return body.contentEditable == 'true' || (body.firstChild && body.firstChild.contentEditable == 'true');
|
||||
default:
|
||||
return elem.contentEditable == 'true';
|
||||
}
|
||||
};
|
||||
|
||||
var isTabNavigable = (dijit.isTabNavigable = function(/*Element*/ elem){
|
||||
// summary:
|
||||
// Tests if an element is tab-navigable
|
||||
|
||||
// TODO: convert (and rename method) to return effective tabIndex; will save time in _getTabNavigable()
|
||||
if(attr(elem, "disabled")){
|
||||
return false;
|
||||
}else if(hasAttr(elem, "tabIndex")){
|
||||
// Explicit tab index setting
|
||||
return attr(elem, "tabIndex") >= 0; // boolean
|
||||
}else{
|
||||
// No explicit tabIndex setting, so depends on node type
|
||||
return dijit.hasDefaultTabStop(elem);
|
||||
}
|
||||
});
|
||||
|
||||
dijit._getTabNavigable = function(/*DOMNode*/ root){
|
||||
// summary:
|
||||
// Finds descendants of the specified root node.
|
||||
//
|
||||
// description:
|
||||
// Finds the following descendants of the specified root node:
|
||||
// * the first tab-navigable element in document order
|
||||
// without a tabIndex or with tabIndex="0"
|
||||
// * the last tab-navigable element in document order
|
||||
// without a tabIndex or with tabIndex="0"
|
||||
// * the first element in document order with the lowest
|
||||
// positive tabIndex value
|
||||
// * the last element in document order with the highest
|
||||
// positive tabIndex value
|
||||
var first, last, lowest, lowestTabindex, highest, highestTabindex, radioSelected = {};
|
||||
function radioName(node) {
|
||||
// If this element is part of a radio button group, return the name for that group.
|
||||
return node && node.tagName.toLowerCase() == "input" &&
|
||||
node.type && node.type.toLowerCase() == "radio" &&
|
||||
node.name && node.name.toLowerCase();
|
||||
}
|
||||
var walkTree = function(/*DOMNode*/parent){
|
||||
dojo.query("> *", parent).forEach(function(child){
|
||||
// Skip hidden elements, and also non-HTML elements (those in custom namespaces) in IE,
|
||||
// since show() invokes getAttribute("type"), which crash on VML nodes in IE.
|
||||
if((dojo.isIE && child.scopeName!=="HTML") || !shown(child)){
|
||||
return;
|
||||
}
|
||||
|
||||
if(isTabNavigable(child)){
|
||||
var tabindex = attr(child, "tabIndex");
|
||||
if(!hasAttr(child, "tabIndex") || tabindex == 0){
|
||||
if(!first){ first = child; }
|
||||
last = child;
|
||||
}else if(tabindex > 0){
|
||||
if(!lowest || tabindex < lowestTabindex){
|
||||
lowestTabindex = tabindex;
|
||||
lowest = child;
|
||||
}
|
||||
if(!highest || tabindex >= highestTabindex){
|
||||
highestTabindex = tabindex;
|
||||
highest = child;
|
||||
}
|
||||
}
|
||||
var rn = radioName(child);
|
||||
if(dojo.attr(child, "checked") && rn) {
|
||||
radioSelected[rn] = child;
|
||||
}
|
||||
}
|
||||
if(child.nodeName.toUpperCase() != 'SELECT'){
|
||||
walkTree(child);
|
||||
}
|
||||
});
|
||||
};
|
||||
if(shown(root)){ walkTree(root) }
|
||||
function rs(node) {
|
||||
// substitute checked radio button for unchecked one, if there is a checked one with the same name.
|
||||
return radioSelected[radioName(node)] || node;
|
||||
}
|
||||
return { first: rs(first), last: rs(last), lowest: rs(lowest), highest: rs(highest) };
|
||||
}
|
||||
dijit.getFirstInTabbingOrder = function(/*String|DOMNode*/ root){
|
||||
// summary:
|
||||
// Finds the descendant of the specified root node
|
||||
// that is first in the tabbing order
|
||||
var elems = dijit._getTabNavigable(dojo.byId(root));
|
||||
return elems.lowest ? elems.lowest : elems.first; // DomNode
|
||||
};
|
||||
|
||||
dijit.getLastInTabbingOrder = function(/*String|DOMNode*/ root){
|
||||
// summary:
|
||||
// Finds the descendant of the specified root node
|
||||
// that is last in the tabbing order
|
||||
var elems = dijit._getTabNavigable(dojo.byId(root));
|
||||
return elems.last ? elems.last : elems.highest; // DomNode
|
||||
};
|
||||
|
||||
/*=====
|
||||
dojo.mixin(dijit, {
|
||||
// defaultDuration: Integer
|
||||
// The default animation speed (in ms) to use for all Dijit
|
||||
// transitional animations, unless otherwise specified
|
||||
// on a per-instance basis. Defaults to 200, overrided by
|
||||
// `djConfig.defaultDuration`
|
||||
defaultDuration: 200
|
||||
});
|
||||
=====*/
|
||||
|
||||
dijit.defaultDuration = dojo.config["defaultDuration"] || 200;
|
||||
|
||||
})();
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/manager",["dojo/_base/array","dojo/_base/config","../registry",".."],function(_1,_2,_3,_4){_1.forEach(["byId","getUniqueId","findWidgets","_destroyAll","byNode","getEnclosingWidget"],function(_5){_4[_5]=_3[_5];});_4.defaultDuration=_2["defaultDuration"]||200;return _4;});
|
||||
76
lib/dijit/_base/manager.js.uncompressed.js
Normal file
76
lib/dijit/_base/manager.js.uncompressed.js
Normal file
@@ -0,0 +1,76 @@
|
||||
define("dijit/_base/manager", [
|
||||
"dojo/_base/array",
|
||||
"dojo/_base/config", // defaultDuration
|
||||
"../registry",
|
||||
".." // for setting exports to dijit namespace
|
||||
], function(array, config, registry, dijit){
|
||||
|
||||
// module:
|
||||
// dijit/_base/manager
|
||||
// summary:
|
||||
// Shim to methods on registry, plus a few other declarations.
|
||||
// New code should access dijit/registry directly when possible.
|
||||
|
||||
/*=====
|
||||
dijit.byId = function(id){
|
||||
// summary:
|
||||
// Returns a widget by it's id, or if passed a widget, no-op (like dom.byId())
|
||||
// id: String|dijit._Widget
|
||||
return registry.byId(id); // dijit._Widget
|
||||
};
|
||||
|
||||
dijit.getUniqueId = function(widgetType){
|
||||
// summary:
|
||||
// Generates a unique id for a given widgetType
|
||||
// widgetType: String
|
||||
return registry.getUniqueId(widgetType); // String
|
||||
};
|
||||
|
||||
dijit.findWidgets = function(root){
|
||||
// summary:
|
||||
// Search subtree under root returning widgets found.
|
||||
// Doesn't search for nested widgets (ie, widgets inside other widgets).
|
||||
// root: DOMNode
|
||||
return registry.findWidgets(root);
|
||||
};
|
||||
|
||||
dijit._destroyAll = function(){
|
||||
// summary:
|
||||
// Code to destroy all widgets and do other cleanup on page unload
|
||||
|
||||
return registry._destroyAll();
|
||||
};
|
||||
|
||||
dijit.byNode = function(node){
|
||||
// summary:
|
||||
// Returns the widget corresponding to the given DOMNode
|
||||
// node: DOMNode
|
||||
return registry.byNode(node); // dijit._Widget
|
||||
};
|
||||
|
||||
dijit.getEnclosingWidget = function(node){
|
||||
// summary:
|
||||
// Returns the widget whose DOM tree contains the specified DOMNode, or null if
|
||||
// the node is not contained within the DOM tree of any widget
|
||||
// node: DOMNode
|
||||
return registry.getEnclosingWidget(node);
|
||||
};
|
||||
=====*/
|
||||
array.forEach(["byId", "getUniqueId", "findWidgets", "_destroyAll", "byNode", "getEnclosingWidget"], function(name){
|
||||
dijit[name] = registry[name];
|
||||
});
|
||||
|
||||
/*=====
|
||||
dojo.mixin(dijit, {
|
||||
// defaultDuration: Integer
|
||||
// The default fx.animation speed (in ms) to use for all Dijit
|
||||
// transitional fx.animations, unless otherwise specified
|
||||
// on a per-instance basis. Defaults to 200, overrided by
|
||||
// `djConfig.defaultDuration`
|
||||
defaultDuration: 200
|
||||
});
|
||||
=====*/
|
||||
dijit.defaultDuration = config["defaultDuration"] || 200;
|
||||
|
||||
return dijit;
|
||||
});
|
||||
@@ -1,376 +1,2 @@
|
||||
/*
|
||||
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.place"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.place"] = true;
|
||||
dojo.provide("dijit._base.place");
|
||||
dojo.require("dojo.window");
|
||||
dojo.require("dojo.AdapterRegistry");
|
||||
|
||||
|
||||
dijit.getViewport = function(){
|
||||
// summary:
|
||||
// Returns the dimensions and scroll position of the viewable area of a browser window
|
||||
|
||||
return dojo.window.getBox();
|
||||
};
|
||||
|
||||
/*=====
|
||||
dijit.__Position = function(){
|
||||
// x: Integer
|
||||
// horizontal coordinate in pixels, relative to document body
|
||||
// y: Integer
|
||||
// vertical coordinate in pixels, relative to document body
|
||||
|
||||
thix.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
=====*/
|
||||
|
||||
|
||||
dijit.placeOnScreen = function(
|
||||
/* DomNode */ node,
|
||||
/* dijit.__Position */ pos,
|
||||
/* String[] */ corners,
|
||||
/* dijit.__Position? */ padding){
|
||||
// summary:
|
||||
// Positions one of the node's corners at specified position
|
||||
// such that node is fully visible in viewport.
|
||||
// description:
|
||||
// NOTE: node is assumed to be absolutely or relatively positioned.
|
||||
// pos:
|
||||
// Object like {x: 10, y: 20}
|
||||
// corners:
|
||||
// Array of Strings representing order to try corners in, like ["TR", "BL"].
|
||||
// Possible values are:
|
||||
// * "BL" - bottom left
|
||||
// * "BR" - bottom right
|
||||
// * "TL" - top left
|
||||
// * "TR" - top right
|
||||
// padding:
|
||||
// set padding to put some buffer around the element you want to position.
|
||||
// example:
|
||||
// Try to place node's top right corner at (10,20).
|
||||
// If that makes node go (partially) off screen, then try placing
|
||||
// bottom left corner at (10,20).
|
||||
// | placeOnScreen(node, {x: 10, y: 20}, ["TR", "BL"])
|
||||
|
||||
var choices = dojo.map(corners, function(corner){
|
||||
var c = { corner: corner, pos: {x:pos.x,y:pos.y} };
|
||||
if(padding){
|
||||
c.pos.x += corner.charAt(1) == 'L' ? padding.x : -padding.x;
|
||||
c.pos.y += corner.charAt(0) == 'T' ? padding.y : -padding.y;
|
||||
}
|
||||
return c;
|
||||
});
|
||||
|
||||
return dijit._place(node, choices);
|
||||
}
|
||||
|
||||
dijit._place = function(/*DomNode*/ node, choices, layoutNode, /*Object*/ aroundNodeCoords){
|
||||
// summary:
|
||||
// Given a list of spots to put node, put it at the first spot where it fits,
|
||||
// of if it doesn't fit anywhere then the place with the least overflow
|
||||
// choices: Array
|
||||
// Array of elements like: {corner: 'TL', pos: {x: 10, y: 20} }
|
||||
// Above example says to put the top-left corner of the node at (10,20)
|
||||
// layoutNode: Function(node, aroundNodeCorner, nodeCorner, size)
|
||||
// for things like tooltip, they are displayed differently (and have different dimensions)
|
||||
// based on their orientation relative to the parent. This adjusts the popup based on orientation.
|
||||
// It also passes in the available size for the popup, which is useful for tooltips to
|
||||
// tell them that their width is limited to a certain amount. layoutNode() may return a value expressing
|
||||
// how much the popup had to be modified to fit into the available space. This is used to determine
|
||||
// what the best placement is.
|
||||
// aroundNodeCoords: Object
|
||||
// Size of aroundNode, ex: {w: 200, h: 50}
|
||||
|
||||
// get {x: 10, y: 10, w: 100, h:100} type obj representing position of
|
||||
// viewport over document
|
||||
var view = dojo.window.getBox();
|
||||
|
||||
// This won't work if the node is inside a <div style="position: relative">,
|
||||
// so reattach it to dojo.doc.body. (Otherwise, the positioning will be wrong
|
||||
// and also it might get cutoff)
|
||||
if(!node.parentNode || String(node.parentNode.tagName).toLowerCase() != "body"){
|
||||
dojo.body().appendChild(node);
|
||||
}
|
||||
|
||||
var best = null;
|
||||
dojo.some(choices, function(choice){
|
||||
var corner = choice.corner;
|
||||
var pos = choice.pos;
|
||||
var overflow = 0;
|
||||
|
||||
// calculate amount of space available given specified position of node
|
||||
var spaceAvailable = {
|
||||
w: corner.charAt(1) == 'L' ? (view.l + view.w) - pos.x : pos.x - view.l,
|
||||
h: corner.charAt(1) == 'T' ? (view.t + view.h) - pos.y : pos.y - view.t
|
||||
};
|
||||
|
||||
// configure node to be displayed in given position relative to button
|
||||
// (need to do this in order to get an accurate size for the node, because
|
||||
// a tooltip's size changes based on position, due to triangle)
|
||||
if(layoutNode){
|
||||
var res = layoutNode(node, choice.aroundCorner, corner, spaceAvailable, aroundNodeCoords);
|
||||
overflow = typeof res == "undefined" ? 0 : res;
|
||||
}
|
||||
|
||||
// get node's size
|
||||
var style = node.style;
|
||||
var oldDisplay = style.display;
|
||||
var oldVis = style.visibility;
|
||||
style.visibility = "hidden";
|
||||
style.display = "";
|
||||
var mb = dojo.marginBox(node);
|
||||
style.display = oldDisplay;
|
||||
style.visibility = oldVis;
|
||||
|
||||
// coordinates and size of node with specified corner placed at pos,
|
||||
// and clipped by viewport
|
||||
var startX = Math.max(view.l, corner.charAt(1) == 'L' ? pos.x : (pos.x - mb.w)),
|
||||
startY = Math.max(view.t, corner.charAt(0) == 'T' ? pos.y : (pos.y - mb.h)),
|
||||
endX = Math.min(view.l + view.w, corner.charAt(1) == 'L' ? (startX + mb.w) : pos.x),
|
||||
endY = Math.min(view.t + view.h, corner.charAt(0) == 'T' ? (startY + mb.h) : pos.y),
|
||||
width = endX - startX,
|
||||
height = endY - startY;
|
||||
|
||||
overflow += (mb.w - width) + (mb.h - height);
|
||||
|
||||
if(best == null || overflow < best.overflow){
|
||||
best = {
|
||||
corner: corner,
|
||||
aroundCorner: choice.aroundCorner,
|
||||
x: startX,
|
||||
y: startY,
|
||||
w: width,
|
||||
h: height,
|
||||
overflow: overflow,
|
||||
spaceAvailable: spaceAvailable
|
||||
};
|
||||
}
|
||||
|
||||
return !overflow;
|
||||
});
|
||||
|
||||
// In case the best position is not the last one we checked, need to call
|
||||
// layoutNode() again.
|
||||
if(best.overflow && layoutNode){
|
||||
layoutNode(node, best.aroundCorner, best.corner, best.spaceAvailable, aroundNodeCoords);
|
||||
}
|
||||
|
||||
// And then position the node. Do this last, after the layoutNode() above
|
||||
// has sized the node, due to browser quirks when the viewport is scrolled
|
||||
// (specifically that a Tooltip will shrink to fit as though the window was
|
||||
// scrolled to the left).
|
||||
//
|
||||
// In RTL mode, set style.right rather than style.left so in the common case,
|
||||
// window resizes move the popup along with the aroundNode.
|
||||
var l = dojo._isBodyLtr(),
|
||||
s = node.style;
|
||||
s.top = best.y + "px";
|
||||
s[l ? "left" : "right"] = (l ? best.x : view.w - best.x - best.w) + "px";
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
dijit.placeOnScreenAroundNode = function(
|
||||
/* DomNode */ node,
|
||||
/* DomNode */ aroundNode,
|
||||
/* Object */ aroundCorners,
|
||||
/* Function? */ layoutNode){
|
||||
|
||||
// summary:
|
||||
// Position node adjacent or kitty-corner to aroundNode
|
||||
// such that it's fully visible in viewport.
|
||||
//
|
||||
// description:
|
||||
// Place node such that corner of node touches a corner of
|
||||
// aroundNode, and that node is fully visible.
|
||||
//
|
||||
// aroundCorners:
|
||||
// Ordered list of pairs of corners to try matching up.
|
||||
// Each pair of corners is represented as a key/value in the hash,
|
||||
// where the key corresponds to the aroundNode's corner, and
|
||||
// the value corresponds to the node's corner:
|
||||
//
|
||||
// | { aroundNodeCorner1: nodeCorner1, aroundNodeCorner2: nodeCorner2, ...}
|
||||
//
|
||||
// The following strings are used to represent the four corners:
|
||||
// * "BL" - bottom left
|
||||
// * "BR" - bottom right
|
||||
// * "TL" - top left
|
||||
// * "TR" - top right
|
||||
//
|
||||
// layoutNode: Function(node, aroundNodeCorner, nodeCorner)
|
||||
// For things like tooltip, they are displayed differently (and have different dimensions)
|
||||
// based on their orientation relative to the parent. This adjusts the popup based on orientation.
|
||||
//
|
||||
// example:
|
||||
// | dijit.placeOnScreenAroundNode(node, aroundNode, {'BL':'TL', 'TR':'BR'});
|
||||
// This will try to position node such that node's top-left corner is at the same position
|
||||
// as the bottom left corner of the aroundNode (ie, put node below
|
||||
// aroundNode, with left edges aligned). If that fails it will try to put
|
||||
// the bottom-right corner of node where the top right corner of aroundNode is
|
||||
// (ie, put node above aroundNode, with right edges aligned)
|
||||
//
|
||||
|
||||
// get coordinates of aroundNode
|
||||
aroundNode = dojo.byId(aroundNode);
|
||||
var aroundNodePos = dojo.position(aroundNode, true);
|
||||
|
||||
// place the node around the calculated rectangle
|
||||
return dijit._placeOnScreenAroundRect(node,
|
||||
aroundNodePos.x, aroundNodePos.y, aroundNodePos.w, aroundNodePos.h, // rectangle
|
||||
aroundCorners, layoutNode);
|
||||
};
|
||||
|
||||
/*=====
|
||||
dijit.__Rectangle = function(){
|
||||
// x: Integer
|
||||
// horizontal offset in pixels, relative to document body
|
||||
// y: Integer
|
||||
// vertical offset in pixels, relative to document body
|
||||
// width: Integer
|
||||
// width in pixels
|
||||
// height: Integer
|
||||
// height in pixels
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
=====*/
|
||||
|
||||
|
||||
dijit.placeOnScreenAroundRectangle = function(
|
||||
/* DomNode */ node,
|
||||
/* dijit.__Rectangle */ aroundRect,
|
||||
/* Object */ aroundCorners,
|
||||
/* Function */ layoutNode){
|
||||
|
||||
// summary:
|
||||
// Like dijit.placeOnScreenAroundNode(), except that the "around"
|
||||
// parameter is an arbitrary rectangle on the screen (x, y, width, height)
|
||||
// instead of a dom node.
|
||||
|
||||
return dijit._placeOnScreenAroundRect(node,
|
||||
aroundRect.x, aroundRect.y, aroundRect.width, aroundRect.height, // rectangle
|
||||
aroundCorners, layoutNode);
|
||||
};
|
||||
|
||||
dijit._placeOnScreenAroundRect = function(
|
||||
/* DomNode */ node,
|
||||
/* Number */ x,
|
||||
/* Number */ y,
|
||||
/* Number */ width,
|
||||
/* Number */ height,
|
||||
/* Object */ aroundCorners,
|
||||
/* Function */ layoutNode){
|
||||
|
||||
// summary:
|
||||
// Like dijit.placeOnScreenAroundNode(), except it accepts coordinates
|
||||
// of a rectangle to place node adjacent to.
|
||||
|
||||
// TODO: combine with placeOnScreenAroundRectangle()
|
||||
|
||||
// Generate list of possible positions for node
|
||||
var choices = [];
|
||||
for(var nodeCorner in aroundCorners){
|
||||
choices.push( {
|
||||
aroundCorner: nodeCorner,
|
||||
corner: aroundCorners[nodeCorner],
|
||||
pos: {
|
||||
x: x + (nodeCorner.charAt(1) == 'L' ? 0 : width),
|
||||
y: y + (nodeCorner.charAt(0) == 'T' ? 0 : height)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return dijit._place(node, choices, layoutNode, {w: width, h: height});
|
||||
};
|
||||
|
||||
dijit.placementRegistry= new dojo.AdapterRegistry();
|
||||
dijit.placementRegistry.register("node",
|
||||
function(n, x){
|
||||
return typeof x == "object" &&
|
||||
typeof x.offsetWidth != "undefined" && typeof x.offsetHeight != "undefined";
|
||||
},
|
||||
dijit.placeOnScreenAroundNode);
|
||||
dijit.placementRegistry.register("rect",
|
||||
function(n, x){
|
||||
return typeof x == "object" &&
|
||||
"x" in x && "y" in x && "width" in x && "height" in x;
|
||||
},
|
||||
dijit.placeOnScreenAroundRectangle);
|
||||
|
||||
dijit.placeOnScreenAroundElement = function(
|
||||
/* DomNode */ node,
|
||||
/* Object */ aroundElement,
|
||||
/* Object */ aroundCorners,
|
||||
/* Function */ layoutNode){
|
||||
|
||||
// summary:
|
||||
// Like dijit.placeOnScreenAroundNode(), except it accepts an arbitrary object
|
||||
// for the "around" argument and finds a proper processor to place a node.
|
||||
|
||||
return dijit.placementRegistry.match.apply(dijit.placementRegistry, arguments);
|
||||
};
|
||||
|
||||
dijit.getPopupAroundAlignment = function(/*Array*/ position, /*Boolean*/ leftToRight){
|
||||
// summary:
|
||||
// Transforms the passed array of preferred positions into a format suitable for passing as the aroundCorners argument to dijit.placeOnScreenAroundElement.
|
||||
//
|
||||
// position: String[]
|
||||
// This variable controls the position of the drop down.
|
||||
// It's an array of strings with the following values:
|
||||
//
|
||||
// * before: places drop down to the left of the target node/widget, or to the right in
|
||||
// the case of RTL scripts like Hebrew and Arabic
|
||||
// * after: places drop down to the right of the target node/widget, or to the left in
|
||||
// the case of RTL scripts like Hebrew and Arabic
|
||||
// * above: drop down goes above target node
|
||||
// * below: drop down goes below target node
|
||||
//
|
||||
// The list is positions is tried, in order, until a position is found where the drop down fits
|
||||
// within the viewport.
|
||||
//
|
||||
// leftToRight: Boolean
|
||||
// Whether the popup will be displaying in leftToRight mode.
|
||||
//
|
||||
var align = {};
|
||||
dojo.forEach(position, function(pos){
|
||||
switch(pos){
|
||||
case "after":
|
||||
align[leftToRight ? "BR" : "BL"] = leftToRight ? "BL" : "BR";
|
||||
break;
|
||||
case "before":
|
||||
align[leftToRight ? "BL" : "BR"] = leftToRight ? "BR" : "BL";
|
||||
break;
|
||||
case "below-alt":
|
||||
leftToRight = !leftToRight;
|
||||
// fall through
|
||||
case "below":
|
||||
// first try to align left borders, next try to align right borders (or reverse for RTL mode)
|
||||
align[leftToRight ? "BL" : "BR"] = leftToRight ? "TL" : "TR";
|
||||
align[leftToRight ? "BR" : "BL"] = leftToRight ? "TR" : "TL";
|
||||
break;
|
||||
case "above-alt":
|
||||
leftToRight = !leftToRight;
|
||||
// fall through
|
||||
case "above":
|
||||
default:
|
||||
// first try to align left borders, next try to align right borders (or reverse for RTL mode)
|
||||
align[leftToRight ? "TL" : "TR"] = leftToRight ? "BL" : "BR";
|
||||
align[leftToRight ? "TR" : "TL"] = leftToRight ? "BR" : "BL";
|
||||
break;
|
||||
}
|
||||
});
|
||||
return align;
|
||||
};
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/place",["dojo/_base/array","dojo/_base/lang","dojo/window","../place",".."],function(_1,_2,_3,_4,_5){_5.getViewport=function(){return _3.getBox();};_5.placeOnScreen=_4.at;_5.placeOnScreenAroundElement=function(_6,_7,_8,_9){var _a;if(_2.isArray(_8)){_a=_8;}else{_a=[];for(var _b in _8){_a.push({aroundCorner:_b,corner:_8[_b]});}}return _4.around(_6,_7,_a,true,_9);};_5.placeOnScreenAroundNode=_5.placeOnScreenAroundElement;_5.placeOnScreenAroundRectangle=_5.placeOnScreenAroundElement;_5.getPopupAroundAlignment=function(_c,_d){var _e={};_1.forEach(_c,function(_f){var ltr=_d;switch(_f){case "after":_e[_d?"BR":"BL"]=_d?"BL":"BR";break;case "before":_e[_d?"BL":"BR"]=_d?"BR":"BL";break;case "below-alt":ltr=!ltr;case "below":_e[ltr?"BL":"BR"]=ltr?"TL":"TR";_e[ltr?"BR":"BL"]=ltr?"TR":"TL";break;case "above-alt":ltr=!ltr;case "above":default:_e[ltr?"TL":"TR"]=ltr?"BL":"BR";_e[ltr?"TR":"TL"]=ltr?"BR":"BL";break;}});return _e;};return _5;});
|
||||
137
lib/dijit/_base/place.js.uncompressed.js
Normal file
137
lib/dijit/_base/place.js.uncompressed.js
Normal file
@@ -0,0 +1,137 @@
|
||||
define("dijit/_base/place", [
|
||||
"dojo/_base/array", // array.forEach
|
||||
"dojo/_base/lang", // lang.isArray
|
||||
"dojo/window", // windowUtils.getBox
|
||||
"../place",
|
||||
".." // export to dijit namespace
|
||||
], function(array, lang, windowUtils, place, dijit){
|
||||
|
||||
// module:
|
||||
// dijit/_base/place
|
||||
// summary:
|
||||
// Back compatibility module, new code should use dijit/place directly instead of using this module.
|
||||
|
||||
dijit.getViewport = function(){
|
||||
// summary:
|
||||
// Deprecated method to return the dimensions and scroll position of the viewable area of a browser window.
|
||||
// New code should use windowUtils.getBox()
|
||||
|
||||
return windowUtils.getBox();
|
||||
};
|
||||
|
||||
/*=====
|
||||
dijit.placeOnScreen = function(node, pos, corners, padding){
|
||||
// summary:
|
||||
// Positions one of the node's corners at specified position
|
||||
// such that node is fully visible in viewport.
|
||||
// Deprecated, new code should use dijit.place.at() instead.
|
||||
};
|
||||
=====*/
|
||||
dijit.placeOnScreen = place.at;
|
||||
|
||||
/*=====
|
||||
dijit.placeOnScreenAroundElement = function(node, aroundElement, aroundCorners, layoutNode){
|
||||
// summary:
|
||||
// Like dijit.placeOnScreenAroundNode(), except it accepts an arbitrary object
|
||||
// for the "around" argument and finds a proper processor to place a node.
|
||||
// Deprecated, new code should use dijit.place.around() instead.
|
||||
};
|
||||
====*/
|
||||
dijit.placeOnScreenAroundElement = function(node, aroundNode, aroundCorners, layoutNode){
|
||||
// Convert old style {"BL": "TL", "BR": "TR"} type argument
|
||||
// to style needed by dijit.place code:
|
||||
// [
|
||||
// {aroundCorner: "BL", corner: "TL" },
|
||||
// {aroundCorner: "BR", corner: "TR" }
|
||||
// ]
|
||||
var positions;
|
||||
if(lang.isArray(aroundCorners)){
|
||||
positions = aroundCorners;
|
||||
}else{
|
||||
positions = [];
|
||||
for(var key in aroundCorners){
|
||||
positions.push({aroundCorner: key, corner: aroundCorners[key]});
|
||||
}
|
||||
}
|
||||
|
||||
return place.around(node, aroundNode, positions, true, layoutNode);
|
||||
};
|
||||
|
||||
/*=====
|
||||
dijit.placeOnScreenAroundNode = function(node, aroundNode, aroundCorners, layoutNode){
|
||||
// summary:
|
||||
// Position node adjacent or kitty-corner to aroundNode
|
||||
// such that it's fully visible in viewport.
|
||||
// Deprecated, new code should use dijit.place.around() instead.
|
||||
};
|
||||
=====*/
|
||||
dijit.placeOnScreenAroundNode = dijit.placeOnScreenAroundElement;
|
||||
|
||||
/*=====
|
||||
dijit.placeOnScreenAroundRectangle = function(node, aroundRect, aroundCorners, layoutNode){
|
||||
// summary:
|
||||
// Like dijit.placeOnScreenAroundNode(), except that the "around"
|
||||
// parameter is an arbitrary rectangle on the screen (x, y, width, height)
|
||||
// instead of a dom node.
|
||||
// Deprecated, new code should use dijit.place.around() instead.
|
||||
};
|
||||
=====*/
|
||||
dijit.placeOnScreenAroundRectangle = dijit.placeOnScreenAroundElement;
|
||||
|
||||
dijit.getPopupAroundAlignment = function(/*Array*/ position, /*Boolean*/ leftToRight){
|
||||
// summary:
|
||||
// Deprecated method, unneeded when using dijit/place directly.
|
||||
// Transforms the passed array of preferred positions into a format suitable for
|
||||
// passing as the aroundCorners argument to dijit.placeOnScreenAroundElement.
|
||||
//
|
||||
// position: String[]
|
||||
// This variable controls the position of the drop down.
|
||||
// It's an array of strings with the following values:
|
||||
//
|
||||
// * before: places drop down to the left of the target node/widget, or to the right in
|
||||
// the case of RTL scripts like Hebrew and Arabic
|
||||
// * after: places drop down to the right of the target node/widget, or to the left in
|
||||
// the case of RTL scripts like Hebrew and Arabic
|
||||
// * above: drop down goes above target node
|
||||
// * below: drop down goes below target node
|
||||
//
|
||||
// The list is positions is tried, in order, until a position is found where the drop down fits
|
||||
// within the viewport.
|
||||
//
|
||||
// leftToRight: Boolean
|
||||
// Whether the popup will be displaying in leftToRight mode.
|
||||
//
|
||||
var align = {};
|
||||
array.forEach(position, function(pos){
|
||||
var ltr = leftToRight;
|
||||
switch(pos){
|
||||
case "after":
|
||||
align[leftToRight ? "BR" : "BL"] = leftToRight ? "BL" : "BR";
|
||||
break;
|
||||
case "before":
|
||||
align[leftToRight ? "BL" : "BR"] = leftToRight ? "BR" : "BL";
|
||||
break;
|
||||
case "below-alt":
|
||||
ltr = !ltr;
|
||||
// fall through
|
||||
case "below":
|
||||
// first try to align left borders, next try to align right borders (or reverse for RTL mode)
|
||||
align[ltr ? "BL" : "BR"] = ltr ? "TL" : "TR";
|
||||
align[ltr ? "BR" : "BL"] = ltr ? "TR" : "TL";
|
||||
break;
|
||||
case "above-alt":
|
||||
ltr = !ltr;
|
||||
// fall through
|
||||
case "above":
|
||||
default:
|
||||
// first try to align left borders, next try to align right borders (or reverse for RTL mode)
|
||||
align[ltr ? "TL" : "TR"] = ltr ? "BL" : "BR";
|
||||
align[ltr ? "TR" : "TL"] = ltr ? "BR" : "BL";
|
||||
break;
|
||||
}
|
||||
});
|
||||
return align;
|
||||
};
|
||||
|
||||
return dijit;
|
||||
});
|
||||
@@ -1,405 +1,2 @@
|
||||
/*
|
||||
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.popup"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.popup"] = true;
|
||||
dojo.provide("dijit._base.popup");
|
||||
dojo.require("dijit._base.focus");
|
||||
dojo.require("dijit._base.place");
|
||||
dojo.require("dijit._base.window");
|
||||
|
||||
|
||||
/*=====
|
||||
dijit.popup.__OpenArgs = function(){
|
||||
// popup: Widget
|
||||
// widget to display
|
||||
// parent: Widget
|
||||
// the button etc. that is displaying this popup
|
||||
// around: DomNode
|
||||
// DOM node (typically a button); place popup relative to this node. (Specify this *or* "x" and "y" parameters.)
|
||||
// x: Integer
|
||||
// Absolute horizontal position (in pixels) to place node at. (Specify this *or* "around" parameter.)
|
||||
// y: Integer
|
||||
// Absolute vertical position (in pixels) to place node at. (Specify this *or* "around" parameter.)
|
||||
// orient: Object|String
|
||||
// When the around parameter is specified, orient should be an
|
||||
// ordered list of tuples of the form (around-node-corner, popup-node-corner).
|
||||
// dijit.popup.open() tries to position the popup according to each tuple in the list, in order,
|
||||
// until the popup appears fully within the viewport.
|
||||
//
|
||||
// The default value is {BL:'TL', TL:'BL'}, which represents a list of two tuples:
|
||||
// 1. (BL, TL)
|
||||
// 2. (TL, BL)
|
||||
// where BL means "bottom left" and "TL" means "top left".
|
||||
// So by default, it first tries putting the popup below the around node, left-aligning them,
|
||||
// and then tries to put it above the around node, still left-aligning them. Note that the
|
||||
// default is horizontally reversed when in RTL mode.
|
||||
//
|
||||
// When an (x,y) position is specified rather than an around node, orient is either
|
||||
// "R" or "L". R (for right) means that it tries to put the popup to the right of the mouse,
|
||||
// specifically positioning the popup's top-right corner at the mouse position, and if that doesn't
|
||||
// fit in the viewport, then it tries, in order, the bottom-right corner, the top left corner,
|
||||
// and the top-right corner.
|
||||
// onCancel: Function
|
||||
// callback when user has canceled the popup by
|
||||
// 1. hitting ESC or
|
||||
// 2. by using the popup widget's proprietary cancel mechanism (like a cancel button in a dialog);
|
||||
// i.e. whenever popupWidget.onCancel() is called, args.onCancel is called
|
||||
// onClose: Function
|
||||
// callback whenever this popup is closed
|
||||
// onExecute: Function
|
||||
// callback when user "executed" on the popup/sub-popup by selecting a menu choice, etc. (top menu only)
|
||||
// padding: dijit.__Position
|
||||
// adding a buffer around the opening position. This is only useful when around is not set.
|
||||
this.popup = popup;
|
||||
this.parent = parent;
|
||||
this.around = around;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.orient = orient;
|
||||
this.onCancel = onCancel;
|
||||
this.onClose = onClose;
|
||||
this.onExecute = onExecute;
|
||||
this.padding = padding;
|
||||
}
|
||||
=====*/
|
||||
|
||||
dijit.popup = {
|
||||
// summary:
|
||||
// This singleton is used to show/hide widgets as popups.
|
||||
|
||||
// _stack: dijit._Widget[]
|
||||
// Stack of currently popped up widgets.
|
||||
// (someone opened _stack[0], and then it opened _stack[1], etc.)
|
||||
_stack: [],
|
||||
|
||||
// _beginZIndex: Number
|
||||
// Z-index of the first popup. (If first popup opens other
|
||||
// popups they get a higher z-index.)
|
||||
_beginZIndex: 1000,
|
||||
|
||||
_idGen: 1,
|
||||
|
||||
_createWrapper: function(/*Widget || DomNode*/ widget){
|
||||
// summary:
|
||||
// Initialization for widgets that will be used as popups.
|
||||
// Puts widget inside a wrapper DIV (if not already in one),
|
||||
// and returns pointer to that wrapper DIV.
|
||||
|
||||
var wrapper = widget.declaredClass ? widget._popupWrapper : (widget.parentNode && dojo.hasClass(widget.parentNode, "dijitPopup")),
|
||||
node = widget.domNode || widget;
|
||||
|
||||
if(!wrapper){
|
||||
// Create wrapper <div> for when this widget [in the future] will be used as a popup.
|
||||
// This is done early because of IE bugs where creating/moving DOM nodes causes focus
|
||||
// to go wonky, see tests/robot/Toolbar.html to reproduce
|
||||
wrapper = dojo.create("div",{
|
||||
"class":"dijitPopup",
|
||||
style:{ display: "none"},
|
||||
role: "presentation"
|
||||
}, dojo.body());
|
||||
wrapper.appendChild(node);
|
||||
|
||||
var s = node.style;
|
||||
s.display = "";
|
||||
s.visibility = "";
|
||||
s.position = "";
|
||||
s.top = "0px";
|
||||
|
||||
if(widget.declaredClass){ // TODO: in 2.0 change signature to always take widget, then remove if()
|
||||
widget._popupWrapper = wrapper;
|
||||
dojo.connect(widget, "destroy", function(){
|
||||
dojo.destroy(wrapper);
|
||||
delete widget._popupWrapper;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
},
|
||||
|
||||
moveOffScreen: function(/*Widget || DomNode*/ widget){
|
||||
// summary:
|
||||
// Moves the popup widget off-screen.
|
||||
// Do not use this method to hide popups when not in use, because
|
||||
// that will create an accessibility issue: the offscreen popup is
|
||||
// still in the tabbing order.
|
||||
|
||||
// Create wrapper if not already there
|
||||
var wrapper = this._createWrapper(widget);
|
||||
|
||||
dojo.style(wrapper, {
|
||||
visibility: "hidden",
|
||||
top: "-9999px", // prevent transient scrollbar causing misalign (#5776), and initial flash in upper left (#10111)
|
||||
display: ""
|
||||
});
|
||||
},
|
||||
|
||||
hide: function(/*dijit._Widget*/ widget){
|
||||
// summary:
|
||||
// Hide this popup widget (until it is ready to be shown).
|
||||
// Initialization for widgets that will be used as popups
|
||||
//
|
||||
// Also puts widget inside a wrapper DIV (if not already in one)
|
||||
//
|
||||
// If popup widget needs to layout it should
|
||||
// do so when it is made visible, and popup._onShow() is called.
|
||||
|
||||
// Create wrapper if not already there
|
||||
var wrapper = this._createWrapper(widget);
|
||||
|
||||
dojo.style(wrapper, "display", "none");
|
||||
},
|
||||
|
||||
getTopPopup: function(){
|
||||
// summary:
|
||||
// Compute the closest ancestor popup that's *not* a child of another popup.
|
||||
// Ex: For a TooltipDialog with a button that spawns a tree of menus, find the popup of the button.
|
||||
var stack = this._stack;
|
||||
for(var pi=stack.length-1; pi > 0 && stack[pi].parent === stack[pi-1].widget; pi--){
|
||||
/* do nothing, just trying to get right value for pi */
|
||||
}
|
||||
return stack[pi];
|
||||
},
|
||||
|
||||
open: function(/*dijit.popup.__OpenArgs*/ args){
|
||||
// summary:
|
||||
// Popup the widget at the specified position
|
||||
//
|
||||
// example:
|
||||
// opening at the mouse position
|
||||
// | dijit.popup.open({popup: menuWidget, x: evt.pageX, y: evt.pageY});
|
||||
//
|
||||
// example:
|
||||
// opening the widget as a dropdown
|
||||
// | dijit.popup.open({parent: this, popup: menuWidget, around: this.domNode, onClose: function(){...}});
|
||||
//
|
||||
// Note that whatever widget called dijit.popup.open() should also listen to its own _onBlur callback
|
||||
// (fired from _base/focus.js) to know that focus has moved somewhere else and thus the popup should be closed.
|
||||
|
||||
var stack = this._stack,
|
||||
widget = args.popup,
|
||||
orient = args.orient || (
|
||||
(args.parent ? args.parent.isLeftToRight() : dojo._isBodyLtr()) ?
|
||||
{'BL':'TL', 'BR':'TR', 'TL':'BL', 'TR':'BR'} :
|
||||
{'BR':'TR', 'BL':'TL', 'TR':'BR', 'TL':'BL'}
|
||||
),
|
||||
around = args.around,
|
||||
id = (args.around && args.around.id) ? (args.around.id+"_dropdown") : ("popup_"+this._idGen++);
|
||||
|
||||
// If we are opening a new popup that isn't a child of a currently opened popup, then
|
||||
// close currently opened popup(s). This should happen automatically when the old popups
|
||||
// gets the _onBlur() event, except that the _onBlur() event isn't reliable on IE, see [22198].
|
||||
while(stack.length && (!args.parent || !dojo.isDescendant(args.parent.domNode, stack[stack.length-1].widget.domNode))){
|
||||
dijit.popup.close(stack[stack.length-1].widget);
|
||||
}
|
||||
|
||||
// Get pointer to popup wrapper, and create wrapper if it doesn't exist
|
||||
var wrapper = this._createWrapper(widget);
|
||||
|
||||
|
||||
dojo.attr(wrapper, {
|
||||
id: id,
|
||||
style: {
|
||||
zIndex: this._beginZIndex + stack.length
|
||||
},
|
||||
"class": "dijitPopup " + (widget.baseClass || widget["class"] || "").split(" ")[0] +"Popup",
|
||||
dijitPopupParent: args.parent ? args.parent.id : ""
|
||||
});
|
||||
|
||||
if(dojo.isIE || dojo.isMoz){
|
||||
if(!widget.bgIframe){
|
||||
// setting widget.bgIframe triggers cleanup in _Widget.destroy()
|
||||
widget.bgIframe = new dijit.BackgroundIframe(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
// position the wrapper node and make it visible
|
||||
var best = around ?
|
||||
dijit.placeOnScreenAroundElement(wrapper, around, orient, widget.orient ? dojo.hitch(widget, "orient") : null) :
|
||||
dijit.placeOnScreen(wrapper, args, orient == 'R' ? ['TR','BR','TL','BL'] : ['TL','BL','TR','BR'], args.padding);
|
||||
|
||||
wrapper.style.display = "";
|
||||
wrapper.style.visibility = "visible";
|
||||
widget.domNode.style.visibility = "visible"; // counteract effects from _HasDropDown
|
||||
|
||||
var handlers = [];
|
||||
|
||||
// provide default escape and tab key handling
|
||||
// (this will work for any widget, not just menu)
|
||||
handlers.push(dojo.connect(wrapper, "onkeypress", this, function(evt){
|
||||
if(evt.charOrCode == dojo.keys.ESCAPE && args.onCancel){
|
||||
dojo.stopEvent(evt);
|
||||
args.onCancel();
|
||||
}else if(evt.charOrCode === dojo.keys.TAB){
|
||||
dojo.stopEvent(evt);
|
||||
var topPopup = this.getTopPopup();
|
||||
if(topPopup && topPopup.onCancel){
|
||||
topPopup.onCancel();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// watch for cancel/execute events on the popup and notify the caller
|
||||
// (for a menu, "execute" means clicking an item)
|
||||
if(widget.onCancel){
|
||||
handlers.push(dojo.connect(widget, "onCancel", args.onCancel));
|
||||
}
|
||||
|
||||
handlers.push(dojo.connect(widget, widget.onExecute ? "onExecute" : "onChange", this, function(){
|
||||
var topPopup = this.getTopPopup();
|
||||
if(topPopup && topPopup.onExecute){
|
||||
topPopup.onExecute();
|
||||
}
|
||||
}));
|
||||
|
||||
stack.push({
|
||||
widget: widget,
|
||||
parent: args.parent,
|
||||
onExecute: args.onExecute,
|
||||
onCancel: args.onCancel,
|
||||
onClose: args.onClose,
|
||||
handlers: handlers
|
||||
});
|
||||
|
||||
if(widget.onOpen){
|
||||
// TODO: in 2.0 standardize onShow() (used by StackContainer) and onOpen() (used here)
|
||||
widget.onOpen(best);
|
||||
}
|
||||
|
||||
return best;
|
||||
},
|
||||
|
||||
close: function(/*dijit._Widget?*/ popup){
|
||||
// summary:
|
||||
// Close specified popup and any popups that it parented.
|
||||
// If no popup is specified, closes all popups.
|
||||
|
||||
var stack = this._stack;
|
||||
|
||||
// Basically work backwards from the top of the stack closing popups
|
||||
// until we hit the specified popup, but IIRC there was some issue where closing
|
||||
// a popup would cause others to close too. Thus if we are trying to close B in [A,B,C]
|
||||
// closing C might close B indirectly and then the while() condition will run where stack==[A]...
|
||||
// so the while condition is constructed defensively.
|
||||
while((popup && dojo.some(stack, function(elem){return elem.widget == popup;})) ||
|
||||
(!popup && stack.length)){
|
||||
var top = stack.pop(),
|
||||
widget = top.widget,
|
||||
onClose = top.onClose;
|
||||
|
||||
if(widget.onClose){
|
||||
// TODO: in 2.0 standardize onHide() (used by StackContainer) and onClose() (used here)
|
||||
widget.onClose();
|
||||
}
|
||||
dojo.forEach(top.handlers, dojo.disconnect);
|
||||
|
||||
// Hide the widget and it's wrapper unless it has already been destroyed in above onClose() etc.
|
||||
if(widget && widget.domNode){
|
||||
this.hide(widget);
|
||||
}
|
||||
|
||||
if(onClose){
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: remove dijit._frames, it isn't being used much, since popups never release their
|
||||
// iframes (see [22236])
|
||||
dijit._frames = new function(){
|
||||
// summary:
|
||||
// cache of iframes
|
||||
|
||||
var queue = [];
|
||||
|
||||
this.pop = function(){
|
||||
var iframe;
|
||||
if(queue.length){
|
||||
iframe = queue.pop();
|
||||
iframe.style.display="";
|
||||
}else{
|
||||
if(dojo.isIE < 9){
|
||||
var burl = dojo.config["dojoBlankHtmlUrl"] || (dojo.moduleUrl("dojo", "resources/blank.html")+"") || "javascript:\"\"";
|
||||
var html="<iframe src='" + burl + "'"
|
||||
+ " style='position: absolute; left: 0px; top: 0px;"
|
||||
+ "z-index: -1; filter:Alpha(Opacity=\"0\");'>";
|
||||
iframe = dojo.doc.createElement(html);
|
||||
}else{
|
||||
iframe = dojo.create("iframe");
|
||||
iframe.src = 'javascript:""';
|
||||
iframe.className = "dijitBackgroundIframe";
|
||||
dojo.style(iframe, "opacity", 0.1);
|
||||
}
|
||||
iframe.tabIndex = -1; // Magic to prevent iframe from getting focus on tab keypress - as style didn't work.
|
||||
dijit.setWaiRole(iframe,"presentation");
|
||||
}
|
||||
return iframe;
|
||||
};
|
||||
|
||||
this.push = function(iframe){
|
||||
iframe.style.display="none";
|
||||
queue.push(iframe);
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
dijit.BackgroundIframe = function(/*DomNode*/ node){
|
||||
// summary:
|
||||
// For IE/FF z-index schenanigans. id attribute is required.
|
||||
//
|
||||
// description:
|
||||
// new dijit.BackgroundIframe(node)
|
||||
// Makes a background iframe as a child of node, that fills
|
||||
// area (and position) of node
|
||||
|
||||
if(!node.id){ throw new Error("no id"); }
|
||||
if(dojo.isIE || dojo.isMoz){
|
||||
var iframe = (this.iframe = dijit._frames.pop());
|
||||
node.appendChild(iframe);
|
||||
if(dojo.isIE<7 || dojo.isQuirks){
|
||||
this.resize(node);
|
||||
this._conn = dojo.connect(node, 'onresize', this, function(){
|
||||
this.resize(node);
|
||||
});
|
||||
}else{
|
||||
dojo.style(iframe, {
|
||||
width: '100%',
|
||||
height: '100%'
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dojo.extend(dijit.BackgroundIframe, {
|
||||
resize: function(node){
|
||||
// summary:
|
||||
// Resize the iframe so it's the same size as node.
|
||||
// Needed on IE6 and IE/quirks because height:100% doesn't work right.
|
||||
if(this.iframe){
|
||||
dojo.style(this.iframe, {
|
||||
width: node.offsetWidth + 'px',
|
||||
height: node.offsetHeight + 'px'
|
||||
});
|
||||
}
|
||||
},
|
||||
destroy: function(){
|
||||
// summary:
|
||||
// destroy the iframe
|
||||
if(this._conn){
|
||||
dojo.disconnect(this._conn);
|
||||
this._conn = null;
|
||||
}
|
||||
if(this.iframe){
|
||||
dijit._frames.push(this.iframe);
|
||||
delete this.iframe;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/popup",["dojo/dom-class","../popup","../BackgroundIframe"],function(_1,_2){var _3=_2._createWrapper;_2._createWrapper=function(_4){if(!_4.declaredClass){_4={_popupWrapper:(_4.parentNode&&_1.contains(_4.parentNode,"dijitPopup"))?_4.parentNode:null,domNode:_4,destroy:function(){}};}return _3.call(this,_4);};var _5=_2.open;_2.open=function(_6){if(_6.orient&&typeof _6.orient!="string"&&!("length" in _6.orient)){var _7=[];for(var _8 in _6.orient){_7.push({aroundCorner:_8,corner:_6.orient[_8]});}_6.orient=_7;}return _5.call(this,_6);};return _2;});
|
||||
50
lib/dijit/_base/popup.js.uncompressed.js
Normal file
50
lib/dijit/_base/popup.js.uncompressed.js
Normal file
@@ -0,0 +1,50 @@
|
||||
define("dijit/_base/popup", [
|
||||
"dojo/dom-class", // domClass.contains
|
||||
"../popup",
|
||||
"../BackgroundIframe" // just loading for back-compat, in case client code is referencing it
|
||||
], function(domClass, popup){
|
||||
|
||||
// module:
|
||||
// dijit/_base/popup
|
||||
// summary:
|
||||
// Old module for popups, new code should use dijit/popup directly
|
||||
|
||||
|
||||
// Hack support for old API passing in node instead of a widget (to various methods)
|
||||
var origCreateWrapper = popup._createWrapper;
|
||||
popup._createWrapper = function(widget){
|
||||
if(!widget.declaredClass){
|
||||
// make fake widget to pass to new API
|
||||
widget = {
|
||||
_popupWrapper: (widget.parentNode && domClass.contains(widget.parentNode, "dijitPopup")) ?
|
||||
widget.parentNode : null,
|
||||
domNode: widget,
|
||||
destroy: function(){}
|
||||
};
|
||||
}
|
||||
return origCreateWrapper.call(this, widget);
|
||||
};
|
||||
|
||||
// Support old format of orient parameter
|
||||
var origOpen = popup.open;
|
||||
popup.open = function(/*dijit.popup.__OpenArgs*/ args){
|
||||
// Convert old hash structure (ex: {"BL": "TL", ...}) of orient to format compatible w/new popup.open() API.
|
||||
// Don't do conversion for:
|
||||
// - null parameter (that means to use the default positioning)
|
||||
// - "R" or "L" strings used to indicate positioning for context menus (when there is no around node)
|
||||
// - new format, ex: ["below", "above"]
|
||||
// - return value from deprecated dijit.getPopupAroundAlignment() method,
|
||||
// ex: ["below", "above"]
|
||||
if(args.orient && typeof args.orient != "string" && !("length" in args.orient)){
|
||||
var ary = [];
|
||||
for(var key in args.orient){
|
||||
ary.push({aroundCorner: key, corner: args.orient[key]});
|
||||
}
|
||||
args.orient = ary;
|
||||
}
|
||||
|
||||
return origOpen.call(this, args);
|
||||
};
|
||||
|
||||
return popup;
|
||||
});
|
||||
@@ -1,22 +1,2 @@
|
||||
/*
|
||||
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.scroll"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.scroll"] = true;
|
||||
dojo.provide("dijit._base.scroll");
|
||||
dojo.require("dojo.window");
|
||||
|
||||
|
||||
dijit.scrollIntoView = function(/*DomNode*/ node, /*Object?*/ pos){
|
||||
// summary:
|
||||
// Scroll the passed node into view, if it is not already.
|
||||
// Deprecated, use `dojo.window.scrollIntoView` instead.
|
||||
|
||||
dojo.window.scrollIntoView(node, pos);
|
||||
};
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/scroll",["dojo/window",".."],function(_1,_2){_2.scrollIntoView=function(_3,_4){_1.scrollIntoView(_3,_4);};});
|
||||
17
lib/dijit/_base/scroll.js.uncompressed.js
Normal file
17
lib/dijit/_base/scroll.js.uncompressed.js
Normal file
@@ -0,0 +1,17 @@
|
||||
define("dijit/_base/scroll", [
|
||||
"dojo/window", // windowUtils.scrollIntoView
|
||||
".." // export symbol to dijit
|
||||
], function(windowUtils, dijit){
|
||||
// module:
|
||||
// dijit/_base/scroll
|
||||
// summary:
|
||||
// Back compatibility module, new code should use windowUtils directly instead of using this module.
|
||||
|
||||
dijit.scrollIntoView = function(/*DomNode*/ node, /*Object?*/ pos){
|
||||
// summary:
|
||||
// Scroll the passed node into view, if it is not already.
|
||||
// Deprecated, use `windowUtils.scrollIntoView` instead.
|
||||
|
||||
windowUtils.scrollIntoView(node, pos);
|
||||
};
|
||||
});
|
||||
@@ -1,21 +1,2 @@
|
||||
/*
|
||||
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.sniff"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.sniff"] = true;
|
||||
dojo.provide("dijit._base.sniff");
|
||||
dojo.require("dojo.uacss");
|
||||
|
||||
|
||||
// summary:
|
||||
// Applies pre-set CSS classes to the top-level HTML node, see
|
||||
// `dojo.uacss` for details.
|
||||
//
|
||||
// Simply doing a require on this module will
|
||||
// establish this CSS. Modified version of Morris' CSS hack.
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/sniff",["dojo/uacss"],function(){});
|
||||
6
lib/dijit/_base/sniff.js.uncompressed.js
Normal file
6
lib/dijit/_base/sniff.js.uncompressed.js
Normal file
@@ -0,0 +1,6 @@
|
||||
define("dijit/_base/sniff", [ "dojo/uacss" ], function(){
|
||||
// module:
|
||||
// dijit/_base/sniff
|
||||
// summary:
|
||||
// Back compatibility module, new code should require dojo/uacss directly instead of this module.
|
||||
});
|
||||
@@ -1,191 +1,2 @@
|
||||
/*
|
||||
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.typematic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.typematic"] = true;
|
||||
dojo.provide("dijit._base.typematic");
|
||||
|
||||
|
||||
dijit.typematic = {
|
||||
// summary:
|
||||
// These functions are used to repetitively call a user specified callback
|
||||
// method when a specific key or mouse click over a specific DOM node is
|
||||
// held down for a specific amount of time.
|
||||
// Only 1 such event is allowed to occur on the browser page at 1 time.
|
||||
|
||||
_fireEventAndReload: function(){
|
||||
this._timer = null;
|
||||
this._callback(++this._count, this._node, this._evt);
|
||||
|
||||
// Schedule next event, timer is at most minDelay (default 10ms) to avoid
|
||||
// browser overload (particularly avoiding starving DOH robot so it never gets to send a mouseup)
|
||||
this._currentTimeout = Math.max(
|
||||
this._currentTimeout < 0 ? this._initialDelay :
|
||||
(this._subsequentDelay > 1 ? this._subsequentDelay : Math.round(this._currentTimeout * this._subsequentDelay)),
|
||||
this._minDelay);
|
||||
this._timer = setTimeout(dojo.hitch(this, "_fireEventAndReload"), this._currentTimeout);
|
||||
},
|
||||
|
||||
trigger: function(/*Event*/ evt, /*Object*/ _this, /*DOMNode*/ node, /*Function*/ callback, /*Object*/ obj, /*Number*/ subsequentDelay, /*Number*/ initialDelay, /*Number?*/ minDelay){
|
||||
// summary:
|
||||
// Start a timed, repeating callback sequence.
|
||||
// If already started, the function call is ignored.
|
||||
// This method is not normally called by the user but can be
|
||||
// when the normal listener code is insufficient.
|
||||
// evt:
|
||||
// key or mouse event object to pass to the user callback
|
||||
// _this:
|
||||
// pointer to the user's widget space.
|
||||
// node:
|
||||
// the DOM node object to pass the the callback function
|
||||
// callback:
|
||||
// function to call until the sequence is stopped called with 3 parameters:
|
||||
// count:
|
||||
// integer representing number of repeated calls (0..n) with -1 indicating the iteration has stopped
|
||||
// node:
|
||||
// the DOM node object passed in
|
||||
// evt:
|
||||
// key or mouse event object
|
||||
// obj:
|
||||
// user space object used to uniquely identify each typematic sequence
|
||||
// subsequentDelay (optional):
|
||||
// if > 1, the number of milliseconds until the 3->n events occur
|
||||
// or else the fractional time multiplier for the next event's delay, default=0.9
|
||||
// initialDelay (optional):
|
||||
// the number of milliseconds until the 2nd event occurs, default=500ms
|
||||
// minDelay (optional):
|
||||
// the maximum delay in milliseconds for event to fire, default=10ms
|
||||
if(obj != this._obj){
|
||||
this.stop();
|
||||
this._initialDelay = initialDelay || 500;
|
||||
this._subsequentDelay = subsequentDelay || 0.90;
|
||||
this._minDelay = minDelay || 10;
|
||||
this._obj = obj;
|
||||
this._evt = evt;
|
||||
this._node = node;
|
||||
this._currentTimeout = -1;
|
||||
this._count = -1;
|
||||
this._callback = dojo.hitch(_this, callback);
|
||||
this._fireEventAndReload();
|
||||
this._evt = dojo.mixin({faux: true}, evt);
|
||||
}
|
||||
},
|
||||
|
||||
stop: function(){
|
||||
// summary:
|
||||
// Stop an ongoing timed, repeating callback sequence.
|
||||
if(this._timer){
|
||||
clearTimeout(this._timer);
|
||||
this._timer = null;
|
||||
}
|
||||
if(this._obj){
|
||||
this._callback(-1, this._node, this._evt);
|
||||
this._obj = null;
|
||||
}
|
||||
},
|
||||
|
||||
addKeyListener: function(/*DOMNode*/ node, /*Object*/ keyObject, /*Object*/ _this, /*Function*/ callback, /*Number*/ subsequentDelay, /*Number*/ initialDelay, /*Number?*/ minDelay){
|
||||
// summary:
|
||||
// Start listening for a specific typematic key.
|
||||
// See also the trigger method for other parameters.
|
||||
// keyObject:
|
||||
// an object defining the key to listen for:
|
||||
// charOrCode:
|
||||
// the printable character (string) or keyCode (number) to listen for.
|
||||
// keyCode:
|
||||
// (deprecated - use charOrCode) the keyCode (number) to listen for (implies charCode = 0).
|
||||
// charCode:
|
||||
// (deprecated - use charOrCode) the charCode (number) to listen for.
|
||||
// ctrlKey:
|
||||
// desired ctrl key state to initiate the callback sequence:
|
||||
// - pressed (true)
|
||||
// - released (false)
|
||||
// - either (unspecified)
|
||||
// altKey:
|
||||
// same as ctrlKey but for the alt key
|
||||
// shiftKey:
|
||||
// same as ctrlKey but for the shift key
|
||||
// returns:
|
||||
// an array of dojo.connect handles
|
||||
if(keyObject.keyCode){
|
||||
keyObject.charOrCode = keyObject.keyCode;
|
||||
dojo.deprecated("keyCode attribute parameter for dijit.typematic.addKeyListener is deprecated. Use charOrCode instead.", "", "2.0");
|
||||
}else if(keyObject.charCode){
|
||||
keyObject.charOrCode = String.fromCharCode(keyObject.charCode);
|
||||
dojo.deprecated("charCode attribute parameter for dijit.typematic.addKeyListener is deprecated. Use charOrCode instead.", "", "2.0");
|
||||
}
|
||||
return [
|
||||
dojo.connect(node, "onkeypress", this, function(evt){
|
||||
if(evt.charOrCode == keyObject.charOrCode &&
|
||||
(keyObject.ctrlKey === undefined || keyObject.ctrlKey == evt.ctrlKey) &&
|
||||
(keyObject.altKey === undefined || keyObject.altKey == evt.altKey) &&
|
||||
(keyObject.metaKey === undefined || keyObject.metaKey == (evt.metaKey || false)) && // IE doesn't even set metaKey
|
||||
(keyObject.shiftKey === undefined || keyObject.shiftKey == evt.shiftKey)){
|
||||
dojo.stopEvent(evt);
|
||||
dijit.typematic.trigger(evt, _this, node, callback, keyObject, subsequentDelay, initialDelay, minDelay);
|
||||
}else if(dijit.typematic._obj == keyObject){
|
||||
dijit.typematic.stop();
|
||||
}
|
||||
}),
|
||||
dojo.connect(node, "onkeyup", this, function(evt){
|
||||
if(dijit.typematic._obj == keyObject){
|
||||
dijit.typematic.stop();
|
||||
}
|
||||
})
|
||||
];
|
||||
},
|
||||
|
||||
addMouseListener: function(/*DOMNode*/ node, /*Object*/ _this, /*Function*/ callback, /*Number*/ subsequentDelay, /*Number*/ initialDelay, /*Number?*/ minDelay){
|
||||
// summary:
|
||||
// Start listening for a typematic mouse click.
|
||||
// See the trigger method for other parameters.
|
||||
// returns:
|
||||
// an array of dojo.connect handles
|
||||
var dc = dojo.connect;
|
||||
return [
|
||||
dc(node, "mousedown", this, function(evt){
|
||||
dojo.stopEvent(evt);
|
||||
dijit.typematic.trigger(evt, _this, node, callback, node, subsequentDelay, initialDelay, minDelay);
|
||||
}),
|
||||
dc(node, "mouseup", this, function(evt){
|
||||
dojo.stopEvent(evt);
|
||||
dijit.typematic.stop();
|
||||
}),
|
||||
dc(node, "mouseout", this, function(evt){
|
||||
dojo.stopEvent(evt);
|
||||
dijit.typematic.stop();
|
||||
}),
|
||||
dc(node, "mousemove", this, function(evt){
|
||||
evt.preventDefault();
|
||||
}),
|
||||
dc(node, "dblclick", this, function(evt){
|
||||
dojo.stopEvent(evt);
|
||||
if(dojo.isIE){
|
||||
dijit.typematic.trigger(evt, _this, node, callback, node, subsequentDelay, initialDelay, minDelay);
|
||||
setTimeout(dojo.hitch(this, dijit.typematic.stop), 50);
|
||||
}
|
||||
})
|
||||
];
|
||||
},
|
||||
|
||||
addListener: function(/*Node*/ mouseNode, /*Node*/ keyNode, /*Object*/ keyObject, /*Object*/ _this, /*Function*/ callback, /*Number*/ subsequentDelay, /*Number*/ initialDelay, /*Number?*/ minDelay){
|
||||
// summary:
|
||||
// Start listening for a specific typematic key and mouseclick.
|
||||
// This is a thin wrapper to addKeyListener and addMouseListener.
|
||||
// See the addMouseListener and addKeyListener methods for other parameters.
|
||||
// mouseNode:
|
||||
// the DOM node object to listen on for mouse events.
|
||||
// keyNode:
|
||||
// the DOM node object to listen on for key events.
|
||||
// returns:
|
||||
// an array of dojo.connect handles
|
||||
return this.addKeyListener(keyNode, keyObject, _this, callback, subsequentDelay, initialDelay, minDelay).concat(
|
||||
this.addMouseListener(mouseNode, _this, callback, subsequentDelay, initialDelay, minDelay));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/typematic",["../typematic"],function(){});
|
||||
3
lib/dijit/_base/typematic.js.uncompressed.js
Normal file
3
lib/dijit/_base/typematic.js.uncompressed.js
Normal file
@@ -0,0 +1,3 @@
|
||||
define("dijit/_base/typematic", ["../typematic"], function(){
|
||||
// for back-compat, just loads top level module
|
||||
});
|
||||
@@ -1,145 +1,2 @@
|
||||
/*
|
||||
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.wai"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.wai"] = true;
|
||||
dojo.provide("dijit._base.wai");
|
||||
|
||||
|
||||
dijit.wai = {
|
||||
onload: function(){
|
||||
// summary:
|
||||
// Detects if we are in high-contrast mode or not
|
||||
|
||||
// This must be a named function and not an anonymous
|
||||
// function, so that the widget parsing code can make sure it
|
||||
// registers its onload function after this function.
|
||||
// DO NOT USE "this" within this function.
|
||||
|
||||
// create div for testing if high contrast mode is on or images are turned off
|
||||
var div = dojo.create("div",{
|
||||
id: "a11yTestNode",
|
||||
style:{
|
||||
cssText:'border: 1px solid;'
|
||||
+ 'border-color:red green;'
|
||||
+ 'position: absolute;'
|
||||
+ 'height: 5px;'
|
||||
+ 'top: -999px;'
|
||||
+ 'background-image: url("' + (dojo.config.blankGif || dojo.moduleUrl("dojo", "resources/blank.gif")) + '");'
|
||||
}
|
||||
}, dojo.body());
|
||||
|
||||
// test it
|
||||
var cs = dojo.getComputedStyle(div);
|
||||
if(cs){
|
||||
var bkImg = cs.backgroundImage;
|
||||
var needsA11y = (cs.borderTopColor == cs.borderRightColor) || (bkImg != null && (bkImg == "none" || bkImg == "url(invalid-url:)" ));
|
||||
dojo[needsA11y ? "addClass" : "removeClass"](dojo.body(), "dijit_a11y");
|
||||
if(dojo.isIE){
|
||||
div.outerHTML = ""; // prevent mixed-content warning, see http://support.microsoft.com/kb/925014
|
||||
}else{
|
||||
dojo.body().removeChild(div);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Test if computer is in high contrast mode.
|
||||
// Make sure the a11y test runs first, before widgets are instantiated.
|
||||
if(dojo.isIE || dojo.isMoz){ // NOTE: checking in Safari messes things up
|
||||
dojo._loaders.unshift(dijit.wai.onload);
|
||||
}
|
||||
|
||||
dojo.mixin(dijit, {
|
||||
hasWaiRole: function(/*Element*/ elem, /*String?*/ role){
|
||||
// summary:
|
||||
// Determines if an element has a particular role.
|
||||
// returns:
|
||||
// True if elem has the specific role attribute and false if not.
|
||||
// For backwards compatibility if role parameter not provided,
|
||||
// returns true if has a role
|
||||
var waiRole = this.getWaiRole(elem);
|
||||
return role ? (waiRole.indexOf(role) > -1) : (waiRole.length > 0);
|
||||
},
|
||||
|
||||
getWaiRole: function(/*Element*/ elem){
|
||||
// summary:
|
||||
// Gets the role for an element (which should be a wai role).
|
||||
// returns:
|
||||
// The role of elem or an empty string if elem
|
||||
// does not have a role.
|
||||
return dojo.trim((dojo.attr(elem, "role") || "").replace("wairole:",""));
|
||||
},
|
||||
|
||||
setWaiRole: function(/*Element*/ elem, /*String*/ role){
|
||||
// summary:
|
||||
// Sets the role on an element.
|
||||
// description:
|
||||
// Replace existing role attribute with new role.
|
||||
|
||||
dojo.attr(elem, "role", role);
|
||||
},
|
||||
|
||||
removeWaiRole: function(/*Element*/ elem, /*String*/ role){
|
||||
// summary:
|
||||
// Removes the specified role from an element.
|
||||
// Removes role attribute if no specific role provided (for backwards compat.)
|
||||
|
||||
var roleValue = dojo.attr(elem, "role");
|
||||
if(!roleValue){ return; }
|
||||
if(role){
|
||||
var t = dojo.trim((" " + roleValue + " ").replace(" " + role + " ", " "));
|
||||
dojo.attr(elem, "role", t);
|
||||
}else{
|
||||
elem.removeAttribute("role");
|
||||
}
|
||||
},
|
||||
|
||||
hasWaiState: function(/*Element*/ elem, /*String*/ state){
|
||||
// summary:
|
||||
// Determines if an element has a given state.
|
||||
// description:
|
||||
// Checks for an attribute called "aria-"+state.
|
||||
// returns:
|
||||
// true if elem has a value for the given state and
|
||||
// false if it does not.
|
||||
|
||||
return elem.hasAttribute ? elem.hasAttribute("aria-"+state) : !!elem.getAttribute("aria-"+state);
|
||||
},
|
||||
|
||||
getWaiState: function(/*Element*/ elem, /*String*/ state){
|
||||
// summary:
|
||||
// Gets the value of a state on an element.
|
||||
// description:
|
||||
// Checks for an attribute called "aria-"+state.
|
||||
// returns:
|
||||
// The value of the requested state on elem
|
||||
// or an empty string if elem has no value for state.
|
||||
|
||||
return elem.getAttribute("aria-"+state) || "";
|
||||
},
|
||||
|
||||
setWaiState: function(/*Element*/ elem, /*String*/ state, /*String*/ value){
|
||||
// summary:
|
||||
// Sets a state on an element.
|
||||
// description:
|
||||
// Sets an attribute called "aria-"+state.
|
||||
|
||||
elem.setAttribute("aria-"+state, value);
|
||||
},
|
||||
|
||||
removeWaiState: function(/*Element*/ elem, /*String*/ state){
|
||||
// summary:
|
||||
// Removes a state from an element.
|
||||
// description:
|
||||
// Sets an attribute called "aria-"+state.
|
||||
|
||||
elem.removeAttribute("aria-"+state);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/wai",["dojo/dom-attr","dojo/_base/lang","..","../hccss"],function(_1,_2,_3){_2.mixin(_3,{hasWaiRole:function(_4,_5){var _6=this.getWaiRole(_4);return _5?(_6.indexOf(_5)>-1):(_6.length>0);},getWaiRole:function(_7){return _2.trim((_1.get(_7,"role")||"").replace("wairole:",""));},setWaiRole:function(_8,_9){_1.set(_8,"role",_9);},removeWaiRole:function(_a,_b){var _c=_1.get(_a,"role");if(!_c){return;}if(_b){var t=_2.trim((" "+_c+" ").replace(" "+_b+" "," "));_1.set(_a,"role",t);}else{_a.removeAttribute("role");}},hasWaiState:function(_d,_e){return _d.hasAttribute?_d.hasAttribute("aria-"+_e):!!_d.getAttribute("aria-"+_e);},getWaiState:function(_f,_10){return _f.getAttribute("aria-"+_10)||"";},setWaiState:function(_11,_12,_13){_11.setAttribute("aria-"+_12,_13);},removeWaiState:function(_14,_15){_14.removeAttribute("aria-"+_15);}});return _3;});
|
||||
105
lib/dijit/_base/wai.js.uncompressed.js
Normal file
105
lib/dijit/_base/wai.js.uncompressed.js
Normal file
@@ -0,0 +1,105 @@
|
||||
define("dijit/_base/wai", [
|
||||
"dojo/dom-attr", // domAttr.attr
|
||||
"dojo/_base/lang", // lang.mixin
|
||||
"..", // export symbols to dijit
|
||||
"../hccss" // not using this module directly, but loading it sets CSS flag on <html>
|
||||
], function(domAttr, lang, dijit){
|
||||
|
||||
// module:
|
||||
// dijit/_base/wai
|
||||
// summary:
|
||||
// Deprecated methods for setting/getting wai roles and states.
|
||||
// New code should call setAttribute()/getAttribute() directly.
|
||||
//
|
||||
// Also loads hccss to apply dijit_a11y class to root node if machine is in high-contrast mode.
|
||||
|
||||
lang.mixin(dijit, {
|
||||
hasWaiRole: function(/*Element*/ elem, /*String?*/ role){
|
||||
// summary:
|
||||
// Determines if an element has a particular role.
|
||||
// returns:
|
||||
// True if elem has the specific role attribute and false if not.
|
||||
// For backwards compatibility if role parameter not provided,
|
||||
// returns true if has a role
|
||||
var waiRole = this.getWaiRole(elem);
|
||||
return role ? (waiRole.indexOf(role) > -1) : (waiRole.length > 0);
|
||||
},
|
||||
|
||||
getWaiRole: function(/*Element*/ elem){
|
||||
// summary:
|
||||
// Gets the role for an element (which should be a wai role).
|
||||
// returns:
|
||||
// The role of elem or an empty string if elem
|
||||
// does not have a role.
|
||||
return lang.trim((domAttr.get(elem, "role") || "").replace("wairole:",""));
|
||||
},
|
||||
|
||||
setWaiRole: function(/*Element*/ elem, /*String*/ role){
|
||||
// summary:
|
||||
// Sets the role on an element.
|
||||
// description:
|
||||
// Replace existing role attribute with new role.
|
||||
|
||||
domAttr.set(elem, "role", role);
|
||||
},
|
||||
|
||||
removeWaiRole: function(/*Element*/ elem, /*String*/ role){
|
||||
// summary:
|
||||
// Removes the specified role from an element.
|
||||
// Removes role attribute if no specific role provided (for backwards compat.)
|
||||
|
||||
var roleValue = domAttr.get(elem, "role");
|
||||
if(!roleValue){ return; }
|
||||
if(role){
|
||||
var t = lang.trim((" " + roleValue + " ").replace(" " + role + " ", " "));
|
||||
domAttr.set(elem, "role", t);
|
||||
}else{
|
||||
elem.removeAttribute("role");
|
||||
}
|
||||
},
|
||||
|
||||
hasWaiState: function(/*Element*/ elem, /*String*/ state){
|
||||
// summary:
|
||||
// Determines if an element has a given state.
|
||||
// description:
|
||||
// Checks for an attribute called "aria-"+state.
|
||||
// returns:
|
||||
// true if elem has a value for the given state and
|
||||
// false if it does not.
|
||||
|
||||
return elem.hasAttribute ? elem.hasAttribute("aria-"+state) : !!elem.getAttribute("aria-"+state);
|
||||
},
|
||||
|
||||
getWaiState: function(/*Element*/ elem, /*String*/ state){
|
||||
// summary:
|
||||
// Gets the value of a state on an element.
|
||||
// description:
|
||||
// Checks for an attribute called "aria-"+state.
|
||||
// returns:
|
||||
// The value of the requested state on elem
|
||||
// or an empty string if elem has no value for state.
|
||||
|
||||
return elem.getAttribute("aria-"+state) || "";
|
||||
},
|
||||
|
||||
setWaiState: function(/*Element*/ elem, /*String*/ state, /*String*/ value){
|
||||
// summary:
|
||||
// Sets a state on an element.
|
||||
// description:
|
||||
// Sets an attribute called "aria-"+state.
|
||||
|
||||
elem.setAttribute("aria-"+state, value);
|
||||
},
|
||||
|
||||
removeWaiState: function(/*Element*/ elem, /*String*/ state){
|
||||
// summary:
|
||||
// Removes a state from an element.
|
||||
// description:
|
||||
// Sets an attribute called "aria-"+state.
|
||||
|
||||
elem.removeAttribute("aria-"+state);
|
||||
}
|
||||
});
|
||||
|
||||
return dijit;
|
||||
});
|
||||
@@ -1,18 +1,2 @@
|
||||
/*
|
||||
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.window"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
||||
dojo._hasResource["dijit._base.window"] = true;
|
||||
dojo.provide("dijit._base.window");
|
||||
dojo.require("dojo.window");
|
||||
|
||||
|
||||
dijit.getDocumentWindow = function(doc){
|
||||
return dojo.window.get(doc);
|
||||
};
|
||||
|
||||
}
|
||||
//>>built
|
||||
define("dijit/_base/window",["dojo/window",".."],function(_1,_2){_2.getDocumentWindow=function(_3){return _1.get(_3);};});
|
||||
13
lib/dijit/_base/window.js.uncompressed.js
Normal file
13
lib/dijit/_base/window.js.uncompressed.js
Normal file
@@ -0,0 +1,13 @@
|
||||
define("dijit/_base/window", [
|
||||
"dojo/window", // windowUtils.get
|
||||
".." // export symbol to dijit
|
||||
], function(windowUtils, dijit){
|
||||
// module:
|
||||
// dijit/_base/window
|
||||
// summary:
|
||||
// Back compatibility module, new code should use windowUtils directly instead of using this module.
|
||||
|
||||
dijit.getDocumentWindow = function(doc){
|
||||
return windowUtils.get(doc);
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user