skinr_ui.rules.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // $Id$
  2. (function ($) {
  3. /**
  4. * Provide the summary information for the block settings vertical tabs.
  5. */
  6. Drupal.behaviors.skinrUIRuleSettingsSummary = {
  7. attach: function (context) {
  8. // The drupalSetSummary method required for this behavior is not available
  9. // on the Blocks administration page, so we need to make sure this
  10. // behavior is processed only if drupalSetSummary is defined.
  11. if (typeof jQuery.fn.drupalSetSummary == 'undefined') {
  12. return;
  13. }
  14. $('fieldset#edit-path', context).drupalSetSummary(function (context) {
  15. if (!$('textarea[name="pages"]', context).val()) {
  16. return Drupal.t('Not restricted');
  17. }
  18. else {
  19. return Drupal.t('Restricted to certain pages');
  20. }
  21. });
  22. $('fieldset#edit-node-type', context).drupalSetSummary(function (context) {
  23. var vals = [];
  24. $('input[type="checkbox"]:checked', context).each(function () {
  25. vals.push($.trim($(this).next('label').text()));
  26. });
  27. if (!vals.length) {
  28. vals.push(Drupal.t('Not restricted'));
  29. }
  30. return vals.join(', ');
  31. });
  32. $('fieldset#edit-role', context).drupalSetSummary(function (context) {
  33. var vals = [];
  34. $('input[type="checkbox"]:checked', context).each(function () {
  35. vals.push($.trim($(this).next('label').text()));
  36. });
  37. if (!vals.length) {
  38. vals.push(Drupal.t('Not restricted'));
  39. }
  40. return vals.join(', ');
  41. });
  42. $('fieldset#edit-user', context).drupalSetSummary(function (context) {
  43. var $radio = $('input[name="custom"]:checked', context);
  44. if ($radio.val() == 0) {
  45. return Drupal.t('Not customizable');
  46. }
  47. else {
  48. return $radio.next('label').text();
  49. }
  50. });
  51. }
  52. };
  53. })(jQuery);