Skip to content

Commit ed46e02

Browse files
author
Jelte Lagendijk
committed
Add option to switch off enclosing div in HTML snippet
1 parent fff7fb3 commit ed46e02

File tree

8 files changed

+41
-10
lines changed

8 files changed

+41
-10
lines changed

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# HTMLSnippet
2-
This widget is useful to add a piece of HTML or JavaScript to a form. For example to embed a YouTube or Flash object. Furthermore it can be used to enhance styling by adding arbitrary HTML elements.
2+
This widget is useful to add a piece of HTML or JavaScript to a form. For example to embed a YouTube or Flash object. Furthermore it can be used to enhance styling by adding arbitrary HTML elements.
33

44
## Contributing
55

6-
For more information on contributing to this repository visit [Contributing to a GitHub repository](https://world.mendix.com/display/howto50/Contributing+to+a+GitHub+repository)!
6+
For more information on contributing to this repository visit [Contributing to a GitHub repository](https://docs.mendix.com/howto7/collaboration-project-management/contribute-to-a-github-repository)!
77

88
## Typical usage scenario
99

@@ -19,16 +19,19 @@ For more information on contributing to this repository visit [Contributing to a
1919

2020
## Dependencies
2121
* Mendix 5.x environment
22-
22+
2323
## Properties
24-
25-
* Content Type [ HTML, JavaScript, JavaScript with jQuery ] :
24+
25+
* Content Type [ HTML, JavaScript, JavaScript with jQuery ] :
2626
Select how the snippet should be rendered. The JavaScript with jQuery option will make sure that jQuery 1.11.3 is loaded and should be available on window.jQuery for the snippet.
27-
* Contents :
27+
* Contents :
2828
The HTML or Javascript to embed.
2929
* External File :
3030
The path to the HTML or JavaScript file you want to add. The root is the theme folder. Will override the Contents section if used.
3131
* On click microflow :
3232
The microflow which should be executed on click. This can be used to, for example, show a page when the snippet is being clicked.
33-
* Documentation :
33+
* Documentation :
3434
Documentation of this widget. Should explain its purpose.
35+
* Refresh on context change: Refresh when the context changes
36+
* Refresh on context update: Refresh when the context updates (works only when context change is true)
37+
* Enclose HTML with DIV: When adding HTML, the widget will wrap it with a DIV. If this is set to false, it will just replace the content of the widget. (For compatibility purposes this is set true on default)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "HTMLSnippet",
3-
"version": "3.9.0",
3+
"version": "3.9.1",
44
"description": "",
55
"license": "",
66
"author": "",

src/HTMLSnippet/HTMLSnippet.xml

+7
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@
6161
<category>Behavior</category>
6262
<description>Refresh when the context updates (works only when context change is true)</description>
6363
</property>
64+
65+
<!-- Enclose HTML with DIV -->
66+
<property key="encloseHTMLWithDiv" type="boolean" defaultValue="true">
67+
<caption>Enclose HTML with DIV</caption>
68+
<category>Behavior</category>
69+
<description>When adding HTML, the widget will wrap it with a DIV. If this is set to false, it will just replace the content of the widget. (For compatibility purposes this is set true on default)</description>
70+
</property>
6471
</properties>
6572
</widget>

src/HTMLSnippet/HTMLSnippetContext.xml

+7
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@
6161
<category>Behavior</category>
6262
<description>Refresh when the context updates (works only when context change is true)</description>
6363
</property>
64+
65+
<!-- Enclose HTML with DIV -->
66+
<property key="encloseHTMLWithDiv" type="boolean" defaultValue="true">
67+
<caption>Enclose HTML with DIV</caption>
68+
<category>Behavior</category>
69+
<description>When adding HTML, the widget will wrap it with a DIV. If this is set to false, it will just replace the content of the widget. (For compatibility purposes this is set true on default)</description>
70+
</property>
6471
</properties>
6572
</widget>

src/HTMLSnippet/widget/HTMLSnippet.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@ define([
88
"dojo/dom-attr",
99
"dojo/dom-construct",
1010
"dojo/_base/lang",
11+
"dojo/html",
1112
"dijit/layout/LinkPane"
12-
], function (declare, _WidgetBase, dom, domStyle, domAttr, domConstruct, lang, LinkPane) {
13+
], function (declare, _WidgetBase, dom, domStyle, domAttr, domConstruct, lang, html, LinkPane) {
1314
"use strict";
1415

1516
return declare("HTMLSnippet.widget.HTMLSnippet", [_WidgetBase], {
1617

18+
// Set in Modeler
19+
contenttype: "html",
20+
contents: "",
21+
contentsPath: "",
22+
onclickmf: "",
23+
documentation: "",
24+
refreshOnContextChange: false,
25+
refreshOnContextUpdate: false,
26+
encloseHTMLWithDiv: true,
27+
28+
// Internal
1729
_objectChangeHandler: null,
1830
contextObj: null,
1931

@@ -40,6 +52,8 @@ define([
4052
console.log("Error loading html path");
4153
}
4254
}).placeAt(this.domNode.id).startup();
55+
} else if (!this.encloseHTMLWithDiv) {
56+
html.set(this.domNode, this.contents);
4357
} else {
4458
domStyle.set(this.domNode, {
4559
"height": "auto",

src/package.xml

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

test/Test.mpr

31 KB
Binary file not shown.

test/widgets/HTMLSnippet.mpk

360 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)