From 033ab869fe642aef32ebd9bdf5831490abdc0d6f Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Tue, 24 Nov 2015 18:12:59 +0100 Subject: [PATCH] chat designer: fix open/close on different widths --- .../app/controllers/_channel/chat.coffee | 40 ++++++++++++++----- .../app/views/channel/chat.jst.eco | 10 ++--- app/assets/stylesheets/zammad.scss | 8 ++-- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_channel/chat.coffee b/app/assets/javascripts/app/controllers/_channel/chat.coffee index 1841ba2d2..0d8836fab 100644 --- a/app/assets/javascripts/app/controllers/_channel/chat.coffee +++ b/app/assets/javascripts/app/controllers/_channel/chat.coffee @@ -15,17 +15,19 @@ class App.ChannelChat extends App.Controller elements: '.js-browser': 'browser' + '.js-browserBody': 'browserBody' '.js-iframe': 'iframe' + '.js-screenshot': 'screenshot' + '.js-website': 'website' '.js-chat': 'chat' + '.js-chatHeader': 'chatHeader' + '.js-chat-welcome': 'chatWelcome' '.js-testurl-input': 'urlInput' '.js-backgroundColor': 'chatBackground' '.js-paramsBlock': 'paramsBlock' '.js-code': 'code' '.js-palette': 'palette' '.js-color': 'colorField' - '.js-screenshot': 'screenshot' - '.js-website': 'website' - '.js-chat-welcome': 'chatWelcome' apiOptions: [ { @@ -97,6 +99,10 @@ class App.ChannelChat extends App.Controller } ] + isOpen: true + browserWidth: 1280 + chatHeight: 360 + constructor: -> super @load() @@ -134,6 +140,7 @@ class App.ChannelChat extends App.Controller @code.each (i, block) -> hljs.highlightBlock block + @adjustBrowserWidth() @updateParams() selectBrowserWidth: (event) => @@ -141,31 +148,42 @@ class App.ChannelChat extends App.Controller # select tab tab.addClass('is-selected').siblings().removeClass('is-selected') - value = tab.attr('data-value') - width = parseInt value, 10 + @browserWidth = tab.attr('data-value') + @adjustBrowserWidth() + + adjustBrowserWidth: -> + width = parseInt @browserWidth, 10 # reset zoom @chat - .css('transform', '') .removeClass('is-fullscreen') + .css 'transform', "translateY(#{ @getChatOffset() }px)" @browser.css('width', '') @website.css transform: '' width: '' height: '' - return if value is 'fit' + return if @browserWidth is 'fit' if width < @el.width() - @chat.addClass('is-fullscreen') + @chat.addClass('is-fullscreen').css 'transform', "translateY(#{ @getChatOffset(true) }px)" @browser.css('width', "#{ width }px") else percentage = @el.width()/width - @chat.css('transform', "scale(#{ percentage })") + @chat.css 'transform', "translateY(#{ @getChatOffset() * percentage }px) scale(#{ percentage })" @website.css transform: "scale(#{ percentage })" width: @el.width() / percentage - height: @el.height() / percentage + height: @browserBody.height() / percentage + + getChatOffset: (fullscreen) -> + return 0 if @isOpen + + if fullscreen + return @browserBody.height() - @chatHeader.outerHeight() + else + return @chatHeight - @chatHeader.outerHeight() changeDemoWebsite: (event) => event.preventDefault() if event @@ -237,6 +255,8 @@ class App.ChannelChat extends App.Controller toggleChat: => @chat.toggleClass('is-open') + @isOpen = @chat.hasClass('is-open') + @adjustBrowserWidth() changeTitle: (event) -> @chatWelcome.html $(event.currentTarget).val() diff --git a/app/assets/javascripts/app/views/channel/chat.jst.eco b/app/assets/javascripts/app/views/channel/chat.jst.eco index c00e0789e..cf6314d67 100644 --- a/app/assets/javascripts/app/views/channel/chat.jst.eco +++ b/app/assets/javascripts/app/views/channel/chat.jst.eco @@ -52,8 +52,8 @@
iPhone 6
-
<%- @T('1:1') %>
-
MacBook
+
<%- @T('1:1') %>
+
MacBook
@@ -66,15 +66,15 @@
-
+
-
-
+
+
<%- @T('Online') %> diff --git a/app/assets/stylesheets/zammad.scss b/app/assets/stylesheets/zammad.scss index bb76db7e1..2f8890c23 100644 --- a/app/assets/stylesheets/zammad.scss +++ b/app/assets/stylesheets/zammad.scss @@ -7455,6 +7455,7 @@ output { width: 100%; height: 100%; background: white; + border-radius: 0 0 5px 5px; } img { @@ -7508,7 +7509,8 @@ output { position: absolute; transform-origin: right bottom; transition: 500ms; - bottom: -318px; + user-select: none; + will-change: transform; .zammad-chat-welcome { display: block !important; @@ -7524,9 +7526,7 @@ output { display: none !important; } - &.is-open { - bottom: 0; - + &.is-open { .zammad-chat-agent { display: block !important; }