home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (page_title.js)

This example Drupal source code file (page_title.js) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

attach, characters, class, context, edit-page-title, fieldset, function, input, php, pt, return, title, var, wrapper

The page_title.js Drupal example source code

// $Id: page_title.js,v 2010/11/01 23:37:52 njt1982 Exp $

(function ($) {

Drupal.behaviors.pageTitleFieldsetSummaries = {
  attach: function (context) {
    $('fieldset#edit-page-title', context).drupalSetSummary(function (context) {
      var pt = $('input', context).val();

      return pt ?
        Drupal.t('Page Title: @pt', { '@pt': pt }) :
        Drupal.t('No Page Title');

Drupal.behaviors.pageTitleCounter = {
  attach : function(context) {
    $('fieldset#edit-page-title', context).each(function() {
      function getLength(element) { return $(element).val().length; }

      var wrapper = this;

      var inputBox = $('input[name=page_title]', wrapper);

      var valueBox = $('div.description', wrapper)
                      .append('<br/><span class="counter">Characters Entered: <span class="value">0</span></span>')

      $('input[name=page_title]', wrapper).keyup(function(e) { $(valueBox).text(getLength(inputBox)); });



Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal page_title.js source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.