Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions gf.placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ var gf_placeholder = function() {
});

var support = (!('placeholder' in document.createElement('input'))); // borrowed from Modernizr.com
if ( support && jquery_placeholder_url )
var placeholders = $('.gform_fields li.gplaceholder').length;

if ( placeholders != 0 && support && jquery_placeholder_url ) {
$.ajax({
cache: true,
dataType: 'script',
Expand All @@ -40,11 +42,12 @@ var gf_placeholder = function() {
},
type: 'get'
});
}
};

$(document).ready(function(){
gf_placeholder();
$(document).bind('gform_page_loaded', gf_placeholder);
$(document).bind('gform_post_render', gf_placeholder);
});

})(jQuery);
})(jQuery);
21 changes: 14 additions & 7 deletions gravityforms-placeholders.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Gravity Forms - Placeholders add-on
Plugin URI: http://github.com/neojp/gravity-forms-placeholders/
Description: Adds HTML5 placeholder support to Gravity Forms' fields with a javascript fallback. Javascript & jQuery are required.
Version: 1.2.1
Version: 1.2.3
Author: Joan Piedra
Author URI: http://joanpiedra.com

Expand All @@ -13,12 +13,19 @@
*/

if ( isset( $GLOBALS['pagenow'] ) && $GLOBALS['pagenow'] == 'wp-login.php' )
return;
return;

// look into using wp_localize_script instead
function gf_placeholder_print_scripts() {
$plugin_dir = plugin_dir_url( __FILE__ );
echo "<script>var jquery_placeholder_url = '" . $plugin_dir . "jquery.placeholder-1.0.1.js';</script>";
}

add_action( 'wp_print_scripts', 'gf_placeholder_print_scripts' );

add_action('wp_print_scripts', 'gf_placeholder_enqueue_scripts');

function gf_placeholder_enqueue_scripts() {
$plugin_url = plugins_url( basename(dirname(__FILE__)) );
echo "<script>var jquery_placeholder_url = '" . $plugin_url . "/jquery.placeholder-1.0.1.js';</script>";
wp_enqueue_script('_gf_placeholders', $plugin_url . '/gf.placeholders.js', array('jquery'), '1.0' );
}
wp_enqueue_script( 'gf_placeholders', plugins_url( 'gf.placeholders.js', __FILE__ ), array( 'jquery' ), '1.0.1', true );
}

add_action( 'wp_enqueue_scripts', 'gf_placeholder_enqueue_scripts' );