Edit File by line
/home/barbar84/www/wp-admin/js
File: dashboard.js
/**
[0] Fix | Delete
* @output wp-admin/js/dashboard.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true, ajaxWidgets */
[4] Fix | Delete
/* global ajaxPopulateWidgets, quickPressLoad, */
[5] Fix | Delete
window.wp = window.wp || {};
[6] Fix | Delete
window.communityEventsData = window.communityEventsData || {};
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Initializes the dashboard widget functionality.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 2.7.0
[12] Fix | Delete
*/
[13] Fix | Delete
jQuery(document).ready( function($) {
[14] Fix | Delete
var welcomePanel = $( '#welcome-panel' ),
[15] Fix | Delete
welcomePanelHide = $('#wp_welcome_panel-hide'),
[16] Fix | Delete
updateWelcomePanel;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Saves the visibility of the welcome panel.
[20] Fix | Delete
*
[21] Fix | Delete
* @since 3.3.0
[22] Fix | Delete
*
[23] Fix | Delete
* @param {boolean} visible Should it be visible or not.
[24] Fix | Delete
*
[25] Fix | Delete
* @return {void}
[26] Fix | Delete
*/
[27] Fix | Delete
updateWelcomePanel = function( visible ) {
[28] Fix | Delete
$.post( ajaxurl, {
[29] Fix | Delete
action: 'update-welcome-panel',
[30] Fix | Delete
visible: visible,
[31] Fix | Delete
welcomepanelnonce: $( '#welcomepanelnonce' ).val()
[32] Fix | Delete
});
[33] Fix | Delete
};
[34] Fix | Delete
[35] Fix | Delete
// Unhide the welcome panel if the Welcome Option checkbox is checked.
[36] Fix | Delete
if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) {
[37] Fix | Delete
welcomePanel.removeClass('hidden');
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
// Hide the welcome panel when the dismiss button or close button is clicked.
[41] Fix | Delete
$('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).on( 'click', function(e) {
[42] Fix | Delete
e.preventDefault();
[43] Fix | Delete
welcomePanel.addClass('hidden');
[44] Fix | Delete
updateWelcomePanel( 0 );
[45] Fix | Delete
$('#wp_welcome_panel-hide').prop('checked', false);
[46] Fix | Delete
});
[47] Fix | Delete
[48] Fix | Delete
// Set welcome panel visibility based on Welcome Option checkbox value.
[49] Fix | Delete
welcomePanelHide.on( 'click', function() {
[50] Fix | Delete
welcomePanel.toggleClass('hidden', ! this.checked );
[51] Fix | Delete
updateWelcomePanel( this.checked ? 1 : 0 );
[52] Fix | Delete
});
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* These widgets can be populated via ajax.
[56] Fix | Delete
*
[57] Fix | Delete
* @since 2.7.0
[58] Fix | Delete
*
[59] Fix | Delete
* @type {string[]}
[60] Fix | Delete
*
[61] Fix | Delete
* @global
[62] Fix | Delete
*/
[63] Fix | Delete
window.ajaxWidgets = ['dashboard_primary'];
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Triggers widget updates via Ajax.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 2.7.0
[69] Fix | Delete
*
[70] Fix | Delete
* @global
[71] Fix | Delete
*
[72] Fix | Delete
* @param {string} el Optional. Widget to fetch or none to update all.
[73] Fix | Delete
*
[74] Fix | Delete
* @return {void}
[75] Fix | Delete
*/
[76] Fix | Delete
window.ajaxPopulateWidgets = function(el) {
[77] Fix | Delete
/**
[78] Fix | Delete
* Fetch the latest representation of the widget via Ajax and show it.
[79] Fix | Delete
*
[80] Fix | Delete
* @param {number} i Number of half-seconds to use as the timeout.
[81] Fix | Delete
* @param {string} id ID of the element which is going to be checked for changes.
[82] Fix | Delete
*
[83] Fix | Delete
* @return {void}
[84] Fix | Delete
*/
[85] Fix | Delete
function show(i, id) {
[86] Fix | Delete
var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
[87] Fix | Delete
// If the element is found in the dom, queue to load latest representation.
[88] Fix | Delete
if ( e.length ) {
[89] Fix | Delete
p = e.parent();
[90] Fix | Delete
setTimeout( function(){
[91] Fix | Delete
// Request the widget content.
[92] Fix | Delete
p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id + '&pagenow=' + pagenow, '', function() {
[93] Fix | Delete
// Hide the parent and slide it out for visual fancyness.
[94] Fix | Delete
p.hide().slideDown('normal', function(){
[95] Fix | Delete
$(this).css('display', '');
[96] Fix | Delete
});
[97] Fix | Delete
});
[98] Fix | Delete
}, i * 500 );
[99] Fix | Delete
}
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
// If we have received a specific element to fetch, check if it is valid.
[103] Fix | Delete
if ( el ) {
[104] Fix | Delete
el = el.toString();
[105] Fix | Delete
// If the element is available as Ajax widget, show it.
[106] Fix | Delete
if ( $.inArray(el, ajaxWidgets) !== -1 ) {
[107] Fix | Delete
// Show element without any delay.
[108] Fix | Delete
show(0, el);
[109] Fix | Delete
}
[110] Fix | Delete
} else {
[111] Fix | Delete
// Walk through all ajaxWidgets, loading them after each other.
[112] Fix | Delete
$.each( ajaxWidgets, show );
[113] Fix | Delete
}
[114] Fix | Delete
};
[115] Fix | Delete
[116] Fix | Delete
// Initially populate ajax widgets.
[117] Fix | Delete
ajaxPopulateWidgets();
[118] Fix | Delete
[119] Fix | Delete
// Register ajax widgets as postbox toggles.
[120] Fix | Delete
postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Control the Quick Press (Quick Draft) widget.
[124] Fix | Delete
*
[125] Fix | Delete
* @since 2.7.0
[126] Fix | Delete
*
[127] Fix | Delete
* @global
[128] Fix | Delete
*
[129] Fix | Delete
* @return {void}
[130] Fix | Delete
*/
[131] Fix | Delete
window.quickPressLoad = function() {
[132] Fix | Delete
var act = $('#quickpost-action'), t;
[133] Fix | Delete
[134] Fix | Delete
// Enable the submit buttons.
[135] Fix | Delete
$( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false );
[136] Fix | Delete
[137] Fix | Delete
t = $('#quick-press').on( 'submit', function( e ) {
[138] Fix | Delete
e.preventDefault();
[139] Fix | Delete
[140] Fix | Delete
// Show a spinner.
[141] Fix | Delete
$('#dashboard_quick_press #publishing-action .spinner').show();
[142] Fix | Delete
[143] Fix | Delete
// Disable the submit button to prevent duplicate submissions.
[144] Fix | Delete
$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
[145] Fix | Delete
[146] Fix | Delete
// Post the entered data to save it.
[147] Fix | Delete
$.post( t.attr( 'action' ), t.serializeArray(), function( data ) {
[148] Fix | Delete
// Replace the form, and prepend the published post.
[149] Fix | Delete
$('#dashboard_quick_press .inside').html( data );
[150] Fix | Delete
$('#quick-press').removeClass('initial-form');
[151] Fix | Delete
quickPressLoad();
[152] Fix | Delete
highlightLatestPost();
[153] Fix | Delete
[154] Fix | Delete
// Focus the title to allow for quickly drafting another post.
[155] Fix | Delete
$('#title').trigger( 'focus' );
[156] Fix | Delete
});
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Highlights the latest post for one second.
[160] Fix | Delete
*
[161] Fix | Delete
* @return {void}
[162] Fix | Delete
*/
[163] Fix | Delete
function highlightLatestPost () {
[164] Fix | Delete
var latestPost = $('.drafts ul li').first();
[165] Fix | Delete
latestPost.css('background', '#fffbe5');
[166] Fix | Delete
setTimeout(function () {
[167] Fix | Delete
latestPost.css('background', 'none');
[168] Fix | Delete
}, 1000);
[169] Fix | Delete
}
[170] Fix | Delete
} );
[171] Fix | Delete
[172] Fix | Delete
// Change the QuickPost action to the publish value.
[173] Fix | Delete
$('#publish').on( 'click', function() { act.val( 'post-quickpress-publish' ); } );
[174] Fix | Delete
[175] Fix | Delete
$('#quick-press').on( 'click focusin', function() {
[176] Fix | Delete
wpActiveEditor = 'content';
[177] Fix | Delete
});
[178] Fix | Delete
[179] Fix | Delete
autoResizeTextarea();
[180] Fix | Delete
};
[181] Fix | Delete
window.quickPressLoad();
[182] Fix | Delete
[183] Fix | Delete
// Enable the dragging functionality of the widgets.
[184] Fix | Delete
$( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' );
[185] Fix | Delete
[186] Fix | Delete
/**
[187] Fix | Delete
* Adjust the height of the textarea based on the content.
[188] Fix | Delete
*
[189] Fix | Delete
* @since 3.6.0
[190] Fix | Delete
*
[191] Fix | Delete
* @return {void}
[192] Fix | Delete
*/
[193] Fix | Delete
function autoResizeTextarea() {
[194] Fix | Delete
// When IE8 or older is used to render this document, exit.
[195] Fix | Delete
if ( document.documentMode && document.documentMode < 9 ) {
[196] Fix | Delete
return;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
// Add a hidden div. We'll copy over the text from the textarea to measure its height.
[200] Fix | Delete
$('body').append( '<div class="quick-draft-textarea-clone" style="display: none;"></div>' );
[201] Fix | Delete
[202] Fix | Delete
var clone = $('.quick-draft-textarea-clone'),
[203] Fix | Delete
editor = $('#content'),
[204] Fix | Delete
editorHeight = editor.height(),
[205] Fix | Delete
/*
[206] Fix | Delete
* 100px roughly accounts for browser chrome and allows the
[207] Fix | Delete
* save draft button to show on-screen at the same time.
[208] Fix | Delete
*/
[209] Fix | Delete
editorMaxHeight = $(window).height() - 100;
[210] Fix | Delete
[211] Fix | Delete
/*
[212] Fix | Delete
* Match up textarea and clone div as much as possible.
[213] Fix | Delete
* Padding cannot be reliably retrieved using shorthand in all browsers.
[214] Fix | Delete
*/
[215] Fix | Delete
clone.css({
[216] Fix | Delete
'font-family': editor.css('font-family'),
[217] Fix | Delete
'font-size': editor.css('font-size'),
[218] Fix | Delete
'line-height': editor.css('line-height'),
[219] Fix | Delete
'padding-bottom': editor.css('paddingBottom'),
[220] Fix | Delete
'padding-left': editor.css('paddingLeft'),
[221] Fix | Delete
'padding-right': editor.css('paddingRight'),
[222] Fix | Delete
'padding-top': editor.css('paddingTop'),
[223] Fix | Delete
'white-space': 'pre-wrap',
[224] Fix | Delete
'word-wrap': 'break-word',
[225] Fix | Delete
'display': 'none'
[226] Fix | Delete
});
[227] Fix | Delete
[228] Fix | Delete
// The 'propertychange' is used in IE < 9.
[229] Fix | Delete
editor.on('focus input propertychange', function() {
[230] Fix | Delete
var $this = $(this),
[231] Fix | Delete
// Add a non-breaking space to ensure that the height of a trailing newline is
[232] Fix | Delete
// included.
[233] Fix | Delete
textareaContent = $this.val() + '&nbsp;',
[234] Fix | Delete
// Add 2px to compensate for border-top & border-bottom.
[235] Fix | Delete
cloneHeight = clone.css('width', $this.css('width')).text(textareaContent).outerHeight() + 2;
[236] Fix | Delete
[237] Fix | Delete
// Default to show a vertical scrollbar, if needed.
[238] Fix | Delete
editor.css('overflow-y', 'auto');
[239] Fix | Delete
[240] Fix | Delete
// Only change the height if it has changed and both heights are below the max.
[241] Fix | Delete
if ( cloneHeight === editorHeight || ( cloneHeight >= editorMaxHeight && editorHeight >= editorMaxHeight ) ) {
[242] Fix | Delete
return;
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
/*
[246] Fix | Delete
* Don't allow editor to exceed the height of the window.
[247] Fix | Delete
* This is also bound in CSS to a max-height of 1300px to be extra safe.
[248] Fix | Delete
*/
[249] Fix | Delete
if ( cloneHeight > editorMaxHeight ) {
[250] Fix | Delete
editorHeight = editorMaxHeight;
[251] Fix | Delete
} else {
[252] Fix | Delete
editorHeight = cloneHeight;
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
// Disable scrollbars because we adjust the height to the content.
[256] Fix | Delete
editor.css('overflow', 'hidden');
[257] Fix | Delete
[258] Fix | Delete
$this.css('height', editorHeight + 'px');
[259] Fix | Delete
});
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
} );
[263] Fix | Delete
[264] Fix | Delete
jQuery( function( $ ) {
[265] Fix | Delete
'use strict';
[266] Fix | Delete
[267] Fix | Delete
var communityEventsData = window.communityEventsData,
[268] Fix | Delete
dateI18n = wp.date.dateI18n,
[269] Fix | Delete
format = wp.date.format,
[270] Fix | Delete
sprintf = wp.i18n.sprintf,
[271] Fix | Delete
__ = wp.i18n.__,
[272] Fix | Delete
_x = wp.i18n._x,
[273] Fix | Delete
app;
[274] Fix | Delete
[275] Fix | Delete
/**
[276] Fix | Delete
* Global Community Events namespace.
[277] Fix | Delete
*
[278] Fix | Delete
* @since 4.8.0
[279] Fix | Delete
*
[280] Fix | Delete
* @memberOf wp
[281] Fix | Delete
* @namespace wp.communityEvents
[282] Fix | Delete
*/
[283] Fix | Delete
app = window.wp.communityEvents = /** @lends wp.communityEvents */{
[284] Fix | Delete
initialized: false,
[285] Fix | Delete
model: null,
[286] Fix | Delete
[287] Fix | Delete
/**
[288] Fix | Delete
* Initializes the wp.communityEvents object.
[289] Fix | Delete
*
[290] Fix | Delete
* @since 4.8.0
[291] Fix | Delete
*
[292] Fix | Delete
* @return {void}
[293] Fix | Delete
*/
[294] Fix | Delete
init: function() {
[295] Fix | Delete
if ( app.initialized ) {
[296] Fix | Delete
return;
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
var $container = $( '#community-events' );
[300] Fix | Delete
[301] Fix | Delete
/*
[302] Fix | Delete
* When JavaScript is disabled, the errors container is shown, so
[303] Fix | Delete
* that "This widget requires JavaScript" message can be seen.
[304] Fix | Delete
*
[305] Fix | Delete
* When JS is enabled, the container is hidden at first, and then
[306] Fix | Delete
* revealed during the template rendering, if there actually are
[307] Fix | Delete
* errors to show.
[308] Fix | Delete
*
[309] Fix | Delete
* The display indicator switches from `hide-if-js` to `aria-hidden`
[310] Fix | Delete
* here in order to maintain consistency with all the other fields
[311] Fix | Delete
* that key off of `aria-hidden` to determine their visibility.
[312] Fix | Delete
* `aria-hidden` can't be used initially, because there would be no
[313] Fix | Delete
* way to set it to false when JavaScript is disabled, which would
[314] Fix | Delete
* prevent people from seeing the "This widget requires JavaScript"
[315] Fix | Delete
* message.
[316] Fix | Delete
*/
[317] Fix | Delete
$( '.community-events-errors' )
[318] Fix | Delete
.attr( 'aria-hidden', 'true' )
[319] Fix | Delete
.removeClass( 'hide-if-js' );
[320] Fix | Delete
[321] Fix | Delete
$container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm );
[322] Fix | Delete
[323] Fix | Delete
/**
[324] Fix | Delete
* Filters events based on entered location.
[325] Fix | Delete
*
[326] Fix | Delete
* @return {void}
[327] Fix | Delete
*/
[328] Fix | Delete
$container.on( 'submit', '.community-events-form', function( event ) {
[329] Fix | Delete
var location = $.trim( $( '#community-events-location' ).val() );
[330] Fix | Delete
[331] Fix | Delete
event.preventDefault();
[332] Fix | Delete
[333] Fix | Delete
/*
[334] Fix | Delete
* Don't trigger a search if the search field is empty or the
[335] Fix | Delete
* search term was made of only spaces before being trimmed.
[336] Fix | Delete
*/
[337] Fix | Delete
if ( ! location ) {
[338] Fix | Delete
return;
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
app.getEvents({
[342] Fix | Delete
location: location
[343] Fix | Delete
});
[344] Fix | Delete
});
[345] Fix | Delete
[346] Fix | Delete
if ( communityEventsData && communityEventsData.cache && communityEventsData.cache.location && communityEventsData.cache.events ) {
[347] Fix | Delete
app.renderEventsTemplate( communityEventsData.cache, 'app' );
[348] Fix | Delete
} else {
[349] Fix | Delete
app.getEvents();
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
app.initialized = true;
[353] Fix | Delete
},
[354] Fix | Delete
[355] Fix | Delete
/**
[356] Fix | Delete
* Toggles the visibility of the Edit Location form.
[357] Fix | Delete
*
[358] Fix | Delete
* @since 4.8.0
[359] Fix | Delete
*
[360] Fix | Delete
* @param {event|string} action 'show' or 'hide' to specify a state;
[361] Fix | Delete
* or an event object to flip between states.
[362] Fix | Delete
*
[363] Fix | Delete
* @return {void}
[364] Fix | Delete
*/
[365] Fix | Delete
toggleLocationForm: function( action ) {
[366] Fix | Delete
var $toggleButton = $( '.community-events-toggle-location' ),
[367] Fix | Delete
$cancelButton = $( '.community-events-cancel' ),
[368] Fix | Delete
$form = $( '.community-events-form' ),
[369] Fix | Delete
$target = $();
[370] Fix | Delete
[371] Fix | Delete
if ( 'object' === typeof action ) {
[372] Fix | Delete
// The action is the event object: get the clicked element.
[373] Fix | Delete
$target = $( action.target );
[374] Fix | Delete
/*
[375] Fix | Delete
* Strict comparison doesn't work in this case because sometimes
[376] Fix | Delete
* we explicitly pass a string as value of aria-expanded and
[377] Fix | Delete
* sometimes a boolean as the result of an evaluation.
[378] Fix | Delete
*/
[379] Fix | Delete
action = 'true' == $toggleButton.attr( 'aria-expanded' ) ? 'hide' : 'show';
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
if ( 'hide' === action ) {
[383] Fix | Delete
$toggleButton.attr( 'aria-expanded', 'false' );
[384] Fix | Delete
$cancelButton.attr( 'aria-expanded', 'false' );
[385] Fix | Delete
$form.attr( 'aria-hidden', 'true' );
[386] Fix | Delete
/*
[387] Fix | Delete
* If the Cancel button has been clicked, bring the focus back
[388] Fix | Delete
* to the toggle button so users relying on screen readers don't
[389] Fix | Delete
* lose their place.
[390] Fix | Delete
*/
[391] Fix | Delete
if ( $target.hasClass( 'community-events-cancel' ) ) {
[392] Fix | Delete
$toggleButton.trigger( 'focus' );
[393] Fix | Delete
}
[394] Fix | Delete
} else {
[395] Fix | Delete
$toggleButton.attr( 'aria-expanded', 'true' );
[396] Fix | Delete
$cancelButton.attr( 'aria-expanded', 'true' );
[397] Fix | Delete
$form.attr( 'aria-hidden', 'false' );
[398] Fix | Delete
}
[399] Fix | Delete
},
[400] Fix | Delete
[401] Fix | Delete
/**
[402] Fix | Delete
* Sends REST API requests to fetch events for the widget.
[403] Fix | Delete
*
[404] Fix | Delete
* @since 4.8.0
[405] Fix | Delete
*
[406] Fix | Delete
* @param {Object} requestParams REST API Request parameters object.
[407] Fix | Delete
*
[408] Fix | Delete
* @return {void}
[409] Fix | Delete
*/
[410] Fix | Delete
getEvents: function( requestParams ) {
[411] Fix | Delete
var initiatedBy,
[412] Fix | Delete
app = this,
[413] Fix | Delete
$spinner = $( '.community-events-form' ).children( '.spinner' );
[414] Fix | Delete
[415] Fix | Delete
requestParams = requestParams || {};
[416] Fix | Delete
requestParams._wpnonce = communityEventsData.nonce;
[417] Fix | Delete
requestParams.timezone = window.Intl ? window.Intl.DateTimeFormat().resolvedOptions().timeZone : '';
[418] Fix | Delete
[419] Fix | Delete
initiatedBy = requestParams.location ? 'user' : 'app';
[420] Fix | Delete
[421] Fix | Delete
$spinner.addClass( 'is-active' );
[422] Fix | Delete
[423] Fix | Delete
wp.ajax.post( 'get-community-events', requestParams )
[424] Fix | Delete
.always( function() {
[425] Fix | Delete
$spinner.removeClass( 'is-active' );
[426] Fix | Delete
})
[427] Fix | Delete
[428] Fix | Delete
.done( function( response ) {
[429] Fix | Delete
if ( 'no_location_available' === response.error ) {
[430] Fix | Delete
if ( requestParams.location ) {
[431] Fix | Delete
response.unknownCity = requestParams.location;
[432] Fix | Delete
} else {
[433] Fix | Delete
/*
[434] Fix | Delete
* No location was passed, which means that this was an automatic query
[435] Fix | Delete
* based on IP, locale, and timezone. Since the user didn't initiate it,
[436] Fix | Delete
* it should fail silently. Otherwise, the error could confuse and/or
[437] Fix | Delete
* annoy them.
[438] Fix | Delete
*/
[439] Fix | Delete
delete response.error;
[440] Fix | Delete
}
[441] Fix | Delete
}
[442] Fix | Delete
app.renderEventsTemplate( response, initiatedBy );
[443] Fix | Delete
})
[444] Fix | Delete
[445] Fix | Delete
.fail( function() {
[446] Fix | Delete
app.renderEventsTemplate({
[447] Fix | Delete
'location' : false,
[448] Fix | Delete
'events' : [],
[449] Fix | Delete
'error' : true
[450] Fix | Delete
}, initiatedBy );
[451] Fix | Delete
});
[452] Fix | Delete
},
[453] Fix | Delete
[454] Fix | Delete
/**
[455] Fix | Delete
* Renders the template for the Events section of the Events & News widget.
[456] Fix | Delete
*
[457] Fix | Delete
* @since 4.8.0
[458] Fix | Delete
*
[459] Fix | Delete
* @param {Object} templateParams The various parameters that will get passed to wp.template.
[460] Fix | Delete
* @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user;
[461] Fix | Delete
* 'app' to indicate it was triggered automatically by the app itself.
[462] Fix | Delete
*
[463] Fix | Delete
* @return {void}
[464] Fix | Delete
*/
[465] Fix | Delete
renderEventsTemplate: function( templateParams, initiatedBy ) {
[466] Fix | Delete
var template,
[467] Fix | Delete
elementVisibility,
[468] Fix | Delete
$toggleButton = $( '.community-events-toggle-location' ),
[469] Fix | Delete
$locationMessage = $( '#community-events-location-message' ),
[470] Fix | Delete
$results = $( '.community-events-results' );
[471] Fix | Delete
[472] Fix | Delete
templateParams.events = app.populateDynamicEventFields(
[473] Fix | Delete
templateParams.events,
[474] Fix | Delete
communityEventsData.time_format
[475] Fix | Delete
);
[476] Fix | Delete
[477] Fix | Delete
/*
[478] Fix | Delete
* Hide all toggleable elements by default, to keep the logic simple.
[479] Fix | Delete
* Otherwise, each block below would have to turn hide everything that
[480] Fix | Delete
* could have been shown at an earlier point.
[481] Fix | Delete
*
[482] Fix | Delete
* The exception to that is that the .community-events container is hidden
[483] Fix | Delete
* when the page is first loaded, because the content isn't ready yet,
[484] Fix | Delete
* but once we've reached this point, it should always be shown.
[485] Fix | Delete
*/
[486] Fix | Delete
elementVisibility = {
[487] Fix | Delete
'.community-events' : true,
[488] Fix | Delete
'.community-events-loading' : false,
[489] Fix | Delete
'.community-events-errors' : false,
[490] Fix | Delete
'.community-events-error-occurred' : false,
[491] Fix | Delete
'.community-events-could-not-locate' : false,
[492] Fix | Delete
'#community-events-location-message' : false,
[493] Fix | Delete
'.community-events-toggle-location' : false,
[494] Fix | Delete
'.community-events-results' : false
[495] Fix | Delete
};
[496] Fix | Delete
[497] Fix | Delete
/*
[498] Fix | Delete
* Determine which templates should be rendered and which elements
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function