/*! PopUp - v4.8.0
 * http://premium.wpmudev.org/project/the-pop-over-plugin/
 * Copyright (c) 2016; * Licensed GPLv2+ */
jQuery(function(){function e(){var e=jQuery(".meta-box-sortables"),t=jQuery(".postbox .hndle");e.length&&(e.sortable({disabled:!0}),t.css("cursor","pointer"))}function t(){function e(){o.hasClass("columns-1")||r.hasClass("po-small")?r.hasClass("sticky-submit")||(r.addClass("sticky-submit"),r.removeClass("floating-submit"),s.css({marginTop:0}),s.find(".sticky-actions").show(),s.find(".non-sticky").hide()):r.hasClass("floating-submit")||(r.addClass("floating-submit"),r.removeClass("sticky-submit"))}function t(){r.hasClass("sticky-submit")&&(r.removeClass("sticky-submit"),s.find(".sticky-actions").hide(),s.find(".non-sticky").show()),r.hasClass("floating-submit")&&r.removeClass("floating-submit")}var i,n,s=jQuery("#submitdiv"),o=jQuery("#post-body"),r=jQuery("body"),a=20;s.length&&(n=s.position().top,jQuery(window).resize(function(){var e=850>=jQuery(window).width();e?r.hasClass("po-small")||r.addClass("po-small"):r.hasClass("po-small")&&(r.removeClass("po-small"),t())}).scroll(function(){i=jQuery(window).scrollTop()-n+a,i>0?e():t()}),window.setTimeout(function(){jQuery(window).trigger("scroll")},100))}function i(){var e=jQuery(".colorpicker");if(e.length&&"function"==typeof e.wpColorPicker){var t=function t(e){var t=jQuery(e.target),i=t.closest(".wp-picker-container"),n=i.find(".colorpicker"),s=jQuery(".colorpicker");i.length&&(s=s.not(n)),s.each(function(){var e=jQuery(this),t=e.closest(".wp-picker-container");e.iris("hide"),e.hide(),t.find(".wp-picker-clear").addClass("hidden"),t.find(".wp-picker-open").removeClass("wp-picker-open")})};e.wpColorPicker(),jQuery(document).on("mousedown",t),jQuery(document).on("click",t),jQuery(document).on("mouseup",t)}}function n(){var e=jQuery("#po-custom-colors"),t=jQuery("#po-custom-size"),i=jQuery("[name=po_display]"),n=jQuery("#po-can-hide"),s=jQuery("#po-close-hides");if(e.length){var o=function o(){var e,t=jQuery(this),i=t.data("toggle"),n=jQuery(i),s=t.data("or"),o=t.data("and"),r=!1;s?(e=jQuery(s),r=e.filter(":checked").length>0):o?(e=jQuery(o),r=e.length===e.filter(":checked").length):r=t.prop("checked"),r?(n.removeClass("inactive"),n.find("input,select,textarea,a").prop("readonly",!1).removeClass("disabled")):(n.addClass("inactive"),n.find("input,select,textarea,a").prop("readonly",!0).addClass("disabled")),n.addClass("inactive-anim")},r=function r(){var e=jQuery(this),t=e.attr("name"),i=jQuery('[name="'+t+'"]');i.each(function(){o.call(this)})},a=function a(){jQuery(".slider").each(function(){var e=jQuery(this),t=e.closest(".slider-wrap"),i=e.data("input"),n=t.find(i+"min"),s=t.find(i+"max"),o=t.find(".slider-min-input"),r=t.find(".slider-min-ignore"),a=t.find(".slider-max-input"),l=t.find(".slider-max-ignore"),c=e.data("min"),h=e.data("max");isNaN(c)&&(c=0),isNaN(h)&&(h=9999),n.prop("readonly",!0),s.prop("readonly",!0);var u=function u(e,t){n.val(e),s.val(t),e===c?(o.hide(),r.show()):(o.show(),r.hide()),t===h?(a.hide(),l.show()):(a.show(),l.hide())};e.slider({range:!0,min:c,max:h,values:[n.val(),s.val()],slide:function(e,t){u(t.values[0],t.values[1])}}),u(n.val(),s.val())})};e.click(o),t.click(o),n.click(o),s.click(o),i.click(r),o.call(e),o.call(t),o.call(n),o.call(s),i.each(function(){o.call(jQuery(this))}),a()}}function s(){var e=jQuery("#meta-rules .all-rules"),t=jQuery("#meta-rules .active-rules");if(e.length){var i=function i(e){var t=jQuery(e.target),i=t.find("input.wpmui-toggle-checkbox");if(!t.closest(".wpmui-toggle").length)return t.hasClass("inactive")?!1:(i.trigger("click"),void 0)},n=function n(){var e=jQuery(this),i=e.closest(".rule"),n=e.data("form"),o=t.find(n),r=e.prop("checked");r?(i.removeClass("off").addClass("on"),o.removeClass("off").addClass("on open")):(i.removeClass("on").addClass("off"),o.removeClass("on").addClass("off")),s(e,r)},s=function s(i,n){var s,o,r,a=i.data("exclude"),l=a?a.split(","):[];for(s=l.length-1;s>=0;s-=1)o=e.find(".rule-"+l[s]),r=t.find("#po-rule-"+l[s]),o.hasClass("on")||(o.prop("disabled",n),n?(o.addClass("inactive off").removeClass("on"),r.addClass("off").removeClass("on")):o.removeClass("inactive off"))},o=function o(){var e=jQuery(this),t=e.closest(".rule");t.toggleClass("open")};e.find("input.wpmui-toggle-checkbox").click(n),e.find(".rule").click(i),t.on("click",".rule-title,.rule-toggle",o),e.find(".rule.on input.wpmui-toggle-checkbox").each(function(){s(jQuery(this),!0)}),jQuery(".init-loading").removeClass("wpmui-loading")}}function o(){var e,t=jQuery(".content-image"),i=t.find(".add_image"),n=t.find(".featured-img"),s=t.find(".reset"),o=t.find(".po-image"),r=t.find(".img-preview"),a=t.find(".lbl-empty"),l=t.find(".img-pos"),c=function c(e){o.val(e),r.attr("src",e).show(),a.hide(),l.show(),n.addClass("has-image")},h=function h(){o.val(""),r.attr("src","").hide(),a.show(),l.hide(),n.removeClass("has-image")},u=function u(t){return t.preventDefault(),e?(e.open(),void 0):(e=wp.media.frames.file_frame=wp.media({title:i.attr("data-title"),button:{text:i.attr("data-button")},multiple:!1}),e.on("select",function(){var t=e.state().get("selection").first().toJSON();c(t.url)}),e.open(),void 0)},d=function d(){var e=jQuery(this);l.find(".option").removeClass("selected"),e.addClass("selected")};i.on("click",u),s.on("click",h),l.on("click",".option",d)}function r(){var e,t=jQuery('select[name="action"] '),i=jQuery('select[name="action2"] ');if(t.length&&"object"==typeof window.po_bulk)for(e in window.po_bulk)jQuery("<option>").val(e).text(window.po_bulk[e]).appendTo(t).clone().appendTo(i)}function a(){var e=jQuery("table.posts"),t=e.find("#the-list");if(t.length){var i=function i(i,n){if(e.removeClass("wpmui-loading"),n)for(var s in i)i.hasOwnProperty(s)&&t.find("#post-"+s+" .the-pos").text(i[s])},n=function n(){var n,s=t.find("tr"),o=[];for(n=0;s.length>n;n+=1)o.push(jQuery(s[n]).attr("id"));e.addClass("wpmui-loading"),wpmUi.ajax(null,"po-ajax").data({"do":"order",order:o}).ondone(i).load_json()};t.sortable({placeholder:"ui-sortable-placeholder",axis:"y",handle:".column-po_order",helper:"clone",opacity:.75,update:n}),t.disableSelection()}}function l(){var e=jQuery(document),t=jQuery("#wpcontent"),i=function i(e){var i=jQuery(this),n=i.data("id");return e.preventDefault(),void 0===window.inc_popup?!1:(t.addClass("wpmui-loading"),window.inc_popup.load(n),!1)},n=function n(e){var i,n=(jQuery(this),jQuery("#post")),s=wpmUi.ajax();return e.preventDefault(),void 0===window.inc_popup?!1:(i=s.extract_data(n),t.addClass("wpmui-loading"),window.inc_popup.load(0,i),!1)},s=function s(e,i){t.removeClass("wpmui-loading"),i.init()};e.on("click",".posts .po-preview",i),e.on("click","#post .preview",n),e.on("popup-initialized",s)}function c(){jQuery(".po_css_editor").each(function(){var e=ace.edit(this.id);jQuery(this).data("editor",e),e.setTheme("ace/theme/chrome"),e.getSession().setMode("ace/mode/css"),e.getSession().setUseWrapMode(!0),e.getSession().setUseWrapMode(!1)}),jQuery(".po_css_editor").each(function(){var e=this,t=jQuery(jQuery(this).data("input"));jQuery(this).data("editor").getSession().on("change",function(){t.val(jQuery(e).data("editor").getSession().getValue())})})}jQuery("body.post-type-inc_popup").length&&(jQuery("body.post-php").length||jQuery("body.post-new-php").length?(e(),t(),i(),n(),s(),l(),o(),c(),wpmUi.upgrade_multiselect()):jQuery("body.edit-php").length&&(a(),r(),l()))});