Instantly share code, notes, and snippets.
Created
March 23, 2016 17:45
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save pcothenet/f6d4bde62dbcb87236e5 to your computer and use it in GitHub Desktop.
Segment_button
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 t(e, n, r) { | |
function i(t) { | |
if (n[t]) return n[t].exports; | |
if (e[t]) return o(t, i); | |
throw new Error('cannot find module "' + t + '"') | |
} | |
function o(i, o) { | |
var u = n[i] = { | |
exports: {} | |
}, | |
c = e[i], | |
a = c[2], | |
s = c[0], | |
l = !0; | |
try { | |
s.call(u.exports, function(t) { | |
var n = e[i][1][t]; | |
return o(n || t) | |
}, u, u.exports, t, e, n, r), l = !1 | |
} finally { | |
l ? delete n[i] : a && (n[a] = n[i]) | |
} | |
return n[i].exports | |
} | |
var u = function() { | |
return this | |
}(); | |
for (var c in r) r[c] ? u[r[c]] = i(c) : i(c); | |
return i.duo = !0, i.cache = n, i.modules = e, i | |
}({ | |
1: [ | |
function(t, e, n) { | |
"use strict"; | |
var r = t("domready"), | |
i = t("./lib/enable-button"); | |
window.segment || (window.segment = {}), window.segment | |
.EnableButton = i, e.exports = window.segment, r(i.init) | |
}, { | |
domready: 2, | |
"./lib/enable-button": 3 | |
} | |
], | |
2: [ | |
function(t, e, n) { | |
! function(t, n) { | |
"undefined" != typeof e ? e.exports = n() : | |
"function" == typeof define && "object" == | |
typeof define.amd ? define(n) : this[t] = n() | |
}("domready", function() { | |
var t, e = [], | |
n = document, | |
r = n.documentElement.doScroll, | |
i = "DOMContentLoaded", | |
o = (r ? /^loaded|^c/ : /^loaded|^i|^c/).test( | |
n.readyState); | |
return o || n.addEventListener(i, t = function() { | |
for (n.removeEventListener(i, t), o = | |
1; t = e.shift();) t() | |
}), | |
function(t) { | |
o ? setTimeout(t, 0) : e.push(t) | |
} | |
}) | |
}, {} | |
], | |
3: [ | |
function(t, e, n) { | |
"use strict"; | |
function r(t) { | |
this.container = i(t.element), this.integration = | |
t.integration, this.settings = t.settings, | |
this.redirectUrl = t.redirectUrl, this.size = | |
t.size || "medium", this.baseUrl = t.baseUrl || | |
d, this.context = t.context || null, this.init() | |
} | |
function i(t) { | |
return t instanceof HTMLElement ? t : document.body | |
.querySelector(t) | |
} | |
function o(t) { | |
for (; t.firstChild;) t.removeChild(t.firstChild); | |
return t | |
} | |
var u = t("base64-encode"), | |
c = t("map"), | |
a = t("querystring").stringify, | |
s = t("set-styles"), | |
l = u(t("./icon.svg")), | |
f = t("text"), | |
d = "https://segment.com"; | |
e.exports = r, r.init = function(t) { | |
t || (t = document.body); | |
var e = t.getElementsByClassName( | |
"segment-enable-button"); | |
return c(e, function(t) { | |
return new r({ | |
element: t, | |
integration: t.getAttribute( | |
"data-integration" | |
), | |
settings: JSON.parse(t.getAttribute( | |
"data-settings" | |
)), | |
redirectUrl: t.getAttribute( | |
"data-redirect-url" | |
), | |
size: t.getAttribute( | |
"data-size"), | |
context: JSON.parse(t.getAttribute( | |
"data-context" | |
)), | |
baseUrl: t.getAttribute( | |
"data-base-url" | |
) | |
}) | |
}) | |
}, r.url = function(t, e, n, r, i) { | |
r || (r = d); | |
var o = { | |
integration: t, | |
settings: u(JSON.stringify(e)) | |
}; | |
return n && (o.redirect_url = u(n)), i && (o.context = | |
u(JSON.stringify(i))), r + "/enable?" + | |
a(o) | |
}, r.prototype.init = function() { | |
return this.container ? this.element ? this.warn( | |
"already initialized") : (this.element = | |
this.el(), void o(this.container).appendChild( | |
this.element)) : this.error( | |
"html element required") | |
}, r.prototype.destroy = function() { | |
return this.element ? (o(this.container), void delete this | |
.element) : this.warn("not initialized") | |
}; | |
var p = { | |
small: "10px", | |
medium: "12px", | |
large: "16px" | |
}; | |
r.prototype.el = function() { | |
var t = this, | |
e = document.createElement("a"); | |
return f(e, "Enable with Segment"), e.onclick = | |
function() { | |
t.onClick.apply(t, arguments) | |
}, e.href = this.url(), s(e, { | |
background: 'url("data:image/svg+xml;base64,' + | |
l + | |
'") .6em 50%/1.25em no-repeat #5CCC5C', | |
borderRadius: "3em", | |
color: "white", | |
display: "inline-block", | |
verticalAlign: "middle", | |
fontFamily: "Lucida Grande, Lucida Sans Unicode, Lucida Sans, Geneva, Verdana, sans-serif", | |
fontSize: p[this.size] || p.medium, | |
padding: "0.5em 1.4em 0.5em 2.6em", | |
textDecoration: "none" | |
}), e | |
}, r.prototype.onClick = function(t) { | |
if ("function" == typeof this.settings) { | |
t.preventDefault(); | |
var e = this.integration, | |
n = this.redirectUrl, | |
i = this.context, | |
o = this.baseUrl; | |
if (1 === this.settings.length) this.settings( | |
function(t) { | |
r.redirect(r.url(e, t, n, o, i)) | |
}); | |
else { | |
var u = this.settings(); | |
r.redirect(r.url(e, u, n, o, i)) | |
} | |
} | |
}, r.prototype.url = function() { | |
var t = "function" == typeof this.settings ? "" : | |
this.settings; | |
return r.url(this.integration, t, this.redirectUrl, | |
this.baseUrl, this.context) | |
}, r.prototype.warn = function(t) { | |
window.console && console.warn( | |
"segment.EnableButton: %s", t) | |
}, r.prototype.error = function(t) { | |
window.console && console.error( | |
"segment.EnableButton: %s", t) | |
}, r.redirect = function(t) { | |
window.location = t | |
} | |
}, { | |
"base64-encode": 4, | |
map: 5, | |
querystring: 6, | |
"set-styles": 7, | |
"./icon.svg": 8, | |
text: 9 | |
} | |
], | |
4: [ | |
function(t, e, n) { | |
function r(t) { | |
var e, n, r, u, c, a, s, l = "", | |
f = 0; | |
for (t = i(t); f < t.length;) e = t.charCodeAt( | |
f++), n = t.charCodeAt(f++), r = t.charCodeAt( | |
f++), u = e >> 2, c = (3 & e) << 4 | n >> | |
4, a = (15 & n) << 2 | r >> 6, s = 63 & r, | |
isNaN(n) ? a = s = 64 : isNaN(r) && (s = 64), | |
l = l + o.charAt(u) + o.charAt(c) + o.charAt( | |
a) + o.charAt(s); | |
return l | |
} | |
var i = t("utf8-encode"), | |
o = | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
e.exports = r | |
}, { | |
"utf8-encode": 10 | |
} | |
], | |
10: [ | |
function(t, e, n) { | |
function r(t) { | |
t = t.replace(/\r\n/g, "\n"); | |
for (var e = "", n = 0; n < t.length; n++) { | |
var r = t.charCodeAt(n); | |
128 > r ? e += String.fromCharCode(r) : r > | |
127 && 2048 > r ? (e += String.fromCharCode( | |
r >> 6 | 192), e += String.fromCharCode( | |
63 & r | 128)) : (e += String.fromCharCode( | |
r >> 12 | 224), e += String.fromCharCode( | |
r >> 6 & 63 | 128), e += String | |
.fromCharCode(63 & r | 128)) | |
} | |
return e | |
} | |
e.exports = r | |
}, {} | |
], | |
5: [ | |
function(t, e, n) { | |
var r = t("to-function"); | |
e.exports = function(t, e) { | |
var n = []; | |
e = r(e); | |
for (var i = 0; i < t.length; ++i) n.push(e(t[i], | |
i)); | |
return n | |
} | |
}, { | |
"to-function": 11 | |
} | |
], | |
11: [ | |
function(t, e, n) { | |
function r(t) { | |
switch ({}.toString.call(t)) { | |
case "[object Object]": | |
return c(t); | |
case "[object Function]": | |
return t; | |
case "[object String]": | |
return u(t); | |
case "[object RegExp]": | |
return o(t); | |
default: | |
return i(t) | |
} | |
} | |
function i(t) { | |
return function(e) { | |
return t === e | |
} | |
} | |
function o(t) { | |
return function(e) { | |
return t.test(e) | |
} | |
} | |
function u(t) { | |
return /^ *\W+/.test(t) ? new Function("_", | |
"return _ " + t) : new Function("_", | |
"return " + a(t)) | |
} | |
function c(t) { | |
var e = {}; | |
for (var n in t) e[n] = "string" == typeof t[n] ? | |
i(t[n]) : r(t[n]); | |
return function(t) { | |
if ("object" != typeof t) return !1; | |
for (var n in e) { | |
if (!(n in t)) return !1; | |
if (!e[n](t[n])) return !1 | |
} | |
return !0 | |
} | |
} | |
function a(t) { | |
var e = l(t); | |
if (!e.length) return "_." + t; | |
var n, r, i; | |
for (r = 0; r < e.length; r++) i = e[r], n = | |
"_." + i, n = "('function' == typeof " + n + | |
" ? " + n + "() : " + n + ")", t = s(i, t, | |
n); | |
return t | |
} | |
function s(t, e, n) { | |
return e.replace(new RegExp("(\\.)?" + t, "g"), | |
function(t, e) { | |
return e ? t : n | |
}) | |
} | |
var l; | |
try { | |
l = t("props") | |
} catch (f) { | |
l = t("component-props") | |
} | |
e.exports = r | |
}, { | |
props: 12, | |
"component-props": 12 | |
} | |
], | |
12: [ | |
function(t, e, n) { | |
function r(t) { | |
return t.replace( | |
/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^\/]+)\//g, | |
"").replace(c, "").match( | |
/[$a-zA-Z_]\w*/g) || [] | |
} | |
function i(t, e, n) { | |
var r = | |
/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^\/]+)\/|[a-zA-Z_]\w*/g; | |
return t.replace(r, function(t) { | |
return "(" == t[t.length - 1] ? n(t) : | |
~e.indexOf(t) ? n(t) : t | |
}) | |
} | |
function o(t) { | |
for (var e = [], n = 0; n < t.length; n++)~e.indexOf( | |
t[n]) || e.push(t[n]); | |
return e | |
} | |
function u(t) { | |
return function(e) { | |
return t + e | |
} | |
} | |
var c = /\b(this|Array|Date|Object|Math|JSON)\b/g; | |
e.exports = function(t, e) { | |
var n = o(r(t)); | |
return e && "string" == typeof e && (e = u(e)), | |
e ? i(t, n, e) : n | |
} | |
}, {} | |
], | |
6: [ | |
function(t, e, n) { | |
var r = t("trim"), | |
i = t("type"), | |
o = /(\w+)\[(\d+)\]/, | |
u = function(t) { | |
try { | |
return encodeURIComponent(t) | |
} catch (e) { | |
return t | |
} | |
}, | |
c = function(t) { | |
try { | |
return decodeURIComponent(t.replace(/\+/g, | |
" ")) | |
} catch (e) { | |
return t | |
} | |
}; | |
n.parse = function(t) { | |
if ("string" != typeof t) return {}; | |
if (t = r(t), "" == t) return {}; | |
"?" == t.charAt(0) && (t = t.slice(1)); | |
for (var e = {}, n = t.split("&"), i = 0; i < n | |
.length; i++) { | |
var u, a = n[i].split("="), | |
s = c(a[0]); | |
(u = o.exec(s)) ? (e[u[1]] = e[u[1]] || [], | |
e[u[1]][u[2]] = c(a[1])) : e[a[0]] = | |
null == a[1] ? "" : c(a[1]) | |
} | |
return e | |
}, n.stringify = function(t) { | |
if (!t) return ""; | |
var e = []; | |
for (var n in t) { | |
var r = t[n]; | |
if ("array" != i(r)) e.push(u(n) + "=" + u( | |
t[n])); | |
else | |
for (var o = 0; o < r.length; ++o) e.push( | |
u(n + "[" + o + "]") + "=" + u( | |
r[o])) | |
} | |
return e.join("&") | |
} | |
}, { | |
trim: 13, | |
type: 14 | |
} | |
], | |
13: [ | |
function(t, e, n) { | |
function r(t) { | |
return t.trim ? t.trim() : t.replace( | |
/^\s*|\s*$/g, "") | |
} | |
n = e.exports = r, n.left = function(t) { | |
return t.trimLeft ? t.trimLeft() : t.replace( | |
/^\s*/, "") | |
}, n.right = function(t) { | |
return t.trimRight ? t.trimRight() : t.replace( | |
/\s*$/, "") | |
} | |
}, {} | |
], | |
14: [ | |
function(t, e, n) { | |
var r = Object.prototype.toString; | |
e.exports = function(t) { | |
switch (r.call(t)) { | |
case "[object Date]": | |
return "date"; | |
case "[object RegExp]": | |
return "regexp"; | |
case "[object Arguments]": | |
return "arguments"; | |
case "[object Array]": | |
return "array"; | |
case "[object Error]": | |
return "error" | |
} | |
return null === t ? "null" : void 0 === t ? | |
"undefined" : t !== t ? "nan" : t && 1 === | |
t.nodeType ? "element" : (t = t.valueOf ? t | |
.valueOf() : Object.prototype.valueOf.apply( | |
t), typeof t) | |
} | |
}, {} | |
], | |
7: [ | |
function(t, e, n) { | |
function r(t) { | |
return t.replace(/[A-Z]/g, function(t) { | |
return "-" + t.toLowerCase() | |
}) | |
} | |
e.exports = function(t, e) { | |
var n = []; | |
for (var i in e) n.push(r(i) + ": " + String(e[ | |
i]) + ";"); | |
t.style.cssText = n.join("") | |
} | |
}, {} | |
], | |
8: [ | |
function(t, e, n) { | |
e.exports = | |
'<svg width="22" height="22" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>Oval-1-Copy Copy 2</title><defs><ellipse id="a" cx="11" cy="11" rx="11" ry="11"/><path id="b" d="M14.165 13.454c0-.744-.238-1.392-.696-1.914-.428-.506-.823-.76-2.073-1.375-.917-.46-1.296-.68-1.628-.95-.333-.284-.523-.68-.523-1.09 0-.822.632-1.36 1.597-1.36.46 0 .917.11 1.265.332.315.19.49.38.837.854l.253-.015.127-.49.237-.79.22-.602c-.853-.332-1.216-.442-1.88-.506-.238-.03-.49-.047-.744-.047C8.678 5.5 7 6.923 7 9.01c.002.79.286 1.503.792 2.01.443.425.854.678 2.087 1.295.948.506 1.296.728 1.596 1.028.27.27.427.664.427 1.06 0 .932-.774 1.565-1.897 1.565-.554 0-1.075-.174-1.534-.506-.316-.237-.474-.427-.806-.917l-.285.047-.125.664-.19.79-.19.618c.822.332 1.154.41 1.85.506.316.03.633.047.933.047 2.625 0 4.507-1.58 4.507-3.763z"/></defs><g fill="none" fill-rule="evenodd"><g><use fill="#FFF" xlink:href="#a"/><use xlink:href="#a"/><use xlink:href="#a"/></g><g><use fill="#FFF" xlink:href="#b"/><use fill="#5CCC5C" xlink:href="#b"/></g></g></svg>' | |
}, {} | |
], | |
9: [ | |
function(t, e, n) { | |
var r = "innerText" in document.createElement("div") ? | |
"innerText" : "textContent"; | |
e.exports = function(t, e) { | |
return null == e ? t[r] : void(t[r] = e) | |
} | |
}, {} | |
] | |
}, {}, { | |
1: "" | |
}); | |
//# sourceMappingURL=index.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment