From f38307a4121023339f63cb02664a8b7153cd5387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Kr=C3=B6ner?= Date: Wed, 21 May 2014 14:45:23 +0200 Subject: [PATCH 1/6] support contenteditable as input use `innerHTML` instead of `value` --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f2e41c3..f715b42 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ Input.prototype.onkeydown = function(e){ */ Input.prototype.onkeyup = function(e){ - var val = this.el.value; + var val = (typeof this.el.value != 'undefined') this.el.value ? this.el.innerHTML; // TODO: more efficient var lines = val.split('\n').length; @@ -77,5 +77,9 @@ Input.prototype.onkeyup = function(e){ */ Input.prototype.clear = function(){ - this.el.value = ''; + if (typeof this.el.value != 'undefined') { + this.el.value = '' + } else { + this.el.innerHTML = ''; + } }; \ No newline at end of file From 3d4a611e8662d00e27d854d81ec44425c5e7a10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Kr=C3=B6ner?= Date: Wed, 21 May 2014 14:48:59 +0200 Subject: [PATCH 2/6] fix shorthand if --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f715b42..025ee92 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ Input.prototype.onkeydown = function(e){ */ Input.prototype.onkeyup = function(e){ - var val = (typeof this.el.value != 'undefined') this.el.value ? this.el.innerHTML; + var val = (typeof this.el.value != 'undefined') ? this.el.value : this.el.innerHTML; // TODO: more efficient var lines = val.split('\n').length; From b5334b97148f9bce0a82c814ada5e11fe9b7e57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Kr=C3=B6ner?= Date: Tue, 27 May 2014 17:24:17 +0200 Subject: [PATCH 3/6] allow user to supply a cleanedValue method --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 025ee92..a0b2575 100644 --- a/index.js +++ b/index.js @@ -66,6 +66,9 @@ Input.prototype.onkeyup = function(e){ if (e.shiftKey) return; // input mode + if (typeof this.cleanedValue != 'undefined') { + val = this.cleanedValue(); + } this.emit('input', val); this.clear(); e.preventDefault(); From 154c13c13ffb3e684199ff2278f4586a06121d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Kr=C3=B6ner?= Date: Wed, 11 Jun 2014 16:26:50 +0200 Subject: [PATCH 4/6] allow Alt+Return for new line --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a0b2575..2ebeba5 100644 --- a/index.js +++ b/index.js @@ -40,7 +40,7 @@ Emitter(Input.prototype); */ Input.prototype.onkeydown = function(e){ - if (13 == e.keyCode && !e.shiftKey) { + if (13 == e.keyCode && !e.shiftKey && !e.altKey) { e.preventDefault(); } }; @@ -64,6 +64,7 @@ Input.prototype.onkeyup = function(e){ // textarea mode if (13 != e.keyCode) return; if (e.shiftKey) return; + if (e.altKey) return; // input mode if (typeof this.cleanedValue != 'undefined') { From d7637089b315d94506dd4a7e1277dc702ee68de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Kr=C3=B6ner?= Date: Thu, 12 Jun 2014 11:32:39 +0200 Subject: [PATCH 5/6] allow Ctrl+Return for new line --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2ebeba5..2539ce2 100644 --- a/index.js +++ b/index.js @@ -40,7 +40,7 @@ Emitter(Input.prototype); */ Input.prototype.onkeydown = function(e){ - if (13 == e.keyCode && !e.shiftKey && !e.altKey) { + if (13 == e.keyCode && !e.shiftKey && !e.altKey && !e.ctrlKey) { e.preventDefault(); } }; @@ -65,6 +65,7 @@ Input.prototype.onkeyup = function(e){ if (13 != e.keyCode) return; if (e.shiftKey) return; if (e.altKey) return; + if (e.ctrlKey) return; // input mode if (typeof this.cleanedValue != 'undefined') { From e32512ec4a236b7bcde06d397e77ba97aa18588c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Kr=C3=B6ner?= Date: Mon, 16 Jun 2014 11:24:26 +0200 Subject: [PATCH 6/6] use latest events and classes components --- component.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component.json b/component.json index a9287be..5e8d3c3 100644 --- a/component.json +++ b/component.json @@ -9,8 +9,8 @@ ], "dependencies": { "component/emitter": "*", - "component/events": "1.0.4", - "component/classes": "1.1.3" + "component/events": "*", + "component/classes": "*" }, "development": {}, "license": "MIT",