<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[42393] trunk/src/wp-admin/js/dashboard.js: Docs: Improve JS Docs for `wp-admin/js/dashboard.js`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/42393">42393</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/42393","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>atimmer</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-12-14 14:10:11 +0000 (Thu, 14 Dec 2017)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Docs: Improve JS Docs for `wp-admin/js/dashboard.js`.
Props jipmoors, andizer, ireneyoast, boblinthorst.
Fixes <a href="https://core.trac.wordpress.org/ticket/42831">#42831</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminjsdashboardjs">trunk/src/wp-admin/js/dashboard.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminjsdashboardjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/dashboard.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/dashboard.js 2017-12-13 14:09:45 UTC (rev 42392)
+++ trunk/src/wp-admin/js/dashboard.js 2017-12-14 14:10:11 UTC (rev 42393)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,11 +2,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
</span><span class="cx" style="display: block; padding: 0 10px"> window.wp = window.wp || {};
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Initializes the dashboard widget functionality.
+ *
+ * @since 2.7.0
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> jQuery(document).ready( function($) {
</span><span class="cx" style="display: block; padding: 0 10px"> var welcomePanel = $( '#welcome-panel' ),
</span><span class="cx" style="display: block; padding: 0 10px"> welcomePanelHide = $('#wp_welcome_panel-hide'),
</span><span class="cx" style="display: block; padding: 0 10px"> updateWelcomePanel;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Saves the visibility of the welcome panel.
+ *
+ * @since 3.3.0
+ *
+ * @param {boolean} visible Should it be visible or not.
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> updateWelcomePanel = function( visible ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $.post( ajaxurl, {
</span><span class="cx" style="display: block; padding: 0 10px"> action: 'update-welcome-panel',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,10 +29,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Unhide the welcome panel if the Welcome Option checkbox is checked.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) {
</span><span class="cx" style="display: block; padding: 0 10px"> welcomePanel.removeClass('hidden');
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Hide the welcome panel when the dismiss button or close button is clicked.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) {
</span><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><span class="cx" style="display: block; padding: 0 10px"> welcomePanel.addClass('hidden');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,21 +42,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $('#wp_welcome_panel-hide').prop('checked', false);
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set welcome panel visibility based on Welcome Option checkbox value.
</ins><span class="cx" style="display: block; padding: 0 10px"> welcomePanelHide.click( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> welcomePanel.toggleClass('hidden', ! this.checked );
</span><span class="cx" style="display: block; padding: 0 10px"> updateWelcomePanel( this.checked ? 1 : 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // These widgets are sometimes populated via ajax
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * These widgets can be populated via ajax.
+ *
+ * @since 2.7.0
+ *
+ * @type {string[]}
+ *
+ * @global
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> ajaxWidgets = ['dashboard_primary'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Triggers widget updates via AJAX.
+ *
+ * @since 2.7.0
+ *
+ * @global
+ *
+ * @param {string} el Optional. Widget to fetch or none to update all.
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> ajaxPopulateWidgets = function(el) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Fetch the latest representation of the widget via Ajax and show it.
+ *
+ * @param {number} i Number of half-seconds to use as the timeout.
+ * @param {string} id ID of the element which is going to be checked for changes.
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> function show(i, id) {
</span><span class="cx" style="display: block; padding: 0 10px"> var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If the element is found in the dom, queue to load latest representation.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( e.length ) {
</span><span class="cx" style="display: block; padding: 0 10px"> p = e.parent();
</span><span class="cx" style="display: block; padding: 0 10px"> setTimeout( function(){
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Request the widget content.
</ins><span class="cx" style="display: block; padding: 0 10px"> p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id + '&pagenow=' + pagenow, '', function() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Hide the parent and slide it out for visual fancyness.
</ins><span class="cx" style="display: block; padding: 0 10px"> p.hide().slideDown('normal', function(){
</span><span class="cx" style="display: block; padding: 0 10px"> $(this).css('display', '');
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,39 +96,67 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If we have received a specific element to fetch, check if it is valid.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( el ) {
</span><span class="cx" style="display: block; padding: 0 10px"> el = el.toString();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If the element is available as AJAX widget, show it.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $.inArray(el, ajaxWidgets) !== -1 ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Show element without any delay.
</ins><span class="cx" style="display: block; padding: 0 10px"> show(0, el);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Walk through all ajaxWidgets, loading them after each other.
</ins><span class="cx" style="display: block; padding: 0 10px"> $.each( ajaxWidgets, show );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Initially populate ajax widgets.
</ins><span class="cx" style="display: block; padding: 0 10px"> ajaxPopulateWidgets();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Register ajax widgets as postbox toggles.
</ins><span class="cx" style="display: block; padding: 0 10px"> postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* QuickPress */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Control the Quick Press (Quick Draft) widget.
+ *
+ * @since 2.7.0
+ *
+ * @global
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> quickPressLoad = function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var act = $('#quickpost-action'), t;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Enable the submit buttons.
</ins><span class="cx" style="display: block; padding: 0 10px"> $( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> t = $('#quick-press').submit( function( e ) {
</span><span class="cx" style="display: block; padding: 0 10px"> e.preventDefault();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Show a spinner.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#dashboard_quick_press #publishing-action .spinner').show();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Disable the submit button to prevent duplicate submissions.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Post the entered data to save it.
</ins><span class="cx" style="display: block; padding: 0 10px"> $.post( t.attr( 'action' ), t.serializeArray(), function( data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Replace the form, and prepend the published post.
</span><span class="cx" style="display: block; padding: 0 10px"> $('#dashboard_quick_press .inside').html( data );
</span><span class="cx" style="display: block; padding: 0 10px"> $('#quick-press').removeClass('initial-form');
</span><span class="cx" style="display: block; padding: 0 10px"> quickPressLoad();
</span><span class="cx" style="display: block; padding: 0 10px"> highlightLatestPost();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Focus the title to allow for quickly drafting another post.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#title').focus();
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Highlights the latest post for one second.
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> function highlightLatestPost () {
</span><span class="cx" style="display: block; padding: 0 10px"> var latestPost = $('.drafts ul li').first();
</span><span class="cx" style="display: block; padding: 0 10px"> latestPost.css('background', '#fffbe5');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,8 +166,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Change the QuickPost action to the publish value.
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Adds accessibility context to inputs.
+ *
+ * Use the 'screen-reader-text' class to hide the label when entering a value.
+ * Apply it when the input is not empty or the input has focus.
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $('#title, #tags-input, #content').each( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var input = $(this), prompt = $('#' + this.id + '-prompt-text');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -124,9 +208,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px"> quickPressLoad();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Enable the dragging functionality of the widgets.
</ins><span class="cx" style="display: block; padding: 0 10px"> $( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Adjust the height of the textarea based on the content.
+ *
+ * @since 3.6.0
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> function autoResizeTextarea() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // When IE8 or older is used to render this document, exit.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( document.documentMode && document.documentMode < 9 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,12 +230,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var clone = $('.quick-draft-textarea-clone'),
</span><span class="cx" style="display: block; padding: 0 10px"> editor = $('#content'),
</span><span class="cx" style="display: block; padding: 0 10px"> editorHeight = editor.height(),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // 100px roughly accounts for browser chrome and allows the
- // save draft button to show on-screen at the same time.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * 100px roughly accounts for browser chrome and allows the
+ * save draft button to show on-screen at the same time.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> editorMaxHeight = $(window).height() - 100;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Match up textarea and clone div as much as possible.
- // Padding cannot be reliably retrieved using shorthand in all browsers.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Match up textarea and clone div as much as possible.
+ * Padding cannot be reliably retrieved using shorthand in all browsers.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> clone.css({
</span><span class="cx" style="display: block; padding: 0 10px"> 'font-family': editor.css('font-family'),
</span><span class="cx" style="display: block; padding: 0 10px"> 'font-size': editor.css('font-size'),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -156,31 +253,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'display': 'none'
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // propertychange is for IE < 9
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The 'propertychange' is used in IE < 9.
</ins><span class="cx" style="display: block; padding: 0 10px"> editor.on('focus input propertychange', function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var $this = $(this),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // is to ensure that the height of a final trailing newline is included.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add a non-breaking space to ensure that the height of a trailing newline is
+ // included.
</ins><span class="cx" style="display: block; padding: 0 10px"> textareaContent = $this.val() + ' ',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // 2px is for border-top & border-bottom
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Add 2px to compensate for border-top & border-bottom.
</ins><span class="cx" style="display: block; padding: 0 10px"> cloneHeight = clone.css('width', $this.css('width')).text(textareaContent).outerHeight() + 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Default to having scrollbars
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Default to show a vertical scrollbar, if needed.
</ins><span class="cx" style="display: block; padding: 0 10px"> editor.css('overflow-y', 'auto');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Only change the height if it has indeed changed and both heights are below the max.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Only change the height if it has changed and both heights are below the max.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( cloneHeight === editorHeight || ( cloneHeight >= editorMaxHeight && editorHeight >= editorMaxHeight ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // 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.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Don't allow editor to exceed the height of the window.
+ * This is also bound in CSS to a max-height of 1300px to be extra safe.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( cloneHeight > editorMaxHeight ) {
</span><span class="cx" style="display: block; padding: 0 10px"> editorHeight = editorMaxHeight;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> editorHeight = cloneHeight;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // No scrollbars as we change height, not for IE < 9
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Disable scrollbars because we adjust the height to the content.
</ins><span class="cx" style="display: block; padding: 0 10px"> editor.css('overflow', 'hidden');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this.css('height', editorHeight + 'px');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -195,7 +295,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var communityEventsData = window.communityEventsData || {},
</span><span class="cx" style="display: block; padding: 0 10px"> app;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- app = window.wp.communityEvents = {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Global Community Events namespace.
+ *
+ * @since 4.8.0
+ *
+ * @memberOf wp
+ * @namespace wp.communityEvents
+ */
+ app = window.wp.communityEvents = /** @lends wp.communityEvents */{
</ins><span class="cx" style="display: block; padding: 0 10px"> initialized: false,
</span><span class="cx" style="display: block; padding: 0 10px"> model: null,
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -203,6 +311,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Initializes the wp.communityEvents object.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.8.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @returns {void}
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> init: function() {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( app.initialized ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -233,6 +343,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters events based on entered location.
+ *
+ * @returns {void}
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> $container.on( 'submit', '.community-events-form', function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var location = $.trim( $( '#community-events-location' ).val() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -267,6 +382,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {event|string} action 'show' or 'hide' to specify a state;
</span><span class="cx" style="display: block; padding: 0 10px"> * or an event object to flip between states.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @returns {void}
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> toggleLocationForm: function( action ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var $toggleButton = $( '.community-events-toggle-location' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -309,7 +426,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.8.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param {object} requestParams
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Object} requestParams REST API Request parameters object.
+ *
+ * @returns {void}
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> getEvents: function( requestParams ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var initiatedBy,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -362,6 +481,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {Object} templateParams The various parameters that will get passed to wp.template.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user;
</span><span class="cx" style="display: block; padding: 0 10px"> * 'app' to indicate it was triggered automatically by the app itself.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @returns {void}
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> renderEventsTemplate: function( templateParams, initiatedBy ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var template,
</span></span></pre>
</div>
</div>
</body>
</html>