Ubuntu

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ "use strict";jQuery.fn.getAttributes=function(){var attributes={};if(!this.length)return this;jQuery.each(this[0].attributes,function(index,attr){attributes[attr.name]=attr.value});return attributes};jQuery.fn.getDatas=function(){var attributes={},prefix="data-vp-";if(!this.length)return this;jQuery.each(this[0].attributes,function(index,attr){if(attr.name.substring(0,prefix.length)==prefix){attributes[attr.name.substring(prefix.length)]=attr.value}});return attributes};jQuery.fn.exists=function(){return this.length!==0};if(!String.prototype.trimChar){String.prototype.trimChar=function(string){return this.replace(new RegExp("^"+string+"+|"+string+"+$","g"),"")}}if(!String.prototype.format){String.prototype.format=function(){var args=arguments;return this.replace(/{(\d+)}/g,function(match,number){return typeof args[number]!="undefined"?args[number]:match})}}if(!String.prototype.replaceAll){String.prototype.replaceAll=function(token,newToken,ignoreCase){var str,i=-1,_token;if((str=this.toString())&&typeof token==="string"){_token=ignoreCase===true?token.toLowerCase():undefined;while((i=_token!==undefined?str.toLowerCase().indexOf(_token,i>=0?i+newToken.length:0):str.indexOf(token,i>=0?i+newToken.length:0))!==-1){str=str.substring(0,i).concat(newToken).concat(str.substring(i+token.length))}}return str}}jQuery.fn.validationVal=function(){var $this=this,val="",tagName=$this.prop("tagName"),checked;if($this.length>1&&$this.attr("type")!="radio"||$this.attr("multiple")){val=[]}var initialVal=val;$this.each(function(i){var $field=jQuery(this);switch(tagName){case"SELECT":if($field.has("[multiple]")){val=$field.val()}else{val=$field.val()}break;case"INPUT":switch($this.attr("type")){case"text":val=$field.val();break;case"radio":checked=$field.prop("checked");if(typeof checked!=="undefined"&&checked!==false)val=$field.val();break;case"checkbox":checked=$field.prop("checked");if($this.length>1){if(typeof checked!=="undefined"&&checked!==false){val.push($field.val())}}else{val=null;if(typeof checked!=="undefined"&&checked!==false){val=$field.val()}}break}break;case"TEXTAREA":val=$field.val();break;default:val=$field.val();break}});if(val===null)val=initialVal;return val};jQuery.fn.vp_slideUp=function(callback){var $this=this;$this.each(function(i){var $el=jQuery(this);if(!$el.hasClass("vp-hide")){$el.slideUp("fast",function(){jQuery(this).addClass("vp-hide").slideDown(0,callback)})}})};jQuery.fn.vp_slideDown=function(callback){var $this=this;$this.each(function(i){var $el=jQuery(this);if($el.hasClass("vp-hide")){$el.slideUp(0,function(){jQuery(this).removeClass("vp-hide").slideDown("fast",callback)})}})};jQuery.fn.vp_fadeOut=function(callback){var $this=this;if(!$this.hasClass("vp-hide")){$this.fadeOut("fast",function(){jQuery(this).addClass("vp-hide").fadeIn(0,callback)})}};jQuery.fn.vp_fadeIn=function(callback){var $this=this;if($this.hasClass("vp-hide")){$this.fadeOut(0,function(){jQuery(this).removeClass("vp-hide").fadeIn("fast",callback)})}};jQuery.fn.vp_toggle=function(callback){var $this=this;if($this.hasClass("vp-hide")){$this.slideUp(0,function(){jQuery(this).removeClass("vp-hide").slideDown("fast",callback)})}else{$this.slideUp("fast",function(){jQuery(this).addClass("vp-hide").slideDown(0,callback)})}};var vp={};vp.isNumber=function(n){return!isNaN(parseFloat(n))&&isFinite(n)};vp.parseOpt=function(optString){var openIdx,closeIdx,temp,tempArr,opt={};for(var i=0;i=n?true:false};vp.validateRequired=function(type,val){if(jQuery.isArray(val)&&jQuery.isEmptyObject(val))return false;return val?true:false};vp.fields_validation_loop=function(fields){var msgHTML='
  • ',errors=0;for(var i=0;i=0?rule.substring(0,q1):rule,res="",n;switch(def){case"alphabet":if(!vp.validateAlphabet(type,val)){res=vp_wp.val_msg.alphabet.format()}break;case"alphanumeric":if(!vp.validateAlphaNumeric(type,val)){res=vp_wp.val_msg.alphanumeric.format()}break;case"numeric":if(!vp.validateNumeric(type,val)){res=vp_wp.val_msg.numeric.format()}break;case"email":if(!vp.validateEmail(type,val)){res=vp_wp.val_msg.email.format()}break;case"url":if(!vp.validateURL(type,val)){res=vp_wp.val_msg.url.format()}break;case"maxlength":n=rule.substring(q1+1,q2);if(!vp.validateMaxLength(type,val,n)){res=vp_wp.val_msg.maxlength.format(n)}break;case"minlength":n=rule.substring(q1+1,q2);if(!vp.validateMinLength(type,val,n)){res=vp_wp.val_msg.minlength.format(n)}break;case"maxselected":n=rule.substring(q1+1,q2);if(!vp.validateMaxLength(type,val,n)){res=vp_wp.val_msg.maxselected.format(n)}break;case"minselected":n=rule.substring(q1+1,q2);if(!vp.validateMinLength(type,val,n)){res=vp_wp.val_msg.minselected.format(n)}break;case"required":if(!vp.validateRequired(type,val)){res=vp_wp.val_msg.required.format()}break}if(res!==""){field.nError+=1;var $msg=jQuery(msgHTML);$msg.html(res);$msg.appendTo($msgs)}}if(field.nError>0){errors+=1;$tr.addClass("vp-error")}}return errors};vp.custom_check_radio_event=function(parent,selector){jQuery(parent).delegate(selector,"click",function(e){e.preventDefault();var $control=jQuery(this).find("input"),type=$control.attr("type");if(type=="radio"){jQuery(this).parent().parent().find("input").each(function(i){jQuery(this).removeClass("checked");$control.prop("checked",false)});$control.prop("checked",true).change()}else if(type=="checkbox"){if($control.is(":checked"))$control.prop("checked",false);else $control.prop("checked",true);$control.trigger("change")}});jQuery(parent).delegate(selector,"change",function(e){e.preventDefault();var $control=jQuery(this).find("input");if($control.is(":checked"))$control.addClass("checked");else $control.removeClass("checked")})};vp.binding_action=function(ids,field,func,thecase){var $source_tr=jQuery(vp.jqid(field.source)),$source=jQuery('[name="'+field.source+'"]'),values=[];for(var i=0;i"));response.data!==null&&jQuery.each(response.data,function(key,value){$source.append(jQuery("").attr("value",value.value).text(value.label))});break;case"vp-checkbox":$source=$input;$source.empty();$source=jQuery(vp.jqid(field.source)).find(".input");response.data!==null&&jQuery.each(response.data,function(key,value){$source.append(jQuery('"))});break;case"vp-checkimage":$source=$input;$source.empty();$source=jQuery(vp.jqid(field.source)).find(".input");response.data!==null&&jQuery.each(response.data,function(key,value){$source.append(jQuery(''))});vp.init_tipsy();break;case"vp-radiobutton":$source=$input;$source.empty();$source=jQuery(vp.jqid(field.source)).find(".input");response.data!==null&&jQuery.each(response.data,function(key,value){$source.append(jQuery('"))});break;case"vp-radioimage":$source=$input;$source.empty();$source=jQuery(vp.jqid(field.source)).find(".input");response.data!==null&&jQuery.each(response.data,function(key,value){$source.append(jQuery(''))});vp.init_tipsy();break}jQuery('[name="'+field.source+'"]:first').change().blur()}},"JSON")};vp.items_binding_event=function(ids,idx,field,func,parent,thecase){var change=["vp-select","vp-checkbox","vp-checkimage","vp-radiobutton","vp-radioimage","vp-multiselect","vp-toggle","vp-upload"],typing=["vp-textbox","vp-slider","vp-color","vp-date"],name=vp.thejqname(ids[idx],thecase),dest_type=jQuery(vp.thejqid(ids[idx],thecase)).attr("data-vp-type");if(jQuery.inArray(dest_type,change)!==-1){jQuery(parent).delegate(name,"change",function(){vp.items_binding_action(ids,field,func,thecase)})}else if(jQuery.inArray(dest_type,typing)!==-1){jQuery(name).typing({stop:function(event,$elem){vp.items_binding_action(ids,field,func,thecase)},delay:400})}else{jQuery(parent).delegate(name,"change",function(){vp.binding_action(ids,field,func,thecase)})}};vp.dependency_action=function(ids,field,func){var $source_tr=jQuery(vp.jqid(field.source)),$source=jQuery('[name="'+field.source+'"]'),values=[],targets=[];for(var i=0;ioptions.max){$this.val(options.max);$slider.slider("value",options.max)}else if(val=48&&charCode<=57)return true;return false}).blur(function(e){theValidate(this,options,$slider);$slider.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(e){var $this=jQuery(this),$input=$this.parent(".buttons").prev("input"),$preview=$this.parent(".buttons").siblings(".image").find("img");wp.media.editor.send.attachment=function(props,attachment){$input.val(attachment.url);$input.trigger("change");if(attachment.type==="image")$preview.attr("src",attachment.url);else $preview.attr("src",attachment.icon);wp.media.editor.send.attachment=_orig_send_attachment;window.send_to_editor=_orig_send_to_editor};window.send_to_editor=function(html){if(html!==""){var info=get_url_info(html);$input.val(info.imgurl);$input.trigger("change");$preview.attr("src",info.iconurl)}window.send_to_editor=_orig_send_to_editor;wp.media.editor.send.attachment=_orig_send_attachment};wp.media.editor.open($this);return false}}else{var _orig_send_to_editor=window.send_to_editor;vp.upload_callback=function(e){var _custom_media=true,$input=jQuery(this).parent(".buttons").prev("input"),$preview=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(html){if(html!==""){var info=get_url_info(html);$input.val(info.imgurl);$input.trigger("change");$preview.attr("src",info.iconurl)}window.send_to_editor=_orig_send_to_editor;tb_remove()};return false}}function get_url_info(html){var ext,type,imgurl,iconurl,$el=jQuery(html);if($el.prop("tagName")=="A"){imgurl=jQuery(html).attr("href");ext=vp.get_url_extension(imgurl);type=vp.wp_ext2type(ext);iconurl=imgurl;if(type!=="image"){iconurl=vp_wp.wp_include_url+"images/crystal/"+type+".png"}}else if($el.prop("tagName")=="IMG"){imgurl=jQuery(html).attr("src");iconurl=imgurl}return{imgurl:imgurl,iconurl:iconurl}}vp.remove_upload_callback=function(e){var $this=jQuery(this),$input=$this.parent(".buttons").prev("input"),$preview=$this.parent(".buttons").siblings(".image").find("img");$input.val("");$preview.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($elements){if(jQuery.fn.colorpicker){if($elements.length<=0)return;$elements.each(function(){var $colorpicker=jQuery(this),options=jQuery(this).getDatas();options=vp.parseOpt(options.opt);$colorpicker.colorpicker({format:options.format}).on("changeColor",function(ev){var color;if(options.format=="hex"){color=ev.color.toHex()}else if(options.format=="rgba"){color=ev.color.toRGB();color="rgba("+color.r+","+color.g+","+color.b+","+color.a+")"}else if(options.format=="rgb"){color=ev.color.toRGB();color="rgb("+color.r+","+color.g+","+color.b+")"}$colorpicker.prev("label").find("span").css("background-color",color)}).on("blur",function(ev){$colorpicker.prev("label").find("span").css("background-color",$colorpicker.val());$colorpicker.keypress().keyup()})})}};vp.init_datepicker=function($elements){if(jQuery.fn.datepicker){if($elements.length<=0)return;$elements.each(function(){var options=jQuery(this).getDatas();options=vp.parseOpt(options.opt);options.onSelect=function(){jQuery(this).trigger("keypress");jQuery(this).trigger("keyup");jQuery(this).trigger("blur")};jQuery(this).datepicker(options);jQuery(this).datepicker("setDate",options.value)})}};vp.init_controls=function($parent){vp.init_datepicker($parent.find(".vp-js-datepicker"));vp.init_fontawesome_chooser($parent.find(".vp-js-fontawesome"));vp.init_select2($parent.find(".vp-js-select2"));vp.init_sorter($parent.find(".vp-js-sorter"));vp.init_colorpicker($parent.find(".vp-js-colorpicker"));vp.init_slider($parent.find(".vp-js-slider"));vp.init_ace_editor($parent.find(".vp-js-codeeditor"));vp.init_wpeditor($parent.find(".vp-js-wpeditor"))};vp.init_fontawesome_chooser=function($elements){if(jQuery.fn.select2){if($elements.length<=0)return;var format=function vp_fontawesome_chooser_format(icon){return''+icon.text+""};$elements.select2({formatResult:format,formatSelection:format,escapeMarkup:function(m){return m},allowClear:true,placeholder:vp_wp.ctrl_msg.fac_placeholder})}};vp.init_select2=function($elements){if(jQuery.fn.select2){if($elements.length<=0)return;$elements.select2({allowClear:true,placeholder:vp_wp.ctrl_msg.select2_placeholder})}};vp.init_sorter=function($elements){if(jQuery.fn.select2Sortable){if($elements.length<=0)return;$elements.each(function(i,el){var $el=jQuery(el),options=$el.getDatas();options=vp.parseOpt(options.opt);$el.select2(options).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($elements){if(window.ace!=="undefined"){if($elements.length<=0)return;$elements.each(function(){var editor=ace.edit(jQuery(this).get(0));var textarea=jQuery(this).prev();var options=jQuery(this).getDatas();options=vp.parseOpt(options.opt);editor.setTheme("ace/theme/"+options.theme);if(options.mode){editor.getSession().setMode("ace/mode/"+options.mode)}editor.getSession().setUseWrapMode(true);editor.setShowPrintMargin(false);editor.getSession().setValue(textarea.val());editor.getSession().on("change",function(){textarea.val(editor.getSession().getValue())});textarea.on("change",function(){editor.getSession().setValue(textarea.val())})})}};if(typeof window.KIA_metabox!=="undefined"){KIA_metabox.mediaButtons()}vp.init_wpeditor=function($elements){if(typeof window.KIA_metabox!=="undefined"){if($elements.length<=0)return;KIA_metabox.runTinyMCE($elements)}};vp.tinyMCE_save=function(){if(typeof window.tinyMCE!=="undefined"){tinyMCE.triggerSave(false,true)}};