Skip to content

Commit 277c3d6

Browse files
committed
Cleaned up dojo modules
1 parent 615784c commit 277c3d6

File tree

5 files changed

+47
-58
lines changed

5 files changed

+47
-58
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
test/javasource/
2+
test/deployment/
3+
test/.classpath
4+
test/.project
5+
*.mws
6+
*.launch
7+
*.tmp
8+
*.lock
9+
.idea/

src/HTMLSnippet/widget/HTMLSnippet.js

Lines changed: 37 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,40 @@
11
/*jslint white: true nomen: true plusplus: true */
22
/*global mx, mxui, mendix, dojo, require, console, define, module */
3-
/**
43

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+
});

src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="HTMLSnippet" version="3.0" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="HTMLSnippet" version="1.2" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="HTMLSnippet/HTMLSnippet.xml"/>
66
</widgetFiles>
Binary file not shown.

test/widgets/HTMLSnippet.mpk

-221 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)