@simhub2/justflipit 3.0.0 → 3.1.0

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.
@@ -160,9 +160,10 @@
160
160
  Click: false,
161
161
  FlipX: false,
162
162
  Style: [],
163
- // NEU: Standard-Animationsoptionen
164
163
  Duration: 400,
165
164
  Easing: "ease-in-out",
165
+ preserveClasses: true, // NEU
166
+ preserveStyles: true // NEU
166
167
  },
167
168
  options,
168
169
  );
@@ -186,63 +187,51 @@
186
187
  _init() {
187
188
  const originalElement = this.element;
188
189
  const originalClassName = this.originalClassName;
190
+
191
+ // Panel-Struktur erzeugen
189
192
  const hoverPanel = document.createElement(this.originalTagName);
190
193
  addClass(hoverPanel, "hover");
191
194
  addClass(hoverPanel, "_justFlipIt_panel");
192
195
  const frontWrapper = document.createElement("div");
193
196
  addClass(frontWrapper, "front");
194
- const clone = originalElement.cloneNode(true);
195
- clone.className = "";
196
197
  const backWrapper = document.createElement("div");
197
198
  addClass(backWrapper, this.backClass);
198
- if (originalClassName) {
199
- originalClassName.split(" ").forEach((cls) => {
200
- if (cls) addClass(backWrapper, cls);
199
+
200
+ // NEU: Klassen übernehmen (Panel, .front, .backY)
201
+ if (this.settings.preserveClasses && originalElement.classList.length) {
202
+ originalElement.classList.forEach(cls => {
203
+ if (!hoverPanel.classList.contains(cls)) hoverPanel.classList.add(cls);
204
+ if (frontWrapper && !frontWrapper.classList.contains(cls)) frontWrapper.classList.add(cls);
205
+ if (backWrapper && !backWrapper.classList.contains(cls)) backWrapper.classList.add(cls);
201
206
  });
202
207
  }
203
208
 
204
- // PATCH: Styles übernehmen und Original komplett transparent machen
205
- copyStyles(originalElement, frontWrapper);
206
- copyStyles(originalElement, backWrapper);
209
+ // NEU: Inline-Styles übernehmen (nur auf Panel)
210
+ if (this.settings.preserveStyles && originalElement.getAttribute("style")) {
211
+ hoverPanel.setAttribute("style", (hoverPanel.getAttribute("style") || "") +
212
+ ";" + originalElement.getAttribute("style"));
213
+ }
207
214
 
208
- // Mache das Original komplett transparent und ohne Border/Shadow/usw.
209
- originalElement.style.all = "inherit"; // Reset alles zur Sicherheit
210
- originalElement.style.background = "transparent";
211
- originalElement.style.backgroundColor = "transparent";
212
- originalElement.style.backgroundImage = "none";
213
- originalElement.style.border = "none";
214
- originalElement.style.borderRadius = "0";
215
- originalElement.style.boxShadow = "none";
216
- originalElement.style.outline = "none";
217
-
218
- // NEU: Wende benutzerdefinierte Animationseinstellungen an
219
- applyAnimationSettings(
220
- frontWrapper,
221
- this.settings.Duration,
222
- this.settings.Easing,
223
- );
224
- applyAnimationSettings(
225
- backWrapper,
226
- this.settings.Duration,
227
- this.settings.Easing,
228
- );
215
+ // Nur den INHALT übernehmen!
216
+ frontWrapper.innerHTML = originalElement.innerHTML;
229
217
 
230
218
  if (this.settings.Template) {
231
219
  backWrapper.innerHTML = this.settings.Template;
232
220
  } else {
233
- backWrapper.appendChild(clone);
221
+ backWrapper.innerHTML = originalElement.innerHTML;
234
222
  }
223
+
224
+ // Panel einfügen und Original entfernen
235
225
  originalElement.parentNode.insertBefore(hoverPanel, originalElement);
236
- frontWrapper.appendChild(originalElement);
237
226
  hoverPanel.appendChild(frontWrapper);
238
227
  hoverPanel.appendChild(backWrapper);
239
- if (originalClassName) {
240
- originalClassName.split(" ").forEach((cls) => {
241
- if (cls) addClass(hoverPanel, cls);
242
- });
243
- }
228
+ originalElement.parentNode.removeChild(originalElement);
229
+
230
+ // Panel-Größe und Styles übernehmen
244
231
  hoverPanel.style.width = this.elementWidth;
245
232
  hoverPanel.style.height = this.elementHeight;
233
+
234
+ // Custom Styles aus Option anwenden
246
235
  if (this.settings.Style && this.settings.Style.length) {
247
236
  this.settings.Style.forEach((styleObj) => {
248
237
  if (styleObj.el) {
@@ -257,7 +246,11 @@
257
246
  }
258
247
  });
259
248
  }
249
+
250
+ // Events setzen
260
251
  this._setupEvents(hoverPanel);
252
+
253
+ // Referenzen speichern
261
254
  this.hoverPanel = hoverPanel;
262
255
  this.frontWrapper = frontWrapper;
263
256
  this.backWrapper = backWrapper;
@@ -1 +1 @@
1
- ((t,e)=>{"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.justFlipIt=e()})("undefined"!=typeof self?self:this,function(){function a(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function o(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var i,s;t.classList?t.classList.toggle(e):(0<=(s=(i=t.className.split(" ")).indexOf(e))?i.splice(s,1):i.push(e),t.className=i.join(" "))}function r(t,e){let i=window.getComputedStyle(t);["background","backgroundColor","backgroundImage","backgroundPosition","backgroundRepeat","backgroundSize","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","borderTop","borderRight","borderBottom","borderLeft","boxShadow","color","opacity"].forEach(t=>{i[t]&&"none"!==i[t]&&"initial"!==i[t]&&""!==i[t]&&(e.style[t]=i[t])})}function l(t,e,i){e=`all ${e/1e3}s `+i;t.style.transition=e,t.style.WebkitTransition=e,t.style.MozTransition=e,t.style.msTransition=e,t.style.OTransition=e}let d=new WeakMap;class s{constructor(t,e={}){var i,s,n;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),i.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}",(s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),s.textContent="._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}",(n=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),n.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(i),document.head.appendChild(s),document.head.appendChild(n)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out"},e),this.elementWidth=a(t,"width"),this.elementHeight=a(t,"height"),this.elementBackgroundColor=a(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),d.set(t,this)}_init(){var t=this.element,e=this.originalClassName;let i=document.createElement(this.originalTagName);o(i,"hover"),o(i,"_justFlipIt_panel");var s=document.createElement("div"),n=(o(s,"front"),t.cloneNode(!0));n.className="";let a=document.createElement("div");o(a,this.backClass),e&&e.split(" ").forEach(t=>{t&&o(a,t)}),r(t,s),r(t,a),t.style.all="inherit",t.style.background="transparent",t.style.backgroundColor="transparent",t.style.backgroundImage="none",t.style.border="none",t.style.borderRadius="0",t.style.boxShadow="none",t.style.outline="none",l(s,this.settings.Duration,this.settings.Easing),l(a,this.settings.Duration,this.settings.Easing),this.settings.Template?a.innerHTML=this.settings.Template:a.appendChild(n),t.parentNode.insertBefore(i,t),s.appendChild(t),i.appendChild(s),i.appendChild(a),e&&e.split(" ").forEach(t=>{t&&o(i,t)}),i.style.width=this.elementWidth,i.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(i.style,e.style):i.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(i),this.hoverPanel=i,this.frontWrapper=s,this.backWrapper=a}_setupEvents(i){!0===this.settings.Click?i.addEventListener("click",t=>{t.preventDefault(),e(i,this.flipClass)}):"string"==typeof this.settings.Click?i.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(i,this.flipClass)})}):(i.addEventListener("mouseenter",()=>{o(i,this.flipClass)}),i.addEventListener("mouseleave",()=>{var t,e;t=i,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),d.delete(this.element)}}function t(t,e={}){var i;return"string"==typeof t?(i=document.querySelectorAll(t),Array.from(i).map(t=>new s(t,e))):t instanceof Element?new s(t,e):t.length?Array.from(t).map(t=>new s(t,e)):void 0}return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=d.get(t);t&&t.destroy()})):t instanceof Element?(e=d.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=d.get(t);t&&t.destroy()})},t});
1
+ ((t,e)=>{"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.justFlipIt=e()})("undefined"!=typeof self?self:this,function(){function n(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function a(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var s,i;t.classList?t.classList.toggle(e):(0<=(i=(s=t.className.split(" ")).indexOf(e))?s.splice(i,1):s.push(e),t.className=s.join(" "))}let l=new WeakMap;class i{constructor(t,e={}){var s,i,a;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),s.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}",(i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),i.textContent="._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}",(a=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),a.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(s),document.head.appendChild(i),document.head.appendChild(a)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out",preserveClasses:!0,preserveStyles:!0},e),this.elementWidth=n(t,"width"),this.elementHeight=n(t,"height"),this.elementBackgroundColor=n(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),l.set(t,this)}_init(){var t=this.element;this.originalClassName;let s=document.createElement(this.originalTagName),e=(a(s,"hover"),a(s,"_justFlipIt_panel"),document.createElement("div")),i=(a(e,"front"),document.createElement("div"));a(i,this.backClass),this.settings.preserveClasses&&t.classList.length&&t.classList.forEach(t=>{s.classList.contains(t)||s.classList.add(t),e&&!e.classList.contains(t)&&e.classList.add(t),i&&!i.classList.contains(t)&&i.classList.add(t)}),this.settings.preserveStyles&&t.getAttribute("style")&&s.setAttribute("style",(s.getAttribute("style")||"")+";"+t.getAttribute("style")),e.innerHTML=t.innerHTML,this.settings.Template?i.innerHTML=this.settings.Template:i.innerHTML=t.innerHTML,t.parentNode.insertBefore(s,t),s.appendChild(e),s.appendChild(i),t.parentNode.removeChild(t),s.style.width=this.elementWidth,s.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(s.style,e.style):s.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(s),this.hoverPanel=s,this.frontWrapper=e,this.backWrapper=i}_setupEvents(s){!0===this.settings.Click?s.addEventListener("click",t=>{t.preventDefault(),e(s,this.flipClass)}):"string"==typeof this.settings.Click?s.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(s,this.flipClass)})}):(s.addEventListener("mouseenter",()=>{a(s,this.flipClass)}),s.addEventListener("mouseleave",()=>{var t,e;t=s,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),l.delete(this.element)}}function t(t,e={}){var s;return"string"==typeof t?(s=document.querySelectorAll(t),Array.from(s).map(t=>new i(t,e))):t instanceof Element?new i(t,e):t.length?Array.from(t).map(t=>new i(t,e)):void 0}return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=l.get(t);t&&t.destroy()})):t instanceof Element?(e=l.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=l.get(t);t&&t.destroy()})},t});
@@ -169,6 +169,8 @@
169
169
  // NEU: Standard-Animationsoptionen
170
170
  Duration: 400,
171
171
  Easing: "ease-in-out",
172
+ preserveClasses: true, // NEU
173
+ preserveStyles: true // NEU
172
174
  },
173
175
  options,
174
176
  );
@@ -192,61 +194,51 @@
192
194
  _init() {
193
195
  const originalElement = this.element;
194
196
  const originalClassName = this.originalClassName;
197
+
198
+ // Panel-Struktur erzeugen
195
199
  const hoverPanel = document.createElement(this.originalTagName);
196
200
  addClass(hoverPanel, "hover");
197
201
  addClass(hoverPanel, "_justFlipIt_panel");
198
202
  const frontWrapper = document.createElement("div");
199
203
  addClass(frontWrapper, "front");
200
- const clone = originalElement.cloneNode(true);
201
- clone.className = "";
202
204
  const backWrapper = document.createElement("div");
203
205
  addClass(backWrapper, this.backClass);
204
- if (originalClassName) {
205
- originalClassName.split(" ").forEach((cls) => {
206
- if (cls) addClass(backWrapper, cls);
206
+
207
+ // NEU: Klassen übernehmen (Panel, .front, .backY)
208
+ if (this.settings.preserveClasses && originalElement.classList.length) {
209
+ originalElement.classList.forEach(cls => {
210
+ if (!hoverPanel.classList.contains(cls)) hoverPanel.classList.add(cls);
211
+ if (frontWrapper && !frontWrapper.classList.contains(cls)) frontWrapper.classList.add(cls);
212
+ if (backWrapper && !backWrapper.classList.contains(cls)) backWrapper.classList.add(cls);
207
213
  });
208
214
  }
209
215
 
210
- // PATCH: Styles übernehmen und Original komplett transparent machen
211
- copyStyles(originalElement, frontWrapper);
212
- copyStyles(originalElement, backWrapper);
213
- originalElement.style.all = "inherit";
214
- originalElement.style.background = "transparent";
215
- originalElement.style.backgroundColor = "transparent";
216
- originalElement.style.backgroundImage = "none";
217
- originalElement.style.border = "none";
218
- originalElement.style.borderRadius = "0";
219
- originalElement.style.boxShadow = "none";
220
- originalElement.style.outline = "none";
216
+ // NEU: Inline-Styles übernehmen (nur auf Panel)
217
+ if (this.settings.preserveStyles && originalElement.getAttribute("style")) {
218
+ hoverPanel.setAttribute("style", (hoverPanel.getAttribute("style") || "") +
219
+ ";" + originalElement.getAttribute("style"));
220
+ }
221
221
 
222
- // NEU: Wende benutzerdefinierte Animationseinstellungen an
223
- applyAnimationSettings(
224
- frontWrapper,
225
- this.settings.Duration,
226
- this.settings.Easing,
227
- );
228
- applyAnimationSettings(
229
- backWrapper,
230
- this.settings.Duration,
231
- this.settings.Easing,
232
- );
222
+ // Nur den INHALT übernehmen!
223
+ frontWrapper.innerHTML = originalElement.innerHTML;
233
224
 
234
225
  if (this.settings.Template) {
235
226
  backWrapper.innerHTML = this.settings.Template;
236
227
  } else {
237
- backWrapper.appendChild(clone);
228
+ backWrapper.innerHTML = originalElement.innerHTML;
238
229
  }
230
+
231
+ // Panel einfügen und Original entfernen
239
232
  originalElement.parentNode.insertBefore(hoverPanel, originalElement);
240
- frontWrapper.appendChild(originalElement);
241
233
  hoverPanel.appendChild(frontWrapper);
242
234
  hoverPanel.appendChild(backWrapper);
243
- if (originalClassName) {
244
- originalClassName.split(" ").forEach((cls) => {
245
- if (cls) addClass(hoverPanel, cls);
246
- });
247
- }
235
+ originalElement.parentNode.removeChild(originalElement);
236
+
237
+ // Panel-Größe und Styles übernehmen
248
238
  hoverPanel.style.width = this.elementWidth;
249
239
  hoverPanel.style.height = this.elementHeight;
240
+
241
+ // Custom Styles aus Option anwenden
250
242
  if (this.settings.Style && this.settings.Style.length) {
251
243
  this.settings.Style.forEach((styleObj) => {
252
244
  if (styleObj.el) {
@@ -261,7 +253,11 @@
261
253
  }
262
254
  });
263
255
  }
256
+
257
+ // Events setzen
264
258
  this._setupEvents(hoverPanel);
259
+
260
+ // Referenzen speichern
265
261
  this.hoverPanel = hoverPanel;
266
262
  this.frontWrapper = frontWrapper;
267
263
  this.backWrapper = backWrapper;
@@ -1 +1 @@
1
- ((e,i)=>{if("function"==typeof define&&define.amd)define(["jquery"],function(t){return i(t||e.jQuery||e.$)});else if("object"==typeof module&&module.exports){var s="undefined"!=typeof window?window.jQuery:void 0;if(!s)try{s=require("jquery")}catch(t){s=null}module.exports=i(s)}else e.justFlipIt=i(e.jQuery||e.$)})("undefined"!=typeof self?self:this,function(i){function o(t,e){let i=window.getComputedStyle(t);["background","backgroundColor","backgroundImage","backgroundPosition","backgroundRepeat","backgroundSize","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","borderTop","borderRight","borderBottom","borderLeft","boxShadow","color","opacity"].forEach(function(t){i[t]&&"none"!==i[t]&&"initial"!==i[t]&&""!==i[t]&&(e.style[t]=i[t])})}function r(t,e,i){e=`all ${e/1e3}s `+i;t.style.transition=e,t.style.WebkitTransition=e,t.style.MozTransition=e,t.style.msTransition=e,t.style.OTransition=e}function a(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function l(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var i,s;t.classList?t.classList.toggle(e):(0<=(s=(i=t.className.split(" ")).indexOf(e))?i.splice(s,1):i.push(e),t.className=i.join(" "))}let d=new WeakMap;class s{constructor(t,e={}){var i,s,n;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),i.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}",(s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),s.textContent="._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}",(n=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),n.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(i),document.head.appendChild(s),document.head.appendChild(n)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out"},e),this.elementWidth=a(t,"width"),this.elementHeight=a(t,"height"),this.elementBackgroundColor=a(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),d.set(t,this)}_init(){var t=this.element,e=this.originalClassName;let i=document.createElement(this.originalTagName);l(i,"hover"),l(i,"_justFlipIt_panel");var s=document.createElement("div"),n=(l(s,"front"),t.cloneNode(!0));n.className="";let a=document.createElement("div");l(a,this.backClass),e&&e.split(" ").forEach(t=>{t&&l(a,t)}),o(t,s),o(t,a),t.style.all="inherit",t.style.background="transparent",t.style.backgroundColor="transparent",t.style.backgroundImage="none",t.style.border="none",t.style.borderRadius="0",t.style.boxShadow="none",t.style.outline="none",r(s,this.settings.Duration,this.settings.Easing),r(a,this.settings.Duration,this.settings.Easing),this.settings.Template?a.innerHTML=this.settings.Template:a.appendChild(n),t.parentNode.insertBefore(i,t),s.appendChild(t),i.appendChild(s),i.appendChild(a),e&&e.split(" ").forEach(t=>{t&&l(i,t)}),i.style.width=this.elementWidth,i.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(i.style,e.style):i.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(i),this.hoverPanel=i,this.frontWrapper=s,this.backWrapper=a}_setupEvents(i){!0===this.settings.Click?i.addEventListener("click",t=>{t.preventDefault(),e(i,this.flipClass)}):"string"==typeof this.settings.Click?i.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(i,this.flipClass)})}):(i.addEventListener("mouseenter",()=>{l(i,this.flipClass)}),i.addEventListener("mouseleave",()=>{var t,e;t=i,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),d.delete(this.element)}}function t(t,e={}){var i;return"string"==typeof t?(i=document.querySelectorAll(t),Array.from(i).map(t=>new s(t,e))):t instanceof Element?new s(t,e):t.length?Array.from(t).map(t=>new s(t,e)):void 0}var n;return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=d.get(t);t&&t.destroy()})):t instanceof Element?(e=d.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=d.get(t);t&&t.destroy()})},i?(i.fn.justFlipIt=function(t){return this.each(function(){i.data(this,"plugin_justFlipIt")||i.data(this,"plugin_justFlipIt",new s(this,t))})},i.fn.destroy=function(){return this.each(function(){var t=d.get(this);t&&(t.destroy(),i.removeData(this,"plugin_justFlipIt"))})},(n=function(t,e){return"string"==typeof t||t instanceof Element?i(t).justFlipIt(e):t instanceof i?t.justFlipIt(e):void 0}).destroy=function(t){"string"==typeof t||t instanceof Element?i(t).destroy():t instanceof i&&t.destroy()},n):t});
1
+ ((e,s)=>{if("function"==typeof define&&define.amd)define(["jquery"],function(t){return s(t||e.jQuery||e.$)});else if("object"==typeof module&&module.exports){var i="undefined"!=typeof window?window.jQuery:void 0;if(!i)try{i=require("jquery")}catch(t){i=null}module.exports=s(i)}else e.justFlipIt=s(e.jQuery||e.$)})("undefined"!=typeof self?self:this,function(s){function a(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function n(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var s,i;t.classList?t.classList.toggle(e):(0<=(i=(s=t.className.split(" ")).indexOf(e))?s.splice(i,1):s.push(e),t.className=s.join(" "))}let r=new WeakMap;class i{constructor(t,e={}){var s,i,n;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),s.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}",(i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),i.textContent="._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}",(n=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),n.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(s),document.head.appendChild(i),document.head.appendChild(n)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out",preserveClasses:!0,preserveStyles:!0},e),this.elementWidth=a(t,"width"),this.elementHeight=a(t,"height"),this.elementBackgroundColor=a(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),r.set(t,this)}_init(){var t=this.element;this.originalClassName;let s=document.createElement(this.originalTagName),e=(n(s,"hover"),n(s,"_justFlipIt_panel"),document.createElement("div")),i=(n(e,"front"),document.createElement("div"));n(i,this.backClass),this.settings.preserveClasses&&t.classList.length&&t.classList.forEach(t=>{s.classList.contains(t)||s.classList.add(t),e&&!e.classList.contains(t)&&e.classList.add(t),i&&!i.classList.contains(t)&&i.classList.add(t)}),this.settings.preserveStyles&&t.getAttribute("style")&&s.setAttribute("style",(s.getAttribute("style")||"")+";"+t.getAttribute("style")),e.innerHTML=t.innerHTML,this.settings.Template?i.innerHTML=this.settings.Template:i.innerHTML=t.innerHTML,t.parentNode.insertBefore(s,t),s.appendChild(e),s.appendChild(i),t.parentNode.removeChild(t),s.style.width=this.elementWidth,s.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(s.style,e.style):s.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(s),this.hoverPanel=s,this.frontWrapper=e,this.backWrapper=i}_setupEvents(s){!0===this.settings.Click?s.addEventListener("click",t=>{t.preventDefault(),e(s,this.flipClass)}):"string"==typeof this.settings.Click?s.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(s,this.flipClass)})}):(s.addEventListener("mouseenter",()=>{n(s,this.flipClass)}),s.addEventListener("mouseleave",()=>{var t,e;t=s,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),r.delete(this.element)}}function t(t,e={}){var s;return"string"==typeof t?(s=document.querySelectorAll(t),Array.from(s).map(t=>new i(t,e))):t instanceof Element?new i(t,e):t.length?Array.from(t).map(t=>new i(t,e)):void 0}var l;return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=r.get(t);t&&t.destroy()})):t instanceof Element?(e=r.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=r.get(t);t&&t.destroy()})},s?(s.fn.justFlipIt=function(t){return this.each(function(){s.data(this,"plugin_justFlipIt")||s.data(this,"plugin_justFlipIt",new i(this,t))})},s.fn.destroy=function(){return this.each(function(){var t=r.get(this);t&&(t.destroy(),s.removeData(this,"plugin_justFlipIt"))})},(l=function(t,e){return"string"==typeof t||t instanceof Element?s(t).justFlipIt(e):t instanceof s?t.justFlipIt(e):void 0}).destroy=function(t){"string"==typeof t||t instanceof Element?s(t).destroy():t instanceof s&&t.destroy()},l):t});
@@ -24,6 +24,16 @@ declare namespace justFlipIt {
24
24
  * Custom styles to apply to elements
25
25
  */
26
26
  Style?: StyleOption[];
27
+
28
+ /**
29
+ * If true, all CSS classes from the original element are copied to the flip panel (default: true)
30
+ */
31
+ preserveClasses?: boolean;
32
+
33
+ /**
34
+ * If true, all inline styles from the original element are copied to the flip panel (default: true)
35
+ */
36
+ preserveStyles?: boolean;
27
37
  }
