diff --git a/js/office_hours.js b/js/office_hours.js index e9a6604..9c518a2 100644 --- a/js/office_hours.js +++ b/js/office_hours.js @@ -219,19 +219,20 @@ // when the checkbox is clicked. $('[id*="all-day"]').bind('click', setAllDayTimeSlot); + const addEl = $('.office-hours-operations-wrapper [id$=add]'); // Attach a function to each add-link to show the next slot if clicked upon. // Show the Add-link, except if the next time slot is hidden. - $('[id$=add]').bind('click', addTimeSlot); + addEl.bind('click', addTimeSlot); - $('[id$=add]').each(showAddLink); + addEl.each(showAddLink); // Attach a function to each clear-link, to clear the slot if clicked upon. - $('[id$=clear]').bind('click', clearTimeSlot); + $('.office-hours-operations-wrapper [id$=clear]').bind('click', clearTimeSlot); // Attach a function to each copy-link, to copy the slot values // from previous day, when user clicks "Copy previous day". // @todo This works for Table widget, not yet for List Widget. - $('[id$=copy]').bind('click', copyPreviousDay); + $('.office-hours-operations-wrapper [id$=copy]').bind('click', copyPreviousDay); }); }, }; diff --git a/src/Element/OfficeHoursBaseSlot.php b/src/Element/OfficeHoursBaseSlot.php index 39d0289..9588b37 100644 --- a/src/Element/OfficeHoursBaseSlot.php +++ b/src/Element/OfficeHoursBaseSlot.php @@ -99,6 +99,13 @@ class OfficeHoursBaseSlot extends FormElement { ]; } + // If there is operations wrap them in div with specific class + // that will be used in JS to target only op buttons comes from this module. + if (!empty($operations)) { + $operations['#prefix'] = "
"; + $operations['#suffix'] = "
"; + } + return $operations; }