Skip to content

Commit bab982a

Browse files
committed
refactor: update classnames when selecting elements in DOM
1 parent c4e7553 commit bab982a

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function RemoteFunctions(config = {}) {
216216
*/
217217
function scrollImageToViewportIfRequired(element, imageGalleryElement) {
218218
let elementRect = element.getBoundingClientRect();
219-
let galleryRect = imageGalleryElement._shadow.querySelector('.phoenix-image-ribbon').getBoundingClientRect();
219+
let galleryRect = imageGalleryElement._shadow.querySelector('.phoenix-image-gallery-container').getBoundingClientRect();
220220

221221
// this will get true when the image element and the image gallery overlaps each other
222222
if (elementRect.bottom >= galleryRect.top) {
@@ -2616,6 +2616,7 @@ function RemoteFunctions(config = {}) {
26162616
26172617
<div class='phoenix-image-gallery-upload-container'>
26182618
<button>${ICONS.selectImageFromComputer} Upload</button>
2619+
<input type="file" class="phoenix-file-input" accept="image/*" style="display: none;">
26192620
</div>
26202621
26212622
<div class='phoenix-image-gallery-right-buttons'>
@@ -2755,7 +2756,7 @@ function RemoteFunctions(config = {}) {
27552756

27562757
_updateSearchInput: function(searchQuery) {
27572758
// write the current query in the search input
2758-
const searchInput = this._shadow.querySelector('.phoenix-ribbon-search input');
2759+
const searchInput = this._shadow.querySelector('.search-wrapper input');
27592760
if (searchInput && searchQuery) {
27602761
searchInput.value = searchQuery;
27612762
searchInput.placeholder = searchQuery;
@@ -2796,7 +2797,7 @@ function RemoteFunctions(config = {}) {
27962797
},
27972798

27982799
_handleNavLeft: function() {
2799-
const container = this._shadow.querySelector('.phoenix-ribbon-strip');
2800+
const container = this._shadow.querySelector('.phoenix-image-gallery-strip');
28002801
if (!container) { return; }
28012802

28022803
const containerWidth = container.clientWidth;
@@ -2808,7 +2809,7 @@ function RemoteFunctions(config = {}) {
28082809
},
28092810

28102811
_handleNavRight: function() {
2811-
const container = this._shadow.querySelector('.phoenix-ribbon-strip');
2812+
const container = this._shadow.querySelector('.phoenix-image-gallery-strip');
28122813
if (!container) { return; }
28132814

28142815
const containerWidth = container.clientWidth;
@@ -2832,9 +2833,9 @@ function RemoteFunctions(config = {}) {
28322833
// this function is responsible to update the nav buttons
28332834
// when we're at the very left, we hide the nav-left button completely
28342835
// when we're at the very right and no more pages available, we hide the nav-right button
2835-
const navLeft = this._shadow.querySelector('.phoenix-ribbon-nav.left');
2836-
const navRight = this._shadow.querySelector('.phoenix-ribbon-nav.right');
2837-
const container = this._shadow.querySelector('.phoenix-ribbon-strip');
2836+
const navLeft = this._shadow.querySelector('.phoenix-image-gallery-nav.left');
2837+
const navRight = this._shadow.querySelector('.phoenix-image-gallery-nav.right');
2838+
const container = this._shadow.querySelector('.phoenix-image-gallery-strip');
28382839

28392840
if (!navLeft || !navRight || !container) { return; }
28402841

@@ -2859,15 +2860,15 @@ function RemoteFunctions(config = {}) {
28592860
},
28602861

28612862
_showLoading: function() {
2862-
const rowElement = this._shadow.querySelector('.phoenix-ribbon-row');
2863+
const rowElement = this._shadow.querySelector('.phoenix-image-gallery-row');
28632864
if (!rowElement) { return; }
28642865

28652866
rowElement.innerHTML = config.strings.imageGalleryLoadingInitial;
2866-
rowElement.className = 'phoenix-ribbon-row phoenix-ribbon-loading';
2867+
rowElement.className = 'phoenix-image-gallery-row phoenix-image-gallery-loading';
28672868
},
28682869

28692870
_showLoadingMore: function() {
2870-
const rowElement = this._shadow.querySelector('.phoenix-ribbon-row');
2871+
const rowElement = this._shadow.querySelector('.phoenix-image-gallery-row');
28712872
if (!rowElement) { return; }
28722873

28732874
// when loading more images we need to show the message at the end of the image ribbon
@@ -2885,15 +2886,15 @@ function RemoteFunctions(config = {}) {
28852886
},
28862887

28872888
_attachEventHandlers: function() {
2888-
const ribbonContainer = this._shadow.querySelector('.phoenix-image-ribbon');
2889-
const ribbonStrip = this._shadow.querySelector('.phoenix-ribbon-strip');
2890-
const searchInput = this._shadow.querySelector('.phoenix-ribbon-search input');
2891-
const searchButton = this._shadow.querySelector('.phoenix-ribbon-search-btn');
2892-
const closeButton = this._shadow.querySelector('.phoenix-ribbon-close');
2893-
const folderSettingsButton = this._shadow.querySelector('.phoenix-ribbon-folder-settings');
2894-
const navLeft = this._shadow.querySelector('.phoenix-ribbon-nav.left');
2895-
const navRight = this._shadow.querySelector('.phoenix-ribbon-nav.right');
2896-
const selectImageBtn = this._shadow.querySelector('.phoenix-select-image-btn');
2889+
const ribbonContainer = this._shadow.querySelector('.phoenix-image-gallery-container');
2890+
const ribbonStrip = this._shadow.querySelector('.phoenix-image-gallery-strip');
2891+
const searchInput = this._shadow.querySelector('.search-wrapper input');
2892+
const searchButton = this._shadow.querySelector('.search-icon');
2893+
const closeButton = this._shadow.querySelector('.phoenix-image-gallery-close-button');
2894+
const folderSettingsButton = this._shadow.querySelector('.phoenix-image-gallery-download-folder-button');
2895+
const navLeft = this._shadow.querySelector('.phoenix-image-gallery-nav.left');
2896+
const navRight = this._shadow.querySelector('.phoenix-image-gallery-nav.right');
2897+
const selectImageBtn = this._shadow.querySelector('.phoenix-image-gallery-upload-container button');
28972898
const fileInput = this._shadow.querySelector('.phoenix-file-input');
28982899

28992900
if (searchInput && searchButton) {
@@ -3000,16 +3001,16 @@ function RemoteFunctions(config = {}) {
30003001
// append true means load more images (user clicked on nav-right)
30013002
// append false means its a new query
30023003
_renderImages: function(images, append = false) {
3003-
const rowElement = this._shadow.querySelector('.phoenix-ribbon-row');
3004+
const rowElement = this._shadow.querySelector('.phoenix-image-gallery-row');
30043005
if (!rowElement) { return; }
30053006

3006-
const container = this._shadow.querySelector('.phoenix-ribbon-strip');
3007+
const container = this._shadow.querySelector('.phoenix-image-gallery-strip');
30073008
const savedScrollPosition = container ? container.scrollLeft : 0;
30083009

30093010
// if not appending we clear the phoenix ribbon
30103011
if (!append) {
30113012
rowElement.innerHTML = '';
3012-
rowElement.className = 'phoenix-ribbon-row';
3013+
rowElement.className = 'phoenix-image-gallery-row';
30133014
} else {
30143015
// when appending we add the new images at the end
30153016
const loadingIndicator = this._shadow.querySelector('.phoenix-loading-more');
@@ -3113,11 +3114,11 @@ function RemoteFunctions(config = {}) {
31133114
},
31143115

31153116
_showError: function(message) {
3116-
const rowElement = this._shadow.querySelector('.phoenix-ribbon-row');
3117+
const rowElement = this._shadow.querySelector('.phoenix-image-gallery-row');
31173118
if (!rowElement) { return; }
31183119

31193120
rowElement.innerHTML = message;
3120-
rowElement.className = 'phoenix-ribbon-row phoenix-ribbon-error';
3121+
rowElement.className = 'phoenix-image-gallery-row phoenix-ribbon-error';
31213122
},
31223123

31233124
// file name with which we need to save the image

0 commit comments

Comments
 (0)