From 1ff456b527034323fae1ea0d3adbe862971e2447 Mon Sep 17 00:00:00 2001
From: greglbd
Date: Tue, 14 Jan 2014 11:38:26 -0800
Subject: [PATCH 1/4] added data-unit option to display input
---
index.html | 14 +++++++++++++-
js/jquery.knob.js | 4 +++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/index.html b/index.html
index 806d64e..40ac362 100755
--- a/index.html
+++ b/index.html
@@ -19,7 +19,11 @@
console.log("cancel : ", this);
},
draw : function () {
-
+ //append unit if it exists
+ if(this.unit != undefined)
+ {
+ this.i.val(this.i.val()+this.unit);
+ }
// "tron" case
if(this.$.data('skin') == 'tron') {
@@ -122,6 +126,14 @@ jQuery Knob
+
+
× display input with unit
+
+data-width="100"
+data-unit="%"
+
+
+
× 'cursor' mode
diff --git a/js/jquery.knob.js b/js/jquery.knob.js
index 96f90d4..6c53fa6 100755
--- a/js/jquery.knob.js
+++ b/js/jquery.knob.js
@@ -110,6 +110,7 @@
fontWeight: this.$.data('font-weight') || 'bold',
inline : false,
step : this.$.data('step') || 1,
+ unit: this.$.data('unit'),
// Hooks
draw : null, // function () {}
@@ -548,7 +549,7 @@
var ori = e.originalEvent
,deltaX = ori.detail || ori.wheelDeltaX
,deltaY = ori.detail || ori.wheelDeltaY
- ,v = s._validate(s.$.val())
+ ,v = s._validate(parseFloat(s.$.val()))
+ (deltaX>0 || deltaY>0 ? s.o.step : deltaX<0 || deltaY<0 ? -s.o.step : 0);
v = max(min(v, s.o.max), s.o.min);
@@ -651,6 +652,7 @@
this.lineWidth = this.xy * this.o.thickness;
this.lineCap = this.o.lineCap;
this.radius = this.xy - this.lineWidth / 2;
+ this.unit = this.o.unit;
this.o.angleOffset
&& (this.o.angleOffset = isNaN(this.o.angleOffset) ? 0 : this.o.angleOffset);
From 56d953ec13c43ff0bd562ae7a98000d94745f99e Mon Sep 17 00:00:00 2001
From: greglbd
Date: Fri, 17 Jan 2014 11:42:37 -0800
Subject: [PATCH 2/4] updated readme
---
README.md | 1 +
index.html | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d1491f3..5908341 100755
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ UI :
* font : font family.
* fontWeight : font weight.
* bgColor : background color.
+* unit: unit option for value inside knob e.g. '%', 'px', 'pt' etc.
Hooks
-------
diff --git a/index.html b/index.html
index 40ac362..a1ee036 100755
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
jQuery Knob demo
-
+
$(function($) {
$(".knob").knob({
@@ -23,6 +23,7 @@
if(this.unit != undefined)
{
this.i.val(this.i.val()+this.unit);
+ console.log(this.i.val)
}
// "tron" case
if(this.$.data('skin') == 'tron') {
From eee1226de99090de38bfdb317dab76afef924cda Mon Sep 17 00:00:00 2001
From: greglbd
Date: Fri, 17 Jan 2014 15:55:04 -0800
Subject: [PATCH 3/4] fixed multiple units bug
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index a1ee036..5c7ad75 100755
--- a/index.html
+++ b/index.html
@@ -22,7 +22,7 @@
//append unit if it exists
if(this.unit != undefined)
{
- this.i.val(this.i.val()+this.unit);
+ this.i.val(parseFloat(this.i.val())+this.unit);
console.log(this.i.val)
}
// "tron" case
From 1102d93b421e305e8d559185da3e5016be725a43 Mon Sep 17 00:00:00 2001
From: greglbd
Date: Fri, 17 Jan 2014 16:49:47 -0800
Subject: [PATCH 4/4] moved unit code into jquery.knob.js files draw function
---
index.html | 7 +------
js/jquery.knob.js | 5 +++++
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/index.html b/index.html
index 5c7ad75..31e3d8f 100755
--- a/index.html
+++ b/index.html
@@ -19,12 +19,7 @@
console.log("cancel : ", this);
},
draw : function () {
- //append unit if it exists
- if(this.unit != undefined)
- {
- this.i.val(parseFloat(this.i.val())+this.unit);
- console.log(this.i.val)
- }
+ //append unit if it exists
// "tron" case
if(this.$.data('skin') == 'tron') {
diff --git a/js/jquery.knob.js b/js/jquery.knob.js
index 6c53fa6..b2df8d1 100755
--- a/js/jquery.knob.js
+++ b/js/jquery.knob.js
@@ -295,6 +295,11 @@
&& (d = s.dH());
(d !== false) && s.draw();
+
+ if(this.unit != undefined)
+ {
+ this.i.val(parseFloat(this.i.val())+this.unit);
+ }
};