123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 |
- if(!dojo._hasResource["dijit.layout.ContentPane"]){
- dojo._hasResource["dijit.layout.ContentPane"] = true;
- dojo.provide("dijit.layout.ContentPane");
- dojo.require("dijit._Widget");
- dojo.require("dijit.layout._ContentPaneResizeMixin");
- dojo.require("dojo.string");
- dojo.require("dojo.html");
- dojo.requireLocalization("dijit", "loading", null, "ROOT,ar,az,bg,ca,cs,da,de,el,es,fi,fr,he,hr,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");
- dojo.declare(
- "dijit.layout.ContentPane", [dijit._Widget, dijit.layout._ContentPaneResizeMixin],
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- href: "",
-
-
-
- extractContent: false,
-
-
- parseOnLoad: true,
-
-
-
-
-
- parserScope: dojo._scopeName,
-
-
- preventCache: false,
-
-
- preload: false,
-
-
- refreshOnShow: false,
-
-
- loadingMessage: "<span class='dijitContentPaneLoading'>${loadingState}</span>",
-
-
- errorMessage: "<span class='dijitContentPaneError'>${errorState}</span>",
-
-
-
-
-
-
-
- isLoaded: false,
- baseClass: "dijitContentPane",
-
-
-
- ioArgs: {},
-
-
-
-
-
-
-
-
- onLoadDeferred: null,
-
-
-
- attributeMap: dojo.delegate(dijit._Widget.prototype.attributeMap, {
- title: []
- }),
-
- stopParser: true,
-
-
-
-
- template: false,
- create: function(params, srcNodeRef){
-
-
-
- if((!params || !params.template) && srcNodeRef && !("href" in params) && !("content" in params)){
- var df = dojo.doc.createDocumentFragment();
- srcNodeRef = dojo.byId(srcNodeRef)
- while(srcNodeRef.firstChild){
- df.appendChild(srcNodeRef.firstChild);
- }
- params = dojo.delegate(params, {content: df});
- }
- this.inherited(arguments, [params, srcNodeRef]);
- },
- postMixInProperties: function(){
- this.inherited(arguments);
- var messages = dojo.i18n.getLocalization("dijit", "loading", this.lang);
- this.loadingMessage = dojo.string.substitute(this.loadingMessage, messages);
- this.errorMessage = dojo.string.substitute(this.errorMessage, messages);
- },
- buildRendering: function(){
- this.inherited(arguments);
-
-
- if(!this.containerNode){
- this.containerNode = this.domNode;
- }
-
-
- this.domNode.title = "";
- if(!dojo.attr(this.domNode,"role")){
- dijit.setWaiRole(this.domNode, "group");
- }
- },
- _startChildren: function(){
-
-
-
- this.inherited(arguments);
-
- if(this._contentSetter){
- dojo.forEach(this._contentSetter.parseResults, function(obj){
- if(!obj._started && !obj._destroyed && dojo.isFunction(obj.startup)){
- obj.startup();
- obj._started = true;
- }
- }, this);
- }
- },
- setHref: function(/*String|Uri*/ href){
-
-
- dojo.deprecated("dijit.layout.ContentPane.setHref() is deprecated. Use set('href', ...) instead.", "", "2.0");
- return this.set("href", href);
- },
- _setHrefAttr: function(/*String|Uri*/ href){
-
-
-
-
-
-
-
-
- this.cancel();
- this.onLoadDeferred = new dojo.Deferred(dojo.hitch(this, "cancel"));
- this.onLoadDeferred.addCallback(dojo.hitch(this, "onLoad"));
- this._set("href", href);
-
-
-
- if(this.preload || (this._created && this._isShown())){
- this._load();
- }else{
-
-
- this._hrefChanged = true;
- }
- return this.onLoadDeferred;
- },
- setContent: function(/*String|DomNode|Nodelist*/data){
-
-
- dojo.deprecated("dijit.layout.ContentPane.setContent() is deprecated. Use set('content', ...) instead.", "", "2.0");
- this.set("content", data);
- },
- _setContentAttr: function(/*String|DomNode|Nodelist*/data){
-
-
-
-
-
-
-
-
-
-
- this._set("href", "");
-
- this.cancel();
-
-
- this.onLoadDeferred = new dojo.Deferred(dojo.hitch(this, "cancel"));
- if(this._created){
-
-
-
- this.onLoadDeferred.addCallback(dojo.hitch(this, "onLoad"));
- }
- this._setContent(data || "");
- this._isDownloaded = false;
- return this.onLoadDeferred;
- },
- _getContentAttr: function(){
-
-
- return this.containerNode.innerHTML;
- },
- cancel: function(){
-
-
- if(this._xhrDfd && (this._xhrDfd.fired == -1)){
- this._xhrDfd.cancel();
- }
- delete this._xhrDfd;
- this.onLoadDeferred = null;
- },
- uninitialize: function(){
- if(this._beingDestroyed){
- this.cancel();
- }
- this.inherited(arguments);
- },
- destroyRecursive: function(/*Boolean*/ preserveDom){
-
-
-
- if(this._beingDestroyed){
- return;
- }
- this.inherited(arguments);
- },
- _onShow: function(){
-
-
-
-
-
-
-
-
-
- this.inherited(arguments);
- if(this.href){
- if(!this._xhrDfd &&
- (!this.isLoaded || this._hrefChanged || this.refreshOnShow)
- ){
- return this.refresh();
- }
- }
- },
- refresh: function(){
-
-
-
-
-
-
-
- this.cancel();
- this.onLoadDeferred = new dojo.Deferred(dojo.hitch(this, "cancel"));
- this.onLoadDeferred.addCallback(dojo.hitch(this, "onLoad"));
- this._load();
- return this.onLoadDeferred;
- },
- _load: function(){
-
-
-
- this._setContent(this.onDownloadStart(), true);
- var self = this;
- var getArgs = {
- preventCache: (this.preventCache || this.refreshOnShow),
- url: this.href,
- handleAs: "text"
- };
- if(dojo.isObject(this.ioArgs)){
- dojo.mixin(getArgs, this.ioArgs);
- }
- var hand = (this._xhrDfd = (this.ioMethod || dojo.xhrGet)(getArgs));
- hand.addCallback(function(html){
- try{
- self._isDownloaded = true;
- self._setContent(html, false);
- self.onDownloadEnd();
- }catch(err){
- self._onError('Content', err);
- }
- delete self._xhrDfd;
- return html;
- });
- hand.addErrback(function(err){
- if(!hand.canceled){
-
- self._onError('Download', err);
- }
- delete self._xhrDfd;
- return err;
- });
-
- delete this._hrefChanged;
- },
- _onLoadHandler: function(data){
-
-
- this._set("isLoaded", true);
- try{
- this.onLoadDeferred.callback(data);
- }catch(e){
- console.error('Error '+this.widgetId+' running custom onLoad code: ' + e.message);
- }
- },
- _onUnloadHandler: function(){
-
-
- this._set("isLoaded", false);
- try{
- this.onUnload();
- }catch(e){
- console.error('Error '+this.widgetId+' running custom onUnload code: ' + e.message);
- }
- },
- destroyDescendants: function(){
-
-
-
- if(this.isLoaded){
- this._onUnloadHandler();
- }
-
-
-
-
- var setter = this._contentSetter;
- dojo.forEach(this.getChildren(), function(widget){
- if(widget.destroyRecursive){
- widget.destroyRecursive();
- }
- });
- if(setter){
-
-
- dojo.forEach(setter.parseResults, function(widget){
- if(widget.destroyRecursive && widget.domNode && widget.domNode.parentNode == dojo.body()){
- widget.destroyRecursive();
- }
- });
- delete setter.parseResults;
- }
-
- dojo.html._emptyNode(this.containerNode);
-
- delete this._singleChild;
- },
- _setContent: function(/*String|DocumentFragment*/ cont, /*Boolean*/ isFakeContent){
-
-
-
- this.destroyDescendants();
-
-
-
-
-
- var setter = this._contentSetter;
- if(! (setter && setter instanceof dojo.html._ContentSetter)){
- setter = this._contentSetter = new dojo.html._ContentSetter({
- node: this.containerNode,
- _onError: dojo.hitch(this, this._onError),
- onContentError: dojo.hitch(this, function(e){
-
-
- var errMess = this.onContentError(e);
- try{
- this.containerNode.innerHTML = errMess;
- }catch(e){
- console.error('Fatal '+this.id+' could not change content due to '+e.message, e);
- }
- })
- });
- };
- var setterParams = dojo.mixin({
- cleanContent: this.cleanContent,
- extractContent: this.extractContent,
- parseContent: this.parseOnLoad,
- parserScope: this.parserScope,
- startup: false,
- dir: this.dir,
- lang: this.lang
- }, this._contentSetterParams || {});
- setter.set( (dojo.isObject(cont) && cont.domNode) ? cont.domNode : cont, setterParams );
-
- delete this._contentSetterParams;
- if(this.doLayout){
- this._checkIfSingleChild();
- }
- if(!isFakeContent){
- if(this._started){
-
- this._startChildren();
-
-
-
-
- this._scheduleLayout();
- }
- this._onLoadHandler(cont);
- }
- },
- _onError: function(type, err, consoleText){
- this.onLoadDeferred.errback(err);
-
-
- var errText = this['on' + type + 'Error'].call(this, err);
- if(consoleText){
- console.error(consoleText, err);
- }else if(errText){
- this._setContent(errText, true);
- }
- },
-
- onLoad: function(data){
-
-
-
-
- },
- onUnload: function(){
-
-
-
-
- },
- onDownloadStart: function(){
-
-
-
-
-
-
-
-
- return this.loadingMessage;
- },
- onContentError: function(/*Error*/ error){
-
-
-
-
-
-
-
-
-
-
- },
- onDownloadError: function(/*Error*/ error){
-
-
-
-
-
-
-
-
-
-
- return this.errorMessage;
- },
- onDownloadEnd: function(){
-
-
-
-
- }
- });
- }
|