[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/themes/fusion/fusion_core/js/ -> jquery.overlabel.js (source)

   1  // $Id: jquery.overlabel.js,v 1.1.2.1 2010/02/14 06:44:15 sociotech Exp $

   2  
   3  (function($) {
   4      // plugin definition

   5      $.fn.overlabel = function(options) {
   6          // build main options before element iteration

   7          var opts = $.extend({}, $.fn.overlabel.defaults, options);
   8          var selection = this.filter('label[for]').map(function() {
   9              var label = $(this);
  10              var id = label.attr('for');
  11              var field = document.getElementById(id);
  12  
  13              if (!field) return;
  14  
  15              // build element specific options

  16              var o = $.meta ? $.extend({}, opts, label.data()) : opts;
  17  
  18              label.addClass(o.label_class);
  19   
  20              var hide_label = function() {label.css(o.hide_css)};
  21              var show_label = function() {this.value || label.css(o.show_css)};
  22   
  23              $(field)
  24                   .parent().addClass(o.wrapper_class).end()
  25                   .focus(hide_label).blur(show_label).each(hide_label).each(show_label);
  26              return this;
  27          });
  28          return opts.filter ? selection : selection.end();
  29      };
  30   
  31      // publicly accessible defaults

  32      $.fn.overlabel.defaults = {
  33          label_class:   'overlabel-apply',
  34          wrapper_class: 'overlabel-wrapper',
  35          hide_css:      {'text-indent': '-10000px'},
  36          show_css:      {'text-indent': '0px', 'cursor': 'text'},
  37          filter:        false
  38      };
  39  })(jQuery);


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7