dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jquery.placeholder: Take placeholder text as parameter
[lhc/web/wiklou.git]
/
resources
/
jquery
/
jquery.placeholder.js
diff --git
a/resources/jquery/jquery.placeholder.js
b/resources/jquery/jquery.placeholder.js
index
7badb11
..
73f701b
100644
(file)
--- a/
resources/jquery/jquery.placeholder.js
+++ b/
resources/jquery/jquery.placeholder.js
@@
-10,17
+10,23
@@
*/
( function ( $ ) {
*/
( 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;
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 the HTML5 placeholder attribute is supported, use it
if ( this.placeholder && 'placeholder' in document.createElement( this.tagName ) ) {
+ if ( textIsValid ) {
+ this.setAttribute( 'placeholder', text );
+ }
return;
}
return;
}
- placeholder = this.getAttribute( 'placeholder' );
+ placeholder = t
extIsValid ? text : t
his.getAttribute( 'placeholder' );
$input = $(this);
// Show initially, if empty
$input = $(this);
// Show initially, if empty