A library to handle numbers & number formats in javascript
Still a work in progress, please be patient :)
Dist ready
Check the compiled javascripts in the dist directory if you do not want to compile coffeescript by yourself
Build from sources
You will need a nodejs runtime, grunt-cli for code generation and codo if you want to generate HTML docs
npm install -g grunt-clinpm install -g codo
Build project into dist/ directory
git clone git@github.com:sixpounder/numberphilejs.gitnpm install && grunt
Numbers manipulation
Following examples are for browser-side use.
Number parsing
// -> 6000 // -> 6000 // -> 6000.45 // -> 6000.45
Chainable operations
// -> 8000 // -> 8001.5 // -> 4000 // -> 12000.9 // -> 3000
Formatting
; // -> 6.000,00; // -> 6.000,20
For node environment you will find NumberphileReactor class and N wrapper function in your exports
var NumberphileReactor = NumberphileReactorvar N = N
jQuery plugin
To easily integrate the library in your DOM we ship an integrated jQuery plugin. The plugin will be triggered for every item having data-numberphile="auto" attribute.
This approach will use data attributes to configure the plugin
You can still call it yourself
;
jQuery utilities
Counter
A simple jQuery plugin to trigger increment step on various elements.
The plugin is automatically activated on every element having role="counter-trigger" attribute, and using data attributes for configuration.
To trigger it manually:
;
The target attribute is a selector identifying the DOM elements for which the value must be changed when the element you're calling the plugin on gets clicked
Example