From d568eda112836d6c763f58d961e42b53ae555a24 Mon Sep 17 00:00:00 2001 From: Iara Ota Date: Wed, 7 Aug 2024 13:30:04 -0500 Subject: [PATCH 1/3] add new buttons to move to previous/next date --- js/gwbootstrap-extra.js | 94 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/js/gwbootstrap-extra.js b/js/gwbootstrap-extra.js index d75e975..c8c6462 100644 --- a/js/gwbootstrap-extra.js +++ b/js/gwbootstrap-extra.js @@ -132,6 +132,44 @@ function shortenDate() { } } + +/* ------------------------------------------------------------------------- */ +/* Summary Pages custom buttons */ + + /** + * Creates an HTML button element with an SVG icon. + * + * @param {string} label - The label used for the button's class and data attributes. + * @param {string} title - The title attribute for the button. + * @param {string} svgPathData - The SVG path data used to draw the icon inside the button. + * @returns {string} - The HTML string representing the button with the SVG icon. + */ + + function createButton(label, title, svgPathData) { + const buttonHTML = + ''; + + return buttonHTML; +} + /** + * Checks if the current date format is a calendar format. + * + * This function retrieves the current date format + * and checks if it is one of the calendar formats: + * 'day', 'week', 'month', or 'year'. + * + * @returns {boolean} - Returns true if the date format is a calendar format, otherwise false. + */ + function isCalendarFormat() { + const dateformat = findDateFormat(); + const periodicFormats = ['day', 'week', 'month', 'year']; + return periodicFormats.includes(dateformat); + } + /* ------------------------------------------------------------------------- */ /* Fancybox images */ @@ -333,6 +371,62 @@ jQuery(window).on('load', function () { type: 'iframe', }); + + /** + * Initializes Fancybox for elements with the `data-fancybox="summary"` attribute. + * This configuration is specifically designed for Summary Pages. + * + * Binds Fancybox to gallery items and customizes the toolbar with two buttons: + * - A "previousDay" button for navigating to the previous day. + * - A "nextDay" button for navigating to the next day. + * + * Clicking either button updates the page URL to reflect the selected date. + * As the gallery image is open, the new page will automatically open the + * gallery with the same image number. + * + * The new buttons are just created for the calendar data formats: + * 'day', 'week', 'month', or 'year'. + */ + + + Fancybox.bind('[data-fancybox="summary"]', { + contentClick: 'toggleZoom', + placeFocusBack: false, + Images: { + initialSize: 'fit', + }, + Thumbs: { + showOnStart: false, + type: 'classic', + }, + Toolbar: { + items: { + ...(isCalendarFormat() && { + previousDay: { + tpl: createButton('previousDay', 'Previous Date', 'M25 10 L15 20 L25 30'), + click: () => { + stepDate(-1); + }, + }, + nextDay: { + tpl: createButton('nextDay', 'Next Date', 'M15 10 L25 20 L15 30'), + click: () => { + stepDate(1); + }, + }, + }), + }, + display: { + ...(isCalendarFormat() && { middle: ["previousDay", "nextDay"] }), + right: [ + 'toggleZoom', + 'download', + 'slideshow', + ], + }, + } + }); + // reposition dropdown if scrolling off the screen jQuery('.dropdown-toggle').on('click', function () { // if page width is small, no-operation From eb9c759adb5d2feca1edb9d4962e545934da9f6c Mon Sep 17 00:00:00 2001 From: Iara Ota Date: Wed, 7 Aug 2024 13:31:50 -0500 Subject: [PATCH 2/3] fix strings --- js/gwbootstrap-extra.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/gwbootstrap-extra.js b/js/gwbootstrap-extra.js index c8c6462..a1cdb7c 100644 --- a/js/gwbootstrap-extra.js +++ b/js/gwbootstrap-extra.js @@ -403,13 +403,13 @@ jQuery(window).on('load', function () { items: { ...(isCalendarFormat() && { previousDay: { - tpl: createButton('previousDay', 'Previous Date', 'M25 10 L15 20 L25 30'), + tpl: createButton('previousDate', 'Previous Date', 'M25 10 L15 20 L25 30'), click: () => { stepDate(-1); }, }, nextDay: { - tpl: createButton('nextDay', 'Next Date', 'M15 10 L25 20 L15 30'), + tpl: createButton('nextDate', 'Next Date', 'M15 10 L25 20 L15 30'), click: () => { stepDate(1); }, @@ -417,7 +417,7 @@ jQuery(window).on('load', function () { }), }, display: { - ...(isCalendarFormat() && { middle: ["previousDay", "nextDay"] }), + ...(isCalendarFormat() && { middle: ["previousDate", "nextDate"] }), right: [ 'toggleZoom', 'download', From 1709b7b1c0321a49e23c15d3b879f4a6e6f6752e Mon Sep 17 00:00:00 2001 From: Iara Ota Date: Wed, 7 Aug 2024 15:30:15 -0500 Subject: [PATCH 3/3] fix buttons --- js/gwbootstrap-extra.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/js/gwbootstrap-extra.js b/js/gwbootstrap-extra.js index a1cdb7c..76a9fa2 100644 --- a/js/gwbootstrap-extra.js +++ b/js/gwbootstrap-extra.js @@ -402,13 +402,13 @@ jQuery(window).on('load', function () { Toolbar: { items: { ...(isCalendarFormat() && { - previousDay: { + previousDate: { tpl: createButton('previousDate', 'Previous Date', 'M25 10 L15 20 L25 30'), click: () => { stepDate(-1); }, }, - nextDay: { + nextDate: { tpl: createButton('nextDate', 'Next Date', 'M15 10 L25 20 L15 30'), click: () => { stepDate(1); @@ -417,11 +417,13 @@ jQuery(window).on('load', function () { }), }, display: { - ...(isCalendarFormat() && { middle: ["previousDate", "nextDate"] }), + middle: isCalendarFormat() ? ["previousDate", "nextDate"] : [], right: [ - 'toggleZoom', - 'download', - 'slideshow', + 'toggleZoom', + 'download', + 'slideshow', + 'thumbs', + 'close', ], }, }