1/* 2 * jQuery ah-placeholder plugin 1.0 3 * 4 * https://github.com/ahomu/jquery.ah-placeholder 5 * http://havelog.ayumusato.com/develop/javascript/e189-jquery-plugin-placeholder.html 6 * 7 * Copyright (c) 2011 Ayumu Sato ( http://havelog.ayumusato.com ) 8 * 9 * Dual licensed under the MIT and GPL licenses: 10 * http://www.opensource.org/licenses/mit-license.php 11 * http://www.gnu.org/licenses/gpl.html 12 */ 13(function($) { 14 $.fn.ahPlaceholder = function(options) 15 { 16 // property 17 var defaults = { 18 placeholderColor : 'silver', 19 necessaryColor : 'hotpink' 20 }, 21 settings = $.extend({}, defaults, options); 22 // method 23 var init = function() 24 { 25 $.data(this, 'placeholder-string', this.title); 26// $.data(this, 'placeholder-color', this.style.color); 27 $.data(this, 'placeholder-color', $(this).css("color")); 28 var phString = $.data(this, 'placeholder-string'), 29 $self = $(this); 30 31 if ( this.value === '' ) { 32 this.value = phString; 33 } 34 if ( this.value === phString ) { 35// this.style.color = settings.placeholderColor; 36 $self.css("color", $self.hasClass('necessary') ? 37 settings.necessaryColor : 38 settings.placeholderColor 39 ); 40 } 41 $self.focus(onFocus); 42 $self.blur(onBlur); 43 $self.parents().filter('form').submit(onSubmit(this)); 44 }, 45 onFocus = function() 46 { 47 if ( this.value === $.data(this, 'placeholder-string') ) { 48 this.value = ''; 49// this.style.color = $.data(this, 'placeholder-color'); 50 $(this).css("color", $.data(this, 'placeholder-color')); 51 } 52 }, 53 onBlur = function() 54 { 55 if ( this.value === '' ) { 56 this.value = $.data(this, 'placeholder-string'); 57// this.style.color = settings.placeholderColor; 58 $(this).css("color", $(this).hasClass('necessary') ? 59 settings.necessaryColor : 60 settings.placeholderColor 61 ); 62 } 63 }, 64 onSubmit= function(elm) 65 { 66 return function() 67 { 68 if ( $(elm).val() === $.data(elm, 'placeholder-string') ) { 69 $(elm).val(''); 70 } 71 return true; 72 }; 73 }; 74 // construct 75 this.each(function() 76 { 77 init.apply(this); 78 }); 79 80 return this; 81 }; 82})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.