diff --git a/app/assets/javascripts/app/controllers/_channel/chat.coffee b/app/assets/javascripts/app/controllers/_channel/chat.coffee index de7a861a3..860e6988e 100644 --- a/app/assets/javascripts/app/controllers/_channel/chat.coffee +++ b/app/assets/javascripts/app/controllers/_channel/chat.coffee @@ -9,9 +9,9 @@ class App.ChannelChat extends App.Controller 'submit .js-testurl': 'changeDemoWebsite' 'blur .js-testurl-input': 'changeDemoWebsite' 'click .js-selectBrowserWidth': 'selectBrowserWidth' + 'click .js-swatch': 'useSwatchColor' elements: - '.js-demo': 'demo' '.js-browser': 'browser' '.js-iframe': 'iframe' '.js-chat': 'chat' @@ -19,6 +19,8 @@ class App.ChannelChat extends App.Controller '.js-backgroundColor': 'chatBackground' '.js-paramsBlock': 'paramsBlock' '.js-code': 'code' + '.js-swatches': 'swatches' + '.js-color': 'colorField' apiOptions: [ { @@ -142,16 +144,16 @@ class App.ChannelChat extends App.Controller return if value is 'fit' - if width < @demo.width() + if width < @el.width() @chat.addClass('is-fullscreen') @browser.css('width', "#{ width }px") else - percentage = @demo.width()/width + percentage = @el.width()/width @chat.css('transform', "scale(#{ percentage })") @iframe.css transform: "scale(#{ percentage })" - width: @demo.width() / percentage - height: @demo.height() / percentage + width: @el.width() / percentage + height: @el.height() / percentage changeDemoWebsite: (event) => event.preventDefault() if event @@ -166,6 +168,41 @@ class App.ChannelChat extends App.Controller src = "http://#{ src }" @iframe.attr 'src', src + @swatches.empty() + + $.ajax + url: 'https://images.zammad.com/api/v1/webpage/colors' + data: + url: src + count: 6 + success: @renderSwatches + dataType: 'json' + + renderSwatches: (data, xhr, status) => + + # filter white + data = _.filter data, (color) => + @getLuminance(color) < 0.85 + + htmlString = "" + + for color in data + htmlString += App.view('channel/color_swatch') + color: color + + @swatches.html htmlString + + getLuminance: (hex) -> + # input: #ffffff, output: 1 + result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec hex + r = parseInt(result[1], 16) + g = parseInt(result[2], 16) + b = parseInt(result[3], 16) + return (0.2126*r + 0.7152*g + 0.0722*b)/255 + + useSwatchColor: (event) -> + @colorField.val $(event.currentTarget).attr('data-color') + @updateParams() new: (e) => new App.ControllerGenericNew( diff --git a/app/assets/javascripts/app/lib/bootstrap/bootstrap-datepicker.js b/app/assets/javascripts/app/lib/bootstrap/bootstrap-datepicker.js index ef1a3f4f5..7e00802d1 100755 --- a/app/assets/javascripts/app/lib/bootstrap/bootstrap-datepicker.js +++ b/app/assets/javascripts/app/lib/bootstrap/bootstrap-datepicker.js @@ -25,6 +25,7 @@ Zammad Edits: - fix todayBtn toggle of display none and block: toggleClass instead - allow custom template as options parameter + - fix that place method doesn't think that the container is the window, but rather the real window is the window */ @@ -685,7 +686,7 @@ calendarHeight = this.picker.outerHeight(), visualPadding = 10, container = $(this.o.container), - windowWidth = container.width(), + windowWidth = $(window).width(), scrollTop = container.scrollTop(), appendOffset = container.offset(); diff --git a/app/assets/javascripts/app/views/channel/chat.jst.eco b/app/assets/javascripts/app/views/channel/chat.jst.eco index f5afc037c..bc5dbee37 100644 --- a/app/assets/javascripts/app/views/channel/chat.jst.eco +++ b/app/assets/javascripts/app/views/channel/chat.jst.eco @@ -41,7 +41,7 @@ <% end %>
<%- @T('Insert the widget-code into the source code of every page the chat should be visible on. It should be placed at the end of the page source code before the `</body>` closing tag.') %>
+<%- marked(@T('Insert the widget-code into the source code of every page the chat should be visible on. It should be placed at the end of the page source code before the `