Source

frontend/helpers/verse_list_title_helper.js

  1. /* This file is part of Ezra Bible App.
  2. Copyright (C) 2019 - 2023 Ezra Bible App Development Team <contact@ezrabibleapp.net>
  3. Ezra Bible App is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. Ezra Bible App is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with Ezra Bible App. See the file LICENSE.
  13. If not, see <http://www.gnu.org/licenses/>. */
  14. /**
  15. * This module contains helper functions to assemble the tab / dialog titles for verse lists (xrefs, tagged verses)
  16. * @module verse_list_title_helper
  17. * @category Helper
  18. */
  19. module.exports.getTaggedVerseListTitle = function(localizedReference, tagTitle) {
  20. localizedReference = localizedReference != null && localizedReference != '' ? localizedReference + ' &ndash; ' : '';
  21. var title = '';
  22. if (platformHelper.isMobile()) {
  23. title = tagTitle;
  24. } else {
  25. title = `${localizedReference}${i18n.t("tags.verses-tagged-with")} <i>${tagTitle}</i>`;
  26. }
  27. return title;
  28. };
  29. module.exports.getXrefsVerseListTitle = function(localizedReference) {
  30. var title = `${localizedReference} &ndash; ${i18n.t("general.module-xrefs")}`;
  31. return title;
  32. };
  33. module.exports.shortenTitleList = function(tagTitleList, lastElement='...') {
  34. const MAX_TAGS_IN_TITLE = 3;
  35. if (tagTitleList != null) {
  36. var tagTitleArray = tagTitleList.split(',');
  37. if (tagTitleArray.length > MAX_TAGS_IN_TITLE) {
  38. while (tagTitleArray.length > MAX_TAGS_IN_TITLE) {
  39. tagTitleArray.pop();
  40. }
  41. tagTitleArray.push(lastElement);
  42. tagTitleList = tagTitleArray.join(', ');
  43. }
  44. }
  45. return tagTitleList;
  46. };