preview.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. (function ($) {
  2. Drupal.color = {
  3. logoChanged: false,
  4. callback: function(context, settings, form, farb, height, width) {
  5. // Change the logo to be the real one.
  6. if (!this.logoChanged) {
  7. $('#preview #preview-logo img').attr('src', Drupal.settings.color.logo);
  8. this.logoChanged = true;
  9. }
  10. // Remove the logo if the setting is toggled off.
  11. if (Drupal.settings.color.logo == null) {
  12. $('div').remove('#preview-logo');
  13. }
  14. // Solid background.
  15. $('#preview', form).css('backgroundColor', $('#palette input[name="palette[bg]"]', form).val());
  16. // Text preview.
  17. $('#preview #preview-main h2, #preview .preview-content', form).css('color', $('#palette input[name="palette[text]"]', form).val());
  18. $('#preview #preview-content a', form).css('color', $('#palette input[name="palette[link]"]', form).val());
  19. // Sidebar block.
  20. $('#preview #preview-sidebar #preview-block', form).css('background-color', $('#palette input[name="palette[sidebar]"]', form).val());
  21. $('#preview #preview-sidebar #preview-block', form).css('border-color', $('#palette input[name="palette[sidebarborders]"]', form).val());
  22. // Footer wrapper background.
  23. $('#preview #preview-footer-wrapper', form).css('background-color', $('#palette input[name="palette[footer]"]', form).val());
  24. // CSS3 Gradients.
  25. var gradient_start = $('#palette input[name="palette[top]"]', form).val();
  26. var gradient_end = $('#palette input[name="palette[bottom]"]', form).val();
  27. $('#preview #preview-header', form).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 + ");");
  28. $('#preview #preview-site-name', form).css('color', $('#palette input[name="palette[titleslogan]"]', form).val());
  29. }
  30. };
  31. })(jQuery);