forked from neojp/gravity-forms-placeholders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gf.placeholders.js.php
executable file
·45 lines (34 loc) · 1.23 KB
/
gf.placeholders.js.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require("../../../wp-load.php");
header("Content-type: text/javascript");
?>
(function($, document, body){
var gf_placeholder = function() {
$('.gform_wrapper')
.find('.gplaceholder')
.find('input[type=text], input[type=password], textarea')
.each(function(){
var $field = $(this);
var id = $field.attr('id');
var $label = $('label[for=' + id + ']');
var label = $label.last().text();
if (!$label.parents('.gfield_radio').length && !$label.parents('.gfield_checkbox').length)
$label.hide();
if (label.length > 0 && label[ label.length-1 ] == '*') {
label = label.substring(0, label.length-1) + ' *';
}
$field.attr('placeholder', label);
});
var support = (Modernizr && !Modernizr.input.placeholder) || !( !!('placeholder' in document.createElement('input')) ); // borrowed from Modernizr.com
if ( support )
$.getScript('<?php echo plugins_url('/jquery.placeholder-1.0.1.js', __FILE__); ?>', function(){
$('input[placeholder], textarea[placeholder]').placeholder({
blankSubmit: true
});
});
};
$(document).ready(function(){
gf_placeholder();
$(document).bind('gform_page_loaded', gf_placeholder);
});
})(jQuery, document, document.body);