Browse files

Added forceint and FAQ

  • Loading branch information...
1 parent 77d833a commit 5e9c3b9d183d7dd5f305d5757b34364bc3e0859b @leegee committed Oct 24, 2012
Showing with 16 additions and 1 deletion.
  1. +12 −0
  2. +4 −1 Source/Knob.js
@@ -115,6 +115,7 @@ The following options are available. Some may be supplied as
* **monitor**: A name for, or instance of, a DOM element that has a **value** field that shoudl be monitored for changes, to be reflected by this control. Intended for text input elements.
* **monitorMs**: (*250*) The interval, in milliseconds, at which to check the **monitor** element, if supplied. The monitor element's *value* (an aria-related) attribute will also be updated with changes to the control.
* **addpointer**: (*↑*) By default the module (since 0.3) replaces **element**'s content with an up-arrow to the element. Disable this by setting this option to null or false.
+* **forceint**: (*false*) Force all values to be integers
@@ -142,3 +143,14 @@ Public Methods
* **attach**: Called at instantiation to attach eveents to allow the control to operate
* **detach**: Removes events
+**When using HTML mark-up to create a knob, why do *valuemin* and *valuemax* not work?**
+The acceptable range of inputs should be specified through **aria-valuemin** and **aria-valuemax*, not **data-valuemin** and **data-valuemax**.
+**Why are arguments all lower case, rather than camel case?**
+To make parsing of **dataset** attributes easier to parse: these are all forced to lower case by the browser.
@@ -43,7 +43,7 @@ var Knob = new Class({
scale: 1, /* Multiplier applied to number of px moved, to acheive change in .value */
keychangeby: 1, /* When arrow keys control knob, incrase knob value by this */
keychangebywithshift: 10, /* As keyUnit but for when shift key is also pressed */
+ forceInt: false, /* Force all values to be integers */
monitor: null, /* May be a string or DOM element to monitor: changes in this elements *value* attribute will change the control's *value* attribute, and cause the control to be re-rendered. */
monitorMs: 1000/4, /* Frequency of checking for monitor.value changes */
@@ -257,6 +257,9 @@ var Knob = new Class({
self.movement = (Math.abs(self.x) > Math.abs(self.y)? self.x : self.y);
self.value = self.initialValue + ( self.movement * self.options.scale);
+ if (self.options.forceint)
+ self.value = parseInt( self.value );

0 comments on commit 5e9c3b9

Please sign in to comment.