From 5f6b1fb59c7f2dfb327d1cc3e058881f846e7001 Mon Sep 17 00:00:00 2001 From: Sinan Yasar Date: Wed, 4 May 2016 15:49:42 -0700 Subject: [PATCH 1/3] inputview: autogrow: prepareclone taken to its own method --- lib/components/inputs/inputview.coffee | 59 +++++++++++++------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/lib/components/inputs/inputview.coffee b/lib/components/inputs/inputview.coffee index 078c23c1..bf937db4 100644 --- a/lib/components/inputs/inputview.coffee +++ b/lib/components/inputs/inputview.coffee @@ -443,45 +443,46 @@ module.exports = class KDInputView extends KDView setAutoGrow:-> - $input = @$() - - $input.css 'overflow', 'hidden' - @setClass 'autogrow' # input content is copied into clone # element to get calculated height @_clone = $ '
', { class: 'invisible' } + @on 'focus', @bound 'prepareClone' + @on 'blur', => @_clone.detach() + @on 'input', @bound 'resize' + + + prepareClone: -> + + $input = @$() + $input.css 'overflow', 'hidden' { type } = @getOptions() isVertical = type.toLowerCase() is 'textarea' + @_clone.appendTo 'body' + @_clone.css + height : if isVertical then 'auto' else $input.css 'height' + zIndex : 100000 + width : if isVertical then $input.css 'width' else 'auto' + boxSizing : $input.css 'box-sizing' + borderTop : $input.css 'border-top' + borderRight : $input.css 'border-right' + borderBottom : $input.css 'border-bottom' + borderLeft : $input.css 'border-left' + minHeight : $input.css 'minHeight' + maxHeight : $input.css 'maxHeight' + paddingTop : $input.css 'padding-top' + paddingRight : $input.css 'padding-right' + paddingBottom : $input.css 'padding-bottom' + paddingLeft : $input.css 'padding-left' + wordBreak : $input.css 'wordBreak' + fontSize : $input.css 'fontSize' + fontWeight : $input.css 'fontWeight' + lineHeight : $input.css 'lineHeight' + whiteSpace : if isVertical then 'pre-line' else 'pre' - @on 'focus', => - @_clone.appendTo 'body' - @_clone.css - height : if isVertical then 'auto' else $input.css 'height' - zIndex : 100000 - width : if isVertical then $input.css 'width' else 'auto' - boxSizing : $input.css 'box-sizing' - borderTop : $input.css 'border-top' - borderRight : $input.css 'border-right' - borderBottom : $input.css 'border-bottom' - borderLeft : $input.css 'border-left' - minHeight : $input.css 'minHeight' - maxHeight : $input.css 'maxHeight' - paddingTop : $input.css 'padding-top' - paddingRight : $input.css 'padding-right' - paddingBottom : $input.css 'padding-bottom' - paddingLeft : $input.css 'padding-left' - wordBreak : $input.css 'wordBreak' - fontSize : $input.css 'fontSize' - fontWeight : $input.css 'fontWeight' - lineHeight : $input.css 'lineHeight' - whiteSpace : if isVertical then 'pre-line' else 'pre' - - @on 'blur', => @_clone.detach() - @on 'input', @bound 'resize' resize: (event) -> From 35fcbf622401baadbe3d17adf7cbdfba463ed44e Mon Sep 17 00:00:00 2001 From: Sinan Yasar Date: Wed, 4 May 2016 15:50:32 -0700 Subject: [PATCH 2/3] inputview: minor repetition clean up --- lib/components/inputs/inputview.coffee | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/components/inputs/inputview.coffee b/lib/components/inputs/inputview.coffee index bf937db4..a033695f 100644 --- a/lib/components/inputs/inputview.coffee +++ b/lib/components/inputs/inputview.coffee @@ -487,6 +487,8 @@ module.exports = class KDInputView extends KDView resize: (event) -> + return unless @_clone + @_clone.appendTo 'body' unless document.body.contains @_clone[0] val = @getElement().value.replace(/\n/g,'\n ') safeValue = Encoder.XSSEncode val @@ -502,8 +504,6 @@ module.exports = class KDInputView extends KDView _resizeHorizontally: (event) -> - return unless @_clone - width = @_clone.width() if @$().css('boxSizing') is 'border-box' @@ -522,8 +522,6 @@ module.exports = class KDInputView extends KDView _resizeVertically: (event) -> - return unless @_clone - height = @_clone.height() if @$().css('boxSizing') is 'border-box' From 863767fcf0ea48e9adfe3a73b48b747b36266ef9 Mon Sep 17 00:00:00 2001 From: Sinan Yasar Date: Wed, 4 May 2016 15:50:58 -0700 Subject: [PATCH 3/3] npm: bump up version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index baf36a7f..bcce43f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kd.js", - "version": "1.1.21", + "version": "1.1.22", "description": "a collection of ui widgets and other nice things", "main": "build/lib/index.js", "scripts": {