X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=blobdiff_plain;f=resources%2Fjquery%2Fjquery.placeholder.js;h=73f701b507694322e84a662a4a591ce4a8b6c164;hb=a8145d6fa2;hp=7badb11ae872270d5b24f815617c772cc8287d7d;hpb=59115b52b40bc534a30ae8c54b0dba3ea6a62d4c;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/jquery/jquery.placeholder.js b/resources/jquery/jquery.placeholder.js index 7badb11ae8..73f701b507 100644 --- a/resources/jquery/jquery.placeholder.js +++ b/resources/jquery/jquery.placeholder.js @@ -10,17 +10,23 @@ */ ( function ( $ ) { - $.fn.placeholder = function () { + $.fn.placeholder = function ( text ) { + // Check whether supplied argument is a string + var textIsValid = ( typeof text === 'string' ); return this.each( function () { var placeholder, $input; + // If the HTML5 placeholder attribute is supported, use it if ( this.placeholder && 'placeholder' in document.createElement( this.tagName ) ) { + if ( textIsValid ) { + this.setAttribute( 'placeholder', text ); + } return; } - placeholder = this.getAttribute( 'placeholder' ); + placeholder = textIsValid ? text : this.getAttribute( 'placeholder' ); $input = $(this); // Show initially, if empty