/[drupal]/contributions/themes/acquia_slate/jquery.overlabel.js
ViewVC logotype

Contents of /contributions/themes/acquia_slate/jquery.overlabel.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sat Feb 28 23:33:58 2009 UTC (8 months, 4 weeks ago) by jwolf
Branch: MAIN
CVS Tags: DRUPAL-6--1-4, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-2, DRUPAL-6--1-3, HEAD
Branch point for: DRUPAL-6--1, DRUPAL-6--2
File MIME type: text/javascript
initial commit of Acquia Slate theme
1 // $Id$
2
3 ( function( $ ) {
4
5 // plugin definition
6 $.fn.overlabel = function( options ) {
7
8 // build main options before element iteration
9 var opts = $.extend( {}, $.fn.overlabel.defaults, options );
10
11 var selection = this.filter( 'label[for]' ).map( function() {
12
13 var label = $( this );
14 var id = label.attr( 'for' );
15 var field = document.getElementById( id );
16
17 if ( !field ) return;
18
19 // build element specific options
20 var o = $.meta ? $.extend( {}, opts, label.data() ) : opts;
21
22 label.addClass( o.label_class );
23
24 var hide_label = function() { label.css( o.hide_css ) };
25 var show_label = function() { this.value || label.css( o.show_css ) };
26
27 $( field )
28 .parent().addClass( o.wrapper_class ).end()
29 .focus( hide_label ).blur( show_label ).each( hide_label ).each( show_label );
30
31 return this;
32
33 } );
34
35 return opts.filter ? selection : selection.end();
36 };
37
38 // publicly accessible defaults
39 $.fn.overlabel.defaults = {
40
41 label_class: 'overlabel-apply',
42 wrapper_class: 'overlabel-wrapper',
43 hide_css: { 'text-indent': '-10000px' },
44 show_css: { 'text-indent': '0px', 'cursor': 'text' },
45 filter: false
46
47 };
48
49 } )( jQuery );

  ViewVC Help
Powered by ViewVC 1.1.2