Skip to content

Commit

Permalink
fixed jquery placeholder plugin bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AndorChen committed Feb 16, 2012
1 parent 75db656 commit 8337941
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
1 change: 0 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function vp_theme_setup() {
* @since 0.0.1
*/
function vp_enqueue_scripts(){
wp_enqueue_script( 'html5placeholder', get_bloginfo('template_url').'/js/jquery.html5.placeholder.js', array('jquery'), '1.0.1', true );
wp_enqueue_script( 'facebox', get_bloginfo( 'template_url' ) . '/js/facebox.js', array( 'jquery' ), '1.3', true );
wp_enqueue_script( 'global', get_bloginfo( 'template_url' ) . '/js/global.js', array( 'jquery' ), '0.0.1', true );

Expand Down
28 changes: 27 additions & 1 deletion js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,30 @@ HotKey.prototype.remove = function(key){
}else{
this._keyfunc[key] = function () {};
}
}
}

/* Enable placeholder attribute for all browsers */
jQuery(function(){
jQuery('[placeholder]').focus(function() {
var input = jQuery(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = jQuery(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur();

jQuery('[placeholder]').parents('form').submit(function() {
jQuery(this).find('[placeholder]').each(function() {
var input = jQuery(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
});
26 changes: 0 additions & 26 deletions js/jquery.html5.placeholder.js

This file was deleted.

2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ audio:not([controls]) { display: none; }
[hidden] { display: none; }
:-moz-placeholder { color: #ccc; }
::-webkit-input-placeholder { color: #ccc; }
.placeholder { color: #ccc; }
.placeholder { color: #ccc!important; }


/* =======
Expand Down

0 comments on commit 8337941

Please sign in to comment.