Using Widgets
Individual or complied
As with all havok modules, widgets are all comply with the AMD specification. They may be loaded individually, built into your own compiled layer with the dojo build tool (or another build tool), or used from the compiled havok.js distributable.
Declataive use
All widgets can be defined declatively as valid HTML and then instantated with the dojo parser.
To define declartively, use the `data-dojo-type` attribute, and parse the html when the dom is ready:
<script type="text/javascript"> require(['dojo/parser', 'havok/widget/Alert','dojo/domReady!'], function(parser){parser.parse()}) </script> <div data-dojo-type="havok/widget/Alert" data-dojo-props="hidden: false"> <strong>Warning!</strong> Best check yo self, you're not looking too good. </div>
Programatic use
To define programatically, first create an instance, then add to the dom, and call `startup`:
<script type="text/javascript"> require(['havok/widget/Alert', 'dojo/domReady!'], function(Alert){ var alert = new Alert({ innerHTML: "<strong>Warning!</strong> Best check yo self, you're not looking too good.", hidden: false }); dom.byId('alert').appendChild(alert.domNode); alert.startup(); }) </script> <div id="alert"></alert>
Leveraging the power of dojo
Widgets are built on dojo's dijit framework, and so use the standard dijit lifecycle, templating, etc.
Stores
Many of the havok widgets use the havok/widget/_StoreMixin
to manage lists of items. Stores allow great flexibility. Items may be fetched via ajax, filtered, sorted, and reused throughout your application.
Properties
This mixin adds four properties to any widget using it:
name | type | default | description |
---|---|---|---|
store | object | undefined | The
When getting, the store object is returned |
query | object | undefined | A query object used to interogate the store. |
queryOptions | object | undefined | Options for start count and sort . |
queryThrottle | integer | 0 | Minimum time in milliseconds between queries on the store. Great for ajax backed stores on a Typeahead to prevent too many requests. |
data | object | undefined | Read only. Returns a data set from the store using the query and queryOptions. |
Examples
Declative store
Store data may be passed in using the data-dojo-props
attribute
<ul data-dojo-type="havok/widget/Dropdown" data-dojo-props="store: { data: [ {id: 0, text: 'Action'}, {id: 1, text: 'Another Action'}, {id: 2, text: 'Something else here'}, {id: 3, type: 'divider'}, {id: 4, href: '#dropdowns', text: 'Dropdowns'} ] }" ></ul>
Programatic store
A store can be created progamatically and passed to the widget. Eg:
<div id="dropdown2"></div> <script type="text/javascript"> require( ['dojo/dom', 'havok/widget/Dropdown', 'dojo/store/Memory', 'dojo/domReady!'], function(dom, Dropdown, Memory){ var dropdown = new Dropdown({ //create a new instance of the Dropdown widget store: new Memory({ //create a new instance of a Memory store for the dropdown widget to consume data: [ {id: 0, text: 'Action'}, {id: 1, text: 'Another Action'}, {id: 2, text: 'Something else here'}, {id: 3, type: 'divider'}, {id: 4, href: '#dropdowns', text: 'Dropdowns'} ] }) }); dom.byId('dropdown2').appendChild(dropdown.domNode); //add the dropdown to the dom dropdown.startup(); //call startup on the dropdown } ) </script>
Store from the Store Manager
The store manager allows data store to be easily interchanged and injected into store consumers. To use a store from the manager, set the store property to the name used to register that store with the manager. Eg:
<ul data-dojo-type="havok/widget/Dropdown" data-dojo-props="store: 'dropdownStore'" ></ul> <script type="text/javascript"> require([ 'havok/get!havok/store/manager', //get the store manager instance from the havok dependency injection container 'dojo/store/Memory' ], function(storeManager, Memory){ storeManager.stores.push( //add a new store to the store manager new Memory({ name: 'dropdownStore', //give the store a name so it can be fetched with that name data: [ {id: 0, text: 'Action'}, {id: 1, text: 'Another Action'}, {id: 2, text: 'Something else here'}, {id: 3, type: 'divider'}, {id: 4, href: '#dropdowns', text: 'Dropdowns'} ] }) ); } ) </script>
Implicit store
If no store is set by one of the above methods, a store is created implicitly from the markup. For example, in the Dropdown widget each li
becomes an item in the store.
Store queries
Any store can be filtered by setting a query on the store.
Basic example
This query will filter so only items with A
in the text will display:
<ul data-dojo-type="havok/widget/Dropdown" data-dojo-props=" query: {text: /^.*A.*$/}, store: { data: [ {id: 0, text: 'Action'}, {id: 1, text: 'Another Action'}, {id: 2, text: 'Something else here'}, {id: 3, type: 'divider'}, {id: 4, text: 'Separated Link'} ] } " > </ul>
Queries on an implicit store
Implicitly created stores can also be queried. Eg:
<ul data-dojo-type="havok/widget/Dropdown" data-dojo-props=" query: {text: /^.*A.*$/} " > <li><a href="">Action</a></li> <li><a href="">Another action</a></li> <li><a href="">Something else here</a></li> <br /> <li><a href="">Separated link</a></li> </ul>
Store query options
Query options can be set to control start
count
and sort
. Eg:
<ul data-dojo-type="havok/widget/Dropdown" data-dojo-props=" queryOptions: { start: 1, count: 3, sort: [{attribute: 'text', descending: true}] }, store: { data: [ {id: 0, text: '0'}, {id: 1, text: '1'}, {id: 2, text: '2'}, {id: 3, text: '3'}, {id: 4, text: '4'}, {id: 5, text: '5'}, {id: 6, text: '6'} ] } " > </ul>
Dropdown menus
DropdownContainer
The havok/widget/DropdownContainer
widget. An empty dropdown that can be filled with whatever content you choose.
Example
Toggleable, contextual menu for displaying anything.
Declarative Example
Stuff here
This is stuff inside a dropdown
<div data-dojo-type="havok/widget/DropdownContainer"> <div> <h5>Stuff here</h5> <p>This is stuff inside a dropdown</p> </div> </div>
Dropdown
The havok/widget/Dropdown
widget. Inherits from havok/widget/_DropdownBase
. Shows a list of links.
Properties
name | type | default | description |
---|---|---|---|
innerHTML | string | undefined | Can be used to populate a Dropdown when creating it programatically. |
templateString | string | content of havok/widget/template/Dropdown.html |
The base template for a Dropdown. |
linkTemplate | string | content of havok/widget/template/DropdownLink.html |
The base template for an A inside a Dropdown. |
dividerTemplate | string | content of havok/widget/template/Divider.html |
The base template for a HR inside a Dropdown. |
Events
name | description |
---|---|
item-click | Fires when an item is clicked. |
Example
Toggleable, contextual menu for displaying lists of links.
Declarative Example
<ul data-dojo-type="havok/widget/Dropdown"> <li><a href="">Action</a></li> <li><a href="">Another action</a></li> <li><a href="">Something else here</a></li> <hr /> <li><a href="">Separated link</a></li> </ul>
Programatic Example
<div id="dropdown1"></div> <script type="text/javascript"> require(['dojo/dom', 'havok/widget/Dropdown', 'dojo/domReady!'], function(dom, Dropdown){ var dropdown = new Dropdown({ innerHTML: [ '<li><a tabindex="-1" href="">Action</a></li>', '<li><a tabindex="-1" href="">Another action</a></li>', '<li><a tabindex="-1" href="">Something else here</a></li>', '<hr />', '<li><a tabindex="-1" href="">Separated link</a></li>' ].join('') }); dom.byId('dropdown1').appendChild(dropdown.domNode); dropdown.startup(); }) </script>
Click events
If the href
attribute is an empty string, the active property will be changed. If the href
attribute is not empty, the link will be followed. Eg:
<ul data-dojo-type="havok/widget/Dropdown"> <li><a href="">item 1</a></li> <li><a href="">item 2</a></li> <li><a href="">item 3</a></li> <li><a href="#dropdowns">#dropdowns anchor</a></li> <li><a href="http://github.com">github.com</a></li> </ul>
To listen to click events, use the .on('item-click', callback)
method. Eg:
<ul id="dropdownClick1" data-dojo-type="havok/widget/Dropdown"> ... </ul> <script type="text/javascript"> require(['dijit/registry', 'havok/parseComplete!'], function(registry){ registry.byId('dropdownClick1').on('item-click', function(item){ alert('Just clicked item: ' + item.id) }) }) </script>
Options
Disabled menu options
Add .disabled
to a <li>
in the dropdown to disable the link, or set 'type': 'disabled'
on the store item. Disabled links are not clickable.
<ul data-dojo-type="havok/widget/Dropdown"> <li><a href="">Regular link</a></li> <li class="disabled"><a href="">Disabled link</a></li> <li><a href="">Another link</a></li> </ul>
Sub menus on dropdowns
To add an extra level of dropdown menus, wrap the submenu in havok/widget/DropdownSubmenu
Heads up! havok/widget/DropdownSubmenu
inherits from havok/widget/DropdownToggle
, and so exposes all the same methods.
Example
<ul data-dojo-type="havok/widget/Dropdown"> <li><a href="">Action</a></li> <li><a href="">Another action</a></li> <li><a href="">Something else here</a></li> <hr /> <li data-dojo-type="havok/widget/DropdownSubmenu"> <a href="">More options</a> <ul data-dojo-type="havok/widget/Dropdown"> <li><a href="">Second level link</a></li> <li><a href="">Second level link</a></li> <li><a href="">Second level link</a></li> <li><a href="">Second level link</a></li> <li><a href="">Second level link</a></li> </ul> </li> </ul>
Example with a store
Use the type: 'dropdown'
to mark parent items. Use parent: id
property to specify child items in the store. Now that's nice syntax!
<ul data-dojo-type="havok/widget/Dropdown" data-dojo-props=" store: { data: [ {id: 0, text: 'Action'}, {id: 1, text: 'Another Action'}, {id: 2, text: 'Something else here'}, {id: 3, type: 'divider'}, {id: 4, type: 'dropdown', text: 'More options'}, {id: 5, parent: 4, text: 'Second level link'}, {id: 6, parent: 4, text: 'Second level link'}, {id: 7, parent: 4, text: 'Second level link'}, {id: 8, parent: 4, text: 'Second level link'} ] } " > </ul>
Date Dropdown
<div data-dojo-type="havok/widget/DateDropdown"> </div>
Markup
To use a dropdown menu, you would normally place it inside a havok/widget/DropdownToggle
.
Dropdown Toggle
Use havok/widget/DropdownToggle
to make a havok/widget/Dropdown
show and hide.
Properties
Name | type | default | description |
---|---|---|---|
dropdown | object | undefined | Reference to the Dropdown widget which the DropdownToggle encloses. |
placement | object | {toggle: 'bottom-left', dropdown: 'top-left'} |
Defines where the dropdown will be placed when it is opened. The toggle defines the corner of the toggle button that will be used for placement. The dropdown defines the corner of the dropdown that will be used for placement. By default the top-left corner of the dropdown is aligned with the bottom-left corner of the toggle. Note that placement will be automatically adjusted if the dropdown will be clipped by and edge of the viewport. |
templateString | string | content of havok/widget/template/DropdownToggle.html |
The base template for a DropdownToggle. |
Methods
name | args | description |
---|---|---|
.show() | - | Shows the enclosed Dropdown |
.hide() | - | Hides the enclosed Dropdown. |
.toggle() | - | Toggles the enclosed Dropdown. |
Events
name | description |
---|---|
item-click | Fires when an item is clicked. |
Examples
Within a navbar
<li data-dojo-type="havok/widget/DropdownToggle"> <a href="">Dropdown <b class="caret"></b></a> <ul data-dojo-type="havok/widget/Dropdown" aria-labelledby="drop1"> <li><a href="http://google.com">Action</a></li> <li><a href="anotherAction">Another action</a></li> <li><a href="">Something else here</a></li> <hr /> <li><a href="">Separated link</a></li> </ul> </li> ...
Within pills
Within overflow hidden element
The Dropdown dom nodes is moved to the end of the document, removing any clipping problems, or display issues with dropdowns in modals.
Usage
Declarative
The first child element inside a havok/widget/DropdownToggle
is the `button` which will toggle the dropdown. The first havok/widget/Dropdown
child widget inside a havok/widget/DropdownToggle
will be toggled.
<div data-dojo-type="havok/widget/DropdownToggle"> <button>Show dropdown</button> <!--this node will show/hide the dropdown--> <ul data-dojo-type="havok/widget/Dropdown" data-dojo-props="store: mystore"> <!--this is the dropdown which will be shown/hidden--> </ul> </div>
Programatic
To create a havok/widget/DropdownToggle
programatically, pass an instance of havok/widget/Dropdown
to the dropdown
property, and the markup to create the button to the innerHTML
property.
<div id="dropdownButton1"> <script type="text/javascript"> require([ 'dojo/dom', 'havok/widget/Dropdown', 'havok/widget/DropdownToggle', 'dojo/domReady!' ], function( dom, Dropdown, DropdownToggle ){ var dropdownToggle = new DropdownToggle({ innerHTML: '<button class="btn">Click me</button>', dropdown: new Dropdown({store: { data: [ {id: 0, text: 'Action'}, {id: 1, text: 'Another Action'}, {id: 2, text: 'Something else here'}, {id: 3, type: 'divider'}, {id: 4, text: 'Separated Link'} ] }}) }); dom.byId('dropdownButton1').appendChild(dropdownToggle.domNode); dropdownToggle.startup(); }) </script> </div>
Fine grained control
Use attach points to control exactly which element in the markup will respond to a click.
Extra text
<div data-dojo-type="havok/widget/DropdownToggle" class="well"> <p>Extra text</p> <button data-dojo-attach-point="button" class="btn">Show Dropdown</button> <ul data-dojo-type="havok/widget/Dropdown"> ... </ul> </div>
Tabs
Bring your tabs to life with havok/widget/TabContainer
.
Tabbable example
The title
attribute will be used to create an instance of havok/widget/NavTab
.
I'm in Section 1.
Howdy, I'm in Section 2.
What up girl, this is Section 3.
<div data-dojo-type="havok/widget/TabContainer" style="margin-bottom: 18px;"> <div title="Section 1" class="active"> <p>I'm in Section 1.</p> </div> <div title="Section 2"> <p>Howdy, I'm in Section 2.</p> </div> <div title="Section 3"> <p>What up girl, this is Section 3.</p> </div> </div>
Tabbable in any direction
Use the placement
property of havok/widget/TabContainer
to alter where the tabs appear.
Tabs on the bottom
I'm in Section 1.
Howdy, I'm in Section 2.
What up girl, this is Section 3.
<div id="tabContainer1" data-dojo-type="havok/widget/TabContainer" data-dojo-props="placement: 'bottom'"> ... </div> <div id="buttonGroup1" data-dojo-type="havok/widget/RadioGroup" data-dojo-props="active: 'bottom', store: {idProperty: 'text', data: [ {type: 'button', text: 'top'}, {type: 'button', text: 'left'}, {type: 'button', text: 'right'}, {type: 'button', text: 'bottom'} ]}" > </div> <script type="text/javascript"> require(['dijit/registry', 'havok/parseComplete!'], function(registry){ var tabContainer = registry.byId('tabContainer1'), buttonGroup = registry.byId('buttonGroup1'); buttonGroup.on('item-click', function(item){ tabContainer.set('placement', item.text); }); }) </script>
Sortable
havok/dnd/_SortableMixin
makes list type elements sortable by drag n drop.
Example
<ul class="nav-stacked" data-dojo-type="havok/widget/NavTab" data-dojo-mixins="havok/widget/_SortableMixin" data-dojo-props="store: { idProperty: 'text', data: [ {text: 'ACT'}, {text: 'NSW'}, {text: 'Vic'}, {text: 'Qld'}, {text: 'SA'}, {text: 'NT'}, {text: 'WA'}, {text: 'Tas'} ] }" > </ul>
Sort between lists
Use the dropTargets
property to allow sorting between lists.
<ul class="span6 nav-stacked" id="leftSortable" data-dojo-type="havok/widget/NavTab" data-dojo-mixins="havok/widget/_SortableMixin" data-dojo-props="dropTargets: ['this', 'rightSortable']" > <li><a>Harry</a></li> <li><a>Max</a></li> <li><a>Phillip</a></li> <li><a>James</a></li> </ul> <ul class="span6 nav-stacked" id="rightSortable" data-dojo-type="havok/widget/NavTab" data-dojo-mixins="havok/widget/_SortableMixin" data-dojo-props="dropTargets: ['this', 'leftSortable']" > <li><a>Michael</a></li> <li><a>Tim</a></li> <li><a>Shaun</a></li> <li><a>Robert</a></li> </ul>
Horizontal example
Tabs example
Tabs in a havok/widget/TabContainer
are sortable by default.
I'm in Section 1.
Howdy, I'm in Section 2.
What up girl, this is Section 3.
Affix
The content of an Affix widget will stay visible in the viewport when it's target element is also visible. By default, Affix will target the parent element.
Example
Fix a widget to always be visible. The nav to the left is an example.
Stand alone widget
Scroll the viewport to see the example working
<style> .affix-example1.affix { top: 40px; } .affix-example1.affix-bottom { position: absolute; top: auto; bottom: 14px; } </style> <div style="height: 300px"> <div class="affix-example1" data-dojo-type="havok/widget/Affix" data-dojo-props="viewportOffset: {top: 40, bottom: 0}" > <button class="btn">I'm affixed!</button> </div> </div>
Alternate affix target
Scroll the viewport to see the example working
Target 1
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.
Target 2
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch.
<style> .affix-example2.affix { top: 40px; } .affix-example2.affix-bottom { position: absolute; top: auto; bottom: 0px; } </style> <div class="row-fluid" style="position:relative"> <div class="span3"> <div class="affix-example2" data-dojo-type="havok/widget/Affix" data-dojo-props=" viewportOffset: {top: 40, bottom: 0}, affixTarget: 'AffixTarget1' " > <button class="btn">Target 1</button> </div> </div> <div class="span9"> <div id ="AffixTarget1" class="well"> <p><b>Target 1</b></p> ... </div> </div> </div> ...
Affix Mixin
Affix behaviour can be mixed in to any widget. Simply use data-dojo-mixins="havok/widget/_AffixMixin"
<div style="height: 300px"> <button class="affix-example1" data-dojo-type="havok/widget/ToggleButton" data-dojo-mixins="havok/widget/_AffixMixin" data-dojo-props="viewportOffset: {top: 40, bottom: 0}" > Affixed toggle </button> </div>
Properties
Name | type | default | description |
---|---|---|---|
affixTarget | dom node | Parent element | The dom node to affix to. |
viewportOffset | object | {top: 0, bottom: 0} | Distance in pixels from the top and bottom of the viewport that affixing should be applied. |
Scrollspy
Example in navbar
The ScrollSpy plugin is for automatically updating nav targets based on scroll position. Scroll the area below the navbar and watch the active class change. The dropdown sub items will be highlighted as well.
Simply use havok/widget/_ScrollSpyMixin
with a nav widget, and set the spyTarget
property.
@superdweebie
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
@crimsonronin
Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard. Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.
one
Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.
two
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
three
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats you probably haven't heard of them consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat before they sold out, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats.
<div data-dojo-type="havok/widget/NavBar" class="navbar-static"> <div class="container" style="width: auto;"> <a class="brand" href="#">Project Name</a> <ul data-dojo-type="havok/widget/NavBarLinks" data-dojo-mixins="havok/widget/_ScrollSpyMixin" data-dojo-props=" spyTarget: 'scrollspyExample1', store:{ idProperty: 'text', data: [ {text: '@superdweebie', spy: 'superdweebie'}, {text: '@crimsonronin', spy: 'crimsonronin'}, {type: 'dropdown', text: 'Dropdown'}, {text: 'one', spy: 'one', parent: 'Dropdown'}, {text: 'two', spy: 'two', parent: 'Dropdown'}, {type: 'divider', text: 'divider1', parent: 'Dropdown'}, {text: 'three', spy: 'three', parent: 'Dropdown'} ] }" > </ul> </div> </div> <div id="scrollspyExample1" class="scrollspy-example"> <h4 id="superdweebie">@superdweebie</h4> <p>...</p> <h4 id="crimsonronin">@crimsonronin</h4> <p>...</p> <h4 id="one">one</h4> <p>...</p> <h4 id="two">two</h4> <p>...</p> <h4 id="three">three</h4> <p>...</p> </div>
Auto populate nav
ScrollSpy can autopopulate the nav using the id
and title
attributes of the child elemnts of spyTarget
.
@superdweebie
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
@crimsonronin
Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard. Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.
one
Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.
two
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
three
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats you probably haven't heard of them consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat before they sold out, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats.
<div class="row-fluid"> <div class="span3"> <ul data-dojo-type="havok/widget/NavPill" data-dojo-mixins="havok/widget/_ScrollSpyMixin" data-dojo-props="spyTarget: 'scrollspyExample2'" class="nav-stacked" > </ul> </div> <div id="scrollspyExample2" class="span9 scrollspy-example"> <h4 id="superdweebie">@superdweebie</h4> <p>...</p> <h4 id="crimsonronin">@crimsonronin</h4> <p>...</p> <h4 id="one" title="ONE">one</h4> <p>...</p> <h4 id="two" title="TWO">two</h4> <p>...</p> <h4 id="three" title="THREE">three</h4> <p>...</p> </div> </div>
Properties
Name | type | default | description |
---|---|---|---|
spyTarget | dom node | The dom node to spy on. |
Accordion
Simply use havok/widget/Accordion
. The title
attribute of the contained divs will be used for the headings.
Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats you probably haven't heard of them consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat before they sold out, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats.
<div data-dojo-type="havok/widget/Accordion"> <div title="one"> <p>...</p> </div> <div title="two"> <p>...</p> </div> <div title="three"> <p>...</p> </div> </div>
Modals
For simple modals use havok/widget/Modal
.
Live Demo
button:
Text in a modal
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem.
Dropdown in a modal
This dropdown should trigger a dropdown on click:
Tooltips in a modal
This link and that link should have tooltips on hover.
Overflowing text to show optional scrollbar
If the modal is too high for the viewport, a scrollbar on the window will appear.
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
<div data-dojo-type="havok/widget/Modal" title="Modal Heading"> ... </div>
Custom footer
Change the modal footer by using data-dojo-attach-point="footer"
. Button names and keys can also be set. (This modal can be closed with ctrl-y)
button:
Text in a modal
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem.
<div data-dojo-type="havok/widget/Modal" id="modal2" title="Custom footer"> <h4>Text in a modal</h4> <p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem.</p> <div data-dojo-attach-point="footer"> <button class="btn" data-dojo-attach-event="click: onCloseClick">Something</button> <button data-dojo-type="havok/widget/Button" data-dojo-attach-event="click: onCloseClick" data-dojo-props="keys: 'ESCAPE', keyTarget: false">No Thanks</button> <button class="btn-info" data-dojo-type="havok/widget/Button" data-dojo-attach-event="click: onOkClick" data-dojo-props="keys: ['ENTER', {char: 'y', ctrl: true}], keyTarget: false">Yeah!</button> </div> </div>
Properties
Name | type | default | description |
---|---|---|---|
button | string | When the modal is closed, this property will be set to the button that was used to close it. | |
value | object | A modal can be used like a form. Inputs inside a modal will populate the modal's value object. | |
hidden | boolean | true | If a modal is hidden or not. |
footerTemplate | string | The markup to add into the modal footer. |
Methods
name | args | description |
---|---|---|
.show(value) | value set's a modal form's value | Shows the modal. Also returns a Deferred which will resolve when the modal is closed. |
.hide() | - | Hides the modal. |
.toggle() | - | Toggles the modal. |
Tooltips
Use havok/widget/Tooltip
to make a tooltip.
Tight pants next level keffiyeh you probably haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.
<a data-dojo-type="havok/widget/Tooltip" title="Default tooltip">you probably</a>
Four directions
<a data-dojo-type="havok/widget/Tooltip" data-dojo-props="placement: 'top'" title="Tooltip on top">Tooltip on top</a>
Custom trigger event
<a data-dojo-type="havok/widget/Tooltip" data-dojo-props="eventShow: 'click'" title="I was clicked">Click to show tooltip</a>
Inverse tooltip
<a class="inverse" data-dojo-type="havok/widget/Tooltip" title="Inverse tooltip">Inverse Tooltip</a>
Alerts
Use havok/widget/Alert
to create and show/hide alerts.
Default alert
Wrap any text in havok/widget/Alert
for a basic warning alert message.
<div data-dojo-type="havok/widget/Alert" data-dojo-props="hidden: false"> <strong>Warning!</strong> Best check your self, you're not looking too good. </div>
Block alerts
Add class alert-block
for longer messages.
Warning!
Best check your self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div data-dojo-type="havok/widget/Alert" class="alert-block" data-dojo-props="hidden: false"> <h4>Warning!</h4> <p>Best check your self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p> </div>
Pretty colors
Add sematic classes for different styling:
<div data-dojo-type="havok/widget/Alert" class="alert-info" data-dojo-props="hidden: false"> <strong>Info!</strong> alert. </div> <div data-dojo-type="havok/widget/Alert" class="alert-error" data-dojo-props="hidden: false"> <strong>Error!</strong> alert. </div> <div data-dojo-type="havok/widget/Alert" class="alert-success" data-dojo-props="hidden: false"> <strong>Success!</strong> alert. </div>
Properties
Name | type | default | description |
---|---|---|---|
hidden | boolean | true | If an alert is hidden or not. |
name | args | description |
---|---|---|
.show() | - | Shows an alert. |
.hide() | - | Hides the alert. |
.toggle() | - | Toggles the alert. |
Overlay
havok/widget/Overlay
A widget designed to act as a Standby/Busy/Disable/Blocking widget to indicate a particular DOM node is processing and cannot be clicked on at this time.
Example
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
This is overlayed<p>...</p> <span id="overlay1" data-dojo-type="havok/widget/Overlay" >This is overlayed</span> <button id="overlayToggle1" data-dojo-type="havok/widget/ToggleButton">Toggle overlay</button> <script> require(['dijit/registry', 'havok/parseComplete!'], function(registry){ registry.byId('overlayToggle1').watch('active', function(){ registry.byId('overlay1').toggle(); }); }) </script>
With wait cursor
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
<p>...</p> <span id="overlay2" class="overlay-wait" data-dojo-type="havok/widget/Overlay" >This is overlayed</span> <button id="overlayToggle2" data-dojo-type="havok/widget/ToggleButton">Toggle overlay</button> <script> require(['dijit/registry', 'havok/parseComplete!'], function(registry){ registry.byId('overlayToggle2').watch('active', function(){ registry.byId('overlay2').toggle(); }); }) </script>
Overlay whole viewport
By default, the overlay widget will target the previous element in the dom. This can be changed by specifying an alternate target node. Eg:
<span id="overlay3" data-dojo-type="havok/widget/Overlay" data-dojo-props="target: document.body" > <button id="overlay3hide" class="btn">Hide overlay</button> </span> <button id="overlay3show" class="btn">Show overlay</button> <script> require(['dijit/registry', 'dojo/dom', 'dojo/on', 'havok/parseComplete!'], function(registry, dom, on){ on(dom.byId('overlay3show'), 'click', function(){ registry.byId('overlay3').show(); }); on(dom.byId('overlay3hide'), 'click', function(){ registry.byId('overlay3').hide(); }); }) </script>
Dragable
havok/dnd/Dragable
makes an element dragable.
Example
<div class="label label-info" data-dojo-type="havok/widget/Dragable">Drag me!</div>
Grip
Add a data-dojo-attach-point="grip"
to indicate a drag grip.
<div class="label label-info" data-dojo-type="havok/widget/Dragable">Drag me! <i class="icon-move icon-white" data-dojo-attach-point="grip"></i></div>
Carousel
Simply use havok/widget/Carousel
. Eg:
-
Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.
-
Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.
-
Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.
<ol data-dojo-type="havok/widget/Carousel"> <li class="active" title="First Thumbnail label"> <img alt="" src="img/carousel-01.jpg"> Cras justo odio... </li> <li title="Second Thumbnail label"> <img alt="" src="img/carousel-02.jpg"> Cras justo odio... </li> <li title="Third Thumbnail label"> <img alt="" src="img/carousel-03.jpg"> Cras justo odio... </li> </ol>
Example using a store:
<ol data-dojo-type="havok/widget/Carousel" data-dojo-props=" active: 2, store: { data: [ {id: 0, title: 'First Thumbnail label', caption: 'caption 1', img: 'img/carousel-01.jpg'}, {id: 1, title: 'Second Thumbnail label', caption: 'caption 2', img: 'img/carousel-02.jpg'}, {id: 2, title: 'Third Thumbnail label', caption: 'caption 3', img: 'img/carousel-03.jpg'} ] }" ></ol>
Text Editor
Example
<div data-dojo-type="havok/widget/TextEditor"> Here is some text to edit. </div>
The tools visible will show and hide as the width of the text editor changes.
Separated toolbar
You can use a separated text editing toolbar, and pass it a target node id to edit. The toolbar below can be used to edit this paragraph.
<div data-dojo-type="havok/widget/TextToolbar" data-dojo-props="target: 'editExample'"></div>
Custom font and size lists
You can change the font and size lists by overriding the appropriate store in di config. Eg:
di: { 'havok/store/stores': { proxies: { font: { base: 'my/alternative/font/store', proxyMethods: [ 'get', 'query' ] } } } }
Properties
Name | type | default | description |
---|---|---|---|
text | string | undefined | The text inside the editor. |