+ $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
+
+ $('#title, #tags-input, #content').each( function() {
+ var input = $(this), prompt = $('#' + this.id + '-prompt-text');
+
+ if ( '' === this.value ) {
+ prompt.removeClass('screen-reader-text');
+ }
+
+ prompt.click( function() {
+ $(this).addClass('screen-reader-text');
+ input.focus();
+ });
+
+ input.blur( function() {
+ if ( '' === this.value ) {
+ prompt.removeClass('screen-reader-text');
+ }
+ });
+
+ input.focus( function() {
+ prompt.addClass('screen-reader-text');
+ });
+ });
+
+ $('#quick-press').on( 'click focusin', function() {
+ wpActiveEditor = 'content';
+ });
+
+ autoResizeTextarea();
+ };
+ quickPressLoad();
+
+ $( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' );
+
+ function autoResizeTextarea() {
+ if ( document.documentMode && document.documentMode < 9 ) {
+ return;
+ }
+
+ // Add a hidden div. We'll copy over the text from the textarea to measure its height.
+ $('body').append( '<div class="quick-draft-textarea-clone" style="display: none;"></div>' );
+
+ var clone = $('.quick-draft-textarea-clone'),
+ editor = $('#content'),
+ editorHeight = editor.height(),
+ // 100px roughly accounts for browser chrome and allows the
+ // save draft button to show on-screen at the same time.
+ editorMaxHeight = $(window).height() - 100;
+
+ // Match up textarea and clone div as much as possible.
+ // Padding cannot be reliably retrieved using shorthand in all browsers.
+ clone.css({
+ 'font-family': editor.css('font-family'),
+ 'font-size': editor.css('font-size'),
+ 'line-height': editor.css('line-height'),
+ 'padding-bottom': editor.css('paddingBottom'),
+ 'padding-left': editor.css('paddingLeft'),
+ 'padding-right': editor.css('paddingRight'),
+ 'padding-top': editor.css('paddingTop'),
+ 'white-space': 'pre-wrap',
+ 'word-wrap': 'break-word',
+ 'display': 'none'
+ });
+
+ // propertychange is for IE < 9
+ editor.on('focus input propertychange', function() {
+ var $this = $(this),
+ // is to ensure that the height of a final trailing newline is included.
+ textareaContent = $this.val() + ' ',
+ // 2px is for border-top & border-bottom
+ cloneHeight = clone.css('width', $this.css('width')).text(textareaContent).outerHeight() + 2;
+
+ // Default to having scrollbars
+ editor.css('overflow-y', 'auto');
+
+ // Only change the height if it has indeed changed and both heights are below the max.
+ if ( cloneHeight === editorHeight || ( cloneHeight >= editorMaxHeight && editorHeight >= editorMaxHeight ) ) {
+ return;
+ }
+
+ // Don't allow editor to exceed height of window.
+ // This is also bound in CSS to a max-height of 1300px to be extra safe.
+ if ( cloneHeight > editorMaxHeight ) {
+ editorHeight = editorMaxHeight;
+ } else {
+ editorHeight = cloneHeight;
+ }
+
+ // No scrollbars as we change height, not for IE < 9
+ editor.css('overflow', 'hidden');