annotate themes/isobartik/color/preview.es6.js @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents e11175134f4e
children
rev   line source
Chris@3 1 /**
Chris@3 2 * @file
Chris@3 3 * Preview for the Bartik theme.
Chris@3 4 */
Chris@3 5 (function ($, Drupal, drupalSettings) {
Chris@3 6 Drupal.color = {
Chris@3 7 logoChanged: false,
Chris@3 8 callback(context, settings, $form) {
Chris@3 9 // Change the logo to be the real one.
Chris@3 10 if (!this.logoChanged) {
Chris@3 11 $('.color-preview .color-preview-logo img').attr('src', drupalSettings.color.logo);
Chris@3 12 this.logoChanged = true;
Chris@3 13 }
Chris@3 14 // Remove the logo if the setting is toggled off.
Chris@3 15 if (drupalSettings.color.logo === null) {
Chris@3 16 $('div').remove('.color-preview-logo');
Chris@3 17 }
Chris@3 18
Chris@3 19 const $colorPreview = $form.find('.color-preview');
Chris@3 20 const $colorPalette = $form.find('.js-color-palette');
Chris@3 21
Chris@3 22 // Solid background.
Chris@3 23 $colorPreview.css('backgroundColor', $colorPalette.find('input[name="palette[bg]"]').val());
Chris@3 24
Chris@3 25 // Text preview.
Chris@3 26 $colorPreview.find('.color-preview-main h2, .color-preview .preview-content').css('color', $colorPalette.find('input[name="palette[text]"]').val());
Chris@3 27 $colorPreview.find('.color-preview-content a').css('color', $colorPalette.find('input[name="palette[link]"]').val());
Chris@3 28
Chris@3 29 // Sidebar block.
Chris@3 30 const $colorPreviewBlock = $colorPreview.find('.color-preview-sidebar .color-preview-block');
Chris@3 31 $colorPreviewBlock.css('background-color', $colorPalette.find('input[name="palette[sidebar]"]').val());
Chris@3 32 $colorPreviewBlock.css('border-color', $colorPalette.find('input[name="palette[sidebarborders]"]').val());
Chris@3 33
Chris@3 34 // Footer wrapper background.
Chris@3 35 $colorPreview.find('.color-preview-footer-wrapper').css('background-color', $colorPalette.find('input[name="palette[footer]"]').val());
Chris@3 36
Chris@3 37 // CSS3 Gradients.
Chris@3 38 const gradient_start = $colorPalette.find('input[name="palette[top]"]').val();
Chris@3 39 const gradient_end = $colorPalette.find('input[name="palette[bottom]"]').val();
Chris@3 40
Chris@3 41 $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 42
Chris@3 43 $colorPreview.find('.color-preview-site-name').css('color', $colorPalette.find('input[name="palette[titleslogan]"]').val());
Chris@3 44 },
Chris@3 45 };
Chris@3 46 }(jQuery, Drupal, drupalSettings));