1/* 2* Vekz 3* http://www.callmekev.com/jquery.autobox.js 4* autobox plugin - 5* Used on text inputs with default values. Clears the default value on focus. 6* Restores the default value on blur if empty or the same 7* overlays text inputs for password boxes and swaps them on focus 8* use straight CSS for styling the focus of the text input 9* 10*/ 11 12jQuery.fn.autobox = function(options){ 13 var settings = $.extend({defaultClass : 'default', filledClass : 'filled'}, options); 14 15 return this.each(function (){ 16 var textInput = $(this); 17 var defaultVal = textInput.val(); 18 textInput.addClass(settings.defaultClass); 19 20 if(textInput.attr('type') == 'password'){ 21 var newInput = $('<input type="text" class="'+settings.defaultClass+'"value="'+textInput.val()+'" />'); 22 newInput.css({ 23 'position' : 'absolute', 24 'z-index' : 10, 25 'top' : textInput.position().top+'px', 26 'left' : textInput.position().left+'px' 27 }); 28 29 $(window).resize(function(){ 30 newInput.css({ 31 'top' : textInput.position().top+'px', 32 'left' : textInput.position().left+'px' 33 }); 34 }); 35 36 newInput.bind('focus', function(){ 37 var $this = $(this); 38 $this.hide(); 39 textInput.show(); 40 textInput.css({'visibility' : 'visible'}); 41 textInput.focus(); 42 }); 43 44 textInput.before(newInput); 45 } 46 47 textInput.bind('focus', function(){ 48 var $this = $(this); 49 $this.removeClass(settings.defaultClass); 50 $this.addClass(settings.filledClass); 51 if($this.val() == defaultVal){ 52 $this.val(''); 53 } 54 }); 55 56 textInput.bind('blur', function(){ 57 var $this = $(this); 58 if($this.val() == ''){ 59 $this.val(defaultVal); 60 $this.addClass(settings.defaultClass); 61 $this.removeClass(settings.filledClass); 62 if($this.attr('type') == 'password'){ 63 newInput.show(); 64 } 65 }else{ 66 $this.addClass(settings.filledClass); 67 } 68 }); 69 }); 70};
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.