1
1
/*jslint white: true nomen: true plusplus: true */
2
2
/*global mx, mxui, mendix, dojo, require, console, define, module */
3
- /**
4
3
5
- HTMLSnippet
6
- ========================
7
-
8
- @file : HTMLSnippet.js
9
- @version : 1.0
10
- @author : ...
11
- @date : Tuesday, January 20, 2015
12
- @copyright : Mendix Technology BV
13
- @license : Apache License, Version 2.0, January 2004
14
-
15
- Documentation
16
- ========================
17
- Describe your widget here.
18
-
19
- */
20
-
21
- ( function ( ) {
22
- 'use strict' ;
23
-
24
- // test
25
- require ( [
26
-
27
- 'mxui/widget/_WidgetBase' , 'dijit/_Widget' ,
28
- 'mxui/dom' , 'dojo/dom' , 'dojo/query' , 'dojo/dom-prop' , 'dojo/dom-geometry' , 'dojo/dom-class' , 'dojo/dom-style' , 'dojo/on' , 'dojo/_base/lang' , 'dojo/_base/declare' , 'dojo/text'
29
-
30
- ] , function ( _WidgetBase , _Widget , domMx , dom , domQuery , domProp , domGeom , domClass , domStyle , on , lang , declare , text ) {
31
-
32
- // Declare widget.
33
- return declare ( 'HTMLSnippet.widget.HTMLSnippet' , [ _WidgetBase , _Widget ] , {
34
-
35
- postCreate : function ( ) {
36
- switch ( this . contenttype ) {
37
- case 'html' :
38
- dojo . style ( this . domNode , {
39
- 'height' : 'auto' ,
40
- 'width' : '100%' ,
41
- 'outline' : 0
42
- } ) ;
43
- dojo . attr ( this . domNode , 'style' , this . style ) ; //might override height and width
44
- this . domNode . innerHTML = this . contents ;
45
- break ;
46
- case 'js' :
47
- try {
48
- eval ( this . contents ) ;
49
- } catch ( e ) {
50
- dojo . html . set ( this . domNode , "Error while evaluating JavaScript: " + e ) ;
51
- }
52
- break ;
53
- }
54
-
55
- this . actLoaded ( ) ;
56
- }
57
- } ) ;
58
- } ) ;
59
-
60
- } ( ) ) ;
4
+ require ( [
5
+ 'dojo/_base/declare' , 'mxui/widget/_WidgetBase' ,
6
+ 'mxui/dom' , 'dojo/query' , 'dojo/dom-prop' , 'dojo/dom-style' ,
7
+ 'dojo/dom-attr'
8
+ ] , function ( declare , _WidgetBase , dom , domQuery , domProp , domStyle , domAttr ) {
9
+
10
+ 'use strict' ;
11
+
12
+ // Declare widget.
13
+ return declare ( 'HTMLSnippet.widget.HTMLSnippet' , [ _WidgetBase ] , {
14
+
15
+ // dijit._WidgetBase.postCreate is called after constructing the widget. Implement to do extra setup work.
16
+ postCreate : function ( ) {
17
+ console . log ( this . id + '.postCreate' ) ;
18
+
19
+ switch ( this . contenttype ) {
20
+ case 'html' :
21
+ domStyle . set ( this . domNode , {
22
+ 'height' : 'auto' ,
23
+ 'width' : '100%' ,
24
+ 'outline' : 0
25
+ } ) ;
26
+
27
+ domAttr . set ( this . domNode , 'style' , this . style ) ; //might override height and width
28
+ this . domNode . innerHTML = this . contents ;
29
+ break ;
30
+ case 'js' :
31
+ try {
32
+ eval ( this . contents ) ;
33
+ } catch ( e ) {
34
+ dojo . html . set ( this . domNode , "Error while evaluating JavaScript: " + e ) ;
35
+ }
36
+ break ;
37
+ }
38
+ }
39
+ } ) ;
40
+ } ) ;
0 commit comments