📄 dojo.js
字号:
}
if((djConfig.parseWidgets)||(sids.length > 0)){
if(dojo.evalObjPath("dojo.widget.Parse")){
// we must do this on a delay to avoid:
// http://www.shaftek.org/blog/archives/000212.html
// (IE bug)
var parser = new dojo.xml.Parse();
if(sids.length > 0){
for(var x=0; x<sids.length; x++){
var tmpNode = document.getElementById(sids[x]);
if(!tmpNode){ continue; }
var frag = parser.parseElement(tmpNode, null, true);
dojo.widget.getParser().createComponents(frag);
}
}else if(djConfig.parseWidgets){
var frag = parser.parseElement(dojo.body(), null, true);
dojo.widget.getParser().createComponents(frag);
}
}
}
}
dojo.addOnLoad(function(){
if(!dojo.render.html.ie) {
dojo.hostenv.makeWidgets();
}
});
try{
if(dojo.render.html.ie){
document.namespaces.add("v","urn:schemas-microsoft-com:vml");
document.createStyleSheet().addRule("v\\:*", "behavior:url(#default#VML)");
}
}catch(e){ }
// stub, over-ridden by debugging code. This will at least keep us from
// breaking when it's not included
dojo.hostenv.writeIncludes = function(){}
//TODOC: HOW TO DOC THIS?
// @global: dj_currentDocument
// summary:
// Current document object. 'dj_currentDocument' can be modified for temporary context shifting.
// description:
// dojo.doc() returns dojo.currentDocument.
// Refer to dojo.doc() rather than referring to 'window.document' to ensure your
// code runs correctly in managed contexts.
if(!dj_undef("document", this)){
dj_currentDocument = this.document;
}
dojo.doc = function(){
// summary:
// return the document object associated with the dojo.global()
return dj_currentDocument;
}
dojo.body = function(){
// summary:
// return the body object associated with dojo.doc()
// Note: document.body is not defined for a strict xhtml document
return dojo.doc().body || dojo.doc().getElementsByTagName("body")[0];
}
dojo.byId = function(/*String*/id, /*DocumentElement*/doc){
// summary:
// similar to other library's "$" function, takes a string
// representing a DOM id or a DomNode and returns the
// corresponding DomNode. If a Node is passed, this function is a
// no-op. Returns a single DOM node or null, working around
// several browser-specific bugs to do so.
// id: DOM id or DOM Node
// doc:
// optional, defaults to the current value of dj_currentDocument.
// Can be used to retreive node references from other documents.
if((id)&&((typeof id == "string")||(id instanceof String))){
if(!doc){ doc = dj_currentDocument; }
var ele = doc.getElementById(id);
// workaround bug in IE and Opera 8.2 where getElementById returns wrong element
if(ele && (ele.id != id) && doc.all){
ele = null;
// get all matching elements with this id
eles = doc.all[id];
if(eles){
// if more than 1, choose first with the correct id
if(eles.length){
for(var i=0; i<eles.length; i++){
if(eles[i].id == id){
ele = eles[i];
break;
}
}
// return 1 and only element
}else{
ele = eles;
}
}
}
return ele; // DomNode
}
return id; // DomNode
}
dojo.setContext = function(/*Object*/globalObject, /*DocumentElement*/globalDocument){
// summary:
// changes the behavior of many core Dojo functions that deal with
// namespace and DOM lookup, changing them to work in a new global
// context. The varibles dj_currentContext and dj_currentDocument
// are modified as a result of calling this function.
dj_currentContext = globalObject;
dj_currentDocument = globalDocument;
};
dojo._fireCallback = function(callback, context, cbArguments){
if((context)&&((typeof callback == "string")||(callback instanceof String))){
callback=context[callback];
}
return (context ? callback.apply(context, cbArguments || [ ]) : callback());
}
dojo.withGlobal = function(/*Object*/globalObject, /*Function*/callback, /*Object?*/thisObject, /*Array?*/cbArguments){
// summary:
// Call callback with globalObject as dojo.global() and globalObject.document
// as dojo.doc(). If provided, globalObject will be executed in the context of
// object thisObject
// description:
// When callback() returns or throws an error, the dojo.global() and dojo.doc() will
// be restored to its previous state.
var rval;
var oldGlob = dj_currentContext;
var oldDoc = dj_currentDocument;
try{
dojo.setContext(globalObject, globalObject.document);
rval = dojo._fireCallback(callback, thisObject, cbArguments);
}finally{
dojo.setContext(oldGlob, oldDoc);
}
return rval;
}
dojo.withDoc = function (/*Object*/documentObject, /*Function*/callback, /*Object?*/thisObject, /*Array?*/cbArguments) {
// summary:
// Call callback with documentObject as dojo.doc(). If provided, callback will be executed
// in the context of object thisObject
// description:
// When callback() returns or throws an error, the dojo.doc() will
// be restored to its previous state.
var rval;
var oldDoc = dj_currentDocument;
try{
dj_currentDocument = documentObject;
rval = dojo._fireCallback(callback, thisObject, cbArguments);
}finally{
dj_currentDocument = oldDoc;
}
return rval;
}
} //if (typeof window != 'undefined')
//Load debug code if necessary.
dojo.requireIf((djConfig["isDebug"] || djConfig["debugAtAllCosts"]), "dojo.debug");
//window.widget is for Dashboard detection
//The full conditionals are spelled out to avoid issues during builds.
//Builds may be looking for require/requireIf statements and processing them.
dojo.requireIf(djConfig["debugAtAllCosts"] && !window.widget && !djConfig["useXDomain"], "dojo.browser_debug");
dojo.requireIf(djConfig["debugAtAllCosts"] && !window.widget && djConfig["useXDomain"], "dojo.browser_debug_xd");
dojo.provide("dojo.string.common");
dojo.string.trim = function(/* string */str, /* integer? */wh){
// summary
// Trim whitespace from str. If wh > 0, trim from start, if wh < 0, trim from end, else both
if(!str.replace){ return str; }
if(!str.length){ return str; }
var re = (wh > 0) ? (/^\s+/) : (wh < 0) ? (/\s+$/) : (/^\s+|\s+$/g);
return str.replace(re, ""); // string
}
dojo.string.trimStart = function(/* string */str) {
// summary
// Trim whitespace at the beginning of 'str'
return dojo.string.trim(str, 1); // string
}
dojo.string.trimEnd = function(/* string */str) {
// summary
// Trim whitespace at the end of 'str'
return dojo.string.trim(str, -1);
}
dojo.string.repeat = function(/* string */str, /* integer */count, /* string? */separator) {
// summary
// Return 'str' repeated 'count' times, optionally placing 'separator' between each rep
var out = "";
for(var i = 0; i < count; i++) {
out += str;
if(separator && i < count - 1) {
out += separator;
}
}
return out; // string
}
dojo.string.pad = function(/* string */str, /* integer */len/*=2*/, /* string */ c/*='0'*/, /* integer */dir/*=1*/) {
// summary
// Pad 'str' to guarantee that it is at least 'len' length with the character 'c' at either the
// start (dir=1) or end (dir=-1) of the string
var out = String(str);
if(!c) {
c = '0';
}
if(!dir) {
dir = 1;
}
while(out.length < len) {
if(dir > 0) {
out = c + out;
} else {
out += c;
}
}
return out; // string
}
dojo.string.padLeft = function(/* string */str, /* integer */len, /* string */c) {
// summary
// same as dojo.string.pad(str, len, c, 1)
return dojo.string.pad(str, len, c, 1); // string
}
dojo.string.padRight = function(/* string */str, /* integer */len, /* string */c) {
// summary
// same as dojo.string.pad(str, len, c, -1)
return dojo.string.pad(str, len, c, -1); // string
}
dojo.provide("dojo.string");
dojo.provide("dojo.lang.common");
dojo.lang.inherits = function(/*Function*/subclass, /*Function*/superclass){
// summary: Set up inheritance between two classes.
if(!dojo.lang.isFunction(superclass)){
dojo.raise("dojo.inherits: superclass argument ["+superclass+"] must be a function (subclass: ["+subclass+"']");
}
subclass.prototype = new superclass();
subclass.prototype.constructor = subclass;
subclass.superclass = superclass.prototype;
// DEPRECATED: super is a reserved word, use 'superclass'
subclass['super'] = superclass.prototype;
}
dojo.lang._mixin = function(/*Object*/ obj, /*Object*/ props){
// summary:
// Adds all properties and methods of props to obj. This addition is
// "prototype extension safe", so that instances of objects will not
// pass along prototype defaults.
var tobj = {};
for(var x in props){
// the "tobj" condition avoid copying properties in "props"
// inherited from Object.prototype. For example, if obj has a custom
// toString() method, don't overwrite it with the toString() method
// that props inherited from Object.protoype
if((typeof tobj[x] == "undefined") || (tobj[x] != props[x])){
obj[x] = props[x];
}
}
// IE doesn't recognize custom toStrings in for..in
if(dojo.render.html.ie
&& (typeof(props["toString"]) == "function")
&& (props["toString"] != obj["toString"])
&& (props["toString"] != tobj["toString"]))
{
obj.toString = props.toString;
}
return obj; // Object
}
dojo.lang.mixin = function(/*Object*/obj, /*Object...*/props){
// summary: Adds all properties and methods of props to obj.
for(var i=1, l=arguments.length; i<l; i++){
dojo.lang._mixin(obj, arguments[i]);
}
return obj; // Object
}
dojo.lang.extend = function(/*Object*/ constructor, /*Object...*/ props){
// summary:
// Adds all properties and methods of props to constructor's
// prototype, making them available to all instances created with
// constructor.
for(var i=1, l=arguments.length; i<l; i++){
dojo.lang._mixin(constructor.prototype, arguments[i]);
}
return constructor; // Object
}
// Promote to dojo module
dojo.inherits = dojo.lang.inherits;
//dojo.lang._mixin = dojo.lang._mixin;
dojo.mixin = dojo.lang.mixin;
dojo.extend = dojo.lang.extend;
dojo.lang.find = function( /*Array*/ array,
/*Object*/ value,
/*Boolean?*/ identity,
/*Boolean?*/ findLast){
// summary:
// Return the index of value in array, returning -1 if not found.
// array: just what you think
// value: the value to locate
// identity:
// If true, matches with identity comparison (===). If false, uses
// normal comparison (==).
// findLast:
// If true, returns index of last instance of value.
// examples:
// find(array, value[, identity [findLast]]) // recommended
// find(value, array[, identity [findLast]]) // deprecated
// support both (array, value) and (value, array)
if(!dojo.lang.isArrayLike(array) && dojo.lang.isArrayLike(value)) {
dojo.deprecated('dojo.lang.find(value, array)', 'use dojo.lang.find(array, value) instead', "0.5");
var temp = array;
array = value;
value = temp;
}
var isString = dojo.lang.isString(array);
if(isString) { array = array.split(""); }
if(findLast) {
var step = -1;
var i = array.length - 1;
var end = -1;
} else {
var step = 1;
var i = 0;
var end = array.length;
}
if(identity){
while(i != end) {
if(array[i] === value){ return i; }
i += step;
}
}else{
while(i != end) {
if(array[i] == value){ return i; }
i += step;
}
}
return -1; // number
}
dojo.lang.indexOf = dojo.lang.find;
dojo.lang.findLast = function(/*Array*/array, /*Object*/value, /*boolean?*/identity){
// summary:
// Return index of last occurance of value in array, returning -1 if
// not found. This is a shortcut for dojo.lang.find() with a true
// value for its "findLast" parameter.
// identity:
// If true, matches with identity comparison (===). If false, uses
// normal comparison (==).
return dojo.lang.find(array, value, identity, true); // number
}
dojo.la
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -