"use strict";jQuery.fn.getAttributes=function(){var a={};if(!this.length){return this}jQuery.each(this[0].attributes,function(c,b){a[b.name]=b.value});return a};jQuery.fn.getDatas=function(){var a={},b="data-vp-";if(!this.length){return this}jQuery.each(this[0].attributes,function(d,c){if(c.name.substring(0,b.length)==b){a[c.name.substring(b.length)]=c.value}});return a};jQuery.fn.exists=function(){return this.length!==0};if(!String.prototype.trimChar){String.prototype.trimChar=function(a){return this.replace(new RegExp("^"+a+"+|"+a+"+$","g"),"")}}if(!String.prototype.format){String.prototype.format=function(){var a=arguments;return this.replace(/{(\d+)}/g,function(b,c){return typeof a[c]!="undefined"?a[c]:b})}}if(!String.prototype.replaceAll){String.prototype.replaceAll=function(c,d,a){var e,b=-1,f;if((e=this.toString())&&typeof c==="string"){f=a===true?c.toLowerCase():undefined;while((b=(f!==undefined?e.toLowerCase().indexOf(f,b>=0?b+d.length:0):e.indexOf(c,b>=0?b+d.length:0)))!==-1){e=e.substring(0,b).concat(d).concat(e.substring(b+c.length))}}return e}}jQuery.fn.validationVal=function(){var d=this,e="",a=d.prop("tagName"),b;if((d.length>1&&d.attr("type")!="radio")||d.attr("multiple")){e=[]}var c=e;d.each(function(f){var g=jQuery(this);switch(a){case"SELECT":if(g.has("[multiple]")){e=g.val()}else{e=g.val()}break;case"INPUT":switch(d.attr("type")){case"text":e=g.val();break;case"radio":b=g.prop("checked");if(typeof b!=="undefined"&&b!==false){e=g.val()}break;case"checkbox":b=g.prop("checked");if(d.length>1){if(typeof b!=="undefined"&&b!==false){e.push(g.val())}}else{e=null;if(typeof b!=="undefined"&&b!==false){e=g.val()}}break}break;case"TEXTAREA":e=g.val();break;default:e=g.val();break}});if(e===null){e=c}return e};jQuery.fn.vp_slideUp=function(b){var a=this;a.each(function(d){var c=jQuery(this);if(!c.hasClass("vp-hide")){c.slideUp("fast",function(){jQuery(this).addClass("vp-hide").slideDown(0,b)})}})};jQuery.fn.vp_slideDown=function(b){var a=this;a.each(function(d){var c=jQuery(this);if(c.hasClass("vp-hide")){c.slideUp(0,function(){jQuery(this).removeClass("vp-hide").slideDown("fast",b)})}})};jQuery.fn.vp_fadeOut=function(b){var a=this;if(!a.hasClass("vp-hide")){a.fadeOut("fast",function(){jQuery(this).addClass("vp-hide").fadeIn(0,b)})}};jQuery.fn.vp_fadeIn=function(b){var a=this;if(a.hasClass("vp-hide")){a.fadeOut(0,function(){jQuery(this).removeClass("vp-hide").fadeIn("fast",b)})}};jQuery.fn.vp_toggle=function(b){var a=this;if(a.hasClass("vp-hide")){a.slideUp(0,function(){jQuery(this).removeClass("vp-hide").slideDown("fast",b)})}else{a.slideUp("fast",function(){jQuery(this).addClass("vp-hide").slideDown(0,b)})}};var vp={};vp.isNumber=function(a){return !isNaN(parseFloat(a))&&isFinite(a)};vp.parseOpt=function(b){var d,c,a,g,f={};for(var e=0;e=c)?true:false};vp.validateRequired=function(a,b){if(jQuery.isArray(b)&&jQuery.isEmptyObject(b)){return false}return(b)?true:false};vp.fields_validation_loop=function(o){var t='
  • ',f=0;for(var s=0;s=0)?d.substring(0,g):d,v="",p;switch(k){case"alphabet":if(!vp.validateAlphabet(c,w)){v=vp_wp.val_msg.alphabet.format()}break;case"alphanumeric":if(!vp.validateAlphaNumeric(c,w)){v=vp_wp.val_msg.alphanumeric.format()}break;case"numeric":if(!vp.validateNumeric(c,w)){v=vp_wp.val_msg.numeric.format()}break;case"email":if(!vp.validateEmail(c,w)){v=vp_wp.val_msg.email.format()}break;case"url":if(!vp.validateURL(c,w)){v=vp_wp.val_msg.url.format()}break;case"maxlength":p=d.substring(g+1,e);if(!vp.validateMaxLength(c,w,p)){v=vp_wp.val_msg.maxlength.format(p)}break;case"minlength":p=d.substring(g+1,e);if(!vp.validateMinLength(c,w,p)){v=vp_wp.val_msg.minlength.format(p)}break;case"maxselected":p=d.substring(g+1,e);if(!vp.validateMaxLength(c,w,p)){v=vp_wp.val_msg.maxselected.format(p)}break;case"minselected":p=d.substring(g+1,e);if(!vp.validateMinLength(c,w,p)){v=vp_wp.val_msg.minselected.format(p)}break;case"required":if(!vp.validateRequired(c,w)){v=vp_wp.val_msg.required.format()}break}if(v!==""){a.nError+=1;var m=jQuery(t);m.html(v);m.appendTo(q)}}if(a.nError>0){f+=1;u.addClass("vp-error")}}return f};vp.custom_check_radio_event=function(b,a){jQuery(b).delegate(a,"click",function(f){f.preventDefault();var d=jQuery(this).find("input"),c=d.attr("type");if(c=="radio"){jQuery(this).parent().parent().find("input").each(function(e){jQuery(this).removeClass("checked");d.prop("checked",false)});d.prop("checked",true).change()}else{if(c=="checkbox"){if(d.is(":checked")){d.prop("checked",false)}else{d.prop("checked",true)}d.trigger("change")}}});jQuery(b).delegate(a,"change",function(d){d.preventDefault();var c=jQuery(this).find("input");if(c.is(":checked")){c.addClass("checked")}else{c.removeClass("checked")}})};vp.binding_action=function(a,k,c,m){var d=jQuery(vp.jqid(k.source)),h=jQuery('[name="'+k.source+'"]'),l=[];for(var g=0;g"));i.data!==null&&jQuery.each(i.data,function(n,o){m.append(jQuery("").attr("value",o.value).text(o.label))});break;case"vp-checkbox":m=h;m.empty();m=jQuery(vp.jqid(j.source)).find(".input");i.data!==null&&jQuery.each(i.data,function(n,o){m.append(jQuery('"))});break;case"vp-checkimage":m=h;m.empty();m=jQuery(vp.jqid(j.source)).find(".input");i.data!==null&&jQuery.each(i.data,function(n,o){m.append(jQuery(''))});vp.init_tipsy();break;case"vp-radiobutton":m=h;m.empty();m=jQuery(vp.jqid(j.source)).find(".input");i.data!==null&&jQuery.each(i.data,function(n,o){m.append(jQuery('"))});break;case"vp-radioimage":m=h;m.empty();m=jQuery(vp.jqid(j.source)).find(".input");i.data!==null&&jQuery.each(i.data,function(n,o){m.append(jQuery(''))});vp.init_tipsy();break}jQuery('[name="'+j.source+'"]:first').change().blur()}},"JSON")};vp.items_binding_event=function(a,h,f,c,g,j){var e=["vp-select","vp-checkbox","vp-checkimage","vp-radiobutton","vp-radioimage","vp-multiselect","vp-toggle","vp-upload"],i=["vp-textbox","vp-slider","vp-color","vp-date"],b=vp.thejqname(a[h],j),d=jQuery(vp.thejqid(a[h],j)).attr("data-vp-type");if(jQuery.inArray(d,e)!==-1){jQuery(g).delegate(b,"change",function(){vp.items_binding_action(a,f,c,j)})}else{if(jQuery.inArray(d,i)!==-1){jQuery(b).typing({stop:function(l,k){vp.items_binding_action(a,f,c,j)},delay:400})}else{jQuery(g).delegate(b,"change",function(){vp.binding_action(a,f,c,j)})}}};vp.dependency_action=function(a,h,b){var c=jQuery(vp.jqid(h.source)),g=jQuery('[name="'+h.source+'"]'),j=[],f=[];for(var e=0;ea.max){c.val(a.max);e.slider("value",a.max)}else{if(d=48&&f<=57)){return true}return false}).blur(function(f){theValidate(this,b,e);e.prev(".slideinput").keypress().keyup()})})}};vp.upload_callback=function(){};if(vp_wp.use_new_media_upload){var _orig_send_attachment=wp.media.editor.send.attachment,_orig_send_link=wp.media.editor.send.link,_orig_send_to_editor=window.send_to_editor;vp.upload_callback=function(c){var b=jQuery(this),d=b.parent(".buttons").prev("input"),a=b.parent(".buttons").siblings(".image").find("img");wp.media.editor.send.attachment=function(e,f){d.val(f.url);d.trigger("change");if(f.type==="image"){a.attr("src",f.url)}else{a.attr("src",f.icon)}wp.media.editor.send.attachment=_orig_send_attachment;window.send_to_editor=_orig_send_to_editor};window.send_to_editor=function(e){if(e!==""){var f=get_url_info(e);d.val(f.imgurl);d.trigger("change");a.attr("src",f.iconurl)}window.send_to_editor=_orig_send_to_editor;wp.media.editor.send.attachment=_orig_send_attachment};wp.media.editor.open(b);return false}}else{var _orig_send_to_editor=window.send_to_editor;vp.upload_callback=function(c){var a=true,d=jQuery(this).parent(".buttons").prev("input"),b=jQuery(this).parent(".buttons").siblings(".image").find("img");tb_show("Upload Image","media-upload.php?&post_id=0&referer=vafpress&TB_iframe=true");window.send_to_editor=function(e){if(e!==""){var f=get_url_info(e);d.val(f.imgurl);d.trigger("change");b.attr("src",f.iconurl)}window.send_to_editor=_orig_send_to_editor;tb_remove()};return false}}function get_url_info(c){var e,d,a,f,b=jQuery(c);if(b.prop("tagName")=="A"){a=jQuery(c).attr("href");e=vp.get_url_extension(a);d=vp.wp_ext2type(e);f=a;if(d!=="image"){f=vp_wp.wp_include_url+"images/crystal/"+d+".png"}}else{if(b.prop("tagName")=="IMG"){a=jQuery(c).attr("src");f=a}}return{imgurl:a,iconurl:f}}vp.remove_upload_callback=function(c){var b=jQuery(this),d=b.parent(".buttons").prev("input"),a=b.parent(".buttons").siblings(".image").find("img");d.val("");a.attr("src","")};jQuery(document).on("click",".vp-js-upload",vp.upload_callback);jQuery(document).on("click",".vp-js-remove-upload",vp.remove_upload_callback);vp.init_colorpicker=function(a){if(jQuery.fn.colorpicker){if(a.length<=0){return}a.each(function(){var c=jQuery(this),b=jQuery(this).getDatas();b=vp.parseOpt(b.opt);c.colorpicker({format:b.format}).on("changeColor",function(e){var d;if(b.format=="hex"){d=e.color.toHex()}else{if(b.format=="rgba"){d=e.color.toRGB();d="rgba("+d.r+","+d.g+","+d.b+","+d.a+")"}else{if(b.format=="rgb"){d=e.color.toRGB();d="rgb("+d.r+","+d.g+","+d.b+")"}}}c.prev("label").find("span").css("background-color",d)}).on("blur",function(d){c.prev("label").find("span").css("background-color",c.val());c.keypress().keyup()})})}};vp.init_datepicker=function(a){if(jQuery.fn.datepicker){if(a.length<=0){return}a.each(function(){var b=jQuery(this).getDatas();b=vp.parseOpt(b.opt);b.onSelect=function(){jQuery(this).trigger("keypress");jQuery(this).trigger("keyup");jQuery(this).trigger("blur")};jQuery(this).datepicker(b);jQuery(this).datepicker("setDate",b.value)})}};vp.init_controls=function(a){vp.init_datepicker(a.find(".vp-js-datepicker"));vp.init_fontawesome_chooser(a.find(".vp-js-fontawesome"));vp.init_select2(a.find(".vp-js-select2"));vp.init_sorter(a.find(".vp-js-sorter"));vp.init_colorpicker(a.find(".vp-js-colorpicker"));vp.init_slider(a.find(".vp-js-slider"));vp.init_ace_editor(a.find(".vp-js-codeeditor"));vp.init_wpeditor(a.find(".vp-js-wpeditor"))};vp.init_fontawesome_chooser=function(a){if(jQuery.fn.select2){if(a.length<=0){return}var c=function b(d){return''+d.text+""};a.select2({formatResult:c,formatSelection:c,escapeMarkup:function(d){return d},allowClear:true,placeholder:vp_wp.ctrl_msg.fac_placeholder})}};vp.init_select2=function(a){if(jQuery.fn.select2){if(a.length<=0){return}a.select2({allowClear:true,placeholder:vp_wp.ctrl_msg.select2_placeholder})}};vp.init_sorter=function(a){if(jQuery.fn.select2Sortable){if(a.length<=0){return}a.each(function(d,e){var c=jQuery(e),b=c.getDatas();b=vp.parseOpt(b.opt);c.select2(b).select2Sortable({bindOrder:"sortableStop"})})}};vp.init_tipsy=function(){if(jQuery.fn.tipsy){jQuery(".vp-js-tipsy.description").tipsy({live:true,gravity:"e"});jQuery(".vp-js-tipsy.slideinput").tipsy({live:true,trigger:"focus"});jQuery(".vp-js-tipsy.image-item").tipsy({live:true})}};vp.init_tipsy();vp.init_ace_editor=function(a){if(window.ace!=="undefined"){if(a.length<=0){return}a.each(function(){var d=ace.edit(jQuery(this).get(0));var b=jQuery(this).prev();var c=jQuery(this).getDatas();c=vp.parseOpt(c.opt);d.setTheme("ace/theme/"+c.theme);if(c.mode){d.getSession().setMode("ace/mode/"+c.mode)}d.getSession().setUseWrapMode(true);d.setShowPrintMargin(false);d.getSession().setValue(b.val());d.getSession().on("change",function(){b.val(d.getSession().getValue())});b.on("change",function(){d.getSession().setValue(b.val())})})}};if(typeof window.KIA_metabox!=="undefined"){KIA_metabox.mediaButtons()}vp.init_wpeditor=function(a){if(typeof window.KIA_metabox!=="undefined"){if(a.length<=0){return}KIA_metabox.runTinyMCE(a)}};vp.tinyMCE_save=function(){if(typeof window.tinyMCE!=="undefined"){tinyMCE.triggerSave(false,true)}};