Skip to content

Commit

Permalink
fixed callback bug which caused errors on resetHandlers via an update
Browse files Browse the repository at this point in the history
Added dropdown menu internal buttons and links - closing behaviour
added an autoclose property which can prevent closing on menu internal clicks
  • Loading branch information
WillemUXMendix committed Jun 30, 2015
1 parent 42acc6a commit 9fd7cdf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/DropdownDivConverter/DropdownDivConverter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<category>General</category>
<description>Will the menu be open on load?</description>
</property>
<property key="autoClose" type="boolean" defaultValue="true" required="true">
<caption>Menu self-close</caption>
<category>General</category>
<description>If set to true: clicking on the menu or it's buttons will close the dropdown menu.</description>
</property>
<property key="buttonSize" type="enumeration" defaultValue="default">
<caption>Button size</caption>
<category>Appearance</category>
Expand Down
26 changes: 24 additions & 2 deletions src/DropdownDivConverter/widget/DropdownDivConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ define([
buttonTitle: "",
isDropUp: "",
startOpen: "",
autoClose: "",
splitButtonActive: "",
splitButtonClicked:"",

Expand Down Expand Up @@ -131,7 +132,26 @@ define([
}

this._toggleMenu();
}));
}));

// prevent default closing on dropdownMenu if needed
if (!this.autoClose){
this.connect(this.dropdownMenu, "click", lang.hitch(this,function(e) {
event.stop(e);
}));
}

// Mendix buttons and links stop events from bubbling: set actions for internal button clicks to close the menu if needed
if (this.autoClose){
var internalButtons = domQuery("button, a",this.dropdownMenu);
dojoArray.forEach(internalButtons, lang.hitch(this,function(node, i){
this.connect(node, "click", lang.hitch(this, function(e) {
if (this._isOpen){
this._toggleMenu();
}
}));
}));
}

// set the action for the possible split group button
if (this.splitButtonActive){
Expand Down Expand Up @@ -176,7 +196,9 @@ define([
}

}
callback();
if (callback){
callback();
}
},

// toggle dropdown state
Expand Down
Binary file modified test/Test.mpr
Binary file not shown.
Binary file modified test/widgets/DropdownDivConverter.mpk
Binary file not shown.

0 comments on commit 9fd7cdf

Please sign in to comment.