the most fun you can have with jQuery and single-page applications
Dial.js is a single-page application framework and a browser history framework built on jQuery with History.js. It simplifies browser history integration of event-driven interfaces and provides a simple alternative to MVC frameworks for single-page applications (SPAs).
View the basic example
##Exposed API
####The DialFactory
object
-
DialFactory.makedial(dialName, historic, selectorAttribute)
Returns a newDial
object
Examplevar dialVar = DialFactory.makeDial('my first dial', true, data-application-attribute);
dialName
The name of the newDial
object that will be returned by this functionhistoric
determines whether changes to the newDial
object's state will be recorded into the browser historyselectorAttribute
contains the name of thedata
attribute that DOM elements will provide to the newDial
object's state functions
-
DialFactory.setSelectorAttribute(selectorAttribute)
Sets the defaultselectorAttribute
for future instances ofDial
objects
####The Dial
object
Note: Dial
objects must be instantiated through the DialFactory
-
dialVar.addState(stateName, fn, queryEffector)
Adds code to apply a state from theDial
object. -
stateName
the name of the state that will be added to theDial
-
fn
the function that will be called when the state namedstateName
is applied. This function will recieve one argument calleddata
-
optional
queryEffector
a function that will be called when a state is applied to change the?var=val
query string in the URL bar. This function will recieve two arguments, the samedata
that was passed tofn
and also theoldquery
old query string. -
dialVar.associateElements(selector, event, stateName)
associate DOM elements with a state of theDial
object -
selector
the jQuery selector of the elements that will activate the statestateName
-
event
the DOM event that will activate the statestateName
when it occurs from any elements matched by theselector
-
stateName
the name of the state that will be applied from thisDial
-
dialVar.trigger(data, stateName, historic)
Applies the statestateName
belonging to thisDial
object, passing argumentdata
to the state's function.data
argument to pass to the state functionstateName
name of the state to apply from thisDial
objecthistoric
overrides thisDial
object's default history-recording behavior wheretrue
means the new state will be part of the browser history andfalse
means the new state will be applied without affecting the browser history.
##Resources
- jQuery 1.12.3: https://jquery.com/download/
- History.js: https://github.com/browserstate/history.js/blob/master/scripts/bundled/html5/jquery.history.js
- Bootstrap (recommended): http://getbootstrap.com/
##License Dial.js is provided under the MIT License