$.fbuilder[ 'controls' ] = ( typeof $.fbuilder[ 'controls' ] != 'undefined' ) ? $.fbuilder[ 'controls' ]: {}; $.fbuilder[ 'forms' ] = ( typeof $.fbuilder[ 'forms' ] != 'undefined' ) ? $.fbuilder[ 'forms' ]: {}; $.fbuilder[ 'htmlEncode' ] = function(value) { value = $('
').text(value).html() value = value.replace( /&/g, '&').replace(/"/g, """); return value; }; $.fbuilder['htmlDecode']=function(value) { if(/&(?:#x[a-f0-9]+|#[0-9]+|[a-z0-9]+);?/ig.test(value))value=$('
').html(value).text();return value; }; $.fbuilder[ 'escape_symbol' ] = function( value ) // Escape the symbols used in regulars expressions { return value.replace(/([\^\$\-\.\,\[\]\(\)\/\\\*\?\+\!\{\}])/g, "\\$1"); }; $.fbuilder[ 'parseValStr' ] = function( value ) { return '"' + value.replace(/'/g, "\\'").replace( /\$/g, '') + '"'; }; $.fbuilder[ 'parseVal' ] = function( value, thousandSeparator, decimalSymbol ) { if( value == '' ) return 0; value += ''; thousandSeparator = new RegExp( $.fbuilder.escape_symbol( ( typeof thousandSeparator == 'undefined' ) ? ',' : thousandSeparator ), 'g' ); decimalSymbol = new RegExp( $.fbuilder.escape_symbol( ( typeof decimalSymbol == 'undefined' ) ? '.' : decimalSymbol ), 'g' ); var t = value.replace( thousandSeparator, '' ).replace( decimalSymbol, '.' ).replace( /\s/g, '' ), p = /[+-]?((\d+(\.\d+)?)|(\.\d+))/.exec( t ); return ( p ) ? p[0]*1 : $.fbuilder[ 'parseValStr' ]( value ); }; $.fn.fbuilder = function(options){ var opt = $.extend({}, { pub:false, identifier:"", title:"" },options, true); opt.messages = $.extend({ previous: "Previous", next: "Next", pageof: "Page {0} of {0}", required: "This field is required.", email: "Please enter a valid email address.", datemmddyyyy: "Please enter a valid date with this format(mm/dd/yyyy)", dateddmmyyyy: "Please enter a valid date with this format(dd/mm/yyyy)", number: "Please enter a valid number.", digits: "Please enter only digits.", maxlength: $.validator.format("Please enter no more than {0} characters"), minlength: $.validator.format("Please enter at least {0} characters."), equalTo: "Please enter the same value again.", max: $.validator.format("Please enter a value less than or equal to {0}."), min: $.validator.format("Please enter a value greater than or equal to {0}.") },opt.messages); opt.messages.max = $.validator.format(opt.messages.max); opt.messages.min = $.validator.format(opt.messages.min); $.extend($.validator.messages, opt.messages); var items = []; var reloadItemsPublic = function() { $("#fieldlist"+opt.identifier).closest( 'form' ).addClass( theForm.formtemplate ); $("#fieldlist"+opt.identifier).html("").addClass(theForm.formlayout); $("#formheader"+opt.identifier).html(theForm.show()); var page = 0; $("#fieldlist"+opt.identifier).append('
'); for (var i=0;i
'); } else { $("#fieldlist"+opt.identifier+" .pb"+page).append(items[i].show()); if (items[i].predefinedClick) { $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).attr("placeholder",items[i].predefined); $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).attr("value",""); } if (items[i].userhelpTooltip) { var uh = $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).closest(".fields"); uh.find(".uh").css("display","none"); if (uh.find(".uh").text()!="") { uh.attr("uh",uh.find(".uh").text()); } } } } if (page>0) { $("#fieldlist"+opt.identifier+" .pb"+page).addClass("pbEnd"); $("#fieldlist"+opt.identifier+" .pbreak").each(function(index) { var code = $(this).html(); var bSubmit = ''; if (index == page) { if ( $( "#cpcaptchalayer"+opt.identifier ).length && !/^\s*$/.test( $( "#cpcaptchalayer"+opt.identifier ).html() ) ) { code += '
'+$("#cpcaptchalayer"+opt.identifier).html()+'
'; $("#cpcaptchalayer"+opt.identifier).html(""); } if ($("#cp_subbtn"+opt.identifier).html()) { bSubmit = '
'+$("#cp_subbtn"+opt.identifier).html()+'
'; } } $(this).html('
'+opt.messages.pageof.replace( /\{\s*\d+\s*\}/, (index+1) ).replace( /\{\s*\d+\s*\}/, (page+1) )+''+code+'
'+opt.messages.previous+'
'+opt.messages.next+'
'+bSubmit+'
'); }); $( '#fieldlist'+opt.identifier).find(".pbPrevious,.pbNext").bind("click", { 'identifier' : opt.identifier }, function( evt ) { var identifier = evt.data.identifier; if ( ($(this).hasClass("pbPrevious")) || (($(this).hasClass("pbNext")) && $(this).parents("form").valid()) ) { var page = parseInt($(this).parents(".pbreak").attr("page")); (($(this).hasClass("pbPrevious"))?page--:page++); $("#fieldlist"+identifier+" .pbreak").css("display","none"); $("#fieldlist"+identifier+" .pbreak").find(".field").addClass("ignorepb"); $("#fieldlist"+identifier+" .pb"+page).css("display","block"); $("#fieldlist"+identifier+" .pb"+page).find(".field").removeClass("ignorepb"); if ($("#fieldlist"+identifier+" .pb"+page).find(".field").length>0) { try { $("#fieldlist"+identifier+" .pb"+page).find(".field")[0].focus(); } catch(e){} } } else { $(this).parents("form").validate().focusInvalid(); } return false; }); } else { if ( $( "#cpcaptchalayer"+opt.identifier ).length && !/^\s*$/.test( $( "#cpcaptchalayer"+opt.identifier ).html() ) ) { $("#fieldlist"+opt.identifier+" .pb"+page).append('
'+$("#cpcaptchalayer"+opt.identifier).html()+'
'); $("#cpcaptchalayer"+opt.identifier).html(""); } if ($("#cp_subbtn"+opt.identifier).html()) { $("#fieldlist"+opt.identifier+" .pb"+page).append('
'+$("#cp_subbtn"+opt.identifier).html()+'
'); } } // Set Captcha Event $( document ).on( 'click', '#fbuilder .captcha img', function(){ var e = $( this ); e.attr( 'src', e.attr( 'src' ).replace( /&\d+$/, '' ) + '&' + Math.floor( Math.random()*1000 ) ); } ); $( '#fieldlist'+opt.identifier).find(".pbSubmit").bind("click", { 'identifier' : opt.identifier }, function( evt ) { $(this).closest("form").submit(); }); if (i>0) { theForm.after_show( opt.identifier ); for (var i=0;i'+(this.title!=''?'

'+this.title+'

':'')+(this.description!=''?''+this.description+'':'')+'
'; }, after_show:function( id ){ $( '#cp_calculatedfieldsf_pform'+id ).attr( 'data-evalequations', this.evalequations ).attr( 'autocomplete', ( ( this.autocomplete ) ? 'on' : 'off' ) ); } }); //var theForm = new fform(), var theForm, ffunct = { getItem: function( name ) { for( var i in items ) { if( items[ i ].name == name ) { return items[ i ]; } } return false; }, getItems: function() { return items; }, loadData:function(f) { var d, e = $("#"+f); this.formId = e.parents( 'form' ).attr( 'id' ); if ( d = $.parseJSON( e.val() )) { if (d.length==2) { items = []; for (var i=0;i