-
Notifications
You must be signed in to change notification settings - Fork 2
/
singly.min.js
1 lines (1 loc) · 10.9 KB
/
singly.min.js
1
(function(){function t(e,n,r){var i=t.resolve(e);if(null==i){r=r||e,n=n||"root";var o=Error('Failed to require "'+r+'" from "'+n+'"');throw o.path=r,o.parent=n,o.require=!0,o}var s=t.modules[i];return s.exports||(s.exports={},s.client=s.component=!0,s.call(this,s.exports,t.relative(i),s)),s.exports}var e=Object.prototype.hasOwnProperty;t.modules={},t.aliases={},t.resolve=function(n){"/"===n.charAt(0)&&(n=n.slice(1));for(var r=n+"/index.js",i=[n,n+".js",n+".json",n+"/index.js",n+"/index.json"],o=0;i.length>o;o++){var n=i[o];if(e.call(t.modules,n))return n}return e.call(t.aliases,r)?t.aliases[r]:void 0},t.normalize=function(t,e){var n=[];if("."!=e.charAt(0))return e;t=t.split("/"),e=e.split("/");for(var r=0;e.length>r;++r)".."==e[r]?t.pop():"."!=e[r]&&""!=e[r]&&n.push(e[r]);return t.concat(n).join("/")},t.register=function(e,n){t.modules[e]=n},t.alias=function(n,r){if(!e.call(t.modules,n))throw Error('Failed to alias "'+n+'", it does not exist');t.aliases[r]=n},t.relative=function(n){function r(t,e){for(var n=t.length;n--;)if(t[n]===e)return n;return-1}function i(e){var r=i.resolve(e);return t(r,n,e)}var o=t.normalize(n,"..");return i.resolve=function(e){var i=e.charAt(0);if("/"==i)return e.slice(1);if("."==i)return t.normalize(o,e);var s=n.split("/"),a=r(s,"deps")+1;return a||(a=0),e=s.slice(0,a+1).join("/")+"/deps/"+e},i.exists=function(n){return e.call(t.modules,i.resolve(n))},i},t.register("component-cookie/index.js",function(t,e,n){function r(t,e,n){n=n||{};var r=a(t)+"="+a(e);null==e&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(r+="; path="+n.path),n.domain&&(r+="; domain="+n.domain),n.expires&&(r+="; expires="+n.expires.toUTCString()),n.secure&&(r+="; secure"),document.cookie=r}function i(){return s(document.cookie)}function o(t){return i()[t]}function s(t){var e,n={},r=t.split(/ *; */);if(""==r[0])return n;for(var i=0;r.length>i;++i)e=r[i].split("="),n[u(e[0])]=u(e[1]);return n}var a=encodeURIComponent,u=decodeURIComponent;n.exports=function(t,e,n){switch(arguments.length){case 3:case 2:return r(t,e,n);case 1:return o(t);default:return i()}}}),t.register("component-emitter/index.js",function(t,e,n){function r(t){return t?i(t):void 0}function i(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}n.exports=r,r.prototype.on=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){r.off(t,n),e.apply(this,arguments)}var r=this;return this._callbacks=this._callbacks||{},e._off=n,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=function(t,e){this._callbacks=this._callbacks||{};var n=this._callbacks[t];if(!n)return this;if(1==arguments.length)return delete this._callbacks[t],this;var r=n.indexOf(e._off||e);return~r&&n.splice(r,1),this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks[t];if(n){n=n.slice(0);for(var r=0,i=n.length;i>r;++r)n[r].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}}),t.register("RedVentures-reduce/index.js",function(t,e,n){n.exports=function(t,e,n){for(var r=0,i=t.length,o=3==arguments.length?n:t[r++];i>r;)o=e.call(null,o,t[r],++r,t);return o}}),t.register("visionmedia-superagent/lib/client.js",function(t,e,n){function r(){}function i(){if(y.XMLHttpRequest&&("file:"!=y.location.protocol||!y.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1}function o(t){return t===Object(t)}function s(t){if(!o(t))return t;var e=[];for(var n in t)e.push(encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e.join("&")}function a(t){for(var e,n,r={},i=t.split("&"),o=0,s=i.length;s>o;++o)n=i[o],e=n.split("="),r[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return r}function u(t){var e,n,r,i,o=t.split(/\r?\n/),s={};o.pop();for(var a=0,u=o.length;u>a;++a)n=o[a],e=n.indexOf(":"),r=n.slice(0,e).toLowerCase(),i=v(n.slice(e+1)),s[r]=i;return s}function c(t){return t.split(/ *; */).shift()}function l(t){return m(t.split(/ *; */),function(t,e){var n=e.split(/ *= */),r=n.shift(),i=n.shift();return r&&i&&(t[r]=i),t},{})}function p(t,e){e=e||{},this.xhr=t,this.text=t.responseText,this.setStatusProperties(t.status),this.header=this.headers=u(t.getAllResponseHeaders()),this.header["content-type"]=t.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body=this.parseBody(this.text)}function h(t,e){var n=this;f.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this.set("X-Requested-With","XMLHttpRequest"),this.on("end",function(){var e=new p(n.xhr);"HEAD"==t&&(e.text=null),n.callback(null,e)})}function d(t,e){return"function"==typeof e?new h("GET",t).end(e):1==arguments.length?new h("GET",t):new h(t,e)}var f=e("emitter"),m=e("reduce"),y="undefined"==typeof window?this:window,v="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};d.serializeObject=s,d.parseString=a,d.types={html:"text/html",json:"application/json",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},d.serialize={"application/x-www-form-urlencoded":s,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":a,"application/json":JSON.parse},p.prototype.get=function(t){return this.header[t.toLowerCase()]},p.prototype.setHeaderProperties=function(){var t=this.header["content-type"]||"";this.type=c(t);var e=l(t);for(var n in e)this[n]=e[n]},p.prototype.parseBody=function(t){var e=d.parse[this.type];return e?e(t):null},p.prototype.setStatusProperties=function(t){var e=0|t/100;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t||1223==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},p.prototype.toError=function(){var t="got "+this.status+" response",e=Error(t);return e.status=this.status,e},d.Response=p,h.prototype=new f,h.prototype.constructor=h,h.prototype.timeout=function(t){return this._timeout=t,this},h.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},h.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},h.prototype.set=function(t,e){if(o(t)){for(var n in t)this.set(n,t[n]);return this}return this.header[t.toLowerCase()]=e,this},h.prototype.type=function(t){return this.set("Content-Type",d.types[t]||t),this},h.prototype.query=function(t){return"string"!=typeof t&&(t=s(t)),this._query.push(t),this},h.prototype.send=function(t){var e=o(t),n=this.header["content-type"];if(e&&o(this._data))for(var r in t)this._data[r]=t[r];else"string"==typeof t?(n||this.type("form"),n=this.header["content-type"],this._data="application/x-www-form-urlencoded"==n?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return e?(n||this.type("json"),this):this},h.prototype.callback=function(t,e){var n=this._callback;return 2==n.length?n(t,e):t?this.emit("error",t):(n(e),void 0)},h.prototype.crossDomainError=function(){var t=Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},h.prototype.timeoutError=function(){var t=this._timeout,e=Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},h.prototype.withCredentials=function(){return this._withCredentials=!0,this},h.prototype.end=function(t){var e=this,n=this.xhr=i(),o=this._query.join("&"),s=this._timeout,a=this._data;if(this._callback=t||r,this._withCredentials&&(n.withCredentials=!0),n.onreadystatechange=function(){return 4==n.readyState?0==n.status?e.aborted?e.timeoutError():e.crossDomainError():(e.emit("end"),void 0):void 0},s&&!this._timer&&(this._timer=setTimeout(function(){e.abort()},s)),o&&(o=d.serializeObject(o),this.url+=~this.url.indexOf("?")?"&"+o:"?"+o),n.open(this.method,this.url,!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a){var u=d.serialize[this.header["content-type"]];u&&(a=u(a))}for(var c in this.header)n.setRequestHeader(c,this.header[c]);return n.send(a),this},d.Request=h,d.get=function(t,e,n){var r=d("GET",t);return"function"==typeof e&&(n=e,e=null),e&&r.query(e),n&&r.end(n),r},d.head=function(t,e,n){var r=d("HEAD",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},d.del=function(t,e){var n=d("DELETE",t);return e&&n.end(e),n},d.patch=function(t,e,n){var r=d("PATCH",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},d.post=function(t,e,n){var r=d("POST",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},d.put=function(t,e,n){var r=d("PUT",t);return"function"==typeof e&&(n=e,e=null),e&&r.send(e),n&&r.end(n),r},n.exports=d}),t.register("singly/dist/singly.js",function(t,e,n){var r,i,o,s,a,u;i=e("cookie"),s=e("superagent"),o=function(t){var e,n,r;return r=window.location.hash,n=RegExp("#"+t+"=([^&]+)(&|$)"),e=r.match(n),null!=e&&null!=e[1]?e[1]:void 0},r=null,a={base:"https://api.singly.com",cookieName:"singly_access_token",setKey:function(t){return r=t},token:function(){return i(a.cookieName)},clearToken:function(){return i(a.cookieName,null),a},setToken:function(t){return i(a.cookieName,t,{maxage:6048e5,path:"/"}),a},authorize:function(t,e){var n;return null==e&&(e=window.location.href),n=""+a.base+"/oauth/authorize?client_id="+r+"&service="+t+"&redirect_uri="+e+"&scope=email&response_type=token",window.location.href=n,a},makeRequest:function(t,e,n,r){var i,o;return null==e&&(e={}),"function"!=typeof e||r||(r=e,e={}),o=""+a.base+t,i=s[n](o).type("json").query(e.qs).query({access_token:a.token()}),("post"===n||"put"===n)&&i.send(e.data),i.end(r),i},get:function(t,e,n){return a.makeRequest(t,e,"get",n)},post:function(t,e,n){return a.makeRequest(t,e,"post",n)},put:function(t,e,n){return a.makeRequest(t,e,"put",n)},del:function(t,e,n){return a.makeRequest(t,e,"del",n)}},u=o("access_token"),null!=u&&a.setToken(u),n.exports=a}),t.alias("component-cookie/index.js","singly/deps/cookie/index.js"),t.alias("visionmedia-superagent/lib/client.js","singly/deps/superagent/lib/client.js"),t.alias("visionmedia-superagent/lib/client.js","singly/deps/superagent/index.js"),t.alias("component-emitter/index.js","visionmedia-superagent/deps/emitter/index.js"),t.alias("RedVentures-reduce/index.js","visionmedia-superagent/deps/reduce/index.js"),t.alias("visionmedia-superagent/lib/client.js","visionmedia-superagent/index.js"),t.alias("singly/dist/singly.js","singly/index.js"),"object"==typeof exports?module.exports=t("singly"):"function"==typeof define&&define.amd?define(t("singly")):window.singly=t("singly")})();