Chris@3: /** Chris@3: * @file Chris@3: * Preview for the Bartik theme. Chris@3: */ Chris@3: (function ($, Drupal, drupalSettings) { Chris@3: Drupal.color = { Chris@3: logoChanged: false, Chris@3: callback(context, settings, $form) { Chris@3: // Change the logo to be the real one. Chris@3: if (!this.logoChanged) { Chris@3: $('.color-preview .color-preview-logo img').attr('src', drupalSettings.color.logo); Chris@3: this.logoChanged = true; Chris@3: } Chris@3: // Remove the logo if the setting is toggled off. Chris@3: if (drupalSettings.color.logo === null) { Chris@3: $('div').remove('.color-preview-logo'); Chris@3: } Chris@3: Chris@3: const $colorPreview = $form.find('.color-preview'); Chris@3: const $colorPalette = $form.find('.js-color-palette'); Chris@3: Chris@3: // Solid background. Chris@3: $colorPreview.css('backgroundColor', $colorPalette.find('input[name="palette[bg]"]').val()); Chris@3: Chris@3: // Text preview. Chris@3: $colorPreview.find('.color-preview-main h2, .color-preview .preview-content').css('color', $colorPalette.find('input[name="palette[text]"]').val()); Chris@3: $colorPreview.find('.color-preview-content a').css('color', $colorPalette.find('input[name="palette[link]"]').val()); Chris@3: Chris@3: // Sidebar block. Chris@3: const $colorPreviewBlock = $colorPreview.find('.color-preview-sidebar .color-preview-block'); Chris@3: $colorPreviewBlock.css('background-color', $colorPalette.find('input[name="palette[sidebar]"]').val()); Chris@3: $colorPreviewBlock.css('border-color', $colorPalette.find('input[name="palette[sidebarborders]"]').val()); Chris@3: Chris@3: // Footer wrapper background. Chris@3: $colorPreview.find('.color-preview-footer-wrapper').css('background-color', $colorPalette.find('input[name="palette[footer]"]').val()); Chris@3: Chris@3: // CSS3 Gradients. Chris@3: const gradient_start = $colorPalette.find('input[name="palette[top]"]').val(); Chris@3: const gradient_end = $colorPalette.find('input[name="palette[bottom]"]').val(); Chris@3: Chris@3: $colorPreview.find('.color-preview-header').attr('style', `background-color: ${gradient_start}; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(${gradient_start}), to(${gradient_end})); background-image: -moz-linear-gradient(-90deg, ${gradient_start}, ${gradient_end});`); Chris@3: Chris@3: $colorPreview.find('.color-preview-site-name').css('color', $colorPalette.find('input[name="palette[titleslogan]"]').val()); Chris@3: }, Chris@3: }; Chris@3: }(jQuery, Drupal, drupalSettings));