styles_ui.js 723 B

123456789101112131415161718192021222324252627
  1. /**
  2. * @file
  3. * jQuery attachment to Styles UI admin pages.
  4. */
  5. (function ($) {
  6. /**
  7. * Change the preview on radio change.
  8. */
  9. Drupal.behaviors.stylesUI = {
  10. attach: function(context, settings) {
  11. $('.styles-ui-preset', context).once('stylesUI', function () {
  12. $(this).bind('change', function() {
  13. $preset = $(this);
  14. if ($preset.val()) {
  15. $.getJSON(Drupal.settings.stylesUI.url + '/' + Drupal.settings.stylesUI.fieldType + '/' + $preset.attr('rel') + '/' + $preset.val(), function(data){
  16. // @TODO: Check for errors.
  17. $(data.id).html(data.preview);
  18. });
  19. }
  20. });
  21. });
  22. }
  23. }
  24. // end of closure
  25. })(jQuery);