HEX
Server: LiteSpeed
System: Linux premium212.web-hosting.com 4.18.0-553.124.4.lve.el8.x86_64 #1 SMP Fri May 15 13:02:13 UTC 2026 x86_64
User: vitanhod (1367)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //home/vitanhod/public_html/wp-content/plugins/woocommerce/assets/js/admin/variation-gallery.min.js
jQuery(function(e){"use strict";const t="#variable_product_options",a="#woocommerce-product-data",i=".wc-variation-gallery-field",n=".wc-variation-gallery-field__thumbs",s=".wc-variation-gallery-field__hero",r=".wc-variation-gallery-field__hero-img",l=".wc-variation-gallery-field__hero-broken",o=".wc-variation-gallery-field__empty-cta",d=".wc-variation-gallery-field__hint",c=".wc-variation-gallery-field__count",h=".wc-variation-gallery-image-ids",m=".wc-variation-gallery-thumb",p=".wc-variation-gallery-thumb__button",g=".wc-variation-gallery-thumb__remove",u=".wc-variation-gallery-manage",v=".wc-variation-gallery-replace",b="[data-primary-badge]",f=".screen-reader-text[data-missing-file-label]",y=".woocommerce_variation",w=".upload_image_id",_=".upload_image_button",F="is-empty",I="is-active",C="is-broken",x="wc-variation-gallery-field__hero-img",A="wc-variation-gallery-field__hero-broken",M=window.wcVariationGalleryL10n||{},S=wp&&wp.a11y||null,P=e=>{e&&S&&"function"==typeof S.speak&&S.speak(e)},k=e=>{const t=e.sizes||{},a=t.medium||t.full;return a&&a.url||e.url||""},L=e=>{const t=e.sizes||{};return t.thumbnail&&t.thumbnail.url||e.url||""},R={manageFrame:null,replaceFrame:null,activeField:null,activePreloadIds:[],activeIndexForReplace:null,wpMediaPostId:wp.media.model.settings.post.id,init(){const i=e(t);i.on("click",u,this.onManage.bind(this)),i.on("click",v,this.onReplace.bind(this)),i.on("click",p,this.onThumbClick.bind(this)),i.on("click",g,this.onRemoveClick.bind(this)),i.on("woocommerce_variations_added",this.initializeSortables.bind(this)),e(a).on("woocommerce_variations_loaded",this.initializeSortables.bind(this)),this.initializeSortables()},initializeSortables(){e(n).each(function(){const t=e(this),a=t.closest(i);R.updateFromDom(a),t.data("wc-variation-gallery-sortable")||(t.sortable({items:"li"+m,cancel:g,cursor:"grabbing",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start(e,a){a.item.addClass("is-dragging"),t.addClass("is-sorting")},stop(e,a){a.item.removeClass("is-dragging"),t.removeClass("is-sorting")},update(){const e=R.getActiveAttachmentId(a);R.setActiveIndex(a,0),R.syncField(a);const t=R.getActiveAttachmentId(a);P(e!==t?M.announcePrimary:M.announceReorder)}}),t.data("wc-variation-gallery-sortable",!0))})},onThumbClick(t){const a=e(t.currentTarget).closest(m),n=a.closest(i),s=a.index();t.preventDefault(),this.setActiveIndex(n,s)},onRemoveClick(t){t.preventDefault(),t.stopPropagation();const a=e(t.currentTarget).closest(m),n=a.closest(i),s=a.index(),r=this.getActiveIndex(n),l=this.getFieldIds(n);let o;l.splice(s,1),o=s<r?r-1:s===r?Math.min(s,l.length-1):r,this.writeGallery(n,l,Math.max(0,o)),P(M.announceRemoved)},onManage(t){const a=e(t.currentTarget).closest(i),n=a.data("variationId");t.preventDefault(),wp.media.model.settings.post.id=n,this.activeField=a,this.activePreloadIds=this.getFieldIds(a),this.manageFrame||(this.manageFrame=wp.media({title:M.manageTitle,library:{type:"image"},button:{text:M.manageButton},multiple:"add"}),this.manageFrame.on("open",()=>this.preloadFrameSelection(this.manageFrame,this.activePreloadIds)),this.manageFrame.on("select",()=>this.onManageSelect(this.manageFrame,this.activeField)),this.manageFrame.on("close",()=>this.restoreMediaPostId())),this.manageFrame.open()},onReplace(t){const a=e(t.currentTarget).closest(i),n=a.data("variationId");t.preventDefault(),wp.media.model.settings.post.id=n,this.activeField=a,this.activeIndexForReplace=this.getActiveIndex(a),this.replaceFrame||(this.replaceFrame=wp.media({title:M.replaceTitle,library:{type:"image"},button:{text:M.replaceButton},multiple:!1}),this.replaceFrame.on("select",()=>this.onReplaceSelect(this.replaceFrame,this.activeField)),this.replaceFrame.on("close",()=>this.restoreMediaPostId())),this.replaceFrame.open()},preloadFrameSelection(e,t){if(!e)return;const a=e.state().get("selection");a&&(a.reset(),t.forEach(e=>{const t=wp.media.attachment(e);t.fetch(),a.add(t)}))},onManageSelect(e,t){const a=[];e.state().get("selection").each(e=>{const t=e.toJSON();t.id&&a.push(Number(t.id))}),this.writeGallery(t,a),P(M.announceUpdated),this.restoreMediaPostId()},onReplaceSelect(e,t){const a=e.state().get("selection").first();if(!a)return;const i=Number(a.toJSON().id),n=this.activeIndexForReplace,s=this.getFieldIds(t);null===n||n<0||n>=s.length||(s[n]=i,this.writeGallery(t,s,n),P(M.announceReplaced),this.restoreMediaPostId())},writeGallery(e,t,a=0){const i=Array.from(new Set(t)).filter(e=>Number.isInteger(e)&&e>0);this.rebuildThumbs(e,i),this.setActiveIndex(e,Math.min(a,Math.max(i.length-1,0))),this.syncField(e)},getCachedAttachmentUrl(e,t){const a=e.find(m+'[data-attachment_id="'+t+'"] '+p+" img");if(a.length)return a.attr("src")||"";const i=e.find(r+'[data-id="'+t+'"]');return i.length&&i.attr("src")||""},resolveAttachmentUrl(e,t,a){const i=this.getCachedAttachmentUrl(e,t);return i||a(wp.media.attachment(t).attributes||{})},rebuildThumbs(e,t){const a=e.find(n),i=t.map(t=>this.resolveAttachmentUrl(e,t,L));a.empty(),t.forEach((e,t)=>{a.append(this.buildThumbMarkup(e,i[t],0===t))}),a.data("wc-variation-gallery-sortable")&&a.sortable("refresh")},buildThumbMarkup(t,a,i){const n=(M.thumbLabel||"Show gallery image %d").replace("%d",t),s=e("<li></li>").addClass("wc-variation-gallery-thumb").toggleClass(I,i).attr("data-attachment_id",t),r=e('<button type="button"></button>').addClass("wc-variation-gallery-thumb__button").attr("aria-label",n),l=e('<button type="button"></button>').addClass("wc-variation-gallery-thumb__remove").attr("aria-label",M.removeLabel||"Remove image").append(e("<span></span>").addClass("dashicons dashicons-no-alt").attr("aria-hidden","true"));if(a){const t=e("<img />").attr("src",a).attr("alt","");return r.append(t),s.append(r,l)}s.addClass(C);const o=e("<span></span>").addClass("dashicons dashicons-format-image"),d=e("<span></span>").addClass("wc-variation-gallery-thumb__broken").attr("aria-hidden","true").append(o),c=e("<span></span>").addClass("screen-reader-text").text(M.missingFileLabel||"Attachment file missing");return r.append(d,c),s.append(r,l)},setActiveIndex(e,t){const a=this.getFieldIds(e);if(!a.length)return void this.setHeroEmpty(e);const i=Math.max(0,Math.min(t,a.length-1)),n=a[i];e.find(s).attr("data-active-index",i),this.setHeroImage(e,n,0===i),e.find(m).removeClass(I),e.find(m+'[data-attachment_id="'+n+'"]').addClass(I)},getActiveIndex:e=>Number(e.find(s).attr("data-active-index")||0),getActiveAttachmentId(e){const t=this.getFieldIds(e);return t.length?t[this.getActiveIndex(e)]||t[0]:0},setHeroImage(t,a,i){const n=t.find(s),d=this.resolveAttachmentUrl(t,a,k);d?((e=>{e.find(o).remove(),e.find(l).remove(),e.find(f).remove()})(n),(t=>{const a=t.find(r);if(a.length)return a;const i=e("<img />").addClass(x).attr("loading","lazy").attr("decoding","async");return t.prepend(i),i})(n).attr("src",d).attr("data-id",a).attr("alt",""),this.ensureHeroControls(n,i)):this.setHeroMissingFile(t,i)},setHeroMissingFile(t,a){const i=t.find(s);if(i.find(o).remove(),i.find(r).remove(),!i.find(l).length){const t=e("<span></span>").addClass("dashicons dashicons-format-image"),a=e("<span></span>").addClass(A).attr("aria-hidden","true").append(t),n=e("<span></span>").addClass("screen-reader-text").attr("data-missing-file-label","true").text(M.missingFileLabel||"Attachment file missing");i.prepend(a,n)}this.ensureHeroControls(i,a)},ensureHeroControls(t,a){if(!t.find(b).length){const a=e("<span></span>").addClass("dashicons dashicons-star-filled"),i=document.createTextNode(" "+(M.primaryLabel||"Primary")),n=e("<span></span>").addClass("wc-variation-gallery-field__badge").attr("data-primary-badge","").attr("aria-hidden","true").append(a).append(i);t.append(n)}if(t.find(b).toggle(Boolean(a)),!t.find(v).length){const a=e('<button type="button"></button>').addClass("button wc-variation-gallery-replace").text(M.replaceLabel||"Replace");t.append(a)}},setHeroEmpty(t){const a=t.find(s),i=e("<span></span>").addClass("dashicons dashicons-plus-alt2").attr("aria-hidden","true"),n=document.createTextNode(" "+(M.emptyCtaLabel||"Add variation images")),r=e('<button type="button"></button>').addClass("wc-variation-gallery-field__empty-cta wc-variation-gallery-manage").append(i).append(n);a.empty().attr("data-active-index",0).append(r),t.addClass(F)},getFieldIds:t=>t.find(m).map(function(){return Number(e(this).attr("data-attachment_id"))}).get().filter(e=>Number.isInteger(e)&&e>0),syncField(e){const t=this.getFieldIds(e),a=t[0]||"";e.find(h).val(t.join(",")).trigger("change"),this.syncLegacyImageSlot(e,a),this.updateFromDom(e,t.length)},syncLegacyImageSlot(e,t){const a=e.closest(y);this.updateLegacyInput(a,t),this.updateLegacyButton(a,t),this.updateLegacyPreview(a,t)},updateLegacyInput(e,t){const a=e.find(w);a.length&&a.val(t).trigger("change")},updateLegacyButton(e,t){const a=e.find(_);a.length&&a.toggleClass("remove",Boolean(t))},updateLegacyPreview(e,t){const a=e.find(_).find("img").first();if(!a.length)return;if(a.attr("data-placeholder-src")||a.attr("data-placeholder-src",a.attr("src")||""),!t)return void a.attr("src",a.attr("data-placeholder-src")||"");const n=e.find(i),s=this.resolveAttachmentUrl(n,t,L);s&&a.attr("src",s)},updateFromDom(e,t=null){const a=null===t?this.getFieldIds(e).length:t,i=(M[(e=>0===e?"countZero":1===e?"countSingular":"countPlural")(a)]||"%d").replace("%d",a);e.toggleClass(F,0===a),e.find(c).text(i),e.find(d).prop("hidden",0===a)},restoreMediaPostId(){wp.media.model.settings.post.id=this.wpMediaPostId}};R.init()});