text: var InputfieldDebugMode=false;function consoleLog(a){if(InputfieldDebugMode){console.log(a)}}var InputfieldDependenciesProcessing=false;function InputfieldDependencies(d){if(InputfieldDependenciesProcessing){return}if(typeof d=="undefined"){var d=$(".InputfieldForm:not(.InputfieldFormNoDependencies)")}else{if(d.hasClass("InputfieldForm")){if(d.hasClass("InputfieldFormNoDependencies")){return}}else{if(d.closest(".InputfieldFormNoDependencies").length>0){return}}}function h(l){l=jQuery.trim(l);var m=l.substring(0,1);var k=l.substring(l.length-1,l.length);if((m=='"'||m=="'")&&m==k){l=l.substring(1,l.length-1)}return l}function i(k){return g(h(k))}function b(m){var l="";var k=m.indexOf(".");if(k>0){l=m.substring(k+1);m=m.substring(0,k)}return{field:m,subfield:l}}function g(n,l){n=jQuery.trim(n);if(n.length>0&&!jQuery.isNumeric(n)){return n}if(n.length==0){var k=typeof l;if(k!="undefined"){if(k=="integer"){return 0}if(k=="float"){return 0}return n}else{return n}}var o=n.indexOf(".");var m=n.lastIndexOf(".");if(o==-1&&/^-?\d+$/.test(n)){return parseInt(n)}if(m>-1&&o!=m){return n}if(/^-?[\d.]+$/.test(n)){return parseFloat(n)}return n}function c(n,l,m,o){var k=0;switch(l){case"=":if(m==o){k++}break;case"!=":if(m!=o){k++}break;case">":if(m>o){k++}break;case"<":if(m<o){k++}break;case">=":if(m>=o){k++}break;case"<=":if(m<=o){k++}break;case"*=":case"%=":if(m.indexOf(o)>-1){k++}break}consoleLog("Field "+n+" - Current value: "+m);consoleLog("Field "+n+" - Matched? "+(k>0?"YES":"NO"));return k}function e(p,s,m){var w=null;var z;consoleLog("getCheckboxFieldAndValue(see-next-line, "+s+", "+m+")");consoleLog(p);if(m=="count"||m=="count-checkbox"){consoleLog("Using count checkbox condition");w=$("#wrap_Inputfield_"+s+" :input");if(w.length){z=$("#wrap_Inputfield_"+s+" :checked").length;p.subfield="count-checkbox";return{field:w,value:z,condition:p}}return null}consoleLog("Using checkbox value or label comparison option");z=[];for(var q=0;q<p.values.length;q++){var t=new String(p.values[q]);var u=h(t.replace(/\s/g,"_"));consoleLog("conditionValue: "+u);var A="#Inputfield_"+s+"_"+u;w=$(A);var o=w.attr("type");if(w.length){consoleLog("Found "+o+" via value "+A);var n="";if(w.is(":checked")){n=w.val();consoleLog(o+" IS checked: "+A)}else{if(w.attr("type")=="radio"){consoleLog(o+" is NOT checked: "+A);var r=w.closest("form").find("input[name="+w.attr("name")+"]:checked");if(r.length){n=r.val();consoleLog("Checked value is: "+n)}}else{consoleLog(o+" is NOT checked: "+A)}}if(n.length){consoleLog("Pushing checked value: "+n);z.push(n)}continue}if(u.length==0||u.match(/^[0-9]+$/)){consoleLog("Unable to locate checkbox "+A+", skipping");continue}consoleLog("Attempting to find checkbox by label: "+u);w=$("#wrap_Inputfield_"+s);var k=w.find("input:checked");for(var y=0;y<k.length;y++){var l=k.eq(y);var v=l.closest("label");if(v.length){var x=jQuery.trim(v.text());if(x==t){consoleLog("Matching checked label found: "+t);z.push(x)}else{consoleLog("Matching checked label not found: "+t)}}}}if(w){return{field:w,value:z,condition:p}}return null}function f(p,y){InputfieldDependenciesProcessing=true;var C=y.attr("id").replace(/wrap_Inputfield_/,"");if(InputfieldDebugMode){consoleLog("-------------------------------------------------------------------");consoleLog('Field "'+C+'" detected a change to a dependency field! Beginning dependency checks...')}var o=0;var J=true;var w=0;var u=0;for(var I=0;I<p.length;I++){var E=p[I];if(InputfieldDebugMode){consoleLog("----");consoleLog("Start Dependency "+I);consoleLog("Condition type: "+E.type);consoleLog("Field: "+E.field);if(E.subfield.length>0){consoleLog("Subfield: "+E.subfield)}consoleLog("Operator: "+E.operator);consoleLog("Required value: "+E.value)}var s=0;for(var q=0;q<E.fields.length;q++){var F=b(E.fields[q]);var r=F.field;var k=F.subfield;var A=null;var B=$("#Inputfield_"+r);var l=false;if(B.length==0){B=$("#"+r)}if(B.length==0){consoleLog("Detected possible checkbox or radio: "+E.field+E.operator+E.value);var H=e(E,r,k);if(H){B=H.field;A=H.value;E=H.condition;l=true}}if(B.length==0){consoleLog("Unable to locate field: "+r);continue}if(A===null){if(B.attr("type")=="checkbox"){A=B.is(":checked")?B.val():null}else{A=B.val()}}var m=[];if(A==null){A=""}if(E.subfield=="count"){A=A.length}if(typeof A=="object"){m=jQuery.makeArray(A)}else{if(typeof A=="array"){m=A}else{m[0]=A}}var G=1;if(E.operator=="!="){G=(m.length*E.values.length)}if((B.attr("type")=="checkbox"||B.attr("type")=="radio")&&!B.is(":checked")){if($("#Inputfield_"+r+"_0").length==0){m[1]="0"}}for(var z=0;z<m.length;z++){for(var D=0;D<E.values.length;D++){var x=g(m[z],E.values[D]);s+=c(r,E.operator,x,E.values[D])}}if(s>=G){break}}consoleLog("----");if(E.type=="show"){if(s>=G){}else{J=false}}else{if(E.type=="required"){if(s>0){w++}else{u++}}}}var t=w>0&&u==0;if(J){consoleLog('Determined that field "'+C+'" should be visible.');if(y.is(".InputfieldStateHidden")){y.removeClass("InputfieldStateHidden").fadeIn();o++;consoleLog("Field is now visible.")}else{consoleLog("Field is already visible.")}}else{consoleLog('Determined that field "'+C+'" should be hidden.');if(!y.is(".InputfieldStateHidden")){y.addClass("InputfieldStateHidden").hide();consoleLog("Field is now hidden.");o++}else{consoleLog("Field is already hidden.")}if(t){consoleLog("Field is required but cancelling that since it is not visible.");t=false}}if(t&&w>0){consoleLog('Determined that field "'+C+'" should be required.');y.addClass("InputfieldStateRequired").find(":input:visible[type!=hidden]").addClass("required")}else{if(!t&&u>0){consoleLog('Determined that field "'+C+'" should not be required.');y.removeClass("InputfieldStateRequired").find(":input.required").removeClass("required")}}if(o>0){consoleLog(o+" visibility changes were made.");InputfieldColumnWidths();$(window).resize()}InputfieldDependenciesProcessing=false}function a(z,m,s){var A=s.attr("data-"+z+"-if");if(!A||A.length<1){return m}A=$("<div />").html(A).text();consoleLog("-------------------------------------------------------------------");consoleLog('Analyzing "'+z+'" selector: '+A);var v=A.match(/(^|,)([^,]+)/g);for(var w=0;w<v.length;w++){var y=v[w];var o=y.match(/^[,\s]*([_.|a-zA-Z0-9]+)(=|!=|<=|>=|<|>|%=)([^,]+),?$/);if(!o){continue}var k=o[1];var q=o[2];var x=o[3];var r="";var t=[];var l=[];if(k.indexOf("|")>-1){consoleLog("OR field dependency: "+k);t=k.split("|")}else{t=[k]}var D=b(k);k=D.field;r=D.subfield;if(InputfieldDebugMode){consoleLog("Field: "+k);if(r.length){consoleLog("Subfield: "+r)}consoleLog("Operator: "+q);consoleLog("value: "+x)}if(x.indexOf("|")>-1){consoleLog("OR value dependency: "+x);l=x.split("|");for(var B=0;B<l.length;B++){l[B]=i(l[B])}}else{l=[i([x])]}var C={type:z,field:k,fields:t,subfield:r,operator:q,value:x,values:l};m[m.length]=C;for(var p=0;p<t.length;p++){var D=b(t[p]);var E=D.field;var u=$("#Inputfield_"+E);if(u.length==0){consoleLog("Unable to find inputfield by: #Inputfield_"+E);u=$("#"+E);if(u.length==0){consoleLog("Unable to find inputfield by: #"+E)}}if(u.length==0){u=$("#wrap_Inputfield_"+E).find(":input");if(u.length==0){consoleLog("Unable to find inputfield by: #wrap_Inputfield_"+E+" :input")}}if(u.length){consoleLog("Attaching change event for: "+u.attr("name"));u.change(function(){f(m,s)})}else{consoleLog("Failed to find inputfield, no change event attached")}}}return m}function j(l){var k=[];k=a("show",k,l);k=a("required",k,l);f(k,l)}InputfieldDependenciesProcessing=true;d.each(function(){$(this).find(".InputfieldStateShowIf, .InputfieldStateRequiredIf").each(function(){j($(this))})});InputfieldDependenciesProcessing=false}function InputfieldColumnWidths(b){var f=true;if(typeof b=="undefined"){f=false;b=$("form.InputfieldForm")}var k=null;var l=null;function h(m){if(m.is(".InputfieldStateHidden")){return 0}var n=m.attr("style");if(typeof n=="undefined"||!n){return m.width()}var o=parseInt(n.match(/width:\s*(\d+)/i)[1]);if(!m.attr("data-original-width")){m.attr("data-original-width",o)}return o}function j(n){var m=parseInt(n.attr("data-original-width"));if(m==0){m=h(n)}return m}function e(n,o,m){n.width(o+"%");if(m){n.css("opacity",0.5);n.animate({opacity:1},150,function(){})}consoleLog("setWidth("+n.attr("id")+": "+o+"%")}function d(m){return m.height()}function g(m,p){var n=d(m);consoleLog("setHeight: "+m.find("label").text()+" >> "+p+" ("+n+")");if(n==p){return}if(m.hasClass("InputfieldStateCollapsed")){return}var q=p-n;if(q<0){q=0}var r=m.children(".InputfieldContent, .ui-widget-content");if(q==0){}else{consoleLog("Adjusting "+m.attr("id")+" from "+n+" to "+p);var o=$("<div class='maxColHeightSpacer'></div>");r.append(o);r.hide();o.height(q);r.show()}}function a(q){var u=q.nextUntil(".InputfieldColumnWidthFirst",".InputfieldColumnWidth:not(.InputfieldStateHidden)");var p=q.is(".InputfieldStateHidden")?0:h(q);var x=q.is(".InputfieldStateHidden")?null:q;var v=x==null?0:p;var w=u.length;if(q.is(".InputfieldStateHidden")){w--;var r=u.eq(0)}else{var r=q}if(l){r.find(".maxColHeightSpacer").remove();u.find(".maxColHeightSpacer").remove()}var n=100-(w*k);var m=l?d(r):0;u.removeClass("InputfieldColumnWidthFirstTmp");u.each(function(){x=$(this);v=h(x);p+=v;if(l){var y=d(x);if(y>m){m=y}}});if(l){if(InputfieldDebugMode){var s=r.find("label").text();consoleLog("maxColHeight: "+s+" = "+m)}if(m>0){g(r,m);u.each(function(){g($(this),m)})}}if(p<n){consoleLog("Expand width of row because rowWidth < maxRowWidth ("+p+" < "+n+")");var t=(n-p);consoleLog("leftoverWidth: "+t);v=v+t;if(x==null&&!q.is(".InputfieldStateHidden")){x=q}if(x){var o=j(x);if(o>0&&v<o){v=o}e(x,v,true)}}else{if(p>n){consoleLog("Reduce width of row because rowWidth > maxRowWidth ("+p+" > "+n+")");if(!q.is(".InputfieldStateHidden")){u=q.add(u)}p=0;u.each(function(){x=$(this);v=j(x);if(v>0){e(x,v,false)}p+=v});var t=n-p;v+=t;var o=j(x);if(o>0&&v<o){v=o}e(x,v,false)}}if(q.is(".InputfieldStateHidden")){r.addClass("InputfieldColumnWidthFirstTmp")}}b.each(function(){var n=$(this);if(!n.hasClass("InputfieldForm")){var m=n.closest(".InputfieldForm");if(m.length){n=m}}if(n.hasClass("InputfieldFormNoWidths")){return}k=n.attr("data-colspacing");if(typeof k=="undefined"){k=1}l=n.hasClass("InputfieldFormNoHeights")?false:true;$(".Inputfield:not(.InputfieldColumnWidth)",n).addClass("InputfieldColumnWidthFirst");$(".InputfieldColumnWidthFirst.InputfieldColumnWidth:visible",n).each(function(){a($(this))})});if(!$("body").hasClass("InputfieldColumnWidthsInit")){$("body").addClass("InputfieldColumnWidthsInit");var c=null;var i=function(){var n=$(this);var m=function(){var o=n.hasClass("InputfieldColumnWidth")?n:n.closest(".InputfieldColumnWidth");var p=o.hasClass("InputfieldColumnWidthFirst")?o:o.prev(".InputfieldColumnWidthFirst");if(p.length){a(p)}};if(n.is(":input")){if(c){clearTimeout(c)}c=setTimeout(m,1000)}else{m()}};$(document).on("change",".InputfieldColumnWidth :input",i);$(document).on("AjaxUploadDone",".InputfieldFileList",i);$(document).on("heightChanged",".InputfieldColumnWidth",i)}}function InputfieldFormBeforeUnloadEvent(b){var a=$(".InputfieldFormConfirm:not(.InputfieldFormSubmitted) .InputfieldStateChanged");if(a.length==0){return}var c=$(".InputfieldFormConfirm:eq(0)").attr("data-confirm")+"\n";a.each(function(){var d=$(this).find(".InputfieldHeader:eq(0)");if(d.length){name=d.text()}else{name=$(this).attr("data-label");if(!name||!name.length){name=$(this).find(":input").attr("name")}}if(name.length){c+="\n• "+$.trim(name)}});(b||window.event).returnValue=c;return c}function InputfieldStates(a){var e=true;if(typeof a=="undefined"){a=$("body");e=false}function c(l){function j(n,s){var p=$("<i class='fa fa-spin fa-spinner'></i>");var r=n.offset();var m;var o=10;var q=0;$("body").append(p.hide());p.css({position:"absolute",top:r.top-(p.height()+5),left:r.left+(n.width()/2)+(p.width()*0.8)}).fadeIn();m=setInterval(function(){if(++q>o||!s.hasClass("InputfieldAjaxLoading")){clearInterval(m);p.fadeOut("normal",function(){p.remove()})}},500)}var k=l.children(".InputfieldContent").children(".renderInputfieldAjax");var f=false;if(!k.length){k=l.children(".renderInputfieldAjax");f=true}var i=k.children("input").attr("value");if(typeof i=="undefined"||i.length<1){return false}var h=null;if(f){var g=$("#_"+l.attr("id"));j(g,l)}else{var g=l.children(".InputfieldHeader");h=$("<i class='fa fa-spin fa-spinner'></i>");h.css("margin-left","0.5em");g.append(h)}l.removeClass("collapsed10 collapsed11").addClass("InputfieldAjaxLoading");$.get(i,function(n){l.removeClass("InputfieldAjaxLoading InputfieldStateCollapsed");k.replaceWith($(n)).hide();k.slideDown();var m=l.find(".Inputfield");if(m.length){m.trigger("reloaded",["InputfieldAjaxLoad"]);InputfieldStates(l);InputfieldColumnWidths()}else{l.trigger("reloaded",["InputfieldAjaxLoad"])}if(l.closest(".InputfieldFormNoDependencies").length==0){InputfieldDependencies(l.parent())}setTimeout(function(){if(h){h.fadeOut("fast",function(){h.remove()})}if(f){g.effect("highlight",500)}else{g.click()}},500)},"html");return true}$(".Inputfield:not(.collapsed9) > .InputfieldHeader, .Inputfield:not(.collapsed9) > .ui-widget-header",a).addClass("InputfieldStateToggle");var b=$(".Inputfields .InputfieldStateCollapsed > .InputfieldHeader i.toggle-icon, .Inputfields .InputfieldStateCollapsed > .ui-widget-header i.toggle-icon",a);b.toggleClass(b.attr("data-to"));if(typeof ProcessWire!="undefined"){var d=ProcessWire.config}if(typeof d!=="undefined"&&d.debug){$("label.InputfieldHeader > i.toggle-icon",a).hover(function(){var f=$(this).parent("label");if(f.length==0){return}var h=f.attr("for").replace(/^Inputfield_/,"");if(h.length){var g=$("<small class='InputfieldNameTip ui-priority-secondary'>&nbsp;"+h+"&nbsp;</small>");g.css("float","right");f.append(g)}},function(){var f=$(this).parent("label");if(f.length==0){return}f.find(".InputfieldNameTip").remove()})}if(e){return}$(document).on("wiretabclick",function(h,g,f){if(g.hasClass("collapsed10")){c(g)}});$(document).on("click",".InputfieldStateToggle, .toggle-icon",function(){var m=$(this);var l=m.closest(".Inputfield");var k=m.hasClass("toggle-icon");var h=k?m:l.children(".InputfieldHeader, .ui-widget-header").find(".toggle-icon");var i=l.hasClass("InputfieldStateCollapsed");var j=l.hasClass("InputfieldStateWasCollapsed");if(l.hasClass("InputfieldAjaxLoading")){return false}if(i&&(l.hasClass("collapsed10")||l.hasClass("collapsed11"))){if(c(l)){return false}}if(i||j||k){l.addClass("InputfieldStateWasCollapsed");l.trigger(i?"openReady":"closeReady");l.toggleClass("InputfieldStateCollapsed",100,function(){if(i){l.trigger("opened");if(l.hasClass("InputfieldColumnWidth")){l.children(".InputfieldContent").show()}if(l.hasClass("InputfieldNoFocus")){return}var o=l.find(":input:visible");if(o.length==1&&!o.is("button")){var n=o.attr("type");if(o.is("textarea")||n=="text"||n=="email"||n=="url"||n=="number"){o.focus()}}}else{l.trigger("closed");if(l.hasClass("InputfieldColumnWidth")){l.children(".InputfieldContent").hide()}}});h.toggleClass(h.attr("data-to"));setTimeout("InputfieldColumnWidths()",500)}else{if(typeof jQuery.ui!="undefined"){var g=h.css("color");var f=l.children(".InputfieldHeader, .ui-widget-header").css("color");h.css("color",f);h.effect("pulsate",300,function(){h.css("color",g)})}if(!l.hasClass("InputfieldNoFocus")){l.find(":input:visible:eq(0)").focus()}}return false});$("#content .InputfieldFormFocusFirst:not(.InputfieldFormNoFocus)").find("input[type=text]:enabled:first:not(.hasDatepicker):not(.InputfieldNoFocus)").each(function(){var f=$(this);if(f.val()){return}if(f.offset().top<$(window).height()){window.setTimeout(function(){if(f.is(":visible")){f.focus()}},250)}});$(document).on("change",".InputfieldFormConfirm :input, .InputfieldFormConfirm .Inputfield",function(){var f=$(this);if(f.hasClass("Inputfield")){if(!f.hasClass("InputfieldIgnoreChanges")){f.addClass("InputfieldStateChanged")}return false}else{if(f.hasClass("InputfieldIgnoreChanges")||f.closest(".InputfieldIgnoreChanges").length){return false}f.closest(".Inputfield").addClass("InputfieldStateChanged")}});$(document).on("submit",".InputfieldFormConfirm",function(){$(this).addClass("InputfieldFormSubmitted")});window.addEventListener("beforeunload",InputfieldFormBeforeUnloadEvent)}function InputfieldIntentions(){$(".InputfieldForm").each(function(){var a=$(this);var b=null;var c=null;a.submit(function(){if(!$(this).hasClass("nosubmit")){return}if(!c){return}var e=null;var d=c.closest(".Inputfields");do{e=d.find("input[type=submit]:visible, button[type=submit]:visible");if(e.length>0){break}d=d.parent().closest(".Inputfields")}while(d.length>0);if(e.length>0){var f=e.eq(0);$("html, body").animate({scrollTop:f.offset().top},"fast");f.focus()}return false}).on("focus","input, select",function(){if(b===null){b=a.find("input[type=submit], button[type=submit]").length}if(b<2){return}a.addClass("nosubmit");c=$(this)}).on("blur","input, select",function(){a.removeClass("nosubmit")})})}var InputfieldWindowResizeQueued=false;function InputfieldWindowResizeActions1(){consoleLog("InputfieldWindowResizeActions1()");$(".Inputfield").trigger("resized")}function InputfieldWindowResizeActions2(){consoleLog("InputfieldWindowResizeActions2()");InputfieldColumnWidths();InputfieldWindowResizeQueued=false}function InputfieldsInit(a){InputfieldStates(a);InputfieldDependencies(a);setTimeout(function(){InputfieldColumnWidths()},100)}jQuery(document).ready(function(b){InputfieldStates();InputfieldDependencies(b(".InputfieldForm:not(.InputfieldFormNoDependencies)"));InputfieldIntentions();setTimeout(function(){InputfieldColumnWidths()},100);var c=function(){if(InputfieldWindowResizeQueued){return}InputfieldWindowResizeQueued=true;setTimeout("InputfieldWindowResizeActions1()",1000);setTimeout("InputfieldWindowResizeActions2()",2000)};var a=function(){if(InputfieldWindowResizeQueued){return}InputfieldWindowResizeQueued=true;setTimeout("InputfieldWindowResizeActions1()",250);setTimeout("InputfieldWindowResizeActions2()",500);return true};b(window).resize(c);b("ul.WireTabs > li > a").click(a);b(document).on("reload",".Inputfield",function(h,g){var j=b(this);var e=j.closest("form");var i=j.attr("id").replace("wrap_Inputfield_","");var f=e.attr("action");if(i.indexOf("_repeater")>0){var d=j.closest(".InputfieldRepeaterItem").attr("data-page");f=f.replace(/\?id=\d+/,"?id="+d);i=i.replace(/_repeater\d+$/,"")}f+=f.indexOf("?")>-1?"&":"?";f+="field="+i+"&reloadInputfieldAjax="+i;if(typeof g!="undefined"){if(typeof g.queryString!="undefined"){f+="&"+g.queryString}}consoleLog("Inputfield reload: "+i);b.get(f,function(l){var m=j.attr("id");var k=b(l).find("#"+m).children(".InputfieldContent");if(!k.length&&m.indexOf("_repeater")>-1){m="wrap_Inputfield_"+i;k=b(l).find("#"+m).children(".InputfieldContent");if(!k.length){console.log("Unable to find #"+j.attr("id")+" in response from "+f)}}j.children(".InputfieldContent").html(k.html());if(typeof jQuery.ui!="undefined"){j.effect("highlight",1000)}j.trigger("reloaded",["reload"])});h.stopPropagation()})});