| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/_base/Deferred", |
| 4 |
"dojo/_base/lang", |
| 5 |
"dojo/_base/window", |
| 6 |
"dojo/_base/xhr", |
| 7 |
"./_ExecScriptMixin", |
| 8 |
"./ProgressIndicator", |
| 9 |
"./lazyLoadUtils" |
| 10 |
], function(declare, Deferred, lang, win, xhr, ExecScriptMixin, ProgressIndicator, lazyLoadUtils){ |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
return declare("dojox.mobile._ContentPaneMixin", ExecScriptMixin, { |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
href: "", |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
lazy: false, |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
content: "", |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
parseOnLoad: true, |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
prog: true, |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
executeScripts: true, |
| 47 |
|
| 48 |
constructor: function(){ |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
if(this.prog){ |
| 54 |
this._p = ProgressIndicator.getInstance(); |
| 55 |
} |
| 56 |
}, |
| 57 |
|
| 58 |
loadHandler: function(response){ |
| 59 |
|
| 60 |
|
| 61 |
this.set("content", response); |
| 62 |
}, |
| 63 |
|
| 64 |
errorHandler: function(err){ |
| 65 |
|
| 66 |
|
| 67 |
if(this._p){ this._p.stop(); } |
| 68 |
}, |
| 69 |
|
| 70 |
load: function(){ |
| 71 |
|
| 72 |
|
| 73 |
this.lazy = false; |
| 74 |
this.set("href", this.href); |
| 75 |
}, |
| 76 |
|
| 77 |
onLoad: function(){ |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
return true; |
| 83 |
}, |
| 84 |
|
| 85 |
_setHrefAttr: function(href){ |
| 86 |
|
| 87 |
|
| 88 |
if(this.lazy || !href || href === this._loaded){ |
| 89 |
this.lazy = false; |
| 90 |
return null; |
| 91 |
} |
| 92 |
var p = this._p; |
| 93 |
if(p){ |
| 94 |
win.body().appendChild(p.domNode); |
| 95 |
p.start(); |
| 96 |
} |
| 97 |
this._set("href", href); |
| 98 |
this._loaded = href; |
| 99 |
return xhr.get({ |
| 100 |
url: href, |
| 101 |
handleAs: "text", |
| 102 |
load: lang.hitch(this, "loadHandler"), |
| 103 |
error: lang.hitch(this, "errorHandler") |
| 104 |
}); |
| 105 |
}, |
| 106 |
|
| 107 |
_setContentAttr: function(data){ |
| 108 |
|
| 109 |
|
| 110 |
this.destroyDescendants(); |
| 111 |
if(typeof data === "object"){ |
| 112 |
this.containerNode.appendChild(data); |
| 113 |
}else{ |
| 114 |
if(this.executeScripts){ |
| 115 |
data = this.execScript(data); |
| 116 |
} |
| 117 |
this.containerNode.innerHTML = data; |
| 118 |
} |
| 119 |
if(this.parseOnLoad){ |
| 120 |
var _this = this; |
| 121 |
return Deferred.when(lazyLoadUtils.instantiateLazyWidgets(_this.containerNode), function(){ |
| 122 |
if(_this._p){ _this._p.stop(); } |
| 123 |
return _this.onLoad(); |
| 124 |
}); |
| 125 |
} |
| 126 |
if(this._p){ this._p.stop(); } |
| 127 |
return this.onLoad(); |
| 128 |
} |
| 129 |
}); |
| 130 |
}); |