X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fjquery%2Fjquery.placeholder.js;h=8044d8803860df574d512f40a49843056c1963e8;hb=b4ee5c38b56237f80e892e27cd7cabad5aa679d8;hp=5ec05f21b824313922568436a2efe599f3e57aa8;hpb=1f086ddbfb9c39a387c0d864128b802a8e2d0e9e;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/jquery/jquery.placeholder.js b/resources/jquery/jquery.placeholder.js index 5ec05f21b8..8044d88038 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 ) { + var hasArg = arguments.length; return this.each( function () { + var placeholder, $input; + + if ( hasArg ) { + this.setAttribute( 'placeholder', text ); + } // If the HTML5 placeholder attribute is supported, use it if ( this.placeholder && 'placeholder' in document.createElement( this.tagName ) ) { return; } - var placeholder = this.getAttribute( 'placeholder' ); - var $input = $(this); + placeholder = hasArg ? text : this.getAttribute( 'placeholder' ); + $input = $(this); // Show initially, if empty if ( this.value === '' || this.value === placeholder ) { @@ -39,7 +45,7 @@ // Hide on focus // Also listen for other events in case $input was // already focused when the events were bound - .bind( 'focus drop keydown paste', function ( e ) { + .on( 'focus drop keydown paste', function ( e ) { if ( $input.hasClass( 'placeholder' ) ) { if ( e.type === 'drop' && e.originalEvent.dataTransfer ) { // Support for drag&drop. Instead of inserting the dropped