Skip to content

Commit

Permalink
Added content of widget package
Browse files Browse the repository at this point in the history
  • Loading branch information
matthijs committed Nov 7, 2014
1 parent 13adb28 commit 817dc67
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
11 changes: 11 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="tabjumper" version="0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="tabjumper/tabjumper.xml"/>
</widgetFiles>
<files>
<file path="tabjumper/"/>
</files>
</clientModule>
</package>
57 changes: 57 additions & 0 deletions tabjumper/tabjumper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8" ?>
<widget id="tabjumper.widget.tabjumper" needsEntityContext="false" xmlns="http://www.mendix.com/widget/1.0/">
<name>Tab Jumper</name>
<description>Tab Jumper.</description>

<icon>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA7wAOAA6+4et8AAAACXBIWXMAAAG7AAABuwE67OPiAAAAB3RJTUUH3gIHDy8NZAa/ywAAAVdJREFUOMu9k7FqAkEQhr+R2xy6cCgIsUsTGwNiY5EqVSAEAyGSN0iZMo+S10iTFLFNWrnmwE4ErRSFwIZw3iFsCtF45rxY5S9nZr+d+XdHrLWkSUTyQBMob6VmQNdaGwI47FZzPB6/uK7rbQajKDKVSuUKeAdwROQYqKcADl3X9bTWfJV/mnCHQ2+zKweoh2H4FEXRL8J8PkdrjZ7NAJago6NEjQMQxzGFQmHbA7TW/CUBbowxT/l8PrUgDEN832c6nQJwfncHQMmYM6DrAORyuZ03+L5PrVbjoFpNxD887209gogwGAwIguAXYDKZ0Gg06PQeuTi5T+RKxrTXgCAIaLVa7DITSEBkNIJicdmBUorFYkEcx7x+Pmea1uk9AnApsn6FQCnVBk6NMQ/sqZVvjrW2D/RFJNPMlK++BKUF/xWQWCalFNfl270AjrM8Kqt1zliqLAXfTGtwCelLETIAAAAASUVORK5CYII=</icon>

<properties>
<property key="tabclass" type="string" required="true">
<caption>Tab class</caption>
<category>Behavior</category>
<description>The class assigned to the tab container on which this widget should act.</description>
</property>
<property key="jumpTo" type="enumeration" required="true" defaultValue="Next">
<caption>Jump to</caption>
<category>Behavior</category>
<description>Select the jump action destination.</description>
<enumerationValues>
<enumerationValue key="First">First Tab</enumerationValue>
<enumerationValue key="Previous">Previous Tab</enumerationValue>
<enumerationValue key="Next">Next Tab</enumerationValue>
<enumerationValue key="Last">Last Tab</enumerationValue>
<enumerationValue key="Titled">Tab title</enumerationValue>
<enumerationValue key="Numbered">Tab number</enumerationValue>
</enumerationValues>
</property>
<property key="tabName" type="string" required="false" defaultValue="">
<caption>Tab Title</caption>
<category>Behavior</category>
<description>The title of the tab to activate. (required when Jump to = Tab title)</description>
</property>
<property key="tabNumber" type="integer" defaultValue="0">
<caption>Tab Number</caption>
<category>Behavior</category>
<description>The number of the the tab to activate. (required when Jump To = Tab number)</description>
</property>
<property key="btnTitle" type="translatableString">
<caption>Button title</caption>
<category>Appearance</category>
<description>The title.</description>
</property>
<property key="showAsButton" type="enumeration" required="true" defaultValue="button">
<caption>Render as</caption>
<category>Appearance</category>
<description>Show as a string or as a button.</description>
<enumerationValues>
<enumerationValue key="button">Button</enumerationValue>
<enumerationValue key="link">Link</enumerationValue>
</enumerationValues>
</property>
<property key="btnIcon" type="image" required="false">
<caption>Image</caption>
<category>Appearance</category>
<description>The button image.</description>
</property>
</properties>
</widget>
80 changes: 80 additions & 0 deletions tabjumper/widget/tabjumper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Created by Matthijs Dekker (Trivento)
* February 2014
*
* V1.0
*/

dojo.provide("tabjumper.widget.tabjumper");

mendix.widget.declare('tabjumper.widget.tabjumper', {
inputargs: {
// styling
btnTitle : '',
showAsButton : '',
btnIcon : '',
// behaviour
tabclass : '',
jumpTo: '',
tabName : '',
tabNumber: 0
},

parent : null,
btn : null,

postCreate : function() {
this.buildJumper();
this.actRendered();
},

buildJumper : function () {
this.btn = new mendix.widget._Button({
caption : this.btnTitle,
iconUrl : this.btnIcon,
onClick : dojo.hitch(this, this.performTabJump),
type : this.showAsButton,
cssclass : ""
});
this.domNode.appendChild(this.btn.domNode);
},

getNewActiveTab : function () {
var tabWidgetCssSelected = dojo.query("."+this.tabclass)[0];
this.parent = dijit.byNode(tabWidgetCssSelected);
var tabList = this.parent.getChildren();
if (this.jumpTo === 'First') {
return tabList[0];
}
if (this.jumpTo === 'Last') {
return tabList[tabList.length-1];
}
if (this.jumpTo === 'Numbered') {
return tabList[this.tabNumber -1];
}
for(var i=0; tabList.length; i++) {
if (this.jumpTo === 'Titled' && tabList[i].title == this.tabName) {
return tabList[i];
}
if (tabList[i].button.className == "active") {
if (this.jumpTo === 'Next') {
return tabList[i+1];
}
if (this.jumpTo === 'Previous') {
return tabList[i-1];
}
}
}
return null;
},

performTabJump : function () {
var tab = this.getNewActiveTab();
if (tab) {
this.parent.show(tab);
}
},

uninitialize : function(){
}
});

0 comments on commit 817dc67

Please sign in to comment.