2018-10-10 00:11:25 -04:00
|
|
|
var wpWidgets;!function(a){var b=a(document);wpWidgets={hoveredSidebar:null,l10n:{save:"{save}",saved:"{saved}",saveAlert:"{saveAlert}"},dirtyWidgets:{},init:function(){var c,d,e=this,f=a(".widgets-chooser"),g=f.find(".widgets-chooser-sidebars"),h=a("div.widgets-sortables"),i=!("undefined"==typeof isRtl||!isRtl);a("#widgets-right .sidebar-name").click(function(){var c=a(this),d=c.closest(".widgets-holder-wrap "),e=c.find(".handlediv");d.hasClass("closed")?(d.removeClass("closed"),e.attr("aria-expanded","true"),c.parent().sortable("refresh")):(d.addClass("closed"),e.attr("aria-expanded","false")),b.triggerHandler("wp-pin-menu")}).find(".handlediv").each(function(b){0!==b&&a(this).attr("aria-expanded","false")}),a(window).on("beforeunload.widgets",function(b){var c,d=[];if(a.each(e.dirtyWidgets,function(a,b){b&&d.push(a)}),0!==d.length)return c=a("#widgets-right").find(".widget").filter(function(){return-1!==d.indexOf(a(this).prop("id").replace(/^widget-\d+_/,""))}),c.each(function(){a(this).hasClass("open")||a(this).find(".widget-title-action:first").click()}),c.first().each(function(){this.scrollIntoViewIfNeeded?this.scrollIntoViewIfNeeded():this.scrollIntoView(),a(this).find(".widget-inside :tabbable:first").focus()}),b.returnValue=wpWidgets.l10n.saveAlert,b.returnValue}),a("#widgets-left .sidebar-name").click(function(){var c=a(this).closest(".widgets-holder-wrap");c.toggleClass("closed").find(".handlediv").attr("aria-expanded",!c.hasClass("closed")),b.triggerHandler("wp-pin-menu")}),a(document.body).bind("click.widgets-toggle",function(b){var c,d,f,g,h,j,k,l=a(b.target),m={"z-index":100},n=l.closest(".widget").find(".widget-top button.widget-action");l.parents(".widget-top").length&&!l.parents("#available-widgets").length?(c=l.closest("div.widget"),d=c.children(".widget-inside"),f=parseInt(c.find("input.widget-width").val(),10),g=c.parent().width(),k=d.find(".widget-id").val(),c.data("dirty-state-initialized")||(j=d.find(".widget-control-save"),j.prop("disabled",!0).val(wpWidgets.l10n.saved),d.on("input change",function(){e.dirtyWidgets[k]=!0,c.addClass("widget-dirty"),j.prop("disabled",!1).val(wpWidgets.l10n.save)}),c.data("dirty-state-initialized",!0)),d.is(":hidden")?(f>250&&f+30>g&&c.closest("div.widgets-sortables").length&&(h=c.closest("div.widget-liquid-right").length?i?"margin-right":"margin-left":i?"margin-left":"margin-right",m[h]=g-(f+30)+"px",c.css(m)),n.attr("aria-expanded","true"),d.slideDown("fast",function(){c.addClass("open")})):(n.attr("aria-expanded","false"),d.slideUp("fast",function(){c.attr("style",""),c.removeClass("open")})),b.preventDefault()):l.hasClass("widget-control-save")?(wpWidgets.save(l.closest("div.widget"),0,1,0),b.preventDefault()):l.hasClass("widget-control-remove")?(wpWidgets.save(l.closest("div.widget"),1,1,0),b.preventDefault()):l.hasClass("widget-control-close")?(c=l.closest("div.widget"),c.removeClass("open"),n.attr("aria-expanded","false"),wpWidgets.close(c),b.preventDefault()):"inactive-widgets-control-remove"===l.attr("id")&&(wpWidgets.removeInactiveWidgets(),b.preventDefault())}),h.children(".widget").each(function(){var b=a(this);wpWidgets.appendTitle(this),b.find("p.widget-error").length&&b.find(".widget-action").trigger("click").attr("aria-expanded","true")}),a("#widget-list").children(".widget").draggable({connectToSortable:"div.widgets-sortables",handle:"> .widget-top > .widget-title",distance:2,helper:"clone",zIndex:100,containment:"#wpwrap",refreshPositions:!0,start:function(b,c){var f=a(this).find(".widgets-chooser");c.helper.find("div.widget-description").hide(),d=this.id,f.length&&(a("#wpbody-content").append(f.hide()),c.helper.find(".widgets-chooser").remove(),e.clearWidgetSelection())},stop:function(){c&&a(c).hide(),c=""}}),h.droppable({tolerance:"intersect",over:function(b){var c=a(b.target).parent();wpWidgets.hoveredSidebar&&!c.is(wpWidgets.hoveredSidebar)&&wpWidgets.closeSidebar(b),c.hasClass("closed")&&(wpWidgets.hoveredSidebar=c,c.removeClass("closed").find(".handlediv").attr("aria-expanded","true")),a(this).sortable("refresh")},out:function(a){wpWidgets.h
|