page_title.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. (function ($) {
  2. Drupal.behaviors.pageTitleFieldsetSummaries = {
  3. attach: function (context) {
  4. $('fieldset#edit-page-title', context).drupalSetSummary(function (context) {
  5. var pt = $('input', context).val();
  6. return pt ?
  7. Drupal.t('Page Title: @pt', { '@pt': pt }) :
  8. Drupal.t('No Page Title');
  9. });
  10. }
  11. };
  12. Drupal.behaviors.pageTitleCounter = {
  13. attach : function(context) {
  14. $('fieldset#edit-page-title', context).each(function() {
  15. function getLength(element) { return $(element).val().length; }
  16. var wrapper = this;
  17. var inputBox = $('input[name=page_title]', wrapper);
  18. var valueBox = $('div.description', wrapper)
  19. .append('<br/><span class="counter">Characters Entered: <span class="value">0</span></span>')
  20. .find('.value')
  21. .text(getLength(inputBox));
  22. $('input[name=page_title]', wrapper).keyup(function(e) { $(valueBox).text(getLength(inputBox)); });
  23. });
  24. }
  25. }
  26. })(jQuery);