XylotrechusZ
!function(e){"use strict";var a="Couldn't add the font because the server didn’t respond.<br/>Please reload the page, then try again",t="Couldn't remove the font because the server didn’t respond.<br/>Please reload the page, then try again";e.AviaElementBehavior=e.AviaElementBehavior||{},e.AviaElementBehavior.wp_media=e.AviaElementBehavior.wp_media||[],e.AviaElementBehavior.wp_media_35=function(){var a=e("body");a.on("click",".avia-media-35",e.AviaElementBehavior.wp_media_35_activate),a.on("click",".avia_uploader_35",e.AviaElementBehavior.wp_media_35_activate)},e.AviaElementBehavior.wp_media_35_activate=function(a){a.preventDefault();var t=e(this).data(),i={frame:t.frame,library:{type:t.type},button:{text:t.button},className:t.class,title:t.title};void 0!==t.state&&(i.state=t.state),t.input_target=e("#"+t.target);var o=wp.media(i);o.states.add([new wp.media.controller.Library({id:"av_select_single_image",priority:20,toolbar:"select",filterable:"uploaded",library:wp.media.query(o.options.library),multiple:!1,editable:!0,displayUserSettings:!1,displaySettings:!0,allowLocalEdits:!0})]),o.on("select update insert",function(){e.AviaElementBehavior.wp_media_35_insert(o,t)}),o.open()},e.AviaElementBehavior.wp_media_35_insert=function(a,t){var i=a.state(),o=i.get("selection").first().toJSON(),n=o.id,r=void 0!==t.fetch&&(r=t.fetch);r&&(n=i.get("selection").map(function(e){var a=e.toJSON();if("url"==r){var t=i.display(e).toJSON();if(a.sizes&&a.sizes[t.size]&&a.sizes[t.size].url)return a.sizes[t.size].url;if(a.url)return a.url}})),t.input_target.val(n).trigger("change"),void 0!==t.trigger&&e("body").trigger(t.trigger,[o,t])},e(function(){e.AviaElementBehavior.wp_media_35(),e("body").on("av_fontello_zip_insert",e.AviaElementBehavior.fontello_insert),e("body").on("click",".avia_iconfont_manager .avia-del-font",e.AviaElementBehavior.fontello_remove),e("body").on("av_typefont_zip_insert",e.AviaElementBehavior.typefont_insert),e("body").on("click",".avia_typefont_manager .avia-del-font",e.AviaElementBehavior.typefont_remove),e("body").on("avia_options_data_saved",e.AviaElementBehavior.typefont_changed),e("body").on("av_config_file_insert",e.AviaElementBehavior.config_file_insert),e("body").on("av_alb_templates_file_insert",e.AviaElementBehavior.alb_templates_file_insert)}),e.AviaElementBehavior.typefont_action=null,e.AviaElementBehavior.typefont_insert=function(t,i,o){if(o.input_target.val(""),"zip"===i.subtype){var n=e(".avia_typefont_manager"),r=o.input_target.parents(".avia_control").eq(0).find(".avia_upload_loading");e.ajax({type:"POST",url:ajaxurl,dataType:"json",cache:!1,data:{action:"avia_ajax_add_zipped_type_font",values:i,avia_request:!0,_wpnonce:e("input[name=avia-nonce]").val()},beforeSend:function(){r.css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:1})},error:function(){e("body").avia_alert({the_class:"error",text:a})},success:function(t){if(void 0===t||void 0===t.success)e("body").avia_alert({the_class:"error",text:a});else if(t.success){var i=t.id.split(",");e.each(i,function(e,a){var t=n.find('[data-font="'+a+'"]');t.length&&t.slideUp(200,function(){t.remove()})}),e(t.result).css({display:"none"}).appendTo(n).slideDown(200),""!=typeof t.redirect&&(e("body").avia_alert({show:1e4,text:t.redirect}),e.AviaElementBehavior.typefont_action="typefont_insert"),e(".avia_button.avia_submit").removeClass("avia_button_inactive").trigger("click")}else e("body").avia_alert({the_class:"error",show:1e4,text:t.error});"undefined"!=typeof console&&console.log(t)},complete:function(e){r.fadeOut()}})}else e("body").avia_alert({the_class:"error",text:"Please upload a valid ZIP file.<br/>You can create the file on Fontello.com"})},e.AviaElementBehavior.typefont_changed=function(a,t){if(null!==e.AviaElementBehavior.typefont_action){if(e.AviaElementBehavior.typefont_action=null,void 0!==t&&void 0!==t.success&&!0===t.success)return window.location.hash="#goto_upload",void window.location.reload(!0);e("body").avia_alert({the_class:"error",show:6500,text:"An error occured saving the options. Please reload the page, check them and try again."})}},e.AviaElementBehavior.typefont_remove=function(i){i.preventDefault();var o=e(this),n=o.parents(".avia-available-font").eq(0),r=(o.parents(".avia_typefont_manager").eq(0).find(".avia-available-font"),o.data("delete")),l=o.parents(".avia_control").eq(0).find(".avia_upload_loading");e.ajax({type:"POST",url:ajaxurl,dataType:"json",cache:!1,data:{action:"avia_ajax_remove_zipped_type_font",del_font:r,avia_request:!0,_wpnonce:e("input[name=avia-nonce]").val()},beforeSend:function(){l.css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:1})},error:function(){e("body").avia_alert({the_class:"error",text:t})},success:function(t){void 0===t||void 0===t.success?e("body").avia_alert({the_class:"error",text:a}):t.success?n.slideUp(200,function(){n.remove()}):e("body").avia_alert({the_class:"error",text:t.error}),"undefined"!=typeof console&&console.log(t)},complete:function(e){l.fadeOut()}})},e.AviaElementBehavior.fontello_insert=function(t,i,o){o.input_target.val("");var n=e(".avia_iconfont_manager");if("zip"===i.subtype){var r=o.input_target.parents(".avia_control").eq(0).find(".avia_upload_loading");e.ajax({type:"POST",url:ajaxurl,data:{action:"avia_ajax_add_zipped_font",values:i,avia_request:!0,_wpnonce:e("input[name=avia-nonce]").val()},beforeSend:function(){r.css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:1})},error:function(){e("body").avia_alert({the_class:"error",text:a})},success:function(a){if(a.match(/avia_font_added/)){var t=a.replace(/avia_font_added:/,""),i=n.find('[data-font="'+t+'"]'),o=n.find(".avia-available-font"),r=n.find(".avia-available-font").eq(0).clone().wrap("<p>").parent().html().replace(/{font_name}/g,t);if(i.length){if(i.removeClass("av-highlight"),setTimeout(function(){i.addClass("av-highlight")},10),1===o.index(i))i.find(".avia-def-font").removeClass("avia-def-font").addClass("avia-del-font").text("Delete")}else e(r).css({display:"none"}).appendTo(n).slideDown(200)}else e("body").avia_alert({the_class:"error",show:6500,text:"Couldn't add the font.<br/>The script returned the following error: <br/><br/>"+a});"undefined"!=typeof console&&console.log(a)},complete:function(e){r.fadeOut()}})}else e("body").avia_alert({the_class:"error",text:"Please upload a valid ZIP file.<br/>You can create the file on Fontello.com"})},e.AviaElementBehavior.fontello_remove=function(a){a.preventDefault();var i=e(this),o=i.parents(".avia-available-font").eq(0),n=i.parents(".avia_iconfont_manager").eq(0).find(".avia-available-font"),r=i.data("delete"),l=i.parents(".avia_control").eq(0).find(".avia_upload_loading");e.ajax({type:"POST",url:ajaxurl,data:{action:"avia_ajax_remove_zipped_font",del_font:r,avia_request:!0,_wpnonce:e("input[name=avia-nonce]").val()},beforeSend:function(){l.css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:1})},error:function(){e("body").avia_alert({the_class:"error",text:t})},success:function(a){if(a.match(/avia_font_removed/))if(1===n.index(o))o.find(".avia-del-font").removeClass("avia-del-font").addClass("avia-def-font").text("(Default Font)");else o.slideUp(200,function(){o.remove()});else e("body").avia_alert({the_class:"error",text:"Couldn't remove the font.<br/>Please reload the page, then try again"});"undefined"!=typeof console&&console.log(a)},complete:function(e){l.fadeOut()}})},e.AviaElementBehavior.alb_templates_file_insert=function(a,t,i){if(i.input_target.val(""),"plain"===t.subtype){var o=i.input_target.parents(".avia_control").eq(0).find(".avia_upload_loading");e.ajax({type:"POST",url:ajaxurl,dataType:"json",cache:!1,data:{action:"avia_ajax_import_alb_templates_file",values:t,avia_request:!0,avia_id:i.target,_wpnonce:e("input[name=avia-nonce]").val()},beforeSend:function(){o.css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:1})},error:function(){e("body").avia_alert({the_class:"error",text:"Couldn't import the templates because the server didn’t respond.<br/>Please reload the page, then try again"})},success:function(a){void 0===a||void 0===a.success?e("body").avia_alert({the_class:"error",text:"Couldn't import the templates because the server returned an invalid respond"}):a.success?e("body").avia_alert({text:a.msg}):e("body").avia_alert({the_class:"error",text:a.msg})},complete:function(e){o.fadeOut()}})}else e("body").avia_alert({the_class:"error",text:'Please upload a valid config file.<br/>You can create the file by clicking on the "Export Layout Builder Templates" button'})},e.AviaElementBehavior.config_file_insert=function(a,t,i){if(i.input_target.val(""),"plain"===t.subtype){var o=i.input_target.parents(".avia_control").eq(0).find(".avia_upload_loading"),n={},r=!1;if(e.each(["filter_tabs","filter_values","skip_tabs","skip_values"],function(e,a){void 0!==i[a]&&(n[a]=i[a],r=!0)}),!r){var l=i.input_target.closest("#avia_upload");if(l.find("input#upload_filter_checkbox:checked").length>0){l.find("input#upload_keep_quick_css:checked").length>0&&(n.skip_values="avia:quick_css");var s=l.find("select#upload_filter_tabs").val();null!=s&&s.length>0&&(n.filter_tabs=s.join(","))}}e.ajax({type:"POST",url:ajaxurl,data:{action:"avia_ajax_import_config_file",values:t,avia_filter:n,avia_request:!0,avia_id:i.target,_wpnonce:e("input[name=avia-nonce]").val()},beforeSend:function(){o.css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:1})},error:function(){e("body").avia_alert({the_class:"error",text:"Couldn't import the config because the server didn’t respond.<br/>Please reload the page, then try again"})},success:function(a){a.match(/avia_config_file_imported/)?e("body").avia_alert({text:"Alright!<br/>Import worked out, no problems whatsoever. <br/>The page will now be reloaded to reflect the changes"},function(){window.location.hash="",window.location.reload(!0)}):e("body").avia_alert({the_class:"error",show:6500,text:"Couldn't import the theme settings file.<br/>The script returned the following error: <br/><br/>"+a}),"undefined"!=typeof console&&console.log(a)},complete:function(e){o.fadeOut()}})}else e("body").avia_alert({the_class:"error",text:'Please upload a valid config file.<br/>You can create the file by clicking on the "Export Theme Settings" button'})}}(jQuery);