// TODO: Fix error collecting.
//window.onerror = function(message, url, lineNumber) {
// 'action': 'nf_log_js_error',
// 'security': nfFrontEnd.ajaxNonce,
// 'lineNumber': lineNumber
// url: nfFrontEnd.adminAjax,
// success: function( data, textStatus, jqXHR ) {
// console.log( 'Parse Error' );
// error: function( jqXHR, textStatus, errorThrown ) {
// console.log('ERRORS: ' + errorThrown);
// console.log( 'Parse Error' );
var nfRadio = Backbone.Radio;
nfRadio.channel( 'form' ).on( 'render:view', function() {
jQuery( '.g-recaptcha' ).each( function() {
var callback = jQuery( this ).data( 'callback' );
var fieldID = jQuery( this ).data( 'fieldid' );
if ( typeof window[ callback ] !== 'function' ){
window[ callback ] = function( response ) {
nfRadio.channel( 'recaptcha' ).request( 'update:response', response, fieldID );
var nfRecaptcha = Marionette.Object.extend( {
* If we've already rendered our form view, render our recaptcha fields.
if ( 0 != jQuery( '.g-recaptcha' ).length ) {
* We haven't rendered our form view, so hook into the view render radio message, and then render.
this.listenTo( nfRadio.channel( 'form' ), 'render:view', this.renderCaptcha );
this.listenTo( nfRadio.channel( 'captcha' ), 'reset', this.renderCaptcha );
renderCaptcha: function() {
jQuery( '.g-recaptcha' ).each( function() {
fieldid: jQuery( this ).data( 'fieldid' ),
size: jQuery( this ).data( 'size' ),
theme: jQuery( this ).data( 'theme' ),
sitekey: jQuery( this ).data( 'sitekey' ),
callback: jQuery( this ).data( 'callback' )
var grecaptchaID = grecaptcha.render( jQuery( this )[0], opts );
if ( opts.size === 'invisible' ) {
grecaptcha.execute( grecaptchaID );
console.log( 'Notice: Error trying to execute grecaptcha.' );
var nfRenderRecaptcha = function() {