From 32b32df4acf8aad712495c2afd1655d9e8c628e7 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Sun, 18 Aug 2019 17:28:11 +0300 Subject: [PATCH] v5: PhotoBrowser: new navbarShowCount param --- .../components/photo-browser/photo-browser-class.js | 10 ++++++++-- src/core/components/photo-browser/photo-browser.d.ts | 2 ++ src/core/components/photo-browser/photo-browser.js | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core/components/photo-browser/photo-browser-class.js b/src/core/components/photo-browser/photo-browser-class.js index ca95475794..bba16ac94a 100644 --- a/src/core/components/photo-browser/photo-browser-class.js +++ b/src/core/components/photo-browser/photo-browser-class.js @@ -73,8 +73,10 @@ class PhotoBrowser extends Framework7Class { $totalEl = $(navbarEl).find('.photo-browser-total'); } } - $currentEl.text(current); - $totalEl.text(total); + if ($currentEl.length && $totalEl.length) { + $currentEl.text(current); + $totalEl.text(total); + } // Update captions if (pb.captions.length > 0) { @@ -167,6 +169,8 @@ class PhotoBrowser extends Framework7Class { const backLinkText = (pb.app.theme === 'ios' || pb.app.theme === 'aurora') && pb.params.backLinkText ? pb.params.backLinkText : ''; + const renderNavbarCount = typeof pb.params.navbarShowCount === 'undefined' ? pb.params.photos.length > 0 : pb.params.navbarShowCount; + const isPopup = pb.params.type !== 'page'; const navbarHtml = ` + ${renderNavbarCount ? `
${pb.params.navbarOfText}
+ ` : ''}
diff --git a/src/core/components/photo-browser/photo-browser.d.ts b/src/core/components/photo-browser/photo-browser.d.ts index e9b884f5bb..2da7000acd 100644 --- a/src/core/components/photo-browser/photo-browser.d.ts +++ b/src/core/components/photo-browser/photo-browser.d.ts @@ -40,6 +40,8 @@ export namespace PhotoBrowser { backLinkText?: string /** Text of "of" in photos counter: "3 of 5" (default "of") */ navbarOfText?: string + /** Defines should it display "3 of 5" text in navbar title or not. If not specified (undefined) then it will show this text if there is more than 1 item */ + navbarShowCount?: boolean | undefined /** One of the default colors */ iconsColor?: string /** Swiper parameters */ diff --git a/src/core/components/photo-browser/photo-browser.js b/src/core/components/photo-browser/photo-browser.js index 475f22c6e9..8fa2f37213 100644 --- a/src/core/components/photo-browser/photo-browser.js +++ b/src/core/components/photo-browser/photo-browser.js @@ -17,6 +17,7 @@ export default { swipeToClose: true, backLinkText: 'Close', navbarOfText: 'of', + navbarShowCount: undefined, view: undefined, url: 'photos/', routableModals: true,