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

1 line
3.1 KiB
JavaScript
Raw Normal View History

var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(o){var t,s=o("#welcome-panel"),e=o("#wp_welcome_panel-hide");t=function(e){o.post(ajaxurl,{action:"update-welcome-panel",visible:e,welcomepanelnonce:o("#welcomepanelnonce").val()})},s.hasClass("hidden")&&e.prop("checked")&&s.removeClass("hidden"),o(".welcome-panel-close, .welcome-panel-dismiss a",s).click(function(e){e.preventDefault(),s.addClass("hidden"),t(0),o("#wp_welcome_panel-hide").prop("checked",!1)}),e.click(function(){s.toggleClass("hidden",!this.checked),t(this.checked?1:0)}),ajaxWidgets=["dashboard_primary"],(ajaxPopulateWidgets=function(e){function t(e,t){var s,i=o("#"+t+" div.inside:visible").find(".widget-loading");i.length&&(s=i.parent(),setTimeout(function(){s.load(ajaxurl+"?action=dashboard-widgets&widget="+t+"&pagenow="+pagenow,"",function(){s.hide().slideDown("normal",function(){o(this).css("display","")})})},500*e))}e?(e=e.toString(),-1!==o.inArray(e,ajaxWidgets)&&t(0,e)):o.each(ajaxWidgets,t)})(),postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets}),(quickPressLoad=function(){var t,s,i,n,a,e=o("#quickpost-action");o('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!1),t=o("#quick-press").submit(function(e){e.preventDefault(),o("#dashboard_quick_press #publishing-action .spinner").show(),o('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",!0),o.post(t.attr("action"),t.serializeArray(),function(e){var t;o("#dashboard_quick_press .inside").html(e),o("#quick-press").removeClass("initial-form"),quickPressLoad(),(t=o(".drafts ul li").first()).css("background","#fffbe5"),setTimeout(function(){t.css("background","none")},1e3),o("#title").focus()})}),o("#publish").click(function(){e.val("post-quickpress-publish")}),o("#title, #tags-input, #content").each(function(){var e=o(this),t=o("#"+this.id+"-prompt-text");""===this.value&&t.removeClass("screen-reader-text"),t.click(function(){o(this).addClass("screen-reader-text"),e.focus()}),e.blur(function(){""===this.value&&t.removeClass("screen-reader-text")}),e.focus(function(){t.addClass("screen-reader-text")})}),o("#quick-press").on("click focusin",function(){wpActiveEditor="content"}),document.documentMode&&document.documentMode<9||(o("body").append('<div class="quick-draft-textarea-clone" style="display: none;"></div>'),s=o(".quick-draft-textarea-clone"),i=o("#content"),n=i.height(),a=o(window).height()-100,s.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=o(this),t=e.val()+"&nbsp;",t=s.css("width",e.css("width")).text(t).outerHeight()+2;i.css("overflow-y","auto"),t===n||a<=t&&a<=n||(n=a<t?a:t,i.css("overflow","hidden"),e.css("height",n+"px"))}))})(),o(".meta-box-sortables").sortable("option","containment","#wpwrap")});