equal
deleted
inserted
replaced
21 * |
21 * |
22 * @since 3.3.0 |
22 * @since 3.3.0 |
23 * |
23 * |
24 * @param {boolean} visible Should it be visible or not. |
24 * @param {boolean} visible Should it be visible or not. |
25 * |
25 * |
26 * @returns {void} |
26 * @return {void} |
27 */ |
27 */ |
28 updateWelcomePanel = function( visible ) { |
28 updateWelcomePanel = function( visible ) { |
29 $.post( ajaxurl, { |
29 $.post( ajaxurl, { |
30 action: 'update-welcome-panel', |
30 action: 'update-welcome-panel', |
31 visible: visible, |
31 visible: visible, |
62 * @global |
62 * @global |
63 */ |
63 */ |
64 window.ajaxWidgets = ['dashboard_primary']; |
64 window.ajaxWidgets = ['dashboard_primary']; |
65 |
65 |
66 /** |
66 /** |
67 * Triggers widget updates via AJAX. |
67 * Triggers widget updates via Ajax. |
68 * |
68 * |
69 * @since 2.7.0 |
69 * @since 2.7.0 |
70 * |
70 * |
71 * @global |
71 * @global |
72 * |
72 * |
73 * @param {string} el Optional. Widget to fetch or none to update all. |
73 * @param {string} el Optional. Widget to fetch or none to update all. |
74 * |
74 * |
75 * @returns {void} |
75 * @return {void} |
76 */ |
76 */ |
77 window.ajaxPopulateWidgets = function(el) { |
77 window.ajaxPopulateWidgets = function(el) { |
78 /** |
78 /** |
79 * Fetch the latest representation of the widget via Ajax and show it. |
79 * Fetch the latest representation of the widget via Ajax and show it. |
80 * |
80 * |
81 * @param {number} i Number of half-seconds to use as the timeout. |
81 * @param {number} i Number of half-seconds to use as the timeout. |
82 * @param {string} id ID of the element which is going to be checked for changes. |
82 * @param {string} id ID of the element which is going to be checked for changes. |
83 * |
83 * |
84 * @returns {void} |
84 * @return {void} |
85 */ |
85 */ |
86 function show(i, id) { |
86 function show(i, id) { |
87 var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading'); |
87 var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading'); |
88 // If the element is found in the dom, queue to load latest representation. |
88 // If the element is found in the dom, queue to load latest representation. |
89 if ( e.length ) { |
89 if ( e.length ) { |
101 } |
101 } |
102 |
102 |
103 // If we have received a specific element to fetch, check if it is valid. |
103 // If we have received a specific element to fetch, check if it is valid. |
104 if ( el ) { |
104 if ( el ) { |
105 el = el.toString(); |
105 el = el.toString(); |
106 // If the element is available as AJAX widget, show it. |
106 // If the element is available as Ajax widget, show it. |
107 if ( $.inArray(el, ajaxWidgets) !== -1 ) { |
107 if ( $.inArray(el, ajaxWidgets) !== -1 ) { |
108 // Show element without any delay. |
108 // Show element without any delay. |
109 show(0, el); |
109 show(0, el); |
110 } |
110 } |
111 } else { |
111 } else { |
125 * |
125 * |
126 * @since 2.7.0 |
126 * @since 2.7.0 |
127 * |
127 * |
128 * @global |
128 * @global |
129 * |
129 * |
130 * @returns {void} |
130 * @return {void} |
131 */ |
131 */ |
132 window.quickPressLoad = function() { |
132 window.quickPressLoad = function() { |
133 var act = $('#quickpost-action'), t; |
133 var act = $('#quickpost-action'), t; |
134 |
134 |
135 // Enable the submit buttons. |
135 // Enable the submit buttons. |
157 }); |
157 }); |
158 |
158 |
159 /** |
159 /** |
160 * Highlights the latest post for one second. |
160 * Highlights the latest post for one second. |
161 * |
161 * |
162 * @returns {void} |
162 * @return {void} |
163 */ |
163 */ |
164 function highlightLatestPost () { |
164 function highlightLatestPost () { |
165 var latestPost = $('.drafts ul li').first(); |
165 var latestPost = $('.drafts ul li').first(); |
166 latestPost.css('background', '#fffbe5'); |
166 latestPost.css('background', '#fffbe5'); |
167 setTimeout(function () { |
167 setTimeout(function () { |
187 /** |
187 /** |
188 * Adjust the height of the textarea based on the content. |
188 * Adjust the height of the textarea based on the content. |
189 * |
189 * |
190 * @since 3.6.0 |
190 * @since 3.6.0 |
191 * |
191 * |
192 * @returns {void} |
192 * @return {void} |
193 */ |
193 */ |
194 function autoResizeTextarea() { |
194 function autoResizeTextarea() { |
195 // When IE8 or older is used to render this document, exit. |
195 // When IE8 or older is used to render this document, exit. |
196 if ( document.documentMode && document.documentMode < 9 ) { |
196 if ( document.documentMode && document.documentMode < 9 ) { |
197 return; |
197 return; |
283 /** |
283 /** |
284 * Initializes the wp.communityEvents object. |
284 * Initializes the wp.communityEvents object. |
285 * |
285 * |
286 * @since 4.8.0 |
286 * @since 4.8.0 |
287 * |
287 * |
288 * @returns {void} |
288 * @return {void} |
289 */ |
289 */ |
290 init: function() { |
290 init: function() { |
291 if ( app.initialized ) { |
291 if ( app.initialized ) { |
292 return; |
292 return; |
293 } |
293 } |
317 $container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm ); |
317 $container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm ); |
318 |
318 |
319 /** |
319 /** |
320 * Filters events based on entered location. |
320 * Filters events based on entered location. |
321 * |
321 * |
322 * @returns {void} |
322 * @return {void} |
323 */ |
323 */ |
324 $container.on( 'submit', '.community-events-form', function( event ) { |
324 $container.on( 'submit', '.community-events-form', function( event ) { |
325 var location = $.trim( $( '#community-events-location' ).val() ); |
325 var location = $.trim( $( '#community-events-location' ).val() ); |
326 |
326 |
327 event.preventDefault(); |
327 event.preventDefault(); |
354 * @since 4.8.0 |
354 * @since 4.8.0 |
355 * |
355 * |
356 * @param {event|string} action 'show' or 'hide' to specify a state; |
356 * @param {event|string} action 'show' or 'hide' to specify a state; |
357 * or an event object to flip between states. |
357 * or an event object to flip between states. |
358 * |
358 * |
359 * @returns {void} |
359 * @return {void} |
360 */ |
360 */ |
361 toggleLocationForm: function( action ) { |
361 toggleLocationForm: function( action ) { |
362 var $toggleButton = $( '.community-events-toggle-location' ), |
362 var $toggleButton = $( '.community-events-toggle-location' ), |
363 $cancelButton = $( '.community-events-cancel' ), |
363 $cancelButton = $( '.community-events-cancel' ), |
364 $form = $( '.community-events-form' ), |
364 $form = $( '.community-events-form' ), |
399 * |
399 * |
400 * @since 4.8.0 |
400 * @since 4.8.0 |
401 * |
401 * |
402 * @param {Object} requestParams REST API Request parameters object. |
402 * @param {Object} requestParams REST API Request parameters object. |
403 * |
403 * |
404 * @returns {void} |
404 * @return {void} |
405 */ |
405 */ |
406 getEvents: function( requestParams ) { |
406 getEvents: function( requestParams ) { |
407 var initiatedBy, |
407 var initiatedBy, |
408 app = this, |
408 app = this, |
409 $spinner = $( '.community-events-form' ).children( '.spinner' ); |
409 $spinner = $( '.community-events-form' ).children( '.spinner' ); |
453 * |
453 * |
454 * @param {Object} templateParams The various parameters that will get passed to wp.template. |
454 * @param {Object} templateParams The various parameters that will get passed to wp.template. |
455 * @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user; |
455 * @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user; |
456 * 'app' to indicate it was triggered automatically by the app itself. |
456 * 'app' to indicate it was triggered automatically by the app itself. |
457 * |
457 * |
458 * @returns {void} |
458 * @return {void} |
459 */ |
459 */ |
460 renderEventsTemplate: function( templateParams, initiatedBy ) { |
460 renderEventsTemplate: function( templateParams, initiatedBy ) { |
461 var template, |
461 var template, |
462 elementVisibility, |
462 elementVisibility, |
463 l10nPlaceholder = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc. |
463 l10nPlaceholder = /%(?:\d\$)?s/g, // Match `%s`, `%1$s`, `%2$s`, etc. |