From ca14bed8e39e2131e06b75dbef3864a015b52b2c Mon Sep 17 00:00:00 2001
From: vitalets <noginsk@rambler.ru>
Date: Tue, 2 Apr 2013 21:15:01 +0400
Subject: [PATCH] clear button for input type = number, fixes #166

---
 CHANGELOG.txt            |  1 +
 src/inputs/html5types.js | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8199f79..5ecb1d9 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -4,6 +4,7 @@ X-editable changelog
 
 Version 1.4.4 wip
 ----------------------------
+[bug #166] clear button forinput type = number (vitalets)
 [bug] checklist don't show checked for single value (vitalets)
 [enh #188] added bootstrap datetime (adeg, vitalets)
 [bug] editable-poshytip on inline mode tries to write in $.Poshytip (vitalets)
diff --git a/src/inputs/html5types.js b/src/inputs/html5types.js
index 97cf94c..139ca41 100644
--- a/src/inputs/html5types.js
+++ b/src/inputs/html5types.js
@@ -123,7 +123,21 @@ Number
             this.setAttr('min');
             this.setAttr('max');
             this.setAttr('step');
-        }
+        },
+        postrender: function() {
+            if(this.$clear) {
+                //can position clear button only here, when form is shown and height can be calculated
+                var h = this.$input.outerHeight() || 20,
+                    delta = (h - this.$clear.height()) / 2;
+                
+                //workaround for plain-popup  
+                if(delta < 3) {
+                   delta = 3; 
+                }
+                //add 12px to offset right for up/down arrows    
+                this.$clear.css({bottom: delta, right: delta + 12});
+            } 
+        }        
     });     
     NumberInput.defaults = $.extend({}, $.fn.editabletypes.text.defaults, {
         tpl: '<input type="number">',