From 75d22c9d1d564277138194a01c5cab5c36166bd2 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Wed, 25 Nov 2015 15:48:54 +0100 Subject: [PATCH] chat designer: fix chat height when changing fontSize --- .../app/controllers/_channel/chat.coffee | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_channel/chat.coffee b/app/assets/javascripts/app/controllers/_channel/chat.coffee index 41639fd9b..5fd4f65fd 100644 --- a/app/assets/javascripts/app/controllers/_channel/chat.coffee +++ b/app/assets/javascripts/app/controllers/_channel/chat.coffee @@ -5,13 +5,12 @@ class App.ChannelChat extends App.Controller 'click .js-remove': 'remove' 'click .js-widget': 'widget' 'change .js-params': 'updateParams' - 'keyup .js-params': 'updateParams' - 'submit .js-demo-head': 'changeDemoWebsite' + 'input .js-params': 'updateParams' + 'submit .js-demo-head': 'onUrlSubmit' 'blur .js-testurl-input': 'changeDemoWebsite' 'click .js-selectBrowserWidth': 'selectBrowserWidth' 'click .js-swatch': 'usePaletteColor' 'click .js-toggle-chat': 'toggleChat' - 'input .js-chatTitle': 'changeTitle' elements: '.js-browser': 'browser' @@ -101,7 +100,6 @@ class App.ChannelChat extends App.Controller isOpen: true browserWidth: 1280 - chatHeight: 360 constructor: -> super @@ -140,11 +138,11 @@ class App.ChannelChat extends App.Controller @code.each (i, block) -> hljs.highlightBlock block - @adjustBrowserWidth() + @updatePreview() @updateParams() - # bind adjustBrowserWidth with parameter animate = false - $(window).on 'resize.chat-designer', => @adjustBrowserWidth false + # bind updatePreview with parameter animate = false + $(window).on 'resize.chat-designer', => @updatePreview false release: -> $(window).off 'resize.chat-designer' @@ -155,9 +153,9 @@ class App.ChannelChat extends App.Controller # select tab tab.addClass('is-selected').siblings().removeClass('is-selected') @browserWidth = tab.attr('data-value') - @adjustBrowserWidth() + @updatePreview() - adjustBrowserWidth: (animate = true) => + updatePreview: (animate = true) => width = parseInt @browserWidth, 10 # reset zoom @@ -190,13 +188,14 @@ class App.ChannelChat extends App.Controller if fullscreen return @browserBody.height() - @chatHeader.outerHeight() else - return @chatHeight - @chatHeader.outerHeight() + return @chat.height() - @chatHeader.outerHeight() - changeDemoWebsite: (event) => + onUrlSubmit: (event) -> event.preventDefault() if event + @urlInput.focus() + @changeDemoWebsite() - # fire both on enter and blur - # but cache url + changeDemoWebsite: -> return if @urlInput.val() is '' or @urlInput.val() is @urlCache @urlCache = @urlInput.val() @@ -204,7 +203,7 @@ class App.ChannelChat extends App.Controller if !@url.startsWith('http') @url = "http://#{ @url }" - @urlInput.addClass('is-loading').focus() + @urlInput.addClass('is-loading') @palette.empty() @@ -263,10 +262,7 @@ class App.ChannelChat extends App.Controller toggleChat: => @chat.toggleClass('is-open') @isOpen = @chat.hasClass('is-open') - @adjustBrowserWidth() - - changeTitle: (event) -> - @chatWelcome.html $(event.currentTarget).val() + @updatePreview() new: (e) => new App.ControllerGenericNew( @@ -329,6 +325,8 @@ class App.ChannelChat extends App.Controller @chat.removeClass('zammad-chat--flat') @chatWelcome.html params.title + @updatePreview false + if @permanent for key, value of @permanent params[key] = value