Created
October 5, 2011 16:34
-
-
Save genee19/1264940 to your computer and use it in GitHub Desktop.
A drop-in script for Ecwid to trigger the product gallery popup when a product thumbnail image is clicked in the product details page. How to use: use theis script as usual on your shop page where you embed Ecwid product browser.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){(function(r,h,M){function H(){var a=k;a.loader={load:N,i:0};return a}function N(a,c,e){var l=c=="c"?O:I;w=0;c=c||"j";x(a)?P(l,a,c,this.i++,y,e):(s.splice(this.i++,0,a),s.length==1&&z());return this}function P(a,c,e,l,m,i){function t(){!f&&(!b.readyState||b.readyState=="loaded"||b.readyState=="complete")&&(g.r=f=1,!w&&n(),b.onload=b.onreadystatechange=null,o(function(){A.removeChild(b)},0))}var b=h.createElement(a),f=0,g={t:e,s:c,e:i};b.src=b.data=c;!B&&(b.style.display="none");b.width= | |
b.height="0";a!="object"&&(b.type=e);b.onload=b.onreadystatechange=t;a=="img"?b.onerror=t:a=="script"&&(b.onerror=function(){g.e=g.r=1;z()});s.splice(l,0,g);A.insertBefore(b,B?null:v);o(function(){f||(A.removeChild(b),g.r=g.e=f=1,n())},k.errorTimeout)}function z(){var a=s.shift();w=1;a?a.t?o(function(){a.t=="c"?Q(a):R(a)},0):(a(),n()):w=0}function Q(a){var c=h.createElement("link"),e;c.href=a.s;c.rel="stylesheet";c.type="text/css";if(!a.e&&(C||D)){var l=function(m){o(function(){if(!e)try{m.sheet.cssRules.length? | |
(e=1,n()):l(m)}catch(i){i.code==1E3||i.message=="security"||i.message=="denied"?(e=1,o(function(){n()},0)):l(m)}},0)};l(c)}else{c.onload=function(){e||(e=1,o(function(){n()},0))};a.e&&c.onload()}o(function(){e||(e=1,n())},k.errorTimeout);!a.e&&v.parentNode.insertBefore(c,v)}function R(a){var c=h.createElement("script"),e;c.src=a.s;c.onreadystatechange=c.onload=function(){!e&&(!c.readyState||c.readyState=="loaded"||c.readyState=="complete")&&(e=1,n(),c.onload=c.onreadystatechange=null)};o(function(){e|| | |
(e=1,n())},k.errorTimeout);a.e?c.onload():v.parentNode.insertBefore(c,v)}function n(){for(var a=1,c=-1;s.length-++c;)if(s[c].s&&!(a=s[c].r))break;a&&z()}var y=h.documentElement,o=r.setTimeout,v=h.getElementsByTagName("script")[0],E={}.toString,s=[],w=0,D="MozAppearance"in y.style,B=D&&!!h.createRange().compareNode,A=B?y:v.parentNode,S=r.opera&&E.call(r.opera)=="[object Opera]",C="webkitAppearance"in y.style,T=C&&"async"in h.createElement("script"),I=D?"object":S||T?"img":"script",O=C?"img":I,J=Array.isArray|| | |
function(a){return E.call(a)=="[object Array]"},x=function(a){return typeof a=="string"},F=function(a){return E.call(a)=="[object Function]"},G=[],K={},L,k;k=function(a){function c(b,f){function g(u){if(x(u))e(u,d,f,0,j);else if(Object(u)===u)for(p in u)u.hasOwnProperty(p)&&e(u[p],d,f,p,j)}var j=!!b.test,q=b.load||b.both,d=b.callback,p;g(j?b.yep:b.nope);g(q);b.complete&&f.load(b.complete)}function e(b,f,g,j,q){var d=l(b),p=d.autoCallback;if(!d.bypass){f&&(f=F(f)?f:f[b]||f[j]||f[b.split("/").pop().split("?")[0]]); | |
if(d.instead)return d.instead(b,f,g,j,q);g.load(d.url,d.forceCSS||!d.forceJS&&/css$/.test(d.url)?"c":M,d.noexec);(F(f)||F(p))&&g.load(function(){H();f&&f(d.origUrl,q,j);p&&p(d.origUrl,q,j)})}}function l(b){b=b.split("!");var f=G.length,g=b.pop(),j=b.length;g={url:g,origUrl:g,prefixes:b};var q,d;for(d=0;d<j;d++)(q=K[b[d]])&&(g=q(g));for(d=0;d<f;d++)g=G[d](g);return g}var m,i,t=this.yepnope.loader;if(x(a))e(a,0,t,0);else if(J(a))for(m=0;m<a.length;m++){i=a[m];x(i)?e(i,0,t,0):J(i)?k(i):Object(i)===i&& | |
c(i,t)}else Object(a)===a&&c(a,t)};k.addPrefix=function(a,c){K[a]=c};k.addFilter=function(a){G.push(a)};k.errorTimeout=1E4;h.readyState==null&&h.addEventListener&&(h.readyState="loading",h.addEventListener("DOMContentLoaded",L=function(){h.removeEventListener("DOMContentLoaded",L,0);h.readyState="complete"},0));r.yepnope=H()})(window,window.document);yepnope({test:"jQuery"in window,nope:"https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js",callback:function(r,h){h||window.jQuery.noConflict()}, | |
complete:function(){window.Ecwid.OnPageLoaded.add(function(r){var h;if(r.type==="PRODUCT"){h=window.jQuery;h(".ecwid-productBrowser-details-thumbnail").css({cursor:"pointer"}).click(function(){h(".ecwid-productBrowser-details-GalleryPanel .ecwid-productBrowser-details-GalleryPanel-imageContainer img.gwt-Image").first().click()})}})}})}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment