diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 5d123e1a..5b71b7f5 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +- TMS-1052: Favorite programs-functionalities - TMS-1051: Add "Print page"-button to single program ## [1.8.17] - 2024-08-21 diff --git a/assets/scripts/program-favorite.js b/assets/scripts/program-favorite.js new file mode 100644 index 00000000..c3a75342 --- /dev/null +++ b/assets/scripts/program-favorite.js @@ -0,0 +1,288 @@ +/* eslint-disable no-console */ +/** + * Favorites-functionality for programs. + */ + +// Use jQuery as $ within this file scope. +const $ = jQuery; + +/** + * Class FavoritePrograms + */ +export default class FavoritePrograms { + /** + * Execute on page load + */ + docReady() { + // Bail if browser does not support localStorage. + if ( typeof Storage === 'undefined' ) { + return; + } + + this.cache(); + this.favorites = this.parseFavorites(); + + if ( ! this.hasFavorites() ) { + this.showNoResults(); + } + + // Init functionalities common to all templates. + this.initCommon(); + + // Init functionalities for favorite-listing. + this.initFavorites(); + + // Favorite popup functionalities + this.favoritePopup(); + } + + /** + * Cache selectors + */ + cache() { + this.classes = { + hasFavorites: 'has-favorites', + isFavorite: 'is-favorite', + hide: 'is-hidden', + }; + + this.selectors = { + button: '.js-toggle-favorite', + }; + this.storageKey = 'tredu-program-favorites'; + this.closeFavorites = $( '#js-favorites-close' ); + this.openFavorites = $( '#js-favorites-open' ); + this.favoritesContainer = $( '#js-favorites-container' ); + this.favoritePrograms = $( '#js-favorite-programs' ); + this.favoritesContent = $( '#js-favorites-content' ); + this.favoritesNoResults = $( '#js-favorites-no-results' ); + } + + /** + * Initialize functionalities common for all templates. + */ + initCommon() { + this.favoriteButtons = $( this.selectors.button ); + + if ( this.favoriteButtons.length > 0 ) { + this.populateFavorites(); + } + } + + /** + * Initialize functionalities for favorites listing. + */ + initFavorites() { + // Fetch favorites according to localStorage. + if ( this.favorites.length !== 0 ) { + dp( 'ProgramFavorites/FavoritePrograms', { + partial: 'header-favorites-item', + tidy: true, + data: true, + args: { + ids: this.favorites, + }, + } ).then( ( response ) => { + if ( ! response.success ) { + this.showNoResults(); + return; + } + + // Set favorites content. + this.favoritePrograms.html( response.success ); + + // Show the container. + this.favoritePrograms.removeClass( this.classes.hide ); + } ).catch( ( error ) => { + console.log( error ); + this.showNoResults(); + } ); + } + + // Update favorites when favorite-button clicked + if ( this.favoritesContainer.length > 0 ) { + this.favoriteButtons.on( 'click', ( e ) => { + e.stopPropagation(); + this.toggleFavorite( e.currentTarget ); + this.loadFavorites(); + } ); + + $( document ).on( 'click', '.js-remove-favorite', ( e ) => { + e.stopPropagation(); + this.removeFavorite( e.currentTarget ); + this.loadFavorites(); + } ); + } + } + + /** + * Update favorite popup button attributes. + */ + favoritePopup() { + this.closeFavorites.on( 'click', ( e ) => { + e.stopPropagation(); + this.openFavorites.attr( 'aria-expanded', 'false' ); + this.openFavorites.removeClass( 'is-active' ); + } ); + } + + /** + * Parse favorite programs from localStorage. + * + * @return {Array} The localStorage values or an empty array. + */ + parseFavorites() { + const favorites = localStorage.getItem( this.storageKey ); + + if ( ! favorites ) { + return []; + } + + return JSON.parse( favorites ); + } + + /** + * Save passed favorites to localStorage. + * + * @param {Array} favorites The favorites as array + */ + saveFavorites( favorites = [] ) { + localStorage.setItem( this.storageKey, JSON.stringify( favorites ) ); + } + + /** + * Populate favorites from localStorage. + * + * @return {void} + */ + populateFavorites() { + // Loop over the favorite buttons and update their favorite-status. + for ( const item of this.favoriteButtons ) { + const programId = $( item ).data( 'program-id' ); + + if ( this.favorites.includes( programId ) ) { + $( item ).addClass( this.classes.isFavorite ); + $( item ).attr( 'aria-pressed', 'true' ); + $( item ).find( '.text-favorite-active' ).removeClass( this.classes.hide ); + $( item ).find( '.text-favorite-inactive' ).addClass( this.classes.hide ); + } + } + } + + /** + * Check if there are favorites in the localStorage. + * + * @return {boolean} True if favorites exist. + */ + hasFavorites() { + return this.favorites.length > 0; + } + + /** + * Changes favorite-status of the selected favorite. + * + * @param {Element} selectedItem The button element to be toggled. + * @return {void} + */ + toggleFavorite( selectedItem ) { + const programId = $( selectedItem ).data( 'program-id' ); + + // Add or remove program ID from localStorage. + if ( this.favorites.includes( programId ) ) { + this.favorites = this.favorites.filter( ( fav ) => fav !== programId ); + $( selectedItem ).removeClass( this.classes.isFavorite ); + $( selectedItem ).find( '.text-favorite-active' ).addClass( this.classes.hide ); + $( selectedItem ).find( '.text-favorite-inactive' ).removeClass( this.classes.hide ); + $( selectedItem ).attr( 'aria-pressed', 'false' ); + } + else { + this.favorites.push( programId ); + $( selectedItem ).addClass( this.classes.isFavorite ); + $( selectedItem ).find( '.text-favorite-active' ).removeClass( this.classes.hide ); + $( selectedItem ).find( '.text-favorite-inactive' ).addClass( this.classes.hide ); + $( selectedItem ).attr( 'aria-pressed', 'true' ); + } + + // Save to localStorage. + this.saveFavorites( this.favorites ); + } + + /** + * Remove favorite. + * + * @param {Element} selectedItem The button element to be toggled. + * @return {void} + */ + removeFavorite( selectedItem ) { + const programId = $( selectedItem ).data( 'program-id' ); + + // Remove program ID from localStorage. + if ( this.favorites.includes( programId ) ) { + this.favorites = this.favorites.filter( ( fav ) => fav !== programId ); + this.toggleFavoriteButton = $( '.js-toggle-favorite[data-program-id="' + programId + '"]' ); + + // Remove toggle-buttons attributes and texts + if ( this.toggleFavoriteButton.length > 0 ) { + this.toggleFavoriteButton.removeClass( this.classes.isFavorite ); + this.toggleFavoriteButton.attr( 'aria-pressed', 'false' ); + this.toggleFavoriteButton.find( '.text-favorite-active' ).addClass( this.classes.hide ); + this.toggleFavoriteButton.find( '.text-favorite-inactive' ).removeClass( this.classes.hide ); + } + } + + // Save to localStorage. + this.saveFavorites( this.favorites ); + } + + /** + * Show "no results" content. + */ + showNoResults() { + this.favoritesContent.addClass( this.classes.hide ); + this.favoritesNoResults.removeClass( this.classes.hide ); + } + + /** + * Hide "no results" content. + */ + hideNoResults() { + this.favoritesContent.removeClass( this.classes.hide ); + this.favoritesNoResults.addClass( this.classes.hide ); + } + + /** + * Load and show the favorite programs. + * + * @return {void} + */ + loadFavorites() { + // Fetch favorites according to localStorage. + dp( 'ProgramFavorites/FavoritePrograms', { + partial: 'header-favorites-item', + tidy: true, + data: true, + args: { + ids: this.favorites, + }, + } ).then( ( response ) => { + if ( ! response.success ) { + this.showNoResults(); + } + else { + this.hideNoResults(); + } + + // Set favorites content. + this.favoritePrograms.html( response.success ); + + // Refresh favorite buttons and add event listeners. + this.initCommon(); + + // Show the container. + this.favoritePrograms.removeClass( this.classes.hide ); + } ).catch( () => { + this.showNoResults(); + } ); + } + +} diff --git a/assets/scripts/theme.js b/assets/scripts/theme.js index 3cdec88d..4b18189a 100755 --- a/assets/scripts/theme.js +++ b/assets/scripts/theme.js @@ -30,6 +30,7 @@ import ProgramSearch from './program-search'; import LoadMore from './load-more'; import SearchFilters from './search-filters'; import FocusOnSearch from './focus-on-search'; +import FavoritePrograms from './program-favorite'; const globalControllers = { Common, @@ -59,6 +60,7 @@ const globalControllers = { LoadMore, SearchFilters, FocusOnSearch, + FavoritePrograms, }; const templateControllers = { diff --git a/assets/styles/ui-components/header/_header-favorites.scss b/assets/styles/ui-components/header/_header-favorites.scss new file mode 100644 index 00000000..1bed3950 --- /dev/null +++ b/assets/styles/ui-components/header/_header-favorites.scss @@ -0,0 +1,45 @@ +#js-favorites-open { + flex: 1 0 auto; + width: 2.375rem; + height: 2.375rem; + + svg { + margin: 0 !important; + } + + @include from($tablet) { + width: rem(50px); + height: rem(50px); + } +} + +#js-favorites-container { + ul { + list-style: none; + padding: 0; + + li { + &:not(:last-of-type) { + border-bottom: 2px solid $primary; + } + + .button-container { + display: flex; + gap: $theme-spacing-two; + + .button.js-remove-favorite { + padding: 0; + background-color: transparent; + border-color: transparent; + + svg.icon { + margin-left: .25rem !important; + margin-right: 0 !important; + height: 1.25rem; + width: 1.25rem; + } + } + } + } + } +} diff --git a/assets/styles/ui-components/header/_language-nav.scss b/assets/styles/ui-components/header/_language-nav.scss index e3c35c65..e7cd449b 100644 --- a/assets/styles/ui-components/header/_language-nav.scss +++ b/assets/styles/ui-components/header/_language-nav.scss @@ -5,7 +5,6 @@ .lang-nav { .dropdown-menu { z-index: 25; - } &--horizontal { @@ -16,8 +15,8 @@ height: 2.375rem; @include from($tablet) { - width: rem(50); - height: rem(50); + width: rem(50px); + height: rem(50px); } } } diff --git a/assets/styles/ui-components/index.scss b/assets/styles/ui-components/index.scss index aa62af79..72c9e0c6 100644 --- a/assets/styles/ui-components/index.scss +++ b/assets/styles/ui-components/index.scss @@ -1,3 +1,4 @@ +@import "header/header-favorites"; @import "header/header-top"; @import "header/bulmally-navbar"; @import "header/primary-nav"; diff --git a/assets/styles/views/_single-program.scss b/assets/styles/views/_single-program.scss index 380dc39b..7cc9854c 100644 --- a/assets/styles/views/_single-program.scss +++ b/assets/styles/views/_single-program.scss @@ -75,6 +75,30 @@ line-height: 1.7; } + &__add-favorite { + .button { + padding: 0; + background-color: transparent; + border-color: transparent; + + .icon-wrapper { + margin-left: $theme-spacing-half; + + svg { + height: 1rem; + width: 1.5rem; + } + } + + // Active favorite + &[aria-pressed="true"] { + svg path { + fill: $color-red; + } + } + } + } + // Print styles @media print { #rs-button, diff --git a/lang/fi.mo b/lang/fi.mo index 3b13b60b..49237480 100644 Binary files a/lang/fi.mo and b/lang/fi.mo differ diff --git a/lang/fi.po b/lang/fi.po index 05c2808b..b9c525ef 100644 --- a/lang/fi.po +++ b/lang/fi.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: TMS Theme Base\n" -"POT-Creation-Date: 2024-08-14 23:19+0300\n" -"PO-Revision-Date: 2024-08-14 23:19+0300\n" +"POT-Creation-Date: 2024-09-03 08:27+0300\n" +"PO-Revision-Date: 2024-09-03 08:27+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: fi\n" @@ -23,6 +23,11 @@ msgstr "" "X-Poedit-SearchPathExcluded-1: vendor\n" "X-Poedit-SearchPathExcluded-2: node_modules\n" +#: assets/dist/vendor.js:4873 +msgctxt "text direction" +msgid "ltr" +msgstr "ltr" + #: comments.php:14 msgid "Comments" msgstr "Kommentit" @@ -592,6 +597,16 @@ msgstr "Koulutushaku" msgid "No search results" msgstr "Ei hakutuloksia" +#: models/shared/program-favorites.php:53 models/strings.php:214 +msgctxt "theme-frontend" +msgid "Remove from favorites" +msgstr "Poista suosikeista" + +#: models/shared/program-favorites.php:54 +msgctxt "theme-frontend" +msgid "Go to program" +msgstr "Siirry koulutukseen" + #: models/single-dial-tredu.php:42 msgid "Go back" msgstr "Takaisin" @@ -693,7 +708,7 @@ msgid "Search from site" msgstr "Etsi sivustolta" #: models/strings.php:56 models/strings.php:83 models/strings.php:146 -#: models/strings.php:159 models/strings.php:168 models/strings.php:268 +#: models/strings.php:159 models/strings.php:168 models/strings.php:277 msgctxt "theme-frontend" msgid "Close" msgstr "Sulje" @@ -843,12 +858,12 @@ msgctxt "theme-frontend" msgid "Articletype:" msgstr "Artikkelityyppi:" -#: models/strings.php:111 models/strings.php:224 +#: models/strings.php:111 models/strings.php:233 msgctxt "theme-frontend" msgid "Month" msgstr "Kuukausi" -#: models/strings.php:112 models/strings.php:225 +#: models/strings.php:112 models/strings.php:234 msgctxt "theme-frontend" msgid "Year" msgstr "Vuosi" @@ -868,62 +883,62 @@ msgctxt "theme-frontend" msgid "The page reloads after the selection." msgstr "Sivu latautuu uudelleen valinnan jälkeen." -#: models/strings.php:118 models/strings.php:238 +#: models/strings.php:118 models/strings.php:247 msgctxt "theme-frontend" msgid "January" msgstr "tammikuu" -#: models/strings.php:119 models/strings.php:239 +#: models/strings.php:119 models/strings.php:248 msgctxt "theme-frontend" msgid "February" msgstr "helmikuu" -#: models/strings.php:120 models/strings.php:240 +#: models/strings.php:120 models/strings.php:249 msgctxt "theme-frontend" msgid "March" msgstr "maaliskuu" -#: models/strings.php:121 models/strings.php:241 +#: models/strings.php:121 models/strings.php:250 msgctxt "theme-frontend" msgid "April" msgstr "huhtikuu" -#: models/strings.php:122 models/strings.php:242 models/strings.php:256 +#: models/strings.php:122 models/strings.php:251 models/strings.php:265 msgctxt "theme-frontend" msgid "May" msgstr "toukokuu" -#: models/strings.php:123 models/strings.php:243 +#: models/strings.php:123 models/strings.php:252 msgctxt "theme-frontend" msgid "June" msgstr "kesäkuu" -#: models/strings.php:124 models/strings.php:244 +#: models/strings.php:124 models/strings.php:253 msgctxt "theme-frontend" msgid "July" msgstr "heinäkuu" -#: models/strings.php:125 models/strings.php:245 +#: models/strings.php:125 models/strings.php:254 msgctxt "theme-frontend" msgid "August" msgstr "elokuu" -#: models/strings.php:126 models/strings.php:246 +#: models/strings.php:126 models/strings.php:255 msgctxt "theme-frontend" msgid "September" msgstr "syyskuu" -#: models/strings.php:127 models/strings.php:247 +#: models/strings.php:127 models/strings.php:256 msgctxt "theme-frontend" msgid "October" msgstr "lokakuu" -#: models/strings.php:128 models/strings.php:248 +#: models/strings.php:128 models/strings.php:257 msgctxt "theme-frontend" msgid "November" msgstr "marraskuu" -#: models/strings.php:129 models/strings.php:249 +#: models/strings.php:129 models/strings.php:258 msgctxt "theme-frontend" msgid "December" msgstr "joulukuu" @@ -1141,219 +1156,208 @@ msgstr "Kuka voi hakea?" #: models/strings.php:208 msgctxt "theme-frontend" +msgid "Favorites" +msgstr "Suosikit" + +#: models/strings.php:209 +msgctxt "theme-frontend" +msgid "No favorites found" +msgstr "Suosikkeja ei löytynyt" + +#: models/strings.php:210 +msgctxt "theme-frontend" +msgid "Open or close favorites" +msgstr "Avaa tai sulje suosikit" + +#: models/strings.php:211 +msgctxt "theme-frontend" +msgid "Close favorites" +msgstr "Sulje suosikkilistaus" + +#: models/strings.php:212 +msgctxt "theme-frontend" +msgid "Add or remove from favorites" +msgstr "Lisää tai poista suosikeista" + +#: models/strings.php:213 +msgctxt "theme-frontend" +msgid "Add to favorites" +msgstr "Lisää suosikkeihin" + +#: models/strings.php:217 +msgctxt "theme-frontend" msgid "Filter by type" msgstr "Rajaa tyypin mukaan" -#: models/strings.php:209 +#: models/strings.php:218 msgctxt "theme-frontend" msgid "Publish date" msgstr "Julkaisupäivä" -#: models/strings.php:210 +#: models/strings.php:219 msgctxt "theme-frontend" msgid "Write search terms" msgstr "Kirjoita hakusanat" -#: models/strings.php:211 +#: models/strings.php:220 msgctxt "theme-frontend" msgid "Page location:" msgstr "Sivun sijainti:" -#: models/strings.php:214 +#: models/strings.php:223 msgctxt "theme-frontend" msgid "Filter" msgstr "Rajaa" -#: models/strings.php:215 +#: models/strings.php:224 msgctxt "theme-frontend" msgid "Clicking the link will download file" msgstr "Linkin avaaminen lataa tiedoston" -#: models/strings.php:219 models/strings.php:227 +#: models/strings.php:228 models/strings.php:236 msgctxt "theme-frontend" msgid "Pick a date" msgstr "Valitse päivämäärä" -#: models/strings.php:220 +#: models/strings.php:229 msgctxt "theme-frontend" msgid "dd.mm.yyyy" msgstr "pp.kk.vvvv" -#: models/strings.php:221 +#: models/strings.php:230 msgctxt "theme-frontend" msgid "The chosen date is" msgstr "Valittu päivämäärä on" -#: models/strings.php:222 +#: models/strings.php:231 msgctxt "theme-frontend" msgid "Previous month" msgstr "Edellinen kuukausi" -#: models/strings.php:223 +#: models/strings.php:232 msgctxt "theme-frontend" msgid "Next month" msgstr "Seuraava kuukausi" -#: models/strings.php:226 +#: models/strings.php:235 msgctxt "theme-frontend" msgid "Close window" msgstr "Sulje ikkuna" -#: models/strings.php:229 +#: models/strings.php:238 msgctxt "theme-frontend" msgid "Sunday" msgstr "Sunnuntai" -#: models/strings.php:230 +#: models/strings.php:239 msgctxt "theme-frontend" msgid "Monday" msgstr "Maanantai" -#: models/strings.php:231 +#: models/strings.php:240 msgctxt "theme-frontend" msgid "Tuesday" msgstr "Tiistai" -#: models/strings.php:232 +#: models/strings.php:241 msgctxt "theme-frontend" msgid "Wednesday" msgstr "Keskiviikko" -#: models/strings.php:233 +#: models/strings.php:242 msgctxt "theme-frontend" msgid "Thursday" msgstr "Torstai" -#: models/strings.php:234 +#: models/strings.php:243 msgctxt "theme-frontend" msgid "Friday" msgstr "Perjantai" -#: models/strings.php:235 +#: models/strings.php:244 msgctxt "theme-frontend" msgid "Saturday" msgstr "Lauantai" -#: models/strings.php:252 +#: models/strings.php:261 msgctxt "theme-frontend" msgid "Jan" msgstr "Tam" -#: models/strings.php:253 +#: models/strings.php:262 msgctxt "theme-frontend" msgid "Feb" msgstr "Hel" -#: models/strings.php:254 +#: models/strings.php:263 msgctxt "theme-frontend" msgid "Mar" msgstr "Maa" -#: models/strings.php:255 +#: models/strings.php:264 msgctxt "theme-frontend" msgid "Apr" msgstr "Huh" -#: models/strings.php:257 +#: models/strings.php:266 msgctxt "theme-frontend" msgid "Jun" msgstr "Kes" -#: models/strings.php:258 +#: models/strings.php:267 msgctxt "theme-frontend" msgid "Jul" msgstr "Hei" -#: models/strings.php:259 +#: models/strings.php:268 msgctxt "theme-frontend" msgid "Aug" msgstr "Elo" -#: models/strings.php:260 +#: models/strings.php:269 msgctxt "theme-frontend" msgid "Sept" msgstr "Syys" -#: models/strings.php:261 +#: models/strings.php:270 msgctxt "theme-frontend" msgid "Oct" msgstr "Loka" -#: models/strings.php:262 +#: models/strings.php:271 msgctxt "theme-frontend" msgid "Nov" msgstr "Mar" -#: models/strings.php:263 +#: models/strings.php:272 msgctxt "theme-frontend" msgid "Dec" msgstr "Jou" -#: models/strings.php:267 +#: models/strings.php:276 msgctxt "theme-frontend" msgid "Enlarged image" msgstr "Suurennettu kuva" -#: models/strings.php:271 +#: models/strings.php:280 msgctxt "theme-frontend" msgid "Load more" msgstr "Lataa lisää" -#: models/strings.php:272 +#: models/strings.php:281 msgctxt "theme-frontend" msgid "Load more programs" msgstr "Lataa lisää koulutuksia" -#: models/strings.php:273 +#: models/strings.php:282 msgctxt "theme-frontend" msgid "More results loaded" msgstr "Lisää tuloksia ladattu" -#: models/strings.php:286 +#: models/strings.php:295 msgid "Pagination" msgstr "Sivutus" -#: wp-content/mu-plugins/acf-codifier/src/Field/FlexibleContent.php:67 -#: wp-content/mu-plugins/acf-codifier/src/Field/Repeater.php:60 -msgid "Add Row" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisitePostObject.php:24 -msgid "Multisite Post Object" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteRelationship.php:24 -msgid "Multisite Relationship" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteTaxonomy.php:23 -msgid "Multisite taxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:23 -msgid "Multitaxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:516 -#, php-format -msgctxt "No terms" -msgid "No %s" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:18 -msgid "PHP" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:48 -msgid "Instructions" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:50 -msgid "" -"This field can only be used with ACF Codifier. Doesn't do anything if " -"defined in the admin side." -msgstr "" - #. Theme Name of the plugin/theme msgid "TMS Theme Tredu" msgstr "" @@ -1370,10 +1374,6 @@ msgstr "Geniem" msgid "https://geniem.fi" msgstr "" -#~ msgctxt "text direction" -#~ msgid "ltr" -#~ msgstr "ltr" - #~ msgid "Ongoing projects only" #~ msgstr "Näytä vain käynnissä olevat projektit" diff --git a/lang/tms-theme-base.pot b/lang/tms-theme-base.pot index 48e28eba..55d28c3e 100644 --- a/lang/tms-theme-base.pot +++ b/lang/tms-theme-base.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: TMS Theme Base\n" -"POT-Creation-Date: 2024-08-14 23:19+0300\n" +"POT-Creation-Date: 2024-09-03 08:27+0300\n" "PO-Revision-Date: 2022-01-12 10:08+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -23,6 +23,11 @@ msgstr "" "X-Poedit-SearchPathExcluded-1: vendor\n" "X-Poedit-SearchPathExcluded-2: node_modules\n" +#: assets/dist/vendor.js:4873 +msgctxt "text direction" +msgid "ltr" +msgstr "" + #: comments.php:14 msgid "Comments" msgstr "" @@ -586,6 +591,16 @@ msgstr "" msgid "No search results" msgstr "" +#: models/shared/program-favorites.php:53 models/strings.php:214 +msgctxt "theme-frontend" +msgid "Remove from favorites" +msgstr "" + +#: models/shared/program-favorites.php:54 +msgctxt "theme-frontend" +msgid "Go to program" +msgstr "" + #: models/single-dial-tredu.php:42 msgid "Go back" msgstr "" @@ -687,7 +702,7 @@ msgid "Search from site" msgstr "" #: models/strings.php:56 models/strings.php:83 models/strings.php:146 -#: models/strings.php:159 models/strings.php:168 models/strings.php:268 +#: models/strings.php:159 models/strings.php:168 models/strings.php:277 msgctxt "theme-frontend" msgid "Close" msgstr "" @@ -837,12 +852,12 @@ msgctxt "theme-frontend" msgid "Articletype:" msgstr "" -#: models/strings.php:111 models/strings.php:224 +#: models/strings.php:111 models/strings.php:233 msgctxt "theme-frontend" msgid "Month" msgstr "" -#: models/strings.php:112 models/strings.php:225 +#: models/strings.php:112 models/strings.php:234 msgctxt "theme-frontend" msgid "Year" msgstr "" @@ -862,62 +877,62 @@ msgctxt "theme-frontend" msgid "The page reloads after the selection." msgstr "" -#: models/strings.php:118 models/strings.php:238 +#: models/strings.php:118 models/strings.php:247 msgctxt "theme-frontend" msgid "January" msgstr "" -#: models/strings.php:119 models/strings.php:239 +#: models/strings.php:119 models/strings.php:248 msgctxt "theme-frontend" msgid "February" msgstr "" -#: models/strings.php:120 models/strings.php:240 +#: models/strings.php:120 models/strings.php:249 msgctxt "theme-frontend" msgid "March" msgstr "" -#: models/strings.php:121 models/strings.php:241 +#: models/strings.php:121 models/strings.php:250 msgctxt "theme-frontend" msgid "April" msgstr "" -#: models/strings.php:122 models/strings.php:242 models/strings.php:256 +#: models/strings.php:122 models/strings.php:251 models/strings.php:265 msgctxt "theme-frontend" msgid "May" msgstr "" -#: models/strings.php:123 models/strings.php:243 +#: models/strings.php:123 models/strings.php:252 msgctxt "theme-frontend" msgid "June" msgstr "" -#: models/strings.php:124 models/strings.php:244 +#: models/strings.php:124 models/strings.php:253 msgctxt "theme-frontend" msgid "July" msgstr "" -#: models/strings.php:125 models/strings.php:245 +#: models/strings.php:125 models/strings.php:254 msgctxt "theme-frontend" msgid "August" msgstr "" -#: models/strings.php:126 models/strings.php:246 +#: models/strings.php:126 models/strings.php:255 msgctxt "theme-frontend" msgid "September" msgstr "" -#: models/strings.php:127 models/strings.php:247 +#: models/strings.php:127 models/strings.php:256 msgctxt "theme-frontend" msgid "October" msgstr "" -#: models/strings.php:128 models/strings.php:248 +#: models/strings.php:128 models/strings.php:257 msgctxt "theme-frontend" msgid "November" msgstr "" -#: models/strings.php:129 models/strings.php:249 +#: models/strings.php:129 models/strings.php:258 msgctxt "theme-frontend" msgid "December" msgstr "" @@ -1129,219 +1144,208 @@ msgstr "" #: models/strings.php:208 msgctxt "theme-frontend" -msgid "Filter by type" +msgid "Favorites" msgstr "" #: models/strings.php:209 msgctxt "theme-frontend" -msgid "Publish date" +msgid "No favorites found" msgstr "" #: models/strings.php:210 msgctxt "theme-frontend" -msgid "Write search terms" +msgid "Open or close favorites" msgstr "" #: models/strings.php:211 msgctxt "theme-frontend" +msgid "Close favorites" +msgstr "" + +#: models/strings.php:212 +msgctxt "theme-frontend" +msgid "Add or remove from favorites" +msgstr "" + +#: models/strings.php:213 +msgctxt "theme-frontend" +msgid "Add to favorites" +msgstr "" + +#: models/strings.php:217 +msgctxt "theme-frontend" +msgid "Filter by type" +msgstr "" + +#: models/strings.php:218 +msgctxt "theme-frontend" +msgid "Publish date" +msgstr "" + +#: models/strings.php:219 +msgctxt "theme-frontend" +msgid "Write search terms" +msgstr "" + +#: models/strings.php:220 +msgctxt "theme-frontend" msgid "Page location:" msgstr "" -#: models/strings.php:214 +#: models/strings.php:223 msgctxt "theme-frontend" msgid "Filter" msgstr "" -#: models/strings.php:215 +#: models/strings.php:224 msgctxt "theme-frontend" msgid "Clicking the link will download file" msgstr "" -#: models/strings.php:219 models/strings.php:227 +#: models/strings.php:228 models/strings.php:236 msgctxt "theme-frontend" msgid "Pick a date" msgstr "" -#: models/strings.php:220 +#: models/strings.php:229 msgctxt "theme-frontend" msgid "dd.mm.yyyy" msgstr "" -#: models/strings.php:221 +#: models/strings.php:230 msgctxt "theme-frontend" msgid "The chosen date is" msgstr "" -#: models/strings.php:222 +#: models/strings.php:231 msgctxt "theme-frontend" msgid "Previous month" msgstr "" -#: models/strings.php:223 +#: models/strings.php:232 msgctxt "theme-frontend" msgid "Next month" msgstr "" -#: models/strings.php:226 +#: models/strings.php:235 msgctxt "theme-frontend" msgid "Close window" msgstr "" -#: models/strings.php:229 +#: models/strings.php:238 msgctxt "theme-frontend" msgid "Sunday" msgstr "" -#: models/strings.php:230 +#: models/strings.php:239 msgctxt "theme-frontend" msgid "Monday" msgstr "" -#: models/strings.php:231 +#: models/strings.php:240 msgctxt "theme-frontend" msgid "Tuesday" msgstr "" -#: models/strings.php:232 +#: models/strings.php:241 msgctxt "theme-frontend" msgid "Wednesday" msgstr "" -#: models/strings.php:233 +#: models/strings.php:242 msgctxt "theme-frontend" msgid "Thursday" msgstr "" -#: models/strings.php:234 +#: models/strings.php:243 msgctxt "theme-frontend" msgid "Friday" msgstr "" -#: models/strings.php:235 +#: models/strings.php:244 msgctxt "theme-frontend" msgid "Saturday" msgstr "" -#: models/strings.php:252 +#: models/strings.php:261 msgctxt "theme-frontend" msgid "Jan" msgstr "" -#: models/strings.php:253 +#: models/strings.php:262 msgctxt "theme-frontend" msgid "Feb" msgstr "" -#: models/strings.php:254 +#: models/strings.php:263 msgctxt "theme-frontend" msgid "Mar" msgstr "" -#: models/strings.php:255 +#: models/strings.php:264 msgctxt "theme-frontend" msgid "Apr" msgstr "" -#: models/strings.php:257 +#: models/strings.php:266 msgctxt "theme-frontend" msgid "Jun" msgstr "" -#: models/strings.php:258 +#: models/strings.php:267 msgctxt "theme-frontend" msgid "Jul" msgstr "" -#: models/strings.php:259 +#: models/strings.php:268 msgctxt "theme-frontend" msgid "Aug" msgstr "" -#: models/strings.php:260 +#: models/strings.php:269 msgctxt "theme-frontend" msgid "Sept" msgstr "" -#: models/strings.php:261 +#: models/strings.php:270 msgctxt "theme-frontend" msgid "Oct" msgstr "" -#: models/strings.php:262 +#: models/strings.php:271 msgctxt "theme-frontend" msgid "Nov" msgstr "" -#: models/strings.php:263 +#: models/strings.php:272 msgctxt "theme-frontend" msgid "Dec" msgstr "" -#: models/strings.php:267 +#: models/strings.php:276 msgctxt "theme-frontend" msgid "Enlarged image" msgstr "" -#: models/strings.php:271 +#: models/strings.php:280 msgctxt "theme-frontend" msgid "Load more" msgstr "" -#: models/strings.php:272 +#: models/strings.php:281 msgctxt "theme-frontend" msgid "Load more programs" msgstr "" -#: models/strings.php:273 +#: models/strings.php:282 msgctxt "theme-frontend" msgid "More results loaded" msgstr "" -#: models/strings.php:286 +#: models/strings.php:295 msgid "Pagination" msgstr "" -#: wp-content/mu-plugins/acf-codifier/src/Field/FlexibleContent.php:67 -#: wp-content/mu-plugins/acf-codifier/src/Field/Repeater.php:60 -msgid "Add Row" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisitePostObject.php:24 -msgid "Multisite Post Object" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteRelationship.php:24 -msgid "Multisite Relationship" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteTaxonomy.php:23 -msgid "Multisite taxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:23 -msgid "Multitaxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:516 -#, php-format -msgctxt "No terms" -msgid "No %s" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:18 -msgid "PHP" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:48 -msgid "Instructions" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:50 -msgid "" -"This field can only be used with ACF Codifier. Doesn't do anything if " -"defined in the admin side." -msgstr "" - #. Theme Name of the plugin/theme msgid "TMS Theme Tredu" msgstr "" diff --git a/models/shared/program-favorites.php b/models/shared/program-favorites.php new file mode 100644 index 00000000..2e30d8d2 --- /dev/null +++ b/models/shared/program-favorites.php @@ -0,0 +1,63 @@ +get_args(); + $data = [ + 'Favorites' => [], + ]; + $posts = []; + + if ( ! empty( $args ) ) { + $program_ids = $args->ids ?? []; + } + + if ( empty( $program_ids ) ) { + return []; + } + + foreach ( $program_ids as $key => $post_id ) { + // Comma separated program-type terms + $term_obj_list = \get_the_terms( $post_id, 'program-type' ); + $terms_string = join( ', ', wp_list_pluck( $term_obj_list, 'name' ) ); + $posts[ $key ] = [ + 'ID' => $post_id, + 'title' => \get_the_title( $post_id ), + 'program_types' => $terms_string, + 'start_date' => date( "d.m.Y", strtotime( \get_field( 'start_date', $post_id ) ) ), + 'start_info' => \get_field( 'start_info', $post_id ), + 'permalink' => \get_the_permalink( $post_id ), + 'remove_favorite_text' => \_x( 'Remove from favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'go_to_program_text' => \_x( 'Go to program', 'theme-frontend', 'tms-theme-tredu' ), + ]; + } + + // Assign favorite posts + $data['Favorites']['posts'] = $posts; + + return $data; + } +} diff --git a/models/strings.php b/models/strings.php index 90dd4a8d..469333bf 100644 --- a/models/strings.php +++ b/models/strings.php @@ -204,6 +204,15 @@ public function s() : array { 'scope' => _x( 'Scope', 'theme-frontend', 'tms-theme-tredu' ), 'who_can_apply' => _x( 'Who can apply?', 'theme-frontend', 'tms-theme-tredu' ), ], + 'program_favorite' => [ + 'favorites_title' => _x( 'Favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'no_favorites_text' => _x( 'No favorites found', 'theme-frontend', 'tms-theme-tredu' ), + 'open_or_close_favorites_text' => _x( 'Open or close favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'close_favorites_text' => _x( 'Close favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'add_to_favorites_aria_label' => _x( 'Add or remove from favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'add_to_favorites_text' => _x( 'Add to favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'remove_from_favorites_text' => _x( 'Remove from favorites', 'theme-frontend', 'tms-theme-tredu' ), + ], 'search' => [ 'filter_by_post_type' => _x( 'Filter by type', 'theme-frontend', 'tms-theme-tredu' ), 'filter_by_date' => _x( 'Publish date', 'theme-frontend', 'tms-theme-tredu' ), diff --git a/partials/shared/header-favorite-toggle.dust b/partials/shared/header-favorite-toggle.dust new file mode 100644 index 00000000..54ecbbd7 --- /dev/null +++ b/partials/shared/header-favorite-toggle.dust @@ -0,0 +1,7 @@ + diff --git a/partials/shared/header-favorites-container.dust b/partials/shared/header-favorites-container.dust new file mode 100644 index 00000000..d4b3ec26 --- /dev/null +++ b/partials/shared/header-favorites-container.dust @@ -0,0 +1,22 @@ + diff --git a/partials/shared/header-favorites-item.dust b/partials/shared/header-favorites-item.dust new file mode 100644 index 00000000..c72d6d92 --- /dev/null +++ b/partials/shared/header-favorites-item.dust @@ -0,0 +1,22 @@ +{#Favorites.posts} +
  • +

    {title|html}

    +

    {program_types|html}

    + {^start_info} +

    {start_date|html}

    + {:else} +

    {start_info|html}

    + {/start_info} +
    + {go_to_program_text|html} + +
    +
  • +{/Favorites.posts} diff --git a/partials/shared/header-inner.dust b/partials/shared/header-inner.dust index 1df407d2..0f8a2b5f 100644 --- a/partials/shared/header-inner.dust +++ b/partials/shared/header-inner.dust @@ -29,8 +29,10 @@ {>"ui/menu/language-nav-dropdown" links=Header.language_nav.links /} {/Header.lang_nav_horizontal} + {>"shared/header-favorite-toggle" /} + {^Header.hide_search} - {>"shared/header-search-toggle" /} + {>"shared/header-search-toggle" /} {/Header.hide_search} {?Header.has_nav_menu} @@ -45,6 +47,8 @@ + {>"shared/header-favorites-container" /} + {^Header.hide_search}