3
3
4
4
require ( [
5
5
'dojo/_base/declare' , 'mxui/widget/_WidgetBase' ,
6
- 'mxui/dom' , 'dojo/dom-style' , 'dojo/dom-attr' , 'dojo/html '
7
- ] , function ( declare , _WidgetBase , dom , domStyle , domAttr , html ) {
6
+ 'mxui/dom' , 'dojo/dom-style' , 'dojo/dom-attr' , 'dojo/dom-construct' , 'dijit/layout/LinkPane '
7
+ ] , function ( declare , _WidgetBase , dom , domStyle , domAttr , domConstruct , linkPane ) {
8
8
9
9
'use strict' ;
10
10
@@ -18,23 +18,54 @@ require([
18
18
postCreate : function ( ) {
19
19
console . log ( this . id + '.postCreate' ) ;
20
20
21
- switch ( this . contenttype ) {
21
+ var external = this . contentsPath != '' ? true : false ;
22
+
23
+ switch ( this . contenttype ) {
22
24
case 'html' :
23
- domStyle . set ( this . domNode , {
24
- 'height' : 'auto' ,
25
- 'width' : '100%' ,
26
- 'outline' : 0
27
- } ) ;
28
25
29
- domAttr . set ( this . domNode , 'style' , this . style ) ; //might override height and width
30
- html . set ( this . domNode , this . contents ) ;
26
+ if ( external )
27
+ {
28
+ new linkPane (
29
+ {
30
+ preload : true ,
31
+ loadingMessage : "" ,
32
+ href : this . contentsPath ,
33
+ onDownloadError : function ( ) { console . log ( "Error loading html path" ) ; }
34
+ } ) . placeAt ( this . domNode . id ) . startup ( ) ;
35
+ }
36
+ else
37
+ {
38
+ domStyle . set ( this . domNode , {
39
+ 'height' : 'auto' ,
40
+ 'width' : '100%' ,
41
+ 'outline' : 0
42
+ } ) ;
43
+
44
+ domAttr . set ( this . domNode , 'style' , this . style ) ; // might override height and width
45
+ domConstruct . place ( this . contents , this . domNode , "only" ) ;
46
+ }
47
+
31
48
break ;
32
49
case 'js' :
33
- try {
34
- eval ( this . contents ) ;
35
- } catch ( e ) {
36
- html . set ( this . domNode , "Error while evaluating JavaScript: " + e ) ;
37
- }
50
+
51
+ if ( external )
52
+ {
53
+ var scriptNode = document . createElement ( "script" ) ,
54
+ intDate = + new Date ( ) ;
55
+
56
+ scriptNode . type = "text/javascript" ;
57
+ scriptNode . src = this . contentsPath + "?v=" + intDate . toString ( ) ;
58
+
59
+ domConstruct . place ( scriptNode , this . domNode , "only" ) ;
60
+ }
61
+ else
62
+ {
63
+ try {
64
+ eval ( this . contents ) ;
65
+ } catch ( e ) {
66
+ domConstruct . place ( "Error while evaluating JavaScript: " + e , this . domNode , "only" ) ;
67
+ }
68
+ }
38
69
break ;
39
70
}
40
71
}
0 commit comments