mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-18 16:45:31 +01:00
7c32cbf990
See #50699. Built from https://develop.svn.wordpress.org/trunk@49325 git-svn-id: http://core.svn.wordpress.org/trunk@49086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
8.6 KiB
JavaScript
2 lines
8.6 KiB
JavaScript
/*! This file is auto-generated */
|
|
window.wp=window.wp||{},window.communityEventsData=window.communityEventsData||{},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,i=c("#"+t+" div.inside:visible").find(".widget-loading");i.length&&(n=i.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 i=c(".quick-draft-textarea-clone"),o=c("#content"),a=o.height(),s=c(window).height()-100;i.css({"font-family":o.css("font-family"),"font-size":o.css("font-size"),"line-height":o.css("line-height"),"padding-bottom":o.css("paddingBottom"),"padding-left":o.css("paddingLeft"),"padding-right":o.css("paddingRight"),"padding-top":o.css("paddingTop"),"white-space":"pre-wrap","word-wrap":"break-word",display:"none"}),o.on("focus input propertychange",function(){var e=c(this),t=e.val()+" ",n=i.css("width",e.css("width")).text(t).outerHeight()+2;o.css("overflow-y","auto"),n===a||s<=n&&s<=a||(a=s<n?s:n,o.css("overflow","hidden"),e.css("height",a+"px"))})}()},window.quickPressLoad(),c(".meta-box-sortables").sortable("option","containment","#wpwrap")}),jQuery(function(c){"use strict";var r,m=window.communityEventsData,s=wp.date.dateI18n,d=wp.date.format,u=wp.i18n.sprintf,l=wp.i18n.__,p=wp.i18n._x;r=window.wp.communityEvents={initialized:!1,model:null,init:function(){if(!r.initialized){var e=c("#community-events");c(".community-events-errors").attr("aria-hidden","true").removeClass("hide-if-js"),e.on("click",".community-events-toggle-location, .community-events-cancel",r.toggleLocationForm),e.on("submit",".community-events-form",function(e){var t=c.trim(c("#community-events-location").val());e.preventDefault(),t&&r.getEvents({location:t})}),m&&m.cache&&m.cache.location&&m.cache.events?r.renderEventsTemplate(m.cache,"app"):r.getEvents(),r.initialized=!0}},toggleLocationForm:function(e){var t=c(".community-events-toggle-location"),n=c(".community-events-cancel"),i=c(".community-events-form"),o=c();"object"==typeof e&&(o=c(e.target),e="true"==t.attr("aria-expanded")?"hide":"show"),"hide"===e?(t.attr("aria-expanded","false"),n.attr("aria-expanded","false"),i.attr("aria-hidden","true"),o.hasClass("community-events-cancel")&&t.focus()):(t.attr("aria-expanded","true"),n.attr("aria-expanded","true"),i.attr("aria-hidden","false"))},getEvents:function(t){var n,i=this,e=c(".community-events-form").children(".spinner");(t=t||{})._wpnonce=m.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),i.renderEventsTemplate(e,n)}).fail(function(){i.renderEventsTemplate({location:!1,events:[],error:!0},n)})},renderEventsTemplate:function(e,t){var n,i,o=c(".community-events-toggle-location"),a=c("#community-events-location-message"),s=c(".community-events-results");e.events=r.populateDynamicEventFields(e.events,m.time_format),i={".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?(a.text(l("Attend an upcoming event near you.")),n=e.events.length?wp.template("community-events-event-list"):wp.template("community-events-no-upcoming-events"),s.html(n(e)),i["#community-events-location-message"]=!0,i[".community-events-toggle-location"]=!0,i[".community-events-results"]=!0):e.location.description?(n=wp.template("community-events-attend-event-near"),a.html(n(e)),n=e.events.length?wp.template("community-events-event-list"):wp.template("community-events-no-upcoming-events"),s.html(n(e)),"user"===t&&wp.a11y.speak(u(l("City updated. Listing events near %s."),e.location.description),"assertive"),i["#community-events-location-message"]=!0,i[".community-events-toggle-location"]=!0,i[".community-events-results"]=!0):e.unknownCity?(n=wp.template("community-events-could-not-locate"),c(".community-events-could-not-locate").html(n(e)),wp.a11y.speak(u(l("We couldn\u2019t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland."),e.unknownCity)),i[".community-events-errors"]=!0,i[".community-events-could-not-locate"]=!0):e.error&&"user"===t?(wp.a11y.speak(l("An error occurred. Please try again.")),i[".community-events-errors"]=!0,i[".community-events-error-occurred"]=!0):(a.text(l("Enter your closest city to find nearby events.")),i["#community-events-location-message"]=!0,i[".community-events-toggle-location"]=!0),_.each(i,function(e,t){c(t).attr("aria-hidden",!e)}),o.attr("aria-expanded",i[".community-events-toggle-location"]),e.location&&(e.location.ip||e.location.latitude)?(r.toggleLocationForm("hide"),"user"===t&&o.focus()):r.toggleLocationForm("show")},populateDynamicEventFields:function(e,i){var t=JSON.parse(JSON.stringify(e));return c.each(t,function(e,t){var n=r.getTimeZone(1e3*t.start_unix_timestamp);t.user_formatted_date=r.getFormattedDate(1e3*t.start_unix_timestamp,1e3*t.end_unix_timestamp,n),t.user_formatted_time=s(i,1e3*t.start_unix_timestamp,n),t.timeZoneAbbreviation=r.getTimeZoneAbbreviation(1e3*t.start_unix_timestamp)}),t},getTimeZone:function(e){var t=Intl.DateTimeFormat().resolvedOptions().timeZone;return void 0===t&&(t=r.getFlippedTimeZoneOffset(e)),t},getFlippedTimeZoneOffset:function(e){return-1*new Date(e).getTimezoneOffset()},getTimeZoneAbbreviation:function(e){var t,n=new Date(e).toLocaleTimeString(void 0,{timeZoneName:"short"}).split(" ");if(3===n.length&&(t=n[2]),void 0===t){var i=r.getFlippedTimeZoneOffset(e),o=-1===Math.sign(i)?"":"+";t=p("GMT","Events widget offset prefix")+o+i/60}return t},getFormattedDate:function(e,t,n){var i=l("l, M j, Y"),o=l("%1$s %2$d\u2013%3$d, %4$d"),a=l("%1$s %2$d \u2013 %3$s %4$d, %5$d");return t&&d("Y-m-d",e)!==d("Y-m-d",t)?d("Y-m",e)===d("Y-m",t)?u(o,s(p("F","upcoming events month format"),e,n),s(p("j","upcoming events day format"),e,n),s(p("j","upcoming events day format"),t,n),s(p("Y","upcoming events year format"),t,n)):u(a,s(p("F","upcoming events month format"),e,n),s(p("j","upcoming events day format"),e,n),s(p("F","upcoming events month format"),t,n),s(p("j","upcoming events day format"),t,n),s(p("Y","upcoming events year format"),t,n)):s(i,e,n)}},c("#dashboard_primary").is(":visible")?r.init():c(document).on("postbox-toggled",function(e,t){var n=c(t);"dashboard_primary"===n.attr("id")&&n.is(":visible")&&r.init()})}),window.communityEventsData.l10n=window.communityEventsData.l10n||{enter_closest_city:"",error_occurred_please_try_again:"",attend_event_near_generic:"",could_not_locate_city:"",city_updated:""},window.communityEventsData.l10n=window.wp.deprecateL10nObject("communityEventsData.l10n",window.communityEventsData.l10n,"5.6.0"); |