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