Skip to content

Commit c92dfbd

Browse files
author
Jelte Lagendijk
committed
Cleanup whitespaces & readability
1 parent 8e3f245 commit c92dfbd

File tree

3 files changed

+92
-94
lines changed

3 files changed

+92
-94
lines changed

src/HTMLSnippet/HTMLSnippet.xml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
<widget id="HTMLSnippet.widget.HTMLSnippet" needsEntityContext="false" xmlns="http://www.mendix.com/widget/1.0/">
33
<name>HTMLSnippet</name>
44
<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/Whclz8Ok8bCYzSq4HKHKww0TvZg18yhis0IF6Y6btM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 MEbvfEEwx8xKUrQ6AJvrUC00iDAHSV6lDuGSB3IYzDzc6rLa5X9Q23bmLZX4RZF3J3baylbyHEBd jYHenhV4Ff1r/BFgACiOjHWT8QsmAAAAAElFTkSuQmCC</icon>
96
<properties>
10-
117
<!-- content type -->
128
<property key="contenttype" type="enumeration" defaultValue="html">
139
<caption>Content Type</caption>
@@ -17,17 +13,17 @@
1713
<enumerationValues>
1814
<enumerationValue key="html">HTML</enumerationValue>
1915
<enumerationValue key="js">JavaScript</enumerationValue>
20-
<enumerationValue key="jsjQuery">JavaScript with jQuery</enumerationValue>
16+
<enumerationValue key="jsjQuery">JavaScript with jQuery</enumerationValue>
2117
</enumerationValues>
2218
</property>
23-
19+
2420
<!-- html/js string -->
2521
<property key="contents" type="translatableString" multiline="true" required="false">
2622
<caption>Contents</caption>
2723
<category>Behavior</category>
2824
<description>The HTML or Javascript to embed.</description>
2925
</property>
30-
26+
3127
<!-- html/js file path -->
3228
<property key="contentsPath" type="string" required="false">
3329
<caption>External File</caption>
@@ -42,7 +38,7 @@
4238
<description>The microflow to execute on click</description>
4339
<returnType type="Void"/>
4440
</property>
45-
41+
4642
<!-- description of what the html/js should do -->
4743
<property key="documentation" type="string" multiline="true" required="false">
4844
<caption>Documentation</caption>
@@ -51,4 +47,3 @@
5147
</property>
5248
</properties>
5349
</widget>
54-

src/HTMLSnippet/widget/HTMLSnippet.js

Lines changed: 86 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2,96 +2,99 @@
22
/*global mx, mxui, mendix, dojo, require, console, define, module, document*/
33

