Skip to content

Commit 2cb076f

Browse files
committed
minor syntax tweaks
1 parent 5db8813 commit 2cb076f

1 file changed

Lines changed: 24 additions & 27 deletions

File tree

assets/js/web-components/prpl-suggested-task.js

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ customElements.define(
267267
${ actionButtons.snooze }
268268
${ actionButtons.complete }
269269
${ actionButtons.delete }
270-
271270
</div>
272-
273271
${ taskPointsElement }
274272
</div>
275273
</li>`;
@@ -294,12 +292,12 @@ customElements.define(
294292
} );
295293

296294
item.querySelectorAll( '.prpl-suggested-task-button' ).forEach(
297-
function ( button ) {
295+
( button ) => {
298296
button.addEventListener( 'click', function () {
299297
let action = button.getAttribute( 'data-action' );
300-
const target = button.getAttribute( 'data-target' ),
301-
tooltipActions =
302-
item.querySelector( '.tooltip-actions' );
298+
const target = button.getAttribute( 'data-target' );
299+
const tooltipActions =
300+
item.querySelector( '.tooltip-actions' );
303301

304302
// If the tooltip was already open, close it.
305303
if (
@@ -311,16 +309,17 @@ customElements.define(
311309
) {
312310
action = 'close-' + target;
313311
} else {
312+
const closestTaskListVisible = item
313+
.closest( '.prpl-suggested-tasks-list' )
314+
.querySelector( `[data-tooltip-visible]` );
314315
// Close the any opened radio group.
315-
item.closest( '.prpl-suggested-tasks-list' )
316-
.querySelector( `[data-tooltip-visible]` )
317-
?.classList.remove(
318-
'prpl-toggle-radio-group-open'
319-
);
316+
closestTaskListVisible?.classList.remove(
317+
'prpl-toggle-radio-group-open'
318+
);
320319
// Remove any existing tooltip visible attribute, in the entire list.
321-
item.closest( '.prpl-suggested-tasks-list' )
322-
.querySelector( `[data-tooltip-visible]` )
323-
?.removeAttribute( 'data-tooltip-visible' );
320+
closestTaskListVisible?.removeAttribute(
321+
'data-tooltip-visible'
322+
);
324323
}
325324

326325
switch ( action ) {
@@ -378,20 +377,20 @@ customElements.define(
378377
case 'move-up':
379378
case 'move-down':
380379
// Move `thisObj` before or after the previous or next sibling.
381-
const previousSibling =
382-
thisObj.previousElementSibling;
383-
const nextSibling = thisObj.nextElementSibling;
384-
if ( 'move-up' === action && previousSibling ) {
380+
if (
381+
'move-up' === action &&
382+
thisObj.previousElementSibling
383+
) {
385384
thisObj.parentNode.insertBefore(
386385
thisObj,
387-
previousSibling
386+
thisObj.previousElementSibling
388387
);
389388
} else if (
390389
'move-down' === action &&
391-
nextSibling
390+
thisObj.nextElementSibling
392391
) {
393392
thisObj.parentNode.insertBefore(
394-
nextSibling,
393+
thisObj.nextElementSibling,
395394
thisObj
396395
);
397396
}
@@ -487,12 +486,10 @@ customElements.define(
487486
runTaskAction = ( task_id, actionType, snoozeDuration ) => {
488487
task_id = task_id.toString();
489488
const providerID = this.querySelector( 'li' ).getAttribute(
490-
'data-task-provider-id'
491-
),
492-
category =
493-
this.querySelector( 'li' ).getAttribute(
494-
'data-task-category'
495-
);
489+
'data-task-provider-id'
490+
);
491+
const category =
492+
this.querySelector( 'li' ).getAttribute( 'data-task-category' );
496493
const taskPoints = parseInt(
497494
this.querySelector( 'li' ).getAttribute( 'data-task-points' )
498495
);

0 commit comments

Comments
 (0)