var wpWidgets;!function(c){var g=c(document);wpWidgets={hoveredSidebar:null,init:function(){var r,o,s=this,i=c(".widgets-chooser"),d=i.find(".widgets-chooser-sidebars"),e=c("div.widgets-sortables"),l=!("undefined"==typeof isRtl||!isRtl);c("#widgets-right .sidebar-name").click(function(){var e=c(this),i=e.closest(".widgets-holder-wrap");i.hasClass("closed")?(i.removeClass("closed"),e.parent().sortable("refresh")):i.addClass("closed"),g.triggerHandler("wp-pin-menu")}),c("#widgets-left .sidebar-name").click(function(){c(this).closest(".widgets-holder-wrap").toggleClass("closed"),g.triggerHandler("wp-pin-menu")}),c(document.body).bind("click.widgets-toggle",function(e){var i,t,s,d,n=c(e.target),a={"z-index":100};n.parents(".widget-top").length&&!n.parents("#available-widgets").length?(t=(i=n.closest("div.widget")).children(".widget-inside"),s=parseInt(i.find("input.widget-width").val(),10),d=i.parent().width(),t.is(":hidden")?(250 .widget-top > .widget-title",distance:2,helper:"clone",zIndex:100,containment:"#wpwrap",refreshPositions:!0,start:function(e,i){var t=c(this).find(".widgets-chooser");i.helper.find("div.widget-description").hide(),o=this.id,t.length&&(c("#wpbody-content").append(t.hide()),i.helper.find(".widgets-chooser").remove(),s.clearWidgetSelection())},stop:function(){r&&c(r).hide(),r=""}}),e.droppable({tolerance:"intersect",over:function(e){var i=c(e.target).parent();wpWidgets.hoveredSidebar&&!i.is(wpWidgets.hoveredSidebar)&&wpWidgets.closeSidebar(e),i.hasClass("closed")&&(wpWidgets.hoveredSidebar=i).removeClass("closed"),c(this).sortable("refresh")},out:function(e){wpWidgets.hoveredSidebar&&wpWidgets.closeSidebar(e)}}),e.sortable({placeholder:"widget-placeholder",items:"> .widget",handle:"> .widget-top > .widget-title",cursor:"move",distance:2,containment:"#wpwrap",tolerance:"pointer",refreshPositions:!0,start:function(e,i){var t=c(this),s=t.parent(),d=i.item.children(".widget-inside");"block"===d.css("display")&&(i.item.removeClass("open"),d.hide(),c(this).sortable("refreshPositions")),s.hasClass("closed")||(i=i.item.hasClass("ui-draggable")?t.height():1+t.height(),t.css("min-height",i+"px"))},stop:function(e,i){var t,s,d,n=i.item,a=o;if(wpWidgets.hoveredSidebar=null,n.hasClass("deleting"))return wpWidgets.save(n,1,0,1),void n.remove();t=n.find("input.add_new").val(),s=n.find("input.multi_number").val(),n.attr("style","").removeClass("ui-draggable"),o="",t&&("multi"===t?(n.html(n.html().replace(/<[^<>]+>/g,function(e){return e.replace(/__i__|%i%/g,s)})),n.attr("id",a.replace("__i__",s)),s++,c("div#"+a).find("input.multi_number").val(s)):"single"===t&&(n.attr("id","new-"+a),r="div#"+a),wpWidgets.save(n,0,0,1),n.find("input.add_new").val(""),g.trigger("widget-added",[n])),(d=n.parent()).parent().hasClass("closed")&&(d.parent().removeClass("closed"),1<(i=d.children(".widget")).length&&(a=i.get(0),i=n.get(0),a.id&&i.id&&a.id!==i.id&&c(a).before(n))),t?n.find("a.widget-action").trigger("click"):wpWidgets.saveOrder(d.attr("id"))},activate:function(){c(this).parent().addClass("widget-hover")},deactivate:function(){c(this).css("min-height","").parent().removeClass("widget-hover")},receive:function(e,i){i=c(i.sender);-1').text(c.trim(i));0===e&&i.addClass("widgets-chooser-selected"),d.append(i),i.data("sidebarId",t)}),c("#available-widgets .widget .widget-title").on("click.widgets-chooser",function(){var e=c(this).closest(".widget");e.hasClass("widget-in-question")||c("#widgets-left").hasClass("chooser")?s.closeChooser():(s.clearWidgetSelection(),c("#widgets-left").addClass("chooser"),e.addClass("widget-in-question").children(".widget-description").after(i),i.slideDown(300,function(){d.find(".widgets-chooser-selected").focus()}),d.find("li").on("focusin.widgets-chooser",function(){d.find(".widgets-chooser-selected").removeClass("widgets-chooser-selected"),c(this).addClass("widgets-chooser-selected")}))}),i.on("click.widgets-chooser",function(e){e=c(e.target);e.hasClass("button-primary")?(s.addWidget(i),s.closeChooser()):e.hasClass("button-secondary")&&s.closeChooser()}).on("keyup.widgets-chooser",function(e){e.which===c.ui.keyCode.ENTER?(c(e.target).hasClass("button-secondary")||s.addWidget(i),s.closeChooser()):e.which===c.ui.keyCode.ESCAPE&&s.closeChooser()})},saveOrder:function(e){var i={action:"widgets-order",savewidgets:c("#_wpnonce_widgets").val(),sidebars:[]};e&&c("#"+e).find(".spinner:first").addClass("is-active"),c("div.widgets-sortables").each(function(){c(this).sortable&&(i["sidebars["+c(this).attr("id")+"]"]=c(this).sortable("toArray").join(","))}),c.post(ajaxurl,i,function(){c("#inactive-widgets-control-remove").prop("disabled",!c("#wp_inactive_widgets .widget").length),c(".spinner").removeClass("is-active")})},save:function(t,s,d,n){var e,a=t.closest("div.widgets-sortables").attr("id"),i=t.find("form").serialize();t=c(t),c(".spinner",t).addClass("is-active"),e={action:"save-widget",savewidgets:c("#_wpnonce_widgets").val(),sidebar:a},s&&(e.delete_widget=1),i+="&"+c.param(e),c.post(ajaxurl,i,function(e){var i;s?(c("input.widget_number",t).val()||(i=c("input.widget-id",t).val(),c("#available-widgets").find("input.widget-id").each(function(){c(this).val()===i&&c(this).closest("div.widget").show()})),d?(n=0,t.slideUp("fast",function(){c(this).remove(),wpWidgets.saveOrder()})):(t.remove(),"wp_inactive_widgets"===a&&c("#inactive-widgets-control-remove").prop("disabled",!c("#wp_inactive_widgets .widget").length))):(c(".spinner").removeClass("is-active"),e&&2]+>/g,"").replace(//g,">");c(e).children(".widget-top").children(".widget-title").children().children(".in-widget-title").html(i)},close:function(e){e.children(".widget-inside").slideUp("fast",function(){e.attr("style","")})},addWidget:function(e){var i=e.find(".widgets-chooser-selected").data("sidebarId"),t=c("#"+i),s=c("#available-widgets").find(".widget-in-question").clone(),d=s.attr("id"),e=s.find("input.add_new").val(),n=s.find("input.multi_number").val();s.find(".widgets-chooser").remove(),"multi"===e?(s.html(s.html().replace(/<[^<>]+>/g,function(e){return e.replace(/__i__|%i%/g,n)})),s.attr("id",d.replace("__i__",n)),n++,c("#"+d).find("input.multi_number").val(n)):"single"===e&&(s.attr("id","new-"+d),c("#"+d).hide()),t.closest(".widgets-holder-wrap").removeClass("closed"),t.append(s),t.sortable("refresh"),wpWidgets.save(s,0,0,1),s.find("input.add_new").val(""),g.trigger("widget-added",[s]),e=(i=c(window).scrollTop())+c(window).height(),(d=t.offset()).bottom=d.top+t.outerHeight(),(i>d.bottom||e