123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864 |
- if(!dojo._hasResource["dijit._WidgetBase"]){
- dojo._hasResource["dijit._WidgetBase"] = true;
- dojo.provide("dijit._WidgetBase");
- dojo.require("dijit._base.manager");
- dojo.require("dojo.Stateful");
- (function(){
- function isEqual(a, b){
-
-
-
-
- return a === b || ( a !== a && b !== b);
- }
- dojo.declare("dijit._WidgetBase", dojo.Stateful, {
-
-
-
-
-
-
-
-
- id: "",
-
-
-
-
-
- lang: "",
-
-
-
-
- dir: "",
-
-
- "class": "",
-
-
- style: "",
-
-
-
-
-
-
-
-
- title: "",
-
-
-
- tooltip: "",
-
-
-
- baseClass: "",
-
-
- srcNodeRef: null,
-
-
-
-
-
- domNode: null,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- containerNode: null,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- attributeMap: {id:"", dir:"", lang:"", "class":"", style:"", title:""},
-
-
-
- _blankGif: (dojo.config.blankGif || dojo.moduleUrl("dojo", "resources/blank.gif")).toString(),
-
- postscript: function(/*Object?*/params, /*DomNode|String*/srcNodeRef){
-
-
-
-
- this.create(params, srcNodeRef);
- },
- create: function(/*Object?*/params, /*DomNode|String?*/srcNodeRef){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.srcNodeRef = dojo.byId(srcNodeRef);
-
-
- this._connects = [];
-
-
- this._subscribes = [];
-
- if(this.srcNodeRef && (typeof this.srcNodeRef.id == "string")){ this.id = this.srcNodeRef.id; }
- if(params){
- this.params = params;
- dojo._mixin(this, params);
- }
- this.postMixInProperties();
-
-
-
- if(!this.id){
- this.id = dijit.getUniqueId(this.declaredClass.replace(/\./g,"_"));
- }
- dijit.registry.add(this);
- this.buildRendering();
- if(this.domNode){
-
-
- this._applyAttributes();
-
-
-
-
- var source = this.srcNodeRef;
- if(source && source.parentNode && this.domNode !== source){
- source.parentNode.replaceChild(this.domNode, source);
- }
- }
- if(this.domNode){
-
-
- this.domNode.setAttribute("widgetId", this.id);
- }
- this.postCreate();
-
- if(this.srcNodeRef && !this.srcNodeRef.parentNode){
- delete this.srcNodeRef;
- }
- this._created = true;
- },
- _applyAttributes: function(){
-
-
-
-
-
-
-
-
-
-
-
-
-
- var condAttrApply = function(attr, scope){
- if((scope.params && attr in scope.params) || scope[attr]){
- scope.set(attr, scope[attr]);
- }
- };
-
- for(var attr in this.attributeMap){
- condAttrApply(attr, this);
- }
-
- dojo.forEach(this._getSetterAttributes(), function(a){
- if(!(a in this.attributeMap)){
- condAttrApply(a, this);
- }
- }, this);
- },
- _getSetterAttributes: function(){
-
-
- var ctor = this.constructor;
- if(!ctor._setterAttrs){
- var r = (ctor._setterAttrs = []),
- attrs,
- proto = ctor.prototype;
- for(var fxName in proto){
- if(dojo.isFunction(proto[fxName]) && (attrs = fxName.match(/^_set([a-zA-Z]*)Attr$/)) && attrs[1]){
- r.push(attrs[1].charAt(0).toLowerCase() + attrs[1].substr(1));
- }
- }
- }
- return ctor._setterAttrs;
- },
- postMixInProperties: function(){
-
-
-
-
-
-
-
- },
- buildRendering: function(){
-
-
-
-
-
-
-
- if(!this.domNode){
-
- this.domNode = this.srcNodeRef || dojo.create('div');
- }
-
-
-
- if(this.baseClass){
- var classes = this.baseClass.split(" ");
- if(!this.isLeftToRight()){
- classes = classes.concat( dojo.map(classes, function(name){ return name+"Rtl"; }));
- }
- dojo.addClass(this.domNode, classes);
- }
- },
- postCreate: function(){
-
-
-
-
-
-
-
-
- },
- startup: function(){
-
-
-
-
-
-
-
- this._started = true;
- },
-
- destroyRecursive: function(/*Boolean?*/ preserveDom){
-
-
-
-
-
-
-
-
-
-
- this._beingDestroyed = true;
- this.destroyDescendants(preserveDom);
- this.destroy(preserveDom);
- },
- destroy: function(/*Boolean*/ preserveDom){
-
-
-
-
-
-
- this._beingDestroyed = true;
- this.uninitialize();
- var d = dojo,
- dfe = d.forEach,
- dun = d.unsubscribe;
- dfe(this._connects, function(array){
- dfe(array, d.disconnect);
- });
- dfe(this._subscribes, function(handle){
- dun(handle);
- });
-
- dfe(this._supportingWidgets || [], function(w){
- if(w.destroyRecursive){
- w.destroyRecursive();
- }else if(w.destroy){
- w.destroy();
- }
- });
- this.destroyRendering(preserveDom);
- dijit.registry.remove(this.id);
- this._destroyed = true;
- },
- destroyRendering: function(/*Boolean?*/ preserveDom){
-
-
-
-
-
-
-
-
- if(this.bgIframe){
- this.bgIframe.destroy(preserveDom);
- delete this.bgIframe;
- }
- if(this.domNode){
- if(preserveDom){
- dojo.removeAttr(this.domNode, "widgetId");
- }else{
- dojo.destroy(this.domNode);
- }
- delete this.domNode;
- }
- if(this.srcNodeRef){
- if(!preserveDom){
- dojo.destroy(this.srcNodeRef);
- }
- delete this.srcNodeRef;
- }
- },
- destroyDescendants: function(/*Boolean?*/ preserveDom){
-
-
-
-
-
-
-
-
- dojo.forEach(this.getChildren(), function(widget){
- if(widget.destroyRecursive){
- widget.destroyRecursive(preserveDom);
- }
- });
- },
- uninitialize: function(){
-
-
-
-
-
- return false;
- },
-
- _setClassAttr: function(/*String*/ value){
-
-
-
-
- var mapNode = this[this.attributeMap["class"] || 'domNode'];
- dojo.replaceClass(mapNode, value, this["class"]);
- this._set("class", value);
- },
- _setStyleAttr: function(/*String||Object*/ value){
-
-
-
-
-
-
-
-
-
- var mapNode = this[this.attributeMap.style || 'domNode'];
-
-
- if(dojo.isObject(value)){
- dojo.style(mapNode, value);
- }else{
- if(mapNode.style.cssText){
- mapNode.style.cssText += "; " + value;
- }else{
- mapNode.style.cssText = value;
- }
- }
- this._set("style", value);
- },
- _attrToDom: function(/*String*/ attr, /*String*/ value){
-
-
-
-
-
-
-
-
- var commands = this.attributeMap[attr];
- dojo.forEach(dojo.isArray(commands) ? commands : [commands], function(command){
-
- var mapNode = this[command.node || command || "domNode"];
- var type = command.type || "attribute";
- switch(type){
- case "attribute":
- if(dojo.isFunction(value)){
- value = dojo.hitch(this, value);
- }
-
-
-
- var attrName = command.attribute ? command.attribute :
- (/^on[A-Z][a-zA-Z]*$/.test(attr) ? attr.toLowerCase() : attr);
- dojo.attr(mapNode, attrName, value);
- break;
- case "innerText":
- mapNode.innerHTML = "";
- mapNode.appendChild(dojo.doc.createTextNode(value));
- break;
- case "innerHTML":
- mapNode.innerHTML = value;
- break;
- case "class":
- dojo.replaceClass(mapNode, value, this[attr]);
- break;
- }
- }, this);
- },
- get: function(name){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var names = this._getAttrNames(name);
- return this[names.g] ? this[names.g]() : this[name];
- },
-
- set: function(name, value){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(typeof name === "object"){
- for(var x in name){
- this.set(x, name[x]);
- }
- return this;
- }
- var names = this._getAttrNames(name);
- if(this[names.s]){
-
- var result = this[names.s].apply(this, Array.prototype.slice.call(arguments, 1));
- }else{
-
- if(name in this.attributeMap){
- this._attrToDom(name, value);
- }
- this._set(name, value);
- }
- return result || this;
- },
-
- _attrPairNames: {},
- _getAttrNames: function(name){
-
-
-
-
-
- var apn = this._attrPairNames;
- if(apn[name]){ return apn[name]; }
- var uc = name.charAt(0).toUpperCase() + name.substr(1);
- return (apn[name] = {
- n: name+"Node",
- s: "_set"+uc+"Attr",
- g: "_get"+uc+"Attr"
- });
- },
- _set: function(/*String*/ name, /*anything*/ value){
-
-
-
- var oldValue = this[name];
- this[name] = value;
- if(this._watchCallbacks && this._created && !isEqual(value, oldValue)){
- this._watchCallbacks(name, oldValue, value);
- }
- },
- toString: function(){
-
-
-
-
-
-
- return '[Widget ' + this.declaredClass + ', ' + (this.id || 'NO ID') + ']';
- },
- getDescendants: function(){
-
-
-
-
- return this.containerNode ? dojo.query('[widgetId]', this.containerNode).map(dijit.byNode) : [];
- },
- getChildren: function(){
-
-
-
- return this.containerNode ? dijit.findWidgets(this.containerNode) : [];
- },
- connect: function(
- /*Object|null*/ obj,
- /*String|Function*/ event,
- /*String|Function*/ method){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var handles = [dojo._connect(obj, event, this, method)];
- this._connects.push(handles);
- return handles;
- },
- disconnect: function(/* _Widget.Handle */ handles){
-
-
-
-
-
- for(var i=0; i<this._connects.length; i++){
- if(this._connects[i] == handles){
- dojo.forEach(handles, dojo.disconnect);
- this._connects.splice(i, 1);
- return;
- }
- }
- },
- subscribe: function(
- /*String*/ topic,
- /*String|Function*/ method){
-
-
-
-
-
-
-
-
-
-
-
-
-
- var handle = dojo.subscribe(topic, this, method);
-
- this._subscribes.push(handle);
- return handle;
- },
- unsubscribe: function(/*Object*/ handle){
-
-
-
- for(var i=0; i<this._subscribes.length; i++){
- if(this._subscribes[i] == handle){
- dojo.unsubscribe(handle);
- this._subscribes.splice(i, 1);
- return;
- }
- }
- },
- isLeftToRight: function(){
-
-
-
-
- return this.dir ? (this.dir == "ltr") : dojo._isBodyLtr();
- },
- placeAt: function(/* String|DomNode|_Widget */reference, /* String?|Int? */position){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(reference.declaredClass && reference.addChild){
- reference.addChild(this, position);
- }else{
- dojo.place(this.domNode, reference, position);
- }
- return this;
- },
- defer: function(fcn, delay){
-
-
-
-
-
-
-
-
- var timer = setTimeout(dojo.hitch(this,
- function(){
- timer = null;
- if(!this._destroyed){
- dojo.hitch(this, fcn)();
- }
- }),
- delay || 0
- );
- return {
- remove: function(){
- if(timer){
- clearTimeout(timer);
- timer = null;
- }
- return null;
- }
- };
- }
- });
- })();
- }
|