forked from razorjack/quicksand
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.quicksand.min.js
6 lines (6 loc) · 2.91 KB
/
jquery.quicksand.min.js
1
2
3
4
5
6
(function(a){a.fn.quicksand=function(s,m,p){function q(e){var c=[];if(a(e).get(0)==undefined)return"";var h=a(e).get(0).nodeName.toLowerCase();if(a(e).attr("id"))h+="#"+a(e).attr("id");c.push(h);for(var i=[];a(e).get(0).nodeName.toLowerCase()!="html";){i.push(e);e=e.parent()}a(i).each(function(){h=a(this).get(0).nodeName.toLowerCase();if(a(this).attr("id"))h+="#"+a(this).attr("id");c.push(h)});return c.reverse().join(" > ")}var b={duration:750,easing:"swing",attribute:"data-id",adjustHeight:true};
a.extend(b,m);b.selector=null;a.extend(b,{selector:"> *"});var k;if(typeof m=="function")k=m;else if(typeof(p=="function"))k=p;return this.each(function(){var e=a(s).clone(),c=a(this);a(this).css("height");var h=a(c).offset(),i=[],l=a(this).find(b.selector);if(a.browser.msie&&a.browser.version.substr(0,1)<7)c.html("").append(e);else{var r=0,j=function(){if(!r){c.html(n.html());a("[data-quicksand-owner="+q(c)+"]").remove();typeof k=="function"&&k.call(this);r=1}},g=c.offsetParent(),d=g.offset();if(g.css("position")==
"relative"){if(g.get(0).nodeName.toLowerCase()!="body"){d.top+=parseFloat(g.css("border-top-width"));d.left+=parseFloat(g.css("border-left-width"))}}else{d.top-=parseFloat(g.css("border-top-width"));d.left-=parseFloat(g.css("border-left-width"));d.top-=parseFloat(g.css("margin-top"));d.left-=parseFloat(g.css("margin-left"))}c.css("height",a(this).height());l.each(function(f){i[f]=a(this).offset()});a(this).stop();l.each(function(f){a(this).stop();a(this).css("position","absolute").css("margin",0).css("top",
i[f].top-parseFloat(a(this).css("margin-top"))-d.top).css("left",i[f].left-parseFloat(a(this).css("margin-left"))-d.left)});var n=a(c).clone().html("").attr("id","").attr("data-quicksand-owner",c.selector).css("height","auto").css("width",c.width()+"px").append(e);n.insertBefore(c).css("z-index",1).css("opacity",0).css("margin",0).css("position","absolute").css("top",h.top-d.top).css("left",h.left-d.left).attr("data-quicksand-owner",q(c));b.adjustHeight&&c.animate({height:n.height()},b.duration,b.easing);
l.each(function(){var f=e.filter("["+b.attribute+"="+a(this).attr(b.attribute)+"]");if(f.length)a.browser.msie?a(this).animate({top:f.offset().top-d.top,left:f.offset().left-d.left,opacity:1},b.duration,b.easing,j):a(this).animate({top:f.offset().top-d.top,left:f.offset().left-d.left,opacity:1,scale:"1.0"},b.duration,b.easing,j);else a.browser.msie?a(this).animate({opacity:"0.0"},b.duration,b.easing,j):a(this).animate({opacity:"0.0",scale:"0.0"},b.duration,b.easing,j)});e.each(function(){var f=l.filter("["+
b.attribute+"="+a(this).attr(b.attribute)+"]"),o=e.filter("["+b.attribute+"="+a(this).attr(b.attribute)+"]");if(f.length===0){f=a.browser.msie?{opacity:"1.0"}:{opacity:"1.0",scale:"1.0"};o.clone().css("position","absolute").css("margin",0).css("top",o.offset().top-d.top).css("left",o.offset().left-d.left).css("opacity",0).css("transform","scale(0.0)").appendTo(c).animate(f,b.duration,b.easing,j)}})}})}})(jQuery);