28
38
 
29
39
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simhub2/justflipit",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "A lightweight JavaScript library that allows you to implement CSS3 based flip animations on any DOM elements",
5
5
  "main": "dist/justFlipIt.js",
6
6
  "module": "dist/justFlipIt.js",
@@ -169,6 +169,8 @@
169
169
  // NEU: Standard-Animationsoptionen
170
170
  Duration: 400,
171
171
  Easing: "ease-in-out",
172
+ preserveClasses: true, // NEU
173
+ preserveStyles: true // NEU
172
174
  },
173
175
  options,
174
176
  );
@@ -192,61 +194,51 @@
192
194
  _init() {
193
195
  const originalElement = this.element;
194
196
  const originalClassName = this.originalClassName;
197
+
198
+ // Panel-Struktur erzeugen
195
199
  const hoverPanel = document.createElement(this.originalTagName);
196
200
  addClass(hoverPanel, "hover");
197
201
  addClass(hoverPanel, "_justFlipIt_panel");
198
202
  const frontWrapper = document.createElement("div");
199
203
  addClass(frontWrapper, "front");
200
- const clone = originalElement.cloneNode(true);
201
- clone.className = "";
202
204
  const backWrapper = document.createElement("div");
203
205
  addClass(backWrapper, this.backClass);
204
- if (originalClassName) {
205
- originalClassName.split(" ").forEach((cls) => {
206
- if (cls) addClass(backWrapper, cls);
206
+
207
+ // NEU: Klassen übernehmen (Panel, .front, .backY)
208
+ if (this.settings.preserveClasses && originalElement.classList.length) {
209
+ originalElement.classList.forEach(cls => {
210
+ if (!hoverPanel.classList.contains(cls)) hoverPanel.classList.add(cls);
211
+ if (frontWrapper && !frontWrapper.classList.contains(cls)) frontWrapper.classList.add(cls);
212
+ if (backWrapper && !backWrapper.classList.contains(cls)) backWrapper.classList.add(cls);
207
213
  });
208
214
  }
209
215
 
210
- // PATCH: Styles übernehmen und Original komplett transparent machen
211
- copyStyles(originalElement, frontWrapper);
212
- copyStyles(originalElement, backWrapper);
213
- originalElement.style.all = "inherit";
214
- originalElement.style.background = "transparent";
215
- originalElement.style.backgroundColor = "transparent";
216
- originalElement.style.backgroundImage = "none";
217
- originalElement.style.border = "none";
218
- originalElement.style.borderRadius = "0";
219
- originalElement.style.boxShadow = "none";
220
- originalElement.style.outline = "none";
216
+ // NEU: Inline-Styles übernehmen (nur auf Panel)
217
+ if (this.settings.preserveStyles && originalElement.getAttribute("style")) {
218
+ hoverPanel.setAttribute("style", (hoverPanel.getAttribute("style") || "") +
219
+ ";" + originalElement.getAttribute("style"));
220
+ }
221
221
 
222
- // NEU: Wende benutzerdefinierte Animationseinstellungen an
223
- applyAnimationSettings(
224
- frontWrapper,
225
- this.settings.Duration,
226
- this.settings.Easing,
227
- );
228
- applyAnimationSettings(
229
- backWrapper,
230
- this.settings.Duration,
231
- this.settings.Easing,
232
- );
222
+ // Nur den INHALT übernehmen!
223
+ frontWrapper.innerHTML = originalElement.innerHTML;
233
224
 
234
225
  if (this.settings.Template) {
235
226
  backWrapper.innerHTML = this.settings.Template;
236
227
  } else {
237
- backWrapper.appendChild(clone);
228
+ backWrapper.innerHTML = originalElement.innerHTML;
238
229
  }
230
+
231
+ // Panel einfügen und Original entfernen
239
232
  originalElement.parentNode.insertBefore(hoverPanel, originalElement);
240
- frontWrapper.appendChild(originalElement);
241
233
  hoverPanel.appendChild(frontWrapper);
242
234
  hoverPanel.appendChild(backWrapper);
243
- if (originalClassName) {
244
- originalClassName.split(" ").forEach((cls) => {
245
- if (cls) addClass(hoverPanel, cls);
246
- });
247
- }
235
+ originalElement.parentNode.removeChild(originalElement);
236
+
237
+ // Panel-Größe und Styles übernehmen
248
238
  hoverPanel.style.width = this.elementWidth;
249
239
  hoverPanel.style.height = this.elementHeight;
240
+
241
+ // Custom Styles aus Option anwenden
250
242
  if (this.settings.Style && this.settings.Style.length) {
251
243
  this.settings.Style.forEach((styleObj) => {
252
244
  if (styleObj.el) {
@@ -261,7 +253,11 @@
261
253
  }
262
254
  });
263
255
  }
256
+
257
+ // Events setzen
264
258
  this._setupEvents(hoverPanel);
259
+
260
+ // Referenzen speichern
265
261
  this.hoverPanel = hoverPanel;
266
262
  this.frontWrapper = frontWrapper;
267
263
  this.backWrapper = backWrapper;
@@ -1 +1 @@
1
- ((e,i)=>{if("function"==typeof define&&define.amd)define(["jquery"],function(t){return i(t||e.jQuery||e.$)});else if("object"==typeof module&&module.exports){var s="undefined"!=typeof window?window.jQuery:void 0;if(!s)try{s=require("jquery")}catch(t){s=null}module.exports=i(s)}else e.justFlipIt=i(e.jQuery||e.$)})("undefined"!=typeof self?self:this,function(i){function o(t,e){let i=window.getComputedStyle(t);["background","backgroundColor","backgroundImage","backgroundPosition","backgroundRepeat","backgroundSize","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","border","borderTop","borderRight","borderBottom","borderLeft","boxShadow","color","opacity"].forEach(function(t){i[t]&&"none"!==i[t]&&"initial"!==i[t]&&""!==i[t]&&(e.style[t]=i[t])})}function r(t,e,i){e=`all ${e/1e3}s `+i;t.style.transition=e,t.style.WebkitTransition=e,t.style.MozTransition=e,t.style.msTransition=e,t.style.OTransition=e}function a(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function l(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var i,s;t.classList?t.classList.toggle(e):(0<=(s=(i=t.className.split(" ")).indexOf(e))?i.splice(s,1):i.push(e),t.className=i.join(" "))}let d=new WeakMap;class s{constructor(t,e={}){var i,s,n;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),i.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}",(s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),s.textContent="._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}",(n=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),n.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(i),document.head.appendChild(s),document.head.appendChild(n)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out"},e),this.elementWidth=a(t,"width"),this.elementHeight=a(t,"height"),this.elementBackgroundColor=a(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),d.set(t,this)}_init(){var t=this.element,e=this.originalClassName;let i=document.createElement(this.originalTagName);l(i,"hover"),l(i,"_justFlipIt_panel");var s=document.createElement("div"),n=(l(s,"front"),t.cloneNode(!0));n.className="";let a=document.createElement("div");l(a,this.backClass),e&&e.split(" ").forEach(t=>{t&&l(a,t)}),o(t,s),o(t,a),t.style.all="inherit",t.style.background="transparent",t.style.backgroundColor="transparent",t.style.backgroundImage="none",t.style.border="none",t.style.borderRadius="0",t.style.boxShadow="none",t.style.outline="none",r(s,this.settings.Duration,this.settings.Easing),r(a,this.settings.Duration,this.settings.Easing),this.settings.Template?a.innerHTML=this.settings.Template:a.appendChild(n),t.parentNode.insertBefore(i,t),s.appendChild(t),i.appendChild(s),i.appendChild(a),e&&e.split(" ").forEach(t=>{t&&l(i,t)}),i.style.width=this.elementWidth,i.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(i.style,e.style):i.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(i),this.hoverPanel=i,this.frontWrapper=s,this.backWrapper=a}_setupEvents(i){!0===this.settings.Click?i.addEventListener("click",t=>{t.preventDefault(),e(i,this.flipClass)}):"string"==typeof this.settings.Click?i.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(i,this.flipClass)})}):(i.addEventListener("mouseenter",()=>{l(i,this.flipClass)}),i.addEventListener("mouseleave",()=>{var t,e;t=i,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),d.delete(this.element)}}function t(t,e={}){var i;return"string"==typeof t?(i=document.querySelectorAll(t),Array.from(i).map(t=>new s(t,e))):t instanceof Element?new s(t,e):t.length?Array.from(t).map(t=>new s(t,e)):void 0}var n;return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=d.get(t);t&&t.destroy()})):t instanceof Element?(e=d.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=d.get(t);t&&t.destroy()})},i?(i.fn.justFlipIt=function(t){return this.each(function(){i.data(this,"plugin_justFlipIt")||i.data(this,"plugin_justFlipIt",new s(this,t))})},i.fn.destroy=function(){return this.each(function(){var t=d.get(this);t&&(t.destroy(),i.removeData(this,"plugin_justFlipIt"))})},(n=function(t,e){return"string"==typeof t||t instanceof Element?i(t).justFlipIt(e):t instanceof i?t.justFlipIt(e):void 0}).destroy=function(t){"string"==typeof t||t instanceof Element?i(t).destroy():t instanceof i&&t.destroy()},n):t});
1
+ ((e,s)=>{if("function"==typeof define&&define.amd)define(["jquery"],function(t){return s(t||e.jQuery||e.$)});else if("object"==typeof module&&module.exports){var i="undefined"!=typeof window?window.jQuery:void 0;if(!i)try{i=require("jquery")}catch(t){i=null}module.exports=s(i)}else e.justFlipIt=s(e.jQuery||e.$)})("undefined"!=typeof self?self:this,function(s){function a(t,e){return window.getComputedStyle(t,null).getPropertyValue(e)}function n(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function e(t,e){var s,i;t.classList?t.classList.toggle(e):(0<=(i=(s=t.className.split(" ")).indexOf(e))?s.splice(i,1):s.push(e),t.className=s.join(" "))}let r=new WeakMap;class i{constructor(t,e={}){var s,i,n;document.querySelector('[data-justflipitstyle="justFlipIt_One"]')||((s=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_One"),s.textContent="._justFlipIt_panel {perspective:1000px;-webkit-perspective:1000px;-moz-perspective:1000px;}._justFlipIt_panel .front{height:inherit;width:inherit;position:absolute;top:0;z-index:900;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel .back{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateX(-180deg);-moz-transform:rotateX(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flip_ .front{z-index:900;-webkit-transform:rotateX(180deg);-moz-transform:rotateX(180deg)}._justFlipIt_panel._flip_ .back{z-index:1000;-webkit-transform:rotateX(0) rotateX(0);-moz-transform:rotateX(0) rotateX(0)}",(i=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Two"),i.textContent="._justFlipIt_panel .backY{height:inherit;width:inherit;position:absolute;top:0;z-index:1000;-webkit-transform:rotateY(-180deg);-moz-transform:rotateY(-180deg);-webkit-transform-style:preserve-3d;-moz-transform-style:preserve-3d;-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-webkit-transition:all .4s ease-in-out;-moz-transition:all .4s ease-in-out;-ms-transition:all .4s ease-in-out;-o-transition:all .4s ease-in-out;transition:all .4s ease-in-out}._justFlipIt_panel._flipY_ .front{z-index:900;-webkit-transform:rotateY(180deg);-moz-transform:rotateY(180deg)}._justFlipIt_panel._flipY_ .backY{z-index:1000;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0)}",(n=document.createElement("style")).setAttribute("data-justflipitstyle","justFlipIt_Transparent"),n.textContent="._justFlipIt_panel {background: transparent !important; box-shadow: none !important;}._justFlipIt_panel > * {box-sizing: border-box;}",document.head.appendChild(s),document.head.appendChild(i),document.head.appendChild(n)),this.element=t,this.settings=Object.assign({},{Template:"",Click:!1,FlipX:!1,Style:[],Duration:400,Easing:"ease-in-out",preserveClasses:!0,preserveStyles:!0},e),this.elementWidth=a(t,"width"),this.elementHeight=a(t,"height"),this.elementBackgroundColor=a(t,"background-color"),this.originalClassName=t.className,this.originalTagName=t.tagName.toLowerCase(),this.originalId=t.id||"",!0===this.settings.FlipX?(this.flipClass="_flip_",this.backClass="back"):(this.flipClass="_flipY_",this.backClass="backY"),this._init(),r.set(t,this)}_init(){var t=this.element;this.originalClassName;let s=document.createElement(this.originalTagName),e=(n(s,"hover"),n(s,"_justFlipIt_panel"),document.createElement("div")),i=(n(e,"front"),document.createElement("div"));n(i,this.backClass),this.settings.preserveClasses&&t.classList.length&&t.classList.forEach(t=>{s.classList.contains(t)||s.classList.add(t),e&&!e.classList.contains(t)&&e.classList.add(t),i&&!i.classList.contains(t)&&i.classList.add(t)}),this.settings.preserveStyles&&t.getAttribute("style")&&s.setAttribute("style",(s.getAttribute("style")||"")+";"+t.getAttribute("style")),e.innerHTML=t.innerHTML,this.settings.Template?i.innerHTML=this.settings.Template:i.innerHTML=t.innerHTML,t.parentNode.insertBefore(s,t),s.appendChild(e),s.appendChild(i),t.parentNode.removeChild(t),s.style.width=this.elementWidth,s.style.height=this.elementHeight,this.settings.Style&&this.settings.Style.length&&this.settings.Style.forEach(e=>{e.el&&("self"===e.el.toLowerCase()?Object.assign(s.style,e.style):s.querySelectorAll(e.el).forEach(t=>{Object.assign(t.style,e.style)}))}),this._setupEvents(s),this.hoverPanel=s,this.frontWrapper=e,this.backWrapper=i}_setupEvents(s){!0===this.settings.Click?s.addEventListener("click",t=>{t.preventDefault(),e(s,this.flipClass)}):"string"==typeof this.settings.Click?s.querySelectorAll(this.settings.Click).forEach(t=>{t.addEventListener("click",()=>{e(s,this.flipClass)})}):(s.addEventListener("mouseenter",()=>{n(s,this.flipClass)}),s.addEventListener("mouseleave",()=>{var t,e;t=s,e=this.flipClass,t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}))}destroy(){var t=this.hoverPanel,e=t.querySelector(".front > *");e.className=this.originalClassName,t.parentNode.insertBefore(e,t),t.parentNode.removeChild(t),r.delete(this.element)}}function t(t,e={}){var s;return"string"==typeof t?(s=document.querySelectorAll(t),Array.from(s).map(t=>new i(t,e))):t instanceof Element?new i(t,e):t.length?Array.from(t).map(t=>new i(t,e)):void 0}var l;return t.destroy=function(t){var e;"string"==typeof t?(e=document.querySelectorAll(t),Array.from(e).forEach(t=>{t=r.get(t);t&&t.destroy()})):t instanceof Element?(e=r.get(t))&&e.destroy():t.length&&Array.from(t).forEach(t=>{t=r.get(t);t&&t.destroy()})},s?(s.fn.justFlipIt=function(t){return this.each(function(){s.data(this,"plugin_justFlipIt")||s.data(this,"plugin_justFlipIt",new i(this,t))})},s.fn.destroy=function(){return this.each(function(){var t=r.get(this);t&&(t.destroy(),s.removeData(this,"plugin_justFlipIt"))})},(l=function(t,e){return"string"==typeof t||t instanceof Element?s(t).justFlipIt(e):t instanceof s?t.justFlipIt(e):void 0}).destroy=function(t){"string"==typeof t||t instanceof Element?s(t).destroy():t instanceof s&&t.destroy()},l):t});
@@ -217,6 +217,8 @@
217
217
  Style: [], // Custom styles
218
218
  Duration: 400, // Animation duration in ms
219
219
  Easing: "ease-in-out", // Animation easing function
220
+ preserveClasses: true, // NEU
221
+ preserveStyles: true // NEU
220
222
  },
221
223
  options,
222
224
  );
@@ -256,79 +258,50 @@
256
258
  const originalElement = this.element;
257
259
  const originalClassName = this.originalClassName;
258
260
 
259
- // Create panel structure
261
+ // Panel-Struktur erzeugen
260
262
  const hoverPanel = document.createElement(this.originalTagName);
261
263
  addClass(hoverPanel, "hover");
262
264
  addClass(hoverPanel, "_justFlipIt_panel");
263
-
264
- // Create front wrapper
265
265
  const frontWrapper = document.createElement("div");
266
266
  addClass(frontWrapper, "front");
267
-
268
- // Clone element for back side if no template provided
269
- const clone = originalElement.cloneNode(true);
270
- clone.className = ""; // Remove classes
271
-
272
- // Create back wrapper
273
267
  const backWrapper = document.createElement("div");
274
268
  addClass(backWrapper, this.backClass);
275
- if (originalClassName) {
276
- originalClassName.split(" ").forEach((cls) => {
277
- if (cls) addClass(backWrapper, cls);
269
+
270
+ // NEU: Klassen übernehmen (Panel, .front, .backY)
271
+ if (this.settings.preserveClasses && originalElement.classList.length) {
272
+ originalElement.classList.forEach(cls => {
273
+ if (!hoverPanel.classList.contains(cls)) hoverPanel.classList.add(cls);
274
+ if (frontWrapper && !frontWrapper.classList.contains(cls)) frontWrapper.classList.add(cls);
275
+ if (backWrapper && !backWrapper.classList.contains(cls)) backWrapper.classList.add(cls);
278
276
  });
279
277
  }
280
278
 
281
- // PATCH: Styles übernehmen und Original komplett transparent machen
282
- copyStyles(originalElement, frontWrapper);
283
- copyStyles(originalElement, backWrapper);
279
+ // NEU: Inline-Styles übernehmen (nur auf Panel)
280
+ if (this.settings.preserveStyles && originalElement.getAttribute("style")) {
281
+ hoverPanel.setAttribute("style", (hoverPanel.getAttribute("style") || "") +
282
+ ";" + originalElement.getAttribute("style"));
283
+ }
284
284
 
285
- // NEU: Wende benutzerdefinierte Animationseinstellungen an
286
- applyAnimationSettings(
287
- frontWrapper,
288
- this.settings.Duration,
289
- this.settings.Easing,
290
- );
291
- applyAnimationSettings(
292
- backWrapper,
293
- this.settings.Duration,
294
- this.settings.Easing,
295
- );
285
+ // Nur den INHALT übernehmen!
286
+ frontWrapper.innerHTML = originalElement.innerHTML;
296
287
 
297
- // Mache das Original komplett transparent und ohne Border/Shadow/usw.
298
- originalElement.style.all = "inherit"; // Reset alles zur Sicherheit
299
- originalElement.style.background = "transparent";
300
- originalElement.style.backgroundColor = "transparent";
301
- originalElement.style.backgroundImage = "none";
302
- originalElement.style.border = "none";
303
- originalElement.style.borderRadius = "0";
304
- originalElement.style.boxShadow = "none";
305
- originalElement.style.outline = "none";
306
-
307
- // If template provided, use that instead of clone
308
288
  if (this.settings.Template) {
309
289
  backWrapper.innerHTML = this.settings.Template;
310
290
  } else {
311
- backWrapper.appendChild(clone);
291
+ backWrapper.innerHTML = originalElement.innerHTML;
312
292
  }
313
293
 
314
- // Restructure DOM
294
+ // Panel einfügen und Original entfernen
315
295
  originalElement.parentNode.insertBefore(hoverPanel, originalElement);
316
- frontWrapper.appendChild(originalElement);
317
296
  hoverPanel.appendChild(frontWrapper);
318
297
  hoverPanel.appendChild(backWrapper);
298
+ originalElement.parentNode.removeChild(originalElement);
319
299
 
320
- // Copy original classes to hover panel
321
- if (originalClassName) {
322
- originalClassName.split(" ").forEach((cls) => {
323
- if (cls) addClass(hoverPanel, cls);
324
- });
325
- }
326
-
327
- // Apply styles
300
+ // Panel-Größe und Styles übernehmen
328
301
  hoverPanel.style.width = this.elementWidth;
329
302
  hoverPanel.style.height = this.elementHeight;
330
303
 
331
- // Apply custom styles
304
+ // Custom Styles aus Option anwenden
332
305
  if (this.settings.Style && this.settings.Style.length) {
333
306
  this.settings.Style.forEach((styleObj) => {
334
307
  if (styleObj.el) {
@@ -344,10 +317,10 @@
344
317
  });
345
318
  }
346
319
 
347
- // Set up event handlers
320
+ // Events setzen
348
321
  this._setupEvents(hoverPanel);
349
322
 
350
- // Store reference to original element
323
+ // Referenzen speichern
351
324
  this.hoverPanel = hoverPanel;
352
325
  this.frontWrapper = frontWrapper;
353
326
  this.backWrapper = backWrapper;