📄 dijit.js.uncompressed.js
字号:
// Format a Date object as a string according a subset of the ISO-8601 standard // // description: // When options.selector is omitted, output follows [RFC3339](http://www.ietf.org/rfc/rfc3339.txt) // The local time zone is included as an offset from GMT, except when selector=='time' (time without a date) // Does not check bounds. Only years between 100 and 9999 are supported. // // dateObject: // A Date object var _ = function(n){ return (n < 10) ? "0" + n : n; }; options = options || {}; var formattedDate = []; var getter = options.zulu ? "getUTC" : "get"; var date = ""; if(options.selector != "time"){ var year = dateObject[getter+"FullYear"](); date = ["0000".substr((year+"").length)+year, _(dateObject[getter+"Month"]()+1), _(dateObject[getter+"Date"]())].join('-'); } formattedDate.push(date); if(options.selector != "date"){ var time = [_(dateObject[getter+"Hours"]()), _(dateObject[getter+"Minutes"]()), _(dateObject[getter+"Seconds"]())].join(':'); var millis = dateObject[getter+"Milliseconds"](); if(options.milliseconds){ time += "."+ (millis < 100 ? "0" : "") + _(millis); } if(options.zulu){ time += "Z"; }else if(options.selector != "time"){ var timezoneOffset = dateObject.getTimezoneOffset(); var absOffset = Math.abs(timezoneOffset); time += (timezoneOffset > 0 ? "-" : "+") + _(Math.floor(absOffset/60)) + ":" + _(absOffset%60); } formattedDate.push(time); } return formattedDate.join('T'); // String}}if(!dojo._hasResource["dojo.parser"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dojo.parser"] = true;dojo.provide("dojo.parser");dojo.parser = new function(){ // summary: The Dom/Widget parsing package var d = dojo; var dtName = d._scopeName + "Type"; var qry = "[" + dtName + "]"; function val2type(/*Object*/ value){ // summary: // Returns name of type of given value. if(d.isString(value)){ return "string"; } if(typeof value == "number"){ return "number"; } if(typeof value == "boolean"){ return "boolean"; } if(d.isFunction(value)){ return "function"; } if(d.isArray(value)){ return "array"; } // typeof [] == "object" if(value instanceof Date) { return "date"; } // assume timestamp if(value instanceof d._Url){ return "url"; } return "object"; } function str2obj(/*String*/ value, /*String*/ type){ // summary: // Convert given string value to given type switch(type){ case "string": return value; case "number": return value.length ? Number(value) : NaN; case "boolean": // for checked/disabled value might be "" or "checked". interpret as true. return typeof value == "boolean" ? value : !(value.toLowerCase()=="false"); case "function": if(d.isFunction(value)){ // IE gives us a function, even when we say something like onClick="foo" // (in which case it gives us an invalid function "function(){ foo }"). // Therefore, convert to string value=value.toString(); value=d.trim(value.substring(value.indexOf('{')+1, value.length-1)); } try{ if(value.search(/[^\w\.]+/i) != -1){ // TODO: "this" here won't work value = d.parser._nameAnonFunc(new Function(value), this); } return d.getObject(value, false); }catch(e){ return new Function(); } case "array": return value.split(/\s*,\s*/); case "date": switch(value){ case "": return new Date(""); // the NaN of dates case "now": return new Date(); // current date default: return d.date.stamp.fromISOString(value); } case "url": return d.baseUrl + value; default: return d.fromJson(value); } } var instanceClasses = { // map from fully qualified name (like "dijit.Button") to structure like // { cls: dijit.Button, params: {label: "string", disabled: "boolean"} } }; function getClassInfo(/*String*/ className){ // className: // fully qualified name (like "dijit.Button") // returns: // structure like // { // cls: dijit.Button, // params: { label: "string", disabled: "boolean"} // } if(!instanceClasses[className]){ // get pointer to widget class var cls = d.getObject(className); if(!d.isFunction(cls)){ throw new Error("Could not load class '" + className + "'. Did you spell the name correctly and use a full path, like 'dijit.form.Button'?"); } var proto = cls.prototype; // get table of parameter names & types var params={}; for(var name in proto){ if(name.charAt(0)=="_"){ continue; } // skip internal properties var defVal = proto[name]; params[name]=val2type(defVal); } instanceClasses[className] = { cls: cls, params: params }; } return instanceClasses[className]; } this._functionFromScript = function(script){ var preamble = ""; var suffix = ""; var argsStr = script.getAttribute("args"); if(argsStr){ d.forEach(argsStr.split(/\s*,\s*/), function(part, idx){ preamble += "var "+part+" = arguments["+idx+"]; "; }); } var withStr = script.getAttribute("with"); if(withStr && withStr.length){ d.forEach(withStr.split(/\s*,\s*/), function(part){ preamble += "with("+part+"){"; suffix += "}"; }); } return new Function(preamble+script.innerHTML+suffix); } this.instantiate = function(/* Array */nodes){ // summary: // Takes array of nodes, and turns them into class instances and // potentially calls a layout method to allow them to connect with // any children var thelist = []; d.forEach(nodes, function(node){ if(!node){ return; } var type = node.getAttribute(dtName); if((!type)||(!type.length)){ return; } var clsInfo = getClassInfo(type); var clazz = clsInfo.cls; var ps = clazz._noScript||clazz.prototype._noScript; // read parameters (ie, attributes). // clsInfo.params lists expected params like {"checked": "boolean", "n": "number"} var params = {}; var attributes = node.attributes; for(var name in clsInfo.params){ var item = attributes.getNamedItem(name); if(!item || (!item.specified && (!dojo.isIE || name.toLowerCase()!="value"))){ continue; } var value = item.value; // Deal with IE quirks for 'class' and 'style' switch(name){ case "class": value = node.className; break; case "style": value = node.style && node.style.cssText; // FIXME: Opera? } var _type = clsInfo.params[name]; params[name] = str2obj(value, _type); } // Process <script type="dojo/*"> script tags // <script type="dojo/method" event="foo"> tags are added to params, and passed to // the widget on instantiation. // <script type="dojo/method"> tags (with no event) are executed after instantiation // <script type="dojo/connect" event="foo"> tags are dojo.connected after instantiation // note: dojo/* script tags cannot exist in self closing widgets, like <input /> if(!ps){ var connects = [], // functions to connect after instantiation calls = []; // functions to call after instantiation d.query("> script[type^='dojo/']", node).orphan().forEach(function(script){ var event = script.getAttribute("event"), type = script.getAttribute("type"), nf = d.parser._functionFromScript(script); if(event){ if(type == "dojo/connect"){ connects.push({event: event, func: nf}); }else{ params[event] = nf; } }else{ calls.push(nf); } }); } var markupFactory = clazz["markupFactory"]; if(!markupFactory && clazz["prototype"]){ markupFactory = clazz.prototype["markupFactory"]; } // create the instance var instance = markupFactory ? markupFactory(params, node, clazz) : new clazz(params, node); thelist.push(instance); // map it to the JS namespace if that makes sense var jsname = node.getAttribute("jsId"); if(jsname){ d.setObject(jsname, instance); } // process connections and startup functions if(!ps){ d.forEach(connects, function(connect){ d.connect(instance, connect.event, null, connect.func); }); d.forEach(calls, function(func){ func.call(instance); }); } }); // Call startup on each top level instance if it makes sense (as for // widgets). Parent widgets will recursively call startup on their // (non-top level) children d.forEach(thelist, function(instance){ if( instance && instance.startup && !instance._started && (!instance.getParent || !instance.getParent()) ){ instance.startup(); } }); return thelist; }; this.parse = function(/*DomNode?*/ rootNode){ // summary: // Search specified node (or root node) recursively for class instances, // and instantiate them Searches for // dojoType="qualified.class.name" var list = d.query(qry, rootNode); // go build the object instances var instances = this.instantiate(list); return instances; };}();//Register the parser callback. It should be the first callback//after the a11y test.(function(){ var parseRunner = function(){ if(dojo.config["parseOnLoad"] == true){ dojo.parser.parse(); } }; // FIXME: need to clobber cross-dependency!! if(dojo.exists("dijit.wai.onload") && (dijit.wai.onload === dojo._loaders[0])){ dojo._loaders.splice(1, 0, parseRunner); }else{ dojo._loaders.unshift(parseRunner); }})();//TODO: ported from 0.4.x Dojo. Can we reduce this?dojo.parser._anonCtr = 0;dojo.parser._anon = {}; // why is this property required?dojo.parser._nameAnonFunc = function(/*Function*/anonFuncPtr, /*Object*/thisObj){ // summary: // Creates a reference to anonFuncPtr in thisObj with a completely // unique name. The new name is returned as a String. var jpn = "$joinpoint"; var nso = (thisObj|| dojo.parser._anon); if(dojo.isIE){ var cn = anonFuncPtr["__dojoNameCache"]; if(cn && nso[cn] === anonFuncPtr){ return anonFuncPtr["__dojoNameCache"]; } } var ret = "__"+dojo.parser._anonCtr++; while(typeof nso[ret] != "undefined"){ ret = "__"+dojo.parser._anonCtr++; } nso[ret] = anonFuncPtr; return ret; // String}}if(!dojo._hasResource["dijit._Widget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dijit._Widget"] = true;dojo.provide("dijit._Widget");dojo.require( "dijit._base" );dojo.declare("dijit._Widget", null, { // summary: // The foundation of dijit widgets. // // id: String // a unique, opaque ID string that can be assigned by users or by the // system. If the developer passes an ID which is known not to be // unique, the specified ID is ignored and the system-generated ID is // used instead. id: "", // lang: String // Rarely used. Overrides the default Dojo locale used to render this widget, // as defined by the [HTML LANG](http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang) attribute. // Value must be among the list of locales specified during by the Dojo bootstrap, // formatted according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt) (like en-us). lang: "", // dir: String // Unsupported by Dijit, but here for completeness. Dijit only supports setting text direction on the // entire document. // Bi-directional support, as defined by the [HTML DIR](http://www.w3.org/TR/html401/struct/dirlang.html#adef-dir) // attribute. Either left-to-right "ltr" or right-to-left "rtl". dir: "", // class: String // HTML class attribute "class": "", // style: String // HTML style attribute style: "", // title: String // HTML title attribute title: "", // srcNodeRef: DomNode // pointer to original dom node srcNodeRef: null, // domNode: DomNode // this is our visible representation of the widget! Other DOM // Nodes may by assigned to other properties, usually through the // template system's dojoAttachPonit syntax, but the domNode // property is the canonical "top level" node in widget UI. domNode: null, // attributeMap: Object // A map of attributes and attachpoints -- typically standard HTML attributes -- to set // on the widget's dom, at the "domNode" attach point, by default. // Other node references can be specified as properties of 'this' attributeMap: {id:"", dir:"", lang:"", "class":"", style:"", title:""}, // TODO: add on* handlers? //////////// INITIALIZATION METHODS /////////////////////////////////////////TODOC: params and srcNodeRef need docs. Is srcNodeRef optional?//TODOC: summary needed for postscript postscript: function(/*Object?*/params, /*DomNode|String*/srcNodeRef){ this.create(params, srcNodeRef); }, create: function(/*Object?*/params, /*DomNode|String*/srcNodeRef){ // summary: // Kick off the life-cycle of a widget // description: // To understand the process by which widgets are instantiated, it // is critical to understand what other methods create calls and // which of them you'll want to override. Of course, adventurous // developers could override create entirely, but this should // only be done as a last resort. // // Below is a list of the methods that
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -