Skip to content

Commit b840566

Browse files
author
Jelte Lagendijk
committed
Cleanup code
1 parent 89d9110 commit b840566

File tree

5 files changed

+72
-72
lines changed

5 files changed

+72
-72
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ test/.project
1414
dist/
1515

1616
node_modules/
17-
.editorconfig
1817
*DS_Store*
1918
.vscode/
2019
*.bak

src/HTMLSnippet/HTMLSnippet.xml

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,65 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<widget id="HTMLSnippet.widget.HTMLSnippet" needsEntityContext="false" xmlns="http://www.mendix.com/widget/1.0/">
3-
<name>HTMLSnippet</name>
4-
<description>The HTMLSnippet widget can be used to insert a custom piece of HTML or JavaScript in the client</description>
5-
<icon>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ bWFnZVJlYWR5ccllPAAAAm9JREFUeNqEU01IVFEU/t6bGcfGJq2RYkhKSKdFIGQxRRAR0q6kZuuq hWZY0SZa1EKhRQsTpEVZrVpUVgxGFETgLgorEdPsZ1FizJhJ1Py8N+/d+97p3DcK80Lr8i733HvO 953vnnOfRkRYaVi2QEADQqcmfQE0tEur3GurEUghPHAq1eo7T6fH/SSKYKWJrjd0eZLILuYoa/DB INGmu0TnJthm33JcEP8ZUhJOjgHHk8COGPDd8Pv1f4FjtRyg64jWAAcbgGNNQFujPybY9/AHrUYQ yX7F2GwGyS37UB8BKpMf6Jsh05TlK+xpXlNZZ0iXMNLYhKPdw7iZ7kLLRiDAaV7NAZ2pG+jZfg17 8/PoFU+g9T5YIEWQMyQcFx5YsmE7BCFdnL4w4lN1NtGP/p7PmPoAjE/Fywpcruahligevf6F9t21 CId0JYQ/QvJeB158zONwax2GXy5iZuAEJqaBREIRcI0sKb1M4aAGS7ge+PrzBWjc6SuPs2iIhZCI h7F5QxVqqnTcGnUwcBvovrhUxKIlUVIEIQ0d+2MI6hrUmepxwXLguqpGa5UglDhBoeQg3z6NeF0I 5+/PQS+YxM/Whclz8Ok8bCYzSq4HKHKww0TvZg18yhis0IF6Y6btMBnBtWzov00bJQYrRzkzOLNc 2isFhKvPMljMS0/BukgAQ53NEGyTRdDaLr2nIzvX49tPCzYfWqzAYnalRNlqFd7krnB3hFNu89b6 MEbvfEEwx8xKUrQ6AJvrUC00iDAHSV6lDuGSB3IYzDzc6rLa5X9Q23bmLZX4RZF3J3baylbyHEBd jYHenhV4Ff1r/BFgACiOjHWT8QsmAAAAAElFTkSuQmCC</icon>
6-
<properties>
7-
<!-- content type -->
8-
<property key="contenttype" type="enumeration" defaultValue="html">
9-
<caption>Content Type</caption>
10-
<category>Behavior</category>
11-
<description>Defines whether this widget provides a piece of HTML or a piece of JavaScript.
12-
</description>
13-
<enumerationValues>
14-
<enumerationValue key="html">HTML</enumerationValue>
15-
<enumerationValue key="js">JavaScript</enumerationValue>
16-
<enumerationValue key="jsjQuery">JavaScript with jQuery</enumerationValue>
17-
</enumerationValues>
18-
</property>
19-
20-
<!-- html/js string -->
21-
<property key="contents" type="translatableString" multiline="true" required="false">
22-
<caption>Contents</caption>
23-
<category>Behavior</category>
24-
<description>The HTML or Javascript to embed.</description>
25-
</property>
26-
27-
<!-- html/js file path -->
28-
<property key="contentsPath" type="string" required="false">
29-
<caption>External File</caption>
30-
<category>Behavior</category>
31-
<description>The path to the HTML or Javascript you want to add. The root folder is theme folder. Will override the Contents if used.</description>
32-
</property>
33-
34-
<!-- The onclick microflow -->
35-
<property key="onclickmf" type="microflow" required="false">
36-
<caption> On click microflow </caption>
37-
<category>Behavior</category>
38-
<description>The microflow to execute on click</description>
39-
<returnType type="Void"/>
40-
</property>
41-
42-
<!-- description of what the html/js should do -->
43-
<property key="documentation" type="string" multiline="true" required="false">
44-
<caption>Documentation</caption>
45-
<category>Common</category>
46-
<description>Documentation of this widget. Should explain its purpose.</description>
47-
</property>
48-
49-
<!-- Refresh when the context changes -->
50-
<property key="refreshOnContextChange" type="boolean" defaultValue="false">
51-
<caption>Refresh on context change</caption>
52-
<category>Behavior</category>
53-
<description>Refresh when the context changes</description>
54-
</property>
55-
56-
<!-- Refresh when the context updates -->
57-
<property key="refreshOnContextUpdate" type="boolean" defaultValue="false">
58-
<caption>Refresh on context update</caption>
59-
<category>Behavior</category>
60-
<description>Refresh when the context updates (works only when context change is true)</description>
61-
</property>
62-
</properties>
3+
<name>HTMLSnippet</name>
4+
<description>The HTMLSnippet widget can be used to insert a custom piece of HTML or JavaScript in the client</description>
5+
6+
<icon>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ bWFnZVJlYWR5ccllPAAAAm9JREFUeNqEU01IVFEU/t6bGcfGJq2RYkhKSKdFIGQxRRAR0q6kZuuq hWZY0SZa1EKhRQsTpEVZrVpUVgxGFETgLgorEdPsZ1FizJhJ1Py8N+/d+97p3DcK80Lr8i733HvO 953vnnOfRkRYaVi2QEADQqcmfQE0tEur3GurEUghPHAq1eo7T6fH/SSKYKWJrjd0eZLILuYoa/DB INGmu0TnJthm33JcEP8ZUhJOjgHHk8COGPDd8Pv1f4FjtRyg64jWAAcbgGNNQFujPybY9/AHrUYQ yX7F2GwGyS37UB8BKpMf6Jsh05TlK+xpXlNZZ0iXMNLYhKPdw7iZ7kLLRiDAaV7NAZ2pG+jZfg17 8/PoFU+g9T5YIEWQMyQcFx5YsmE7BCFdnL4w4lN1NtGP/p7PmPoAjE/Fywpcruahligevf6F9t21 CId0JYQ/QvJeB158zONwax2GXy5iZuAEJqaBREIRcI0sKb1M4aAGS7ge+PrzBWjc6SuPs2iIhZCI h7F5QxVqqnTcGnUwcBvovrhUxKIlUVIEIQ0d+2MI6hrUmepxwXLguqpGa5UglDhBoeQg3z6NeF0I 5+/PQS+YxM/Whclz8Ok8bCYzSq4HKHKww0TvZg18yhis0IF6Y6btMBnBtWzov00bJQYrRzkzOLNc 2isFhKvPMljMS0/BukgAQ53NEGyTRdDaLr2nIzvX49tPCzYfWqzAYnalRNlqFd7krnB3hFNu89b6 MEbvfEEwx8xKUrQ6AJvrUC00iDAHSV6lDuGSB3IYzDzc6rLa5X9Q23bmLZX4RZF3J3baylbyHEBd jYHenhV4Ff1r/BFgACiOjHWT8QsmAAAAAElFTkSuQmCC</icon>
7+
8+
<properties>
9+
<!-- content type -->
10+
<property key="contenttype" type="enumeration" defaultValue="html">
11+
<caption>Content Type</caption>
12+
<category>Behavior</category>
13+
<description>Defines whether this widget provides a piece of HTML or a piece of JavaScript.
14+
</description>
15+
<enumerationValues>
16+
<enumerationValue key="html">HTML</enumerationValue>
17+
<enumerationValue key="js">JavaScript</enumerationValue>
18+
<enumerationValue key="jsjQuery">JavaScript with jQuery</enumerationValue>
19+
</enumerationValues>
20+
</property>
21+
22+
<!-- html/js string -->
23+
<property key="contents" type="translatableString" multiline="true" required="false">
24+
<caption>Contents</caption>
25+
<category>Behavior</category>
26+
<description>The HTML or Javascript to embed.</description>
27+
</property>
28+
29+
<!-- html/js file path -->
30+
<property key="contentsPath" type="string" required="false">
31+
<caption>External File</caption>
32+
<category>Behavior</category>
33+
<description>The path to the HTML or Javascript you want to add. The root folder is theme folder. Will override the Contents if used.</description>
34+
</property>
35+
36+
<!-- The onclick microflow -->
37+
<property key="onclickmf" type="microflow" required="false">
38+
<caption> On click microflow </caption>
39+
<category>Behavior</category>
40+
<description>The microflow to execute on click</description>
41+
<returnType type="Void"/>
42+
</property>
43+
44+
<!-- description of what the html/js should do -->
45+
<property key="documentation" type="string" multiline="true" required="false">
46+
<caption>Documentation</caption>
47+
<category>Common</category>
48+
<description>Documentation of this widget. Should explain its purpose.</description>
49+
</property>
50+
51+
<!-- Refresh when the context changes -->
52+
<property key="refreshOnContextChange" type="boolean" defaultValue="false">
53+
<caption>Refresh on context change</caption>
54+
<category>Behavior</category>
55+
<description>Refresh when the context changes</description>
56+
</property>
57+
58+
<!-- Refresh when the context updates -->
59+
<property key="refreshOnContextUpdate" type="boolean" defaultValue="false">
60+
<caption>Refresh on context update</caption>
61+
<category>Behavior</category>
62+
<description>Refresh when the context updates (works only when context change is true)</description>
63+
</property>
64+
</properties>
6365
</widget>

src/HTMLSnippet/widget/HTMLSnippet.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/*jslint white: true, nomen: true, plusplus: true */
2-
/*global mx, mxui, mendix, dojo, require, console, define, module, document*/
3-
4-
require([
1+
/*jslint -W061:false*/
2+
define([
53
"dojo/_base/declare",
64
"mxui/widget/_WidgetBase",
75

@@ -66,7 +64,9 @@ require([
6664
domConstruct.place(scriptNode, this.domNode, "only");
6765
} else {
6866
if (this.contenttype === "jsjQuery") {
69-
require(["HTMLSnippet/lib/jquery-1.11.3"], lang.hitch(this, this.evalJs));
67+
require([
68+
"HTMLSnippet/lib/jquery-1.11.3"
69+
], lang.hitch(this, this.evalJs));
7070
} else {
7171
this.evalJs();
7272
}
@@ -81,11 +81,10 @@ require([
8181

8282
if (this.refreshOnContextUpdate) {
8383
if (this._objectChangeHandler !== null) {
84-
this.unsubscribe(this._objectChangeHandler);
84+
mx.data.unsubscribe(this._objectChangeHandler);
8585
}
86-
8786
if (obj) {
88-
this.subscribe({
87+
this._objectChangeHandler = mx.data.subscribe({
8988
guid: obj.getGuid(),
9089
callback: lang.hitch(this, function() {
9190
this.executeCode();
@@ -95,8 +94,7 @@ require([
9594
}
9695
}
9796

98-
99-
callback();
97+
mendix.lang.nullExec(callback);
10098
},
10199

102100
_setupEvents: function() {
@@ -131,6 +129,7 @@ require([
131129
domConstruct.place("<div class=\"alert alert-danger\">Error while evaluating javascript input: " + e + "</div>", this.domNode, "only");
132130
}
133131
}
134-
135132
});
136133
});
134+
135+
require(["HTMLSnippet/widget/HTMLSnippet"]);

test/Test.mpr

13 KB
Binary file not shown.

test/widgets/HTMLSnippet.mpk

-19 KB
Binary file not shown.

0 commit comments

Comments
 (0)