zoomora 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,10 +22,10 @@ var __spreadValues = (a, b) => {
22
22
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
23
 
24
24
  /*!
25
- * Zoomora Lightbox Plugin v1.1.0
25
+ * Zoomora Lightbox Plugin v1.2.1
26
26
  * A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
27
27
  *
28
- * Copyright (c) 2025 Faruk Ahmed (FrontTheme)
28
+ * Copyright (c) 2026 Faruk Ahmed (FrontTheme)
29
29
  * Licensed under MIT License
30
30
  */
31
31
  (function(global, factory) {
@@ -59,6 +59,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
59
59
  // Zoom step for scroll wheel
60
60
  animationDuration: 300,
61
61
  // Animation duration in ms
62
+ closeOnBackgroundClick: true,
63
+ // Close lightbox when clicking on background
62
64
  onOpen: null,
63
65
  // Callback when lightbox opens
64
66
  onClose: null,
@@ -162,21 +164,27 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
162
164
  <div class="zoomora" id="zoomoraLightbox">
163
165
  <div class="zoomora-container">
164
166
  <div class="zoomora-header" id="zoomoraHeader">
165
- <div class="zoomora-counter" id="zoomoraCounter">1 / 1</div>
167
+ <div class="zoomora-counter" id="zoomoraCounter" ${!this.options.showCounter ? 'style="opacity:0;visibility:hidden;"' : ""}>1 / 1</div>
166
168
  <div class="zoomora-controls">
167
- <button class="zoomora-btn" id="zoomoraThumbnailBtn" title="Toggle Thumbnails">
168
- <i class="zoomorai-thumbnails"></i>
169
- </button>
169
+ ${this.options.showThumbnails ? `
170
+ <button class="zoomora-btn" id="zoomoraThumbnailBtn" title="Toggle Thumbnails">
171
+ <i class="zoomorai-thumbnails"></i>
172
+ </button>
173
+ ` : ""}
170
174
  ${autoHideButtonHTML}
171
- <button class="zoomora-btn" id="zoomoraZoomBtn" title="Zoom">
172
- <i class="zoomorai-zoom"></i>
173
- </button>
174
- <button class="zoomora-btn" id="zoomoraFullscreenBtn" title="Fullscreen">
175
- <i class="zoomorai-expand"></i>
176
- </button>
177
- <button class="zoomora-btn" id="zoomoraCollapseBtn" title="Exit Fullscreen" style="display: none;">
178
- <i class="zoomorai-collapse"></i>
179
- </button>
175
+ ${this.options.showZoom ? `
176
+ <button class="zoomora-btn" id="zoomoraZoomBtn" title="Zoom">
177
+ <i class="zoomorai-zoom"></i>
178
+ </button>
179
+ ` : ""}
180
+ ${this.options.showFullscreen ? `
181
+ <button class="zoomora-btn" id="zoomoraFullscreenBtn" title="Fullscreen">
182
+ <i class="zoomorai-expand"></i>
183
+ </button>
184
+ <button class="zoomora-btn" id="zoomoraCollapseBtn" title="Exit Fullscreen" style="display: none;">
185
+ <i class="zoomorai-collapse"></i>
186
+ </button>
187
+ ` : ""}
180
188
  <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">
181
189
  <i class="zoomorai-close"></i>
182
190
  </button>
@@ -195,8 +203,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
195
203
  <i class="zoomorai-arrow-right"></i>
196
204
  </button>
197
205
 
198
- <div class="zoomora-caption" id="zoomoraCaption"></div>
199
- <div class="zoomora-thumbnails" id="zoomoraThumbs"></div>
206
+ <div class="zoomora-caption" id="zoomoraCaption" ${!this.options.showThumbnails ? 'style="bottom:20px;"' : ""}></div>
207
+ <div class="zoomora-thumbnails" id="zoomoraThumbs" ${!this.options.showThumbnails ? 'style="display:none;"' : ""}></div>
200
208
  </div>
201
209
  </div>
202
210
  `;
@@ -223,10 +231,16 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
223
231
  this.addEventListener(document.getElementById("zoomoraCloseBtn"), "click", () => this.close());
224
232
  this.addEventListener(document.getElementById("zoomoraPrevBtn"), "click", () => this.prev());
225
233
  this.addEventListener(document.getElementById("zoomoraNextBtn"), "click", () => this.next());
226
- this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom());
227
- this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen());
228
- this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen());
229
- this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails());
234
+ if (this.options.showZoom) {
235
+ this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom());
236
+ }
237
+ if (this.options.showFullscreen) {
238
+ this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen());
239
+ this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen());
240
+ }
241
+ if (this.options.showThumbnails) {
242
+ this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails());
243
+ }
230
244
  this.addEventListener(document, "fullscreenchange", this.boundMethods.handleFullscreenChange);
231
245
  this.addEventListener(document, "webkitfullscreenchange", this.boundMethods.handleFullscreenChange);
232
246
  this.addEventListener(document, "mozfullscreenchange", this.boundMethods.handleFullscreenChange);
@@ -313,11 +327,15 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
313
327
  * Handle fullscreen change events
314
328
  */
315
329
  handleFullscreenChange() {
316
- const isInFullscreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement;
330
+ const isInFullscreen = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
317
331
  if (!isInFullscreen && this.isFullscreen) {
318
332
  this.isFullscreen = false;
319
333
  this.zoomora.classList.remove("fullscreen");
320
334
  this.updateButtons();
335
+ } else if (isInFullscreen && !this.isFullscreen) {
336
+ this.isFullscreen = true;
337
+ this.zoomora.classList.add("fullscreen");
338
+ this.updateButtons();
321
339
  }
322
340
  }
323
341
  /**
@@ -325,7 +343,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
325
343
  * @param {Event} e - Click event
326
344
  */
327
345
  handleZoomoraClick(e) {
328
- if (e.target === this.zoomora) {
346
+ if (e.target === this.zoomora && this.options.closeOnBackgroundClick) {
329
347
  this.close();
330
348
  }
331
349
  }
@@ -337,9 +355,37 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
337
355
  if (Date.now() - this.lastDragTime < 200) {
338
356
  return;
339
357
  }
340
- const media = e.target.closest(".zoomora-media");
341
- if (media && !media.classList.contains("no-zoom")) {
342
- this.toggleZoom();
358
+ if (this.header && this.header.contains(e.target)) {
359
+ return;
360
+ }
361
+ if (e.target.closest("button")) {
362
+ return;
363
+ }
364
+ const mediaElement = e.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");
365
+ if (mediaElement) {
366
+ if (mediaElement.classList.contains("zoomora-media") && !mediaElement.classList.contains("no-zoom")) {
367
+ this.toggleZoom();
368
+ }
369
+ return;
370
+ }
371
+ const videoContainer = e.target.closest(".zoomora-video-container");
372
+ if (videoContainer) {
373
+ if (e.target.closest(".zoomora-play-button")) {
374
+ return;
375
+ }
376
+ if (this.options.closeOnBackgroundClick) {
377
+ this.close();
378
+ }
379
+ return;
380
+ }
381
+ const clickedElement = e.target;
382
+ const isBackgroundElement = clickedElement.classList.contains("zoomora-content") || clickedElement.classList.contains("zoomora-slide-container") || clickedElement.classList.contains("zoomora-slide") || clickedElement.classList.contains("zoomora-slides-container") || clickedElement.id === "zoomoraContent" || clickedElement.id === "zoomoraSlidesContainer";
383
+ if (isBackgroundElement && this.options.closeOnBackgroundClick) {
384
+ this.close();
385
+ return;
386
+ }
387
+ if (this.options.closeOnBackgroundClick) {
388
+ this.close();
343
389
  }
344
390
  }
345
391
  /**
@@ -805,11 +851,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
805
851
  img.classList.add("no-zoom");
806
852
  }
807
853
  }
808
- /**
809
- * Calculate zoom levels for an image
810
- * @param {HTMLImageElement} img - Image element
811
- * @returns {Object} Zoom configuration
812
- */
813
854
  /**
814
855
  * Calculate zoom levels for an image
815
856
  * @param {HTMLImageElement} img - Image element
@@ -950,7 +991,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
950
991
  if (!media || media.tagName !== "IMG") return;
951
992
  const zoomConfig = this.calculateZoomLevels(media);
952
993
  if (!zoomConfig.canZoom) {
953
- console.log("Image cannot be zoomed (already at full size or larger)");
954
994
  return;
955
995
  }
956
996
  if (!media.dataset.zoomLevel) {
@@ -981,7 +1021,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
981
1021
  media.style.transform = `translate(0px, 0px) scale(${targetScale})`;
982
1022
  media.style.cursor = "grab";
983
1023
  media.classList.add("zoomed");
984
- console.log(`Zoomed to level ${currentLevel}/${zoomConfig.levels.length - 1} (${(targetScale * 100).toFixed(0)}%)`);
985
1024
  }
986
1025
  }
987
1026
  /**
@@ -1013,17 +1052,37 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1013
1052
  */
1014
1053
  enterFullscreen() {
1015
1054
  const element = this.zoomora;
1016
- const requestFullscreen = element.requestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen || element.msRequestFullscreen;
1017
- if (requestFullscreen) {
1018
- requestFullscreen.call(element).then(() => {
1055
+ try {
1056
+ if (element.requestFullscreen) {
1057
+ element.requestFullscreen().then(() => {
1058
+ this.isFullscreen = true;
1059
+ this.zoomora.classList.add("fullscreen");
1060
+ this.updateButtons();
1061
+ }).catch((err) => {
1062
+ console.warn("Zoomora: Fullscreen request failed:", err.message);
1063
+ this.fallbackFullscreen();
1064
+ });
1065
+ } else if (element.webkitRequestFullscreen) {
1066
+ element.webkitRequestFullscreen();
1019
1067
  this.isFullscreen = true;
1020
1068
  this.zoomora.classList.add("fullscreen");
1021
1069
  this.updateButtons();
1022
- }).catch((err) => {
1023
- console.warn("Zoomora: Could not enter fullscreen:", err);
1070
+ } else if (element.mozRequestFullScreen) {
1071
+ element.mozRequestFullScreen();
1072
+ this.isFullscreen = true;
1073
+ this.zoomora.classList.add("fullscreen");
1074
+ this.updateButtons();
1075
+ } else if (element.msRequestFullscreen) {
1076
+ element.msRequestFullscreen();
1077
+ this.isFullscreen = true;
1078
+ this.zoomora.classList.add("fullscreen");
1079
+ this.updateButtons();
1080
+ } else {
1081
+ console.warn("Zoomora: Fullscreen API not supported, using CSS fallback");
1024
1082
  this.fallbackFullscreen();
1025
- });
1026
- } else {
1083
+ }
1084
+ } catch (error) {
1085
+ console.error("Zoomora: Error entering fullscreen:", error);
1027
1086
  this.fallbackFullscreen();
1028
1087
  }
1029
1088
  }
@@ -1031,22 +1090,41 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1031
1090
  * Exit fullscreen mode
1032
1091
  */
1033
1092
  exitFullscreen() {
1034
- const isInFullscreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement;
1035
- if (isInFullscreen) {
1036
- const exitFullscreen = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
1037
- if (exitFullscreen) {
1038
- exitFullscreen.call(document).then(() => {
1093
+ const isInFullscreen = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
1094
+ if (!isInFullscreen) {
1095
+ this.fallbackExitFullscreen();
1096
+ return;
1097
+ }
1098
+ try {
1099
+ if (document.exitFullscreen) {
1100
+ document.exitFullscreen().then(() => {
1039
1101
  this.isFullscreen = false;
1040
1102
  this.zoomora.classList.remove("fullscreen");
1041
1103
  this.updateButtons();
1042
1104
  }).catch((err) => {
1043
- console.warn("Zoomora: Could not exit fullscreen:", err);
1105
+ console.warn("Zoomora: Exit fullscreen failed:", err.message);
1044
1106
  this.fallbackExitFullscreen();
1045
1107
  });
1108
+ } else if (document.webkitExitFullscreen) {
1109
+ document.webkitExitFullscreen();
1110
+ this.isFullscreen = false;
1111
+ this.zoomora.classList.remove("fullscreen");
1112
+ this.updateButtons();
1113
+ } else if (document.mozCancelFullScreen) {
1114
+ document.mozCancelFullScreen();
1115
+ this.isFullscreen = false;
1116
+ this.zoomora.classList.remove("fullscreen");
1117
+ this.updateButtons();
1118
+ } else if (document.msExitFullscreen) {
1119
+ document.msExitFullscreen();
1120
+ this.isFullscreen = false;
1121
+ this.zoomora.classList.remove("fullscreen");
1122
+ this.updateButtons();
1046
1123
  } else {
1047
1124
  this.fallbackExitFullscreen();
1048
1125
  }
1049
- } else {
1126
+ } catch (error) {
1127
+ console.error("Zoomora: Error exiting fullscreen:", error);
1050
1128
  this.fallbackExitFullscreen();
1051
1129
  }
1052
1130
  }