From 33c168bce7507d1f0da26a6abf0f9e263368040f Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Fri, 16 Feb 2024 15:10:42 +0000 Subject: [PATCH] Fix formatting --- assets/css/translation-events.css | 4 +- assets/js/translation-events.js | 82 ++++++++++++++++--------------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/assets/css/translation-events.css b/assets/css/translation-events.css index 5a7337c6..5c43f767 100644 --- a/assets/css/translation-events.css +++ b/assets/css/translation-events.css @@ -70,8 +70,8 @@ span.event-list-date { font-weight: bold; } span.event-list-date.events-i-am-attending { - font-size: .8em; - font-weight: normal; + font-size: .8em; + font-weight: normal; } .event-list-item a{ font-weight: bold; diff --git a/assets/js/translation-events.js b/assets/js/translation-events.js index 608f282f..51e7fdcd 100644 --- a/assets/js/translation-events.js +++ b/assets/js/translation-events.js @@ -18,7 +18,7 @@ } ); - $('.delete-event').on( + $( '.delete-event' ).on( 'click', function ( e ) { e.preventDefault(); @@ -41,36 +41,36 @@ } } $( '#event-form-action' ).val( btnClicked ); - const $form = $( '.translation-event-form' ); - const $is_creation = $('#form-name').val() === 'create_event'; + const $form = $( '.translation-event-form' ); + const $is_creation = $( '#form-name' ).val() === 'create_event'; $.ajax( { type: 'POST', url: $translation_event.url, data:$form.serialize(), - success: function(response) { + success: function ( response ) { if ( response.data.eventId ) { history.replaceState( '', '', response.data.eventEditUrl ); - $('#form-name').val('edit_event'); - $('.event-page-title').text('Edit Event'); - $('#event-id').val(response.data.eventId); - if( btnClicked === 'publish' ) { - $('button[data-event-status="draft"]').hide(); - $('button[data-event-status="publish"]').text('Update Event'); + $( '#form-name' ).val( 'edit_event' ); + $( '.event-page-title' ).text( 'Edit Event' ); + $( '#event-id' ).val( response.data.eventId ); + if ( btnClicked === 'publish' ) { + $( 'button[data-event-status="draft"]' ).hide(); + $( 'button[data-event-status="publish"]' ).text( 'Update Event' ); } - if( btnClicked === 'draft' ) { - $('button[data-event-status="draft"]').text('Update Draft'); + if ( btnClicked === 'draft' ) { + $( 'button[data-event-status="draft"]' ).text( 'Update Draft' ); } - $('#event-url').removeClass('hide-event-url').find('a').attr('href', response.data.eventUrl).text(response.data.eventUrl); + $( '#event-url' ).removeClass( 'hide-event-url' ).find( 'a' ).attr( 'href', response.data.eventUrl ).text( response.data.eventUrl ); if ( $is_creation ) { - $('#delete-button').toggle(); + $( '#delete-button' ).toggle(); } - $gp.notices.success(response.data.message); + $gp.notices.success( response.data.message ); } }, - error: function(error) { - $gp.notices.error(response.data.message); + error: function ( error ) { + $gp.notices.error( response.data.message ); } } ); @@ -80,25 +80,27 @@ if ( ! confirm( 'Are you sure you want to delete this event?' ) ) { return; } - const $form = $('.translation-event-form'); - $('#form-name').val('delete_event'); - $('#event-form-action').val('delete'); - $.ajax({ - type: 'POST', - url: $translation_event.url, - data:$form.serialize(), - success: function(response) { - window.location = response.data.eventDeleteUrl; - }, - error: function(error) { - $gp.notices.error(response.data.message); - }, - }); + const $form = $( '.translation-event-form' ); + $( '#form-name' ).val( 'delete_event' ); + $( '#event-form-action' ).val( 'delete' ); + $.ajax( + { + type: 'POST', + url: $translation_event.url, + data:$form.serialize(), + success: function ( response ) { + window.location = response.data.eventDeleteUrl; + }, + error: function ( error ) { + $gp.notices.error( response.data.message ); + }, + } + ); } function validateEventDates() { - const startDateTimeInput = $('#event-start'); - const endDateTimeInput = $('#event-end'); + const startDateTimeInput = $( '#event-start' ); + const endDateTimeInput = $( '#event-end' ); if ( ! startDateTimeInput.length || ! endDateTimeInput.length ) { return; } @@ -106,9 +108,9 @@ startDateTimeInput.add( endDateTimeInput ).on( 'input', function () { - endDateTimeInput.prop('min', startDateTimeInput.val()); + endDateTimeInput.prop( 'min', startDateTimeInput.val() ); if (endDateTimeInput.val() < startDateTimeInput.val()) { - endDateTimeInput.val(startDateTimeInput.val()); + endDateTimeInput.val( startDateTimeInput.val() ); } } ); @@ -122,16 +124,16 @@ } function convertToUserLocalTime() { - const timeElements = document.querySelectorAll('time.event-utc-time'); + const timeElements = document.querySelectorAll( 'time.event-utc-time' ); if ( timeElements.length === 0 ) { return; } timeElements.forEach( function ( timeEl ) { - const eventDateObj = new Date( timeEl.getAttribute('datetime') ); - const userTimezoneOffset = new Date().getTimezoneOffset(); + const eventDateObj = new Date( timeEl.getAttribute( 'datetime' ) ); + const userTimezoneOffset = new Date().getTimezoneOffset(); const userTimezoneOffsetMs = userTimezoneOffset * 60 * 1000; - const userLocalDateTime = new Date(eventDateObj.getTime() - userTimezoneOffsetMs); + const userLocalDateTime = new Date( eventDateObj.getTime() - userTimezoneOffsetMs ); const options = { weekday: 'short', @@ -144,7 +146,7 @@ timeZoneName: 'short' }; - timeEl.textContent = userLocalDateTime.toLocaleString('en-US', options); + timeEl.textContent = userLocalDateTime.toLocaleString( 'en-US', options ); } ); }