diff --git a/app/javascript/legacy/settings.coffee b/app/javascript/legacy/settings.coffee index 9b4e6276..203d2190 100644 --- a/app/javascript/legacy/settings.coffee +++ b/app/javascript/legacy/settings.coffee @@ -104,27 +104,27 @@ if window.URL? or window.webkitURL? previewStyle = null -$(document).ready -> - previewStyle = document.createElement 'style' - document.body.appendChild previewStyle +$(document).on 'ready turbolinks:load', -> + if $('#update_theme').length > 0 + previewStyle = document.createElement 'style' + document.body.appendChild previewStyle - previewTimeout = null + previewTimeout = null - $('#update_theme .color').each -> - $this = $ this - this.value = '#' + getHexColorFromThemeValue(this.value) + $('#update_theme .color').each -> + $this = $ this + this.value = '#' + getHexColorFromThemeValue(this.dataset.default) - $this.minicolors - control: 'hue' - defaultValue: this.value - letterCase: 'lowercase' - position: 'bottom left' - theme: 'bootstrap' - inline: false - change: -> - clearTimeout previewTimeout - previewTimeout = setTimeout(previewTheme, 1000) - true + $this.minicolors + control: 'hue' + defaultValue: this.value + letterCase: 'lowercase' + position: 'bottom left' + theme: 'bootstrap' + inline: false + change: -> + clearTimeout previewTimeout + previewTimeout = setTimeout(previewTheme, 1000) $(document).on 'click', 'a.theme_preset', (event) -> preset = [].concat themePresets[this.dataset.preset] diff --git a/app/javascript/packs/legacy.coffee b/app/javascript/packs/legacy.coffee index a7352337..505ed10f 100644 --- a/app/javascript/packs/legacy.coffee +++ b/app/javascript/packs/legacy.coffee @@ -8,6 +8,7 @@ import 'bootstrap' import 'jquery.guillotine' import 'particleground/jquery.particleground.min' import 'jquery.growl' +import 'jquery-minicolors' import 'sweetalert' import Cookies from 'js-cookie' import moment from 'moment' @@ -16,6 +17,7 @@ require('nprogress/nprogress.css') require('jquery.growl/stylesheets/jquery.growl.css') require('jquery.guillotine/css/jquery.guillotine.css') require('sweetalert/dist/sweetalert.css') +require('jquery-minicolors/jquery.minicolors.css') # this file is generated by Rails import I18n from '../legacy/i18n'