var mbResponsive=function(e){this.jquery=e};mbResponsive.prototype={jquery:null,mbAdmin:null,responsiveMap:null},mbResponsive.prototype.init=function(e){$=this.jquery,this.mbAdmin=e,0!=$("#new-button-form").length&&(this.checkAutoQuery(),$('input[name="auto_responsive"]').on("click",$.proxy(this.checkAutoQuery,this)),$(".add_media_query").on("click",$.proxy(this.addMediaQuery,this)),this.responsiveMap=JSON.parse(responsiveMap),$(document).on("click",".removebutton",$.proxy(this.removeMediaQuery,this)))},mbResponsive.prototype.checkAutoQuery=function(){$=this.jquery,$('input[name="auto_responsive"]').is(":checked")?($(".media_queries_options").hide(),$(".option-design.new-query").hide()):($(".media_queries_options").show(),$(".option-design.new-query").show())},mbResponsive.prototype.addMediaQuery=function(){$=this.jquery,this.mbAdmin.saveIndicator(!0);var e=$(".media_option_prot").children().clone(),t=$("#new_query").val(),i=$("#new_query :selected").text(),n=$("#media_desc").children("#"+t).text();$(e).data("query",t),$(e).children('input[name="media_query[]"]').val(t),$(e).children(".title").text(i),$(e).children(".description").text(n),"custom"==t&&$(e).find(".custom").removeClass("hidden");var r=$('input[name="next_media_index"]').val();$(e).find("label, select, input").each(function(){var e=$(this).attr("name"),t=$(this).attr("id"),i=$(this).data("field"),n=$(this).prop("tagName").toLowerCase();if("undefined"!=typeof t&&$(this).attr("id",t.replace("[]","["+r+"]")),"undefined"!=typeof e&&$(this).attr("name",e.replace("[]","["+r+"]")),"undefined"!=typeof i&&$(this).data("field",i.replace("[]","["+r+"]")),"label"==n){var o=$(this).attr("for");"undefined"!=typeof o&&$(this).attr("for",o.replace("[]","["+r+"]"))}}),$(document).trigger("reinitConditionals"),r=parseInt(r),$('input[name="next_media_index"]').val(r+1),"custom"!==t&&($("#new_query :selected").prop("disabled",!0),$("#new_query :selected").prop("selected",!1)),$(".new_query_space").append(e);var o=$(".new_query_space").offset().top;$(window).scrollTop(o-100)},mbResponsive.prototype.removeMediaQuery=function(e){$=this.jquery;var t=e.target,i=$(t).parents(".media_query").data("query");$(t).parents(".media_query").fadeOut(function(){$(this).remove()}),$('#new_query option[value="'+i+'"]').prop("disabled",!1)},mbResponsive.prototype.toggleResponsivePreview=function(e){var t=$(e.target),i=t.attr("id");i=i.replace("mq_preview[",""),i=i.replace("]",""),this.renderPreview(i)},mbResponsive.prototype.renderPreview=function(e){var t=["mq_container_width","mq_container_float","mq_custom_minwidth","mq_custom_minheight","mq_hide"],i=this.responsiveMap,n=this;$.each(i,function(r){var o=this.css,s='[id^="'+r+'["]',a='[id^="'+r+'_unit["]',d=$(s).eq(e),p=d.attr("id");if(p=p.replace(/\[[0-9]\]/gi,""),$.inArray(p,t)>=0)return!0;if(p.indexOf("_unit")>=0)return!0;var u=d.val(),c="";if("undefined"!=typeof i[r+"_unit"])var c=$(a).eq(e).val();var m={css:o};"font-size"==o&&(m.csspart="mb-text,mb-text2"),n.mbAdmin.putCSS(m,u+c)})};