WordPress/wp-admin/js/dashboard.min.js

2 lines
6.5 KiB
JavaScript

/*! This file is auto-generated */
window.wp=window.wp||{},jQuery(document).ready(function(c){var t,n=c("#welcome-panel"),e=c("#wp_welcome_panel-hide");t=function(e){c.post(ajaxurl,{action:"update-welcome-panel",visible:e,welcomepanelnonce:c("#welcomepanelnonce").val()})},n.hasClass("hidden")&&e.prop("checked")&&n.removeClass("hidden"),c(".welcome-panel-close, .welcome-panel-dismiss a",n).click(function(e){e.preventDefault(),n.addClass("hidden"),t(0),c("#wp_welcome_panel-hide").prop("checked",!1)}),e.click(function(){n.toggleClass("hidden",!this.checked),t(this.checked?1:0)}),window.ajaxWidgets=["dashboard_primary"],window.ajaxPopulateWidgets=function(e){function t(e,t){var n,o=c("#"+t+" div.inside:visible").find(".widget-loading");o.length&&(n=o.parent(),setTimeout(function(){n.load(ajaxurl+"?action=dashboard-widgets&widget="+t+"&pagenow="+pagenow,"",function(){n.hide().slideDown("normal",function(){c(this).css("display","")})})},500*e))}e?(e=e.toString(),-1!==c.inArray(e,ajaxWidgets)&&t(0,e)):c.each(ajaxWidgets,t)},ajaxPopulateWidgets(),postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets}),window.quickPressLoad=function(){var t,e=c("#quickpost-action");c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!1),t=c("#quick-press").submit(function(e){e.preventDefault(),c("#dashboard_quick_press #publishing-action .spinner").show(),c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!0),c.post(t.attr("action"),t.serializeArray(),function(e){c("#dashboard_quick_press .inside").html(e),c("#quick-press").removeClass("initial-form"),quickPressLoad(),function(){var e=c(".drafts ul li").first();e.css("background","#fffbe5"),setTimeout(function(){e.css("background","none")},1e3)}(),c("#title").focus()})}),c("#publish").click(function(){e.val("post-quickpress-publish")}),c("#quick-press").on("click focusin",function(){wpActiveEditor="content"}),function(){if(document.documentMode&&document.documentMode<9)return;c("body").append('<div class="quick-draft-textarea-clone" style="display: none;"></div>');var o=c(".quick-draft-textarea-clone"),i=c("#content"),a=i.height(),s=c(window).height()-100;o.css({"font-family":i.css("font-family"),"font-size":i.css("font-size"),"line-height":i.css("line-height"),"padding-bottom":i.css("paddingBottom"),"padding-left":i.css("paddingLeft"),"padding-right":i.css("paddingRight"),"padding-top":i.css("paddingTop"),"white-space":"pre-wrap","word-wrap":"break-word",display:"none"}),i.on("focus input propertychange",function(){var e=c(this),t=e.val()+"&nbsp;",n=o.css("width",e.css("width")).text(t).outerHeight()+2;i.css("overflow-y","auto"),n===a||s<=n&&s<=a||(a=s<n?s:n,i.css("overflow","hidden"),e.css("height",a+"px"))})}()},window.quickPressLoad(),c(".meta-box-sortables").sortable("option","containment","#wpwrap")}),jQuery(function(r){"use strict";var l,d=window.communityEventsData||{};l=window.wp.communityEvents={initialized:!1,model:null,init:function(){if(!l.initialized){var e=r("#community-events");r(".community-events-errors").attr("aria-hidden","true").removeClass("hide-if-js"),e.on("click",".community-events-toggle-location, .community-events-cancel",l.toggleLocationForm),e.on("submit",".community-events-form",function(e){var t=r.trim(r("#community-events-location").val());e.preventDefault(),t&&l.getEvents({location:t})}),d&&d.cache&&d.cache.location&&d.cache.events?l.renderEventsTemplate(d.cache,"app"):l.getEvents(),l.initialized=!0}},toggleLocationForm:function(e){var t=r(".community-events-toggle-location"),n=r(".community-events-cancel"),o=r(".community-events-form"),i=r();"object"==typeof e&&(i=r(e.target),e="true"==t.attr("aria-expanded")?"hide":"show"),"hide"===e?(t.attr("aria-expanded","false"),n.attr("aria-expanded","false"),o.attr("aria-hidden","true"),i.hasClass("community-events-cancel")&&t.focus()):(t.attr("aria-expanded","true"),n.attr("aria-expanded","true"),o.attr("aria-hidden","false"))},getEvents:function(t){var n,o=this,e=r(".community-events-form").children(".spinner");(t=t||{})._wpnonce=d.nonce,t.timezone=window.Intl?window.Intl.DateTimeFormat().resolvedOptions().timeZone:"",n=t.location?"user":"app",e.addClass("is-active"),wp.ajax.post("get-community-events",t).always(function(){e.removeClass("is-active")}).done(function(e){"no_location_available"===e.error&&(t.location?e.unknownCity=t.location:delete e.error),o.renderEventsTemplate(e,n)}).fail(function(){o.renderEventsTemplate({location:!1,error:!0},n)})},renderEventsTemplate:function(e,t){var n,o,i=/%(?:\d\$)?s/g,a=r(".community-events-toggle-location"),s=r("#community-events-location-message"),c=r(".community-events-results");o={".community-events":!0,".community-events-loading":!1,".community-events-errors":!1,".community-events-error-occurred":!1,".community-events-could-not-locate":!1,"#community-events-location-message":!1,".community-events-toggle-location":!1,".community-events-results":!1},e.location.ip?(s.text(d.l10n.attend_event_near_generic),n=e.events.length?wp.template("community-events-event-list"):wp.template("community-events-no-upcoming-events"),c.html(n(e)),o["#community-events-location-message"]=!0,o[".community-events-toggle-location"]=!0,o[".community-events-results"]=!0):e.location.description?(n=wp.template("community-events-attend-event-near"),s.html(n(e)),n=e.events.length?wp.template("community-events-event-list"):wp.template("community-events-no-upcoming-events"),c.html(n(e)),"user"===t&&wp.a11y.speak(d.l10n.city_updated.replace(i,e.location.description),"assertive"),o["#community-events-location-message"]=!0,o[".community-events-toggle-location"]=!0,o[".community-events-results"]=!0):e.unknownCity?(n=wp.template("community-events-could-not-locate"),r(".community-events-could-not-locate").html(n(e)),wp.a11y.speak(d.l10n.could_not_locate_city.replace(i,e.unknownCity)),o[".community-events-errors"]=!0,o[".community-events-could-not-locate"]=!0):e.error&&"user"===t?(wp.a11y.speak(d.l10n.error_occurred_please_try_again),o[".community-events-errors"]=!0,o[".community-events-error-occurred"]=!0):(s.text(d.l10n.enter_closest_city),o["#community-events-location-message"]=!0,o[".community-events-toggle-location"]=!0),_.each(o,function(e,t){r(t).attr("aria-hidden",!e)}),a.attr("aria-expanded",o[".community-events-toggle-location"]),e.location&&(e.location.ip||e.location.latitude)?(l.toggleLocationForm("hide"),"user"===t&&a.focus()):l.toggleLocationForm("show")}},r("#dashboard_primary").is(":visible")?l.init():r(document).on("postbox-toggled",function(e,t){var n=r(t);"dashboard_primary"===n.attr("id")&&n.is(":visible")&&l.init()})});