/*! reflection.js for jquery v1.12 (c) 2006-2013 christophe beyls mit-style license. */ ;(function($) { $.fn.reflect = function(options) { options = $.extend({ height: 1/3, opacity: 0.5 }, options); return this.unreflect().each(function() { var img = this; if (/^img$/i.test(img.tagname)) { function doreflect() { var imagewidth = img.width, imageheight = img.height, reflection, reflectionheight, wrapper, context, gradient; reflectionheight = math.floor((options.height > 1) ? math.min(imageheight, options.height) : imageheight * options.height); reflection = $("")[0]; if (reflection.getcontext) { context = reflection.getcontext("2d"); try { $(reflection).attr({width: imagewidth, height: reflectionheight}); context.save(); context.translate(0, imageheight-1); context.scale(1, -1); context.drawimage(img, 0, 0, imagewidth, imageheight); context.restore(); context.globalcompositeoperation = "destination-out"; gradient = context.createlineargradient(0, 0, 0, reflectionheight); gradient.addcolorstop(0, "rgba(255, 255, 255, " + (1 - options.opacity) + ")"); gradient.addcolorstop(1, "rgba(255, 255, 255, 1.0)"); context.fillstyle = gradient; context.rect(0, 0, imagewidth, reflectionheight); context.fill(); } catch(e) { return; } } else { if (!window.activexobject) return; reflection = $("").attr("src", img.src).css({ width: imagewidth, height: imageheight, marginbottom: reflectionheight - imageheight, filter: "flipv progid:dximagetransform.microsoft.alpha(opacity=" + (options.opacity * 100) + ", finishopacity=0, style=1, startx=0, starty=0, finishx=0, finishy=" + (reflectionheight / imageheight * 100) + ")" })[0]; } $(reflection).css({display: "block", border: 0}); wrapper = $(/^a$/i.test(img.parentnode.tagname) ? "" : "
").insertafter(img).append([img, reflection])[0]; wrapper.classname = img.classname; $(img).data("reflected", wrapper.style.csstext = img.style.csstext); $(wrapper).css({width: imagewidth, height: imageheight + reflectionheight, overflow: "hidden"}); img.style.csstext = "display: block; border: 0px"; img.classname = "reflected"; } if (img.complete) doreflect(); else $(img).load(doreflect); } }); } $.fn.unreflect = function() { return this.unbind("load").each(function() { var img = this, reflected = $(this).data("reflected"), wrapper; if (reflected !== undefined) { wrapper = img.parentnode; img.classname = wrapper.classname; img.style.csstext = reflected; $(img).data("reflected", null); wrapper.parentnode.replacechild(img, wrapper); } }); } })(window.jquery || window.zepto);