forked from ccampbell/xtab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raindrop.min.js
21 lines (21 loc) · 9.22 KB
/
raindrop.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* raindrop v0.2.4 */'use strict';(function(){function a(e,b){if(!(this instanceof a)){if("string"===typeof e){if(!document.querySelectorAll)return new a;var g=(b?b[0]:document).querySelectorAll(e);if(1!==g.length)return new a(g);e=g[0]}return e&&e.__rid?d[e.__rid]:new a(e)}if(!e)return this.length=0,this;c++;if(e.nodeType||e===window)e.__rid=c,e={"0":e,length:1};this.id=c;f(this,e);this.length=e.length;d[c]=this}function f(e,a){for(var d in a)a.hasOwnProperty(d)&&(e[d]=a[d]);return e}var c=0,b,d={};a.ready=function(e){var a;
document.addEventListener("DOMContentLoaded",a=function(){document.removeEventListener("DOMContentLoaded",a,!1);e()},!1)};a.extend=f;a.matches=function(e,a){var d;b||(e.matches&&(b=e.matches),e.webkitMatchesSelector&&(b=e.webkitMatchesSelector),e.mozMatchesSelector&&(b=e.mozMatchesSelector),e.msMatchesSelector&&(b=e.msMatchesSelector),e.oMatchesSelector&&(b=e.oMatchesSelector),b||(b=function(){}));d=b;return d.call(e,a)};a.prototype.each=function(e){for(var a=0;a<this.length&&!1!==e.call(this[a],
a);a++);};window.Raindrop=window.$=a})();
(function(a){function f(e,d,c){if("_root"==d)return c;if(e!==c){if(a.matches(e,d))return e;if(e.parentNode)return b++,f(e.parentNode,d,c)}}function c(e,c,g,m,n,t,u){function v(g){return function(h){a:{var m=e.id,j=c;if(d[m][g]){var l=h.target,n,p,k={},q=p=0;b=0;for(n in d[m][g])if(d[m][g].hasOwnProperty(n)&&(p=f(l,n,j))&&a.matchesEvent(g,j,p,"_root"==n,h))b++,d[m][g][n].match=p,k[b]=d[m][g][n];h.stopPropagation=function(){h.cancelBubble=!0};for(p=0;p<=b;p++)if(k[p])for(q=0;q<k[p].length;q++){if(!1===
k[p][q].call(k[p].match,h)){a.cancel(h);break a}if(h.cancelBubble)break a}}}}}g instanceof Array||(g=[g]);!n&&"function"==typeof m&&(n=m,m="_root");c.bound=c.bound||{};for(var k=0;k<g.length;k++)if(c.bound[g[k]]||(a._addEvent(c,g[k],v(g[k])),c.bound[g[k]]=1),t)if(u){var h=e.id,j=g[k],l=m,q=n;if(d[h])if(j)if(!q&&!l)d[h][j]={};else if(q){if(d[h][j][l])for(var r=0;r<d[h][j][l].length;r++)if(d[h][j][l][r]===q){d[h][j][l].splice(r,1);break}}else delete d[h][j][l];else for(j in j=void 0,d[h])d[h].hasOwnProperty(j)&&
(d[h][j]={})}else h=e.id,j=g[k],l=m,q=n,d[h]||(d[h]={}),d[h][j]||(d[h][j]={}),d[h][j][l]||(d[h][j][l]=[]),d[h][j][l].push(q)}var b=0,d={};a._addEvent=function(a,d,c){"mouseenter"==d&&(d="mouseover");"mouseleave"==d&&(d="mouseout");a.addEventListener(d,c,"blur"==d||"focus"==d)};a.matchesEvent=function(d,a,c,b,f){return"mouseenter"==d||"mouseleave"==d?(d=f.relatedTarget?b&&a!==c?!1:c===f.relatedTarget?!1:c===window||c.contains(f.relatedTarget)?!1:!0:!0,d):!0};a.cancel=function(d){d.preventDefault();
d.stopPropagation()};a.prototype.on=function(d,a,b){for(var f=0;f<this.length;f++)c(this,this[f],d,a,b,0===f);return this};a.prototype.off=function(d,a,b){for(var f=0;f<this.length;f++)c(this,this[f],d,a,b,0===f,!0);return this};a.prototype.trigger=function(d){for(var a=0;a<this.length;a++){if("function"===typeof this[a][d])this[a][d]();if("focus"===d)break}}})(Raindrop);
(function(a){function f(c,b){return!c?!1:1!==c.nodeType?!0:!b?!1:!a.matches(c,b)}a.prototype.attr=function(a,b){if(void 0===b)return!this.length?void 0:this[0].getAttribute(a);for(var d=0;d<this.length;d++)this[d].setAttribute(a,b);return this};a.prototype.prop=function(a,b){if(void 0===b)return!this.length?void 0:this[0][a];for(var d=0;d<this.length;d++)this[d][a]=b;return this};a.prototype.is=function(c){return!this.length?!1:":"!=c[0]?a.matches(this[0],c):!1};a.prototype.contains=function(a){return this[0].contains(a)};
a.prototype.text=function(a){return this.prop("textContent",a)};a.prototype.html=function(a){return this.prop("innerHTML",a)};a.prototype.data=function(a,b){return this.attr("data-"+a,b)};a.prototype.before=function(c){if(!this.length)return this;c instanceof a&&(c=c[0]);for(var b=0;b<this.length;b++)0<b&&(c=c.cloneNode(!0)),this[b].parentNode.insertBefore(c,this[b]);return this};a.prototype.after=function(a){return this.next().before(a)};a.prototype.prepend=function(c){if("string"===typeof c)return this.html(c+
this.html());c instanceof a&&(c=c[0]);for(var b=0;b<this.length;b++)0<b&&(c=c.cloneNode(!0)),this[b].insertBefore(c,this[b].firstChild)};a.prototype.append=function(c){if("string"===typeof c)return this.html(this.html()+c);c instanceof a&&(c=c[0]);for(var b=0;b<this.length;b++)this[b].appendChild(c)};a.prototype.hasClass=function(a){return!this.length||!this[0].className?!1:-1!==this[0].className.split(" ").indexOf(a)};a.prototype.toggleClass=function(a){this.hasClass(a)?this.removeClass(a):this.addClass(a)};
a.prototype.addClass=function(a){if(!this.length)return this;var b,d;for(d=0;d<this.length;d++)b=this[d].className?this[d].className.split(" "):[],-1<b.indexOf(a)||(b.push(a),this[d].className=b.join(" "));return this};a.prototype.removeClass=function(a){if(!this.length)return this;var b,d,e;for(e=0;e<this.length;e++){d=null;for(b=this[e].className?this[e].className.split(" "):[];-1!==d;)d=b.indexOf(a),-1!==d&&b.splice(d,1);this[e].className=b.join(" ")}return this};a.prototype.next=function(c){if(!this.length)return this;
for(var b=this[0].nextSibling;f(b,c);)b=b.nextSibling;return a(b)};a.prototype.prev=function(c){if(!this.length)return this;for(var b=this[0].previousSibling;f(b,c);)b=b.previousSibling;return a(b)};a.prototype.parent=function(c){if(!this.length)return this;for(var b=this[0].parentNode;f(b,c);)b=b.parentNode;return a(b)};a.prototype.children=function(c){if(!this.length)return a();var b=[],d;for(d=0;d<this[0].childNodes.length;d++)f(this[0].childNodes[d],c)||b.push(this[0].childNodes[d]);return a(b)};
a.prototype.remove=function(){for(var a=0;a<this.length;a++)this[a].parentNode&&this[a].parentNode.removeChild(this[a]);return this};a.prototype.clone=function(c){return!this.length?this:a(this[0].cloneNode(void 0!==c?c:!0))}})(Raindrop);(function(a){a.prototype.val=function(a){if(this.length)return void 0!==this[0].selectedIndex?this.prop("selectedIndex",void 0!==a?a:void 0):"checkbox"===this.attr("type")?this.prop("checked",void 0!==a?a:void 0):this.prop("value",void 0!==a?a:void 0)}})(Raindrop);
(function(a){function f(a,b){if({width:1,height:1,top:1,left:1,right:1,bottom:1}[a]){if(""===b)return null;if(!isNaN(parseFloat(b))&&isFinite(b))return b+"px"}return b}function c(a){return a.is("body")?!0:"none"===a.css("display")||"hidden"===a.css("visibility")||0===a.outerHeight()||0===a.outerWidth()?!1:c(a.parent())}var b=a.prototype.is;a.css=function(a,b,c){if(void 0===b&&void 0===c)return window.getComputedStyle(a);if(void 0===c&&"string"===typeof b)return window.getComputedStyle(a)[b];if(void 0===
c)for(var g in b)b.hasOwnProperty(g)&&(a.style[g]=f(g,b[g]));else a.style[b]=f(b,c)};a.prototype.css=function(d,b){if(void 0===b&&(void 0===d||"string"===typeof d))return a.css(this[0],d);for(var c=0;c<this.length;c++)a.css(this[c],d,b);return this};a.prototype.is=function(a){return b.call(this,a)?!0:":visible"==a?c(this):!1};a.prototype.position=function(){if(!this.length)return{};for(var b=this.offset(),c=this[0].offsetParent||document.body;c&&!a.matches(c,"body")&&!a.matches(c,"html")&&"static"===
a.css(c,"position");)c=c.offsetParent;c=a(c||document.body).offset();b.top-=parseInt(a.css(this[0],"margin-top"),10);b.left-=parseInt(a.css(this[0],"margin-left"),10);return{top:b.top-c.top,left:b.left-c.left}};a.prototype.offset=function(){if(!this.length)return{};var a=this.rect();return{top:a.top+(window.pageYOffset||document.documentElement.scrollTop)-(document.documentElement.clientTop||document.body.clientTop),left:a.left+(window.pageXOffset||document.documentElement.scrollLeft)-(document.documentElement.clientLeft||
document.body.clientLeft)}};a.prototype.show=function(){return this.css("display","block")};a.prototype.hide=function(){return this.css("display","none")};a.prototype.width=function(){return this.length?this[0]===window?this[0].innerWidth:parseInt(this.css("width"),10):0};a.prototype.height=function(){return this.length?this[0]===window?this[0].innerHeight:parseInt(this.css("height"),10):0};a.prototype.rect=function(){if(this.length)return this[0].getBoundingClientRect()};a.prototype.outerHeight=
function(){return this.length?Math.ceil(this.rect().height):0};a.prototype.outerWidth=function(){return this.length?Math.ceil(this.rect().width):0}})(Raindrop);
(function(a){a.prototype.index=function(f){f instanceof a&&(f=f[0]);for(var c=0;c<this.length;c++)if(this[c]===f)return c;return-1};a.prototype.slice=function(f,c){for(var b=[];f<c;)this[f]&&b.push(this[f]),f++;return a(b)};a.prototype.eq=function(f){return f in this?a(this[f]):a()};a.prototype.first=function(){return this.eq(0)};a.prototype.last=function(){return this.eq(this.length-1)};a.prototype.add=function(f){f instanceof a&&(f=f[0]);f&&(this.length+=1,this[this.length-1]=f);return this}})(Raindrop);
(function(a){function f(a){var d=[],c;for(c in a)a.hasOwnProperty(c)&&d.push(c+"="+a[c]);return d.join("&")}function c(a){try{return JSON.parse(a.responseText)}catch(c){return a.responseText}}a.ajax=function(a,d,e,s){var g;g=window.XDomainRequest?new XDomainRequest:new XMLHttpRequest;g.open(a,d);g.setRequestHeader("Content-Type","application/x-www-form-urlencoded");g.setRequestHeader("X-Requested-With","XMLHttpRequest");g.withCredentials=!0;g.onload=function(){s.call(g,c(g))};g.onerror=function(){s.call(g,
c(g))};g.send(f(e))};a.get=function(b,c,e){a.ajax("GET",b,{},c,e)};a.post=function(b,c,e,f){a.ajax("POST",b,c,e,f)}})(Raindrop);