44
require([
5-
'dojo/_base/declare', 'mxui/widget/_WidgetBase',
6-
'mxui/dom', 'dojo/dom-style', 'dojo/dom-attr', 'dojo/dom-construct', 'dojo/_base/lang', 'dijit/layout/LinkPane'
7-
], function (declare, _WidgetBase, dom, domStyle, domAttr, domConstruct, lang, linkPane) {
8-
'use strict';
5+
"dojo/_base/declare",
6+
"mxui/widget/_WidgetBase",
97

10-
return declare('HTMLSnippet.widget.HTMLSnippet', [_WidgetBase], {
11-
postCreate: function () {
12-
var external = this.contentsPath !== '' ? true : false;
8+
"mxui/dom",
9+
"dojo/dom-style",
10+
"dojo/dom-attr",
11+
"dojo/dom-construct",
12+
"dojo/_base/lang",
13+
"dijit/layout/LinkPane"
14+
], function (declare, _WidgetBase, dom, domStyle, domAttr, domConstruct, lang, linkPane) {
15+
"use strict";
1316

14-
this._setupEvents();
15-
16-
switch (this.contenttype) {
17-
case 'html':
17+
return declare("HTMLSnippet.widget.HTMLSnippet", [_WidgetBase], {
1818

19-
if (external) {
20-
new linkPane(
21-
{
22-
preload: true,
23-
loadingMessage: "",
24-
href: this.contentsPath,
25-
onDownloadError: function(){ console.log("Error loading html path");}
26-
}).placeAt(this.domNode.id).startup();
27-
}
28-
else {
29-
domStyle.set(this.domNode, {
30-
'height': 'auto',
31-
'width': '100%',
32-
'outline': 0
33-
});
19+
postCreate: function () {
20+
var external = this.contentsPath !== "" ? true : false;
21+
this._setupEvents();
3422

35-
domAttr.set(this.domNode, 'style', this.style); // might override height and width
36-
domConstruct.place(this.contents, this.domNode, "only");
37-
}
38-
39-
break;
40-
case 'js':
41-
case 'jsjQuery':
42-
43-
if (external) {
44-
var scriptNode = document.createElement("script"),
45-
intDate = +new Date();
46-
47-
scriptNode.type = "text/javascript";
48-
scriptNode.src = this.contentsPath + "?v=" + intDate.toString();
49-
50-
domConstruct.place(scriptNode, this.domNode, "only");
51-
}
52-
else {
53-
if (this.contenttype == 'jsjQuery') {
54-
require(["HTMLSnippet/lib/jquery-1.11.3"], lang.hitch(this, this.evalJs));
55-
} else {
56-
this.evalJs();
57-
}
58-
}
59-
break;
60-
}
61-
},
23+
switch (this.contenttype) {
24+
case "html":
25+
if (external) {
26+
new linkPane({
27+
preload: true,
28+
loadingMessage: "",
29+
href: this.contentsPath,
30+
onDownloadError: function(){
31+
console.log("Error loading html path");
32+
}
33+
}).placeAt(this.domNode.id).startup();
34+
} else {
35+
domStyle.set(this.domNode, {
36+
"height": "auto",
37+
"width": "100%",
38+
"outline": 0
39+
});
40+
domAttr.set(this.domNode, "style", this.style); // might override height and width
41+
domConstruct.place(this.contents, this.domNode, "only");
42+
}
43+
break;
6244

63-
_setupEvents: function () {
64-
if (this.onclickmf) {
65-
this.connect(this.domNode, "click", this._executeMicroflow)};
66-
},
45+
case "js":
46+
case "jsjQuery":
47+
if (external) {
48+
var scriptNode = document.createElement("script"),
49+
intDate = +new Date();
6750

68-
_executeMicroflow: function () {
69-
if (this.onclickmf) {
70-
mx.data.action({
71-
store: {
72-
caller: this.mxform
73-
},
74-
params: {
75-
actionname: this.onclickmf
76-
},
77-
callback: function () {
78-
// ok
79-
},
80-
error: function () {
81-
// error
82-
}
51+
scriptNode.type = "text/javascript";
52+
scriptNode.src = this.contentsPath + "?v=" + intDate.toString();
8353

84-
});
54+
domConstruct.place(scriptNode, this.domNode, "only");
55+
} else {
56+
if (this.contenttype == "jsjQuery") {
57+
require(["HTMLSnippet/lib/jquery-1.11.3"], lang.hitch(this, this.evalJs));
58+
} else {
59+
this.evalJs();
8560
}
86-
},
61+
}
62+
break;
63+
}
64+
},
65+
66+
_setupEvents: function () {
67+
if (this.onclickmf) {
68+
this.connect(this.domNode, "click", this._executeMicroflow);
69+
}
70+
},
71+
72+
_executeMicroflow: function () {
73+
if (this.onclickmf) {
74+
mx.data.action({
75+
store: {
76+
caller: this.mxform
77+
},
78+
params: {
79+
actionname: this.onclickmf
80+
},
81+
callback: function () {
82+
// ok
83+
},
84+
error: function () {
85+
// error
86+
}
87+
});
88+
}
89+
},
90+
91+
evalJs: function () {
92+
try {
93+
eval(this.contents + "\r\n//# sourceURL=" + this.id + ".js");
94+
} catch (e) {
95+
domConstruct.place("<div class=\"alert alert-danger\">Error while evaluating javascript input: " + e + "</div>", this.domNode, "only");
96+
}
97+
}
8798

88-
89-
evalJs: function () {
90-
try {
91-
eval(this.contents + "\r\n//# sourceURL=" + this.id + ".js");
92-
} catch (e) {
93-
domConstruct.place("<div class=\"alert alert-danger\">Error while evaluating javascript input: " + e + "</div>", this.domNode, "only");
94-
}
95-
}
96-
});
99+
});
97100
});

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="1.3" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="HTMLSnippet" version="1.4" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="HTMLSnippet/HTMLSnippet.xml"/>
66
</widgetFiles>

0 commit comments

Comments
 (0)