Skip to content

Commit dd18879

Browse files
Added glyphicon support for dropdown button.
1 parent 8821951 commit dd18879

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

src/DropdownDivConverter/DropdownDivConverter.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<category>General</category>
1212
<description>The label on the dropdown button.</description>
1313
</property>
14+
<property key="buttonGlyphicon" type="string" defaultValue="" required="false">
15+
<caption>Glyphicon icon</caption>
16+
<category>General</category>
17+
<description>Add a Bootstrap glyphicon icon to the button by entering the glyphicon classname (e.g. 'glyphicon-user'). If left empty, no icon will be created.</description>
18+
</property>
1419
<property key="isDropUp" type="boolean" defaultValue="false" required="true">
1520
<caption>Drop up</caption>
1621
<category>General</category>

src/DropdownDivConverter/widget/DropdownDivConverter.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ define([
3333

3434
// Parameters configured in the Modeler.
3535
buttonTitle: "",
36+
buttonGlyphicon: "",
3637
isDropUp: "",
3738
isRightAligned: "",
3839
startOpen: "",
@@ -83,7 +84,12 @@ define([
8384

8485
// Really render the interface, if renderAsOpen is true: render the menu in open state
8586
_renderInterface: function(renderAsOpen, callback) {
86-
this.dropdownButton.innerHTML = this.buttonTitle + "<span class='caret'></span>";
87+
this.dropdownButton.innerHTML = this.buttonTitle + "<span class='caret'></span>";
88+
// if a glyphicon icon was requested and the splitButton is not wanted: add the glyphicon to the button.
89+
if (this.buttonGlyphicon !== '' && !this.splitButtonActive){
90+
this._addGlyphicon(this.dropdownButton);
91+
}
92+
8793
this._setButtonTypes(this.dropdownButton);
8894

8995
// implement visual settings of the widget
@@ -102,7 +108,7 @@ define([
102108
if (this.splitButtonActive) {
103109
this._createSplitButton();
104110
} else {
105-
domConstruct.destroy(this.splitButton);
111+
domConstruct.destroy(this.splitButton);
106112
}
107113

108114
this._setupEvents(callback);
@@ -251,11 +257,20 @@ define([
251257
_createSplitButton: function() {
252258
// create the new split button
253259
this.splitButton.innerHTML = this.buttonTitle;
260+
// if a glyphicon icon was requested: add the glyphicon to the button.
261+
if (this.buttonGlyphicon !== ''){
262+
this._addGlyphicon(this.splitButton);
263+
}
254264
this._setButtonTypes(this.splitButton);
255265

256266
// adjust the dropdownButtons content
257267
this.dropdownButton.innerHTML = "<span class='caret'></span><span class='sr-only'>Toggle Dropdown</span";
258268
},
269+
270+
// Add a glyphicon to a button
271+
_addGlyphicon: function(buttonObject) {
272+
buttonObject.innerHTML = "<span class='glyphicon " + this.buttonGlyphicon + "'></span>" + buttonObject.innerHTML;
273+
},
259274

260275
// Reset subscriptions.
261276
_resetSubscriptions: function () {

src/DropdownDivConverter/widget/ui/DropdownDivConverter.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
}
1717

1818
.dropdown-div-converter.open .dropdown-menu {
19-
display:block;
19+
display: block;
20+
}
21+
22+
.dropdown-div-converter button .glyphicon {
23+
margin-right: 0.8em;
2024
}
2125

2226
/* for bootstrap versions below 3.1 */

test/Test.mpr

12 KB
Binary file not shown.
308 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)