Instantly share code, notes, and snippets.

@cneill /page.js Secret
Last active Oct 17, 2015

Embed
What would you like to do?
var a2a_config = a2a_config || {};
a2a_config.vars = {
vars : ["menu_type", "static_server", "linkname", "linkurl", "linkname_escape", ["ssl", document.location.protocol != "http:" ? "https://static.addtoany.com/menu" : false], "show_title", "onclick", "num_services", "hide_embeds", "prioritize", "exclude_services", "custom_services", ["templates", {}], "orientation", ["track_links", false], ["track_links_key", ""], "awesm", "tracking_callback", "track_pub", "color_main", "color_bg", "color_border", "color_link_text", "color_link_text_hover", "color_arrow",
"color_arrow_hover", ["localize", "", 1], ["add_services", false, 1], "locale", "delay", "icon_color", "no_3p", "show_menu", "target"],
/**
* @return {undefined}
*/
process : function() {
var tmp_keys = a2a_config.vars.vars;
/** @type {number} */
var i = 0;
/** @type {string} */
var name = "a2a_";
var valuesLen = tmp_keys.length;
var key;
var value;
var val;
var l;
var b;
for (;i < valuesLen;i++) {
if (typeof tmp_keys[i] == "string") {
key = tmp_keys[i];
value = window[name + key];
/** @type {boolean} */
l = false;
} else {
key = tmp_keys[i][0];
value = window[name + key];
val = tmp_keys[i][1];
/** @type {boolean} */
l = true;
b = tmp_keys[i][2];
}
if (typeof value != "undefined" && value != null) {
a2a_config[key] = value;
if (!b) {
try {
delete window[name + key];
} catch (h) {
/** @type {null} */
window[name + key] = null;
}
}
} else {
if (l && !a2a_config[key]) {
a2a_config[key] = val;
}
}
}
}
};
a2a_config.vars.process();
a2a_config.static_server = a2a_config.static_server || (a2a_config.ssl ? a2a_config.ssl : "http://static.addtoany.com/menu");
var a2a = a2a || {
total : 0,
kit_services : [],
icons_img_url : a2a_config.static_server + "/icons.33.png",
head_tag : document.getElementsByTagName("head")[0],
/**
* @return {?}
*/
ieo : function() {
/** @type {number} */
var ieo = -1;
/** @type {Element} */
var blue = document.createElement("b");
for (;blue.innerHTML = "\x3c!--[if gt IE " + ++ieo + "]>1<![endif]--\x3e", +blue.innerHTML;) {
}
/**
* @return {?}
*/
a2a.ieo = function() {
return ieo;
};
return ieo;
},
quirks : document.compatMode && document.compatMode == "BackCompat" ? 1 : null,
has_touch : "ontouchend" in window,
has_pointer : navigator.msPointerEnabled,
fn_queue : [],
dom : {
isReady : false,
/**
* @param {Function} callback
* @return {undefined}
*/
ready : function(callback) {
/**
* @return {?}
*/
var ready = function() {
if (!document.body) {
return setTimeout(a2a.dom.ready(callback));
}
callback();
/** @type {boolean} */
a2a.dom.isReady = true;
};
/**
* @param {Event} e
* @return {undefined}
*/
var completed = function(e) {
if (document.addEventListener || (e.type === "load" || document.readyState === "complete")) {
init();
ready();
}
};
/**
* @return {undefined}
*/
var init = function() {
if (document.addEventListener) {
document.removeEventListener("DOMContentLoaded", completed, false);
window.removeEventListener("load", completed, false);
} else {
document.detachEvent("onreadystatechange", completed);
window.detachEvent("onload", completed);
}
};
if (document.readyState === "complete") {
ready();
} else {
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", completed, false);
window.addEventListener("load", completed, false);
} else {
document.attachEvent("onreadystatechange", completed);
window.attachEvent("onload", completed);
/** @type {boolean} */
var top = false;
try {
/** @type {(Element|boolean)} */
top = window.frameElement == null && document.documentElement;
} catch (d) {
}
if (top && top.doScroll) {
(function doScrollCheck() {
if (!a2a.dom.isReady) {
try {
top.doScroll("left");
} catch (i) {
return setTimeout(doScrollCheck, 50);
}
init();
ready();
}
})();
}
}
}
}
},
/**
* @param {string} type
* @param {Object} opts
* @param {number} dataAndEvents
* @return {undefined}
*/
init : function(type, opts, dataAndEvents) {
var options = a2a.c;
opts = opts || {};
var d = {};
/** @type {null} */
var elem = null;
var ret;
var self = {};
var p;
var image;
var i;
var classToRemove;
/** @type {string} */
var origin = location.href;
/**
* @param {Object} config
* @param {Object} e
* @return {undefined}
*/
var init = function(config, e) {
a2a.total++;
a2a.n = a2a.total;
/** @type {Object} */
a2a["n" + a2a.n] = config;
var item = config.node = a2a.set_this_index(config.node);
/** @type {Element} */
var main = document.createElement("div");
var result;
var temp;
var name = a2a.getData(item)["a2a-title"];
var opt_button = a2a.getData(item)["a2a-url"];
if (!item) {
if (!a2a.c.show_menu) {
a2a.total--;
}
return;
}
if (config.linkname_escape) {
temp = a2a.getByClass("a2a_linkname_escape", item.parentNode)[0] || a2a.getByClass("a2a_linkname_escape", item.parentNode.parentNode)[0];
if (temp) {
config.linkname = temp.innerHTML;
}
}
config.linkname = e.linkname = name || config.linkname;
config.linkurl = e.linkurl = opt_button || config.linkurl;
if (name) {
/** @type {boolean} */
config.linkname_implicit = false;
}
if (opt_button) {
/** @type {boolean} */
config.linkurl_implicit = false;
}
main.innerHTML = config.linkname;
result = main.childNodes[0];
if (result) {
config.linkname = result.nodeValue;
}
delete main;
if (item.a2a_kit) {
a2a.kit(config, e);
} else {
a2a.button(config);
}
};
a2a.make_once(type);
for (p in opts) {
options[p] = opts[p];
}
for (p in options) {
d[p] = options[p];
}
image = options.target;
if (image) {
if (typeof image == "string") {
/** @type {string} */
i = image.substr(0, 1);
/** @type {string} */
classToRemove = image.substr(1);
if (i == ".") {
a2a.multi_init(a2a.HTMLcollToArray(a2a.getByClass(classToRemove, document)), type, opts);
/** @type {boolean} */
options.target = false;
return;
} else {
elem = a2a.gEl(classToRemove);
ret = elem.className;
if (ret.indexOf("a2a_kit") >= 0 && ret.indexOf("a2a_target") < 0) {
/** @type {null} */
elem = null;
}
}
} else {
elem = options.target;
}
}
type = options.menu_type ? "mail" : type;
if (type) {
/** @type {string} */
a2a.type = type;
options.vars.process();
}
self.type = a2a.type;
self.node = elem;
self.linkname = a2a[self.type].last_linkname = options.linkname || (a2a[self.type].last_linkname || (document.title || location.href));
self.linkurl = a2a[self.type].last_linkurl = options.linkurl || (a2a[self.type].last_linkurl || location.href);
self.linkname_escape = options.linkname_escape;
/** @type {boolean} */
self.linkname_implicit = !options.linkname_escape && (document.title || origin) == self.linkname;
/** @type {boolean} */
self.linkurl_implicit = origin == self.linkurl;
self.orientation = options.orientation || false;
self.track_links = options.track_links || false;
self.track_links_key = options.track_links_key || "";
self.track_pub = options.track_pub || false;
/** @type {boolean} */
options.linkname = options.linkurl = options.onclick = options.linkname_escape = options.show_title = options.custom_services = options.exclude_services = options.orientation = options.num_services = options.track_pub = options.target = false;
if (options.track_links == "custom") {
/** @type {boolean} */
options.track_links = false;
/** @type {string} */
options.track_links_key = "";
}
a2a.last_type = a2a.type;
/** @type {number} */
window["a2a" + a2a.type + "_init"] = 1;
if (a2a.locale && !dataAndEvents) {
a2a.fn_queue.push(function(self, data) {
return function() {
init(self, data);
};
}(self, d));
} else {
init(self, d);
/** @type {boolean} */
options.menu_type = false;
a2a.init_show();
}
},
/**
* @param {string} param
* @return {undefined}
*/
init_all : function(param) {
var a2a_menu_container = a2a.unindexed(function(elem) {
if (elem.className.indexOf("a2a_follow") >= 0) {
a2a.init("feed");
} else {
a2a.init(param);
}
}, true);
if (!a2a_menu_container && a2a.gEl("a2a_menu_container")) {
a2a.init(param);
}
},
/**
* @param {Array} values
* @param {string} listener
* @param {Object} el
* @return {undefined}
*/
multi_init : function(values, listener, el) {
/** @type {number} */
var i = 0;
var valuesLen = values.length;
for (;i < valuesLen;i++) {
el.target = values[i];
a2a.init(listener, el);
}
},
/**
* @param {Object} data
* @return {undefined}
*/
button : function(data) {
var node = data.node;
var eventType = data.type;
var testNode = a2a.gEl("a2a" + eventType + "_dropdown");
/** @type {string} */
var down = "mousedown";
/** @type {string} */
var up = "mouseup";
if ((!node.getAttribute("onclick") || (node.getAttribute("onclick") + "").indexOf("a2a_") == -1) && (!node.getAttribute("onmouseover") || (node.getAttribute("onmouseover") + "").indexOf("a2a_") == -1)) {
a2a.fast_click.make(node, function(ev) {
a2a.preventDefault(ev);
a2a.stopPropagation(ev);
if (testNode.style.display == "block") {
var name = a2a[eventType].time_open;
if (a2a[eventType].onclick || name && name == "OK") {
a2a.toggle_dropdown("none", eventType);
} else {
a2a[eventType].last_focus = document.activeElement;
testNode.focus();
}
} else {
a2a.show_menu(node);
a2a[eventType].last_focus = document.activeElement;
testNode.focus();
}
});
if (a2a.has_touch) {
/** @type {string} */
down = "touchstart";
/** @type {string} */
up = "touchend";
} else {
if (a2a.has_pointer) {
/** @type {string} */
down = "MSPointerDown";
/** @type {string} */
up = "MSPointerUp";
}
}
a2a.add_event(node, down, a2a.stopPropagation);
a2a.add_event(node, up, function(e) {
a2a.stopPropagation(e);
/** @type {number} */
a2a.touch_used = 1;
});
if (!a2a[a2a.type].onclick) {
if (a2a.c.delay) {
/**
* @return {undefined}
*/
node.onmouseover = function() {
/** @type {number} */
a2a[a2a.type].over_delay = setTimeout(function() {
a2a.show_menu(node);
}, a2a.c.delay);
};
} else {
/**
* @return {undefined}
*/
node.onmouseover = function() {
a2a.show_menu(node);
};
}
/**
* @return {undefined}
*/
node.onmouseout = function() {
a2a.onMouseOut_delay();
if (a2a[a2a.type].over_delay) {
clearTimeout(a2a[a2a.type].over_delay);
}
};
}
}
if (!node.getAttribute("aria-label")) {
node.setAttribute("aria-label", eventType == "feed" ? a2a.c.localize.Subscribe : a2a.c.localize.Share);
}
if (node.tagName.toLowerCase() == "a" && a2a.type == "page") {
/** @type {string} */
node.href = "https://www.addtoany.com/share#url=" + encodeURIComponent(data.linkurl) + "&title=" + encodeURIComponent(data.linkname).replace(/'/g, "%27") + "&description=" + encodeURIComponent(a2a.selection()).replace(/'/g, "%27");
}
},
/**
* @param {Object} params
* @param {Object} arg
* @return {undefined}
*/
kit : function(params, arg) {
var type = a2a.type;
var posts = {
behance : {
icon : "behance",
url : "https://www.behance.net/${id}"
},
facebook : {
icon : "facebook",
url : "https://www.facebook.com/${id}"
},
flickr : {
icon : "flickr",
url : "https://www.flickr.com/photos/${id}"
},
foursquare : {
icon : "foursquare",
url : "https://foursquare.com/${id}"
},
google_plus : {
icon : "google_plus",
url : "https://plus.google.com/${id}"
},
instagram : {
icon : "instagram",
url : "https://instagram.com/${id}"
},
linkedin : {
icon : "linkedin",
url : "https://www.linkedin.com/in/${id}"
},
linkedin_company : {
icon : "linkedin",
url : "https://www.linkedin.com/company/${id}"
},
pinterest : {
icon : "pinterest",
url : "https://www.pinterest.com/${id}"
},
tumblr : {
icon : "tumblr",
url : "http://${id}.tumblr.com"
},
twitter : {
icon : "twitter",
url : "https://twitter.com/${id}"
},
vimeo : {
icon : "vimeo",
url : "https://vimeo.com/${id}"
},
youtube : {
icon : "youtube",
url : "https://www.youtube.com/user/${id}"
},
youtube_channel : {
icon : "youtube",
url : "https://www.youtube.com/channel/${id}"
}
};
/**
* @param {(Object|string)} node
* @param {?} name
* @return {?}
*/
var fn = function(node, name) {
var data;
var ps = getDataset(node, {});
var key = ps["a2a-follow"];
if (key) {
data = posts[name].url.replace("${id}", key);
}
return data || node.href;
};
/** @type {Array} */
var stringProps = ["facebook_like", "twitter_tweet", "google_plusone", "google_plus_share", "pinterest_pin"];
var reversed = a2a.counters.avail;
/**
* @param {string} c
* @param {boolean} dataAndEvents
* @return {?}
*/
var some = function(c, dataAndEvents) {
if (c != "facebook_like" && c != "twitter_tweet") {
/** @type {number} */
var i = 0;
var codeSegments = a2a[type].services;
var valuesLen = codeSegments.length;
for (;i < valuesLen;i++) {
if (c == codeSegments[i][1]) {
return[codeSegments[i][0], codeSegments[i][2], codeSegments[i][3], codeSegments[i][4]];
}
}
}
if (dataAndEvents) {
return false;
}
return[c, c];
};
/**
* @param {Object} node
* @param {?} obj
* @return {?}
*/
var getDataset = function(node, obj) {
/** @type {number} */
var i = 0;
var valuesLen = node.attributes.length;
var attribute;
var dataset = obj;
for (;i < valuesLen;i++) {
attribute = node.attributes[i];
if (attribute.name && attribute.name.substr(0, 5) == "data-") {
dataset[attribute.name.substr(5)] = attribute.value;
}
}
return dataset;
};
/**
* @return {undefined}
*/
var onEvent = function() {
a2a.linker(this);
};
/**
* @param {string} name
* @param {string} x
* @param {Event} data
* @return {undefined}
*/
var init = function(name, x, data) {
var defaults = {
node : x,
service : name,
title : title,
url : url
};
var options = a2a.cbs("share", defaults);
if (typeof options != "undefined") {
if (options.url) {
params.linkurl = options.url;
/** @type {boolean} */
params.linkurl_implicit = false;
}
if (options.title) {
params.linkname = options.title;
/** @type {boolean} */
params.linkname_implicit = false;
}
a2a.linker(x);
if (options.stop && data) {
a2a.preventDefault(data);
}
}
};
var templates = a2a.c.templates;
var el = params.node;
var fontSize = a2a.getData(el);
var parentElement = el.a2a_follow;
var nodes = a2a.HTMLcollToArray(el.getElementsByTagName("a"));
var len = nodes.length;
/** @type {Element} */
var star = document.createElement("div");
/** @type {function (string): string} */
var trim = encodeURIComponent;
var url = params.linkurl;
/** @type {string} */
var camelKey = trim(params.linkurl).replace(/'/g, "%27");
var title = params.linkname;
/** @type {string} */
var l = trim(params.linkname).replace(/'/g, "%27");
var text = fontSize["a2a-icon-color"] || a2a.c.icon_color;
var horizontalOffset = el.className.match(/a2a_kit_size_([\w\.]+)(?:\s|$)/);
var width = horizontalOffset ? horizontalOffset[1] : false;
/** @type {string} */
var val = width + "px";
/** @type {string} */
var className = "a2a_img a2a_i_";
var options = {};
var style = {};
/** @type {boolean} */
var isFixed = el.className.indexOf("a2a_vertical_style") >= 0 ? true : false;
if (width && !isNaN(width)) {
a2a.svg_css();
if (text && (text != "unset" && a2a.svg_works())) {
/** @type {string} */
className = "a2a_svg a2a_w__default a2a_w_";
options.backgroundColor = text;
} else {
/** @type {string} */
className = "a2a_svg a2a_s__default a2a_s_";
}
/** @type {string} */
el.style.lineHeight = style.height = style.lineHeight = val;
/** @type {string} */
style.width = width * 2 + "px";
/** @type {string} */
style.fontSize = "16px";
if (isFixed) {
/** @type {string} */
style.height = style.lineHeight = width / 2 + "px";
/** @type {string} */
style.fontSize = "10px";
/** @type {string} */
style.width = width + "px";
}
if (width != 32) {
/** @type {string} */
options.backgroundSize = options.height = options.lineHeight = options.width = val;
/** @type {string} */
style.borderRadius = options.borderRadius = (width * 0.14).toFixed() + "px";
/** @type {string} */
style.fontSize = (parseInt(style.height, 10) + (isFixed ? 4 : 0)) / 2 + "px";
}
}
/**
* @return {undefined}
*/
a2a.kit.facebook_like = function() {
settings.href = url;
/** @type {string} */
settings.width = "90";
/** @type {string} */
settings.layout = "button_count";
/** @type {string} */
settings.ref = "addtoany";
settings = getDataset(node, settings);
/** @type {string} */
node.style.width = settings.width + "px";
/**
* @return {undefined}
*/
var initialize = function() {
FB.init({
appId : "0",
status : false,
xfbml : true,
version : "v2.3"
});
FB.Event.subscribe("edge.create", function(url, dataAndEvents) {
a2a.GA.track("Facebook Like", "facebook_like", url, "pages", "AddToAny Share/Save Button");
init("Facebook Like", node);
});
};
var text = a2a.i18n();
text = text ? text.replace(/-/g, "_") : "en_US";
if (text.length == 2) {
text += "_" + text.toUpperCase();
}
for (key in settings) {
optsData += " data-" + key + '="' + settings[key] + '"';
}
if (!window.fbAsyncInit) {
/** @type {function (): undefined} */
window.fbAsyncInit = initialize;
/** @type {Element} */
elem = document.createElement("span");
/** @type {string} */
elem.id = "fb-root";
document.body.insertBefore(elem, document.body.firstChild);
}
if (!a2a.kit.facebook_like_script) {
(function(d, s, id) {
var js;
var insertAt = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
/** @type {Element} */
js = d.createElement(s);
/** @type {string} */
js.id = id;
/** @type {string} */
js.src = "//connect.facebook.net/" + text + "/sdk.js";
insertAt.parentNode.insertBefore(js, insertAt);
})(document, "script", "facebook-jssdk");
}
/** @type {number} */
a2a.kit.facebook_like_script = 1;
/** @type {string} */
node.innerHTML = '<div class="fb-like"' + optsData + "></div>";
try {
FB.XFBML.parse(node);
} catch (n) {
}
};
/**
* @return {undefined}
*/
a2a.kit.twitter_tweet = function() {
settings.url = url;
settings.lang = a2a.i18n() || "en";
/** @type {string} */
settings.related = "AddToAny,micropat";
var x = templates.twitter;
var p = x ? x.lastIndexOf("@") : null;
if (p && p !== -1) {
p++;
p = x.substr(p).split(" ", 1);
p = p[0].replace(/:/g, "").replace(/\//g, "").replace(/-/g, "").replace(/\./g, "").replace(/,/g, "").replace(/;/g, "").replace(/!/g, "");
/** @type {string} */
settings.related = p + ",AddToAny";
}
settings = getDataset(node, settings);
/** @type {Element} */
var element = document.createElement("a");
/** @type {string} */
element.className = "twitter-share-button";
for (key in settings) {
element.setAttribute("data-" + key, settings[key]);
}
node.appendChild(element);
if (!a2a.kit.twitter_tweet_script) {
(function(d, s, id) {
var self;
var js;
var insertAt = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
/** @type {Element} */
js = d.createElement(s);
/** @type {string} */
js.id = id;
/** @type {string} */
js.src = "//platform.twitter.com/widgets.js";
insertAt.parentNode.insertBefore(js, insertAt);
window.twttr = window.twttr || (self = {
_e : [],
/**
* @param {Function} socket
* @return {undefined}
*/
ready : function(socket) {
self._e.push(socket);
}
});
})(document, "script", "twitter-wjs");
}
/** @type {number} */
a2a.kit.twitter_tweet_script = 1;
try {
twttr.ready(function($scope) {
if (!a2a.twitter_bind) {
$scope.events.bind("click", function(e) {
if (e && e.region == "tweet") {
var entry = function() {
var fullName = e.target.src.split("#")[1] || "";
if (fullName && fullName.indexOf("url=") > -1) {
var dst = {};
var values = fullName.split("&");
var valuesLen = values.length;
/** @type {number} */
var i = 0;
for (;i < valuesLen;i++) {
var src = values[i].split("=");
dst[src[0]] = src[1];
}
return dst;
} else {
return false;
}
}();
if (entry && entry.url) {
a2a.GA.track("Twitter Tweet", "twitter_tweet", unescape(entry.url), "pages", "AddToAny Share/Save Button");
init("Twitter Tweet", node);
}
}
});
/** @type {number} */
a2a.twitter_bind = 1;
}
if ($scope.widgets) {
$scope.widgets.load();
}
});
} catch (n) {
}
};
/**
* @return {undefined}
*/
a2a.kit.pinterest_pin = function() {
/** @type {string} */
settings["pin-config"] = "beside";
/** @type {string} */
settings["pin-do"] = "buttonPin";
settings.url = url;
settings = getDataset(node, settings);
/** @type {Element} */
var element = document.createElement("a");
for (key in settings) {
element.setAttribute("data-" + key, settings[key]);
}
if (settings["pin-config"] == "beside" && settings["pin-do"] == "buttonPin") {
/** @type {string} */
node.style.width = "76px";
}
/** @type {string} */
element.href = "//www.pinterest.com/pin/create/button/?url=" + settings.url + (settings.media ? "&media=" + encodeURIComponent(settings.media) : "") + (settings.description ? "&description=" + encodeURIComponent(settings.description).replace(/'/g, "%27") : "");
a2a.add_event(node, "click", function() {
a2a.GA.track("Pinterest Pin", "pinterest_pin", url, "pages", "AddToAny Share/Save Button");
init("Pinterest Pin", node);
});
node.appendChild(element);
if (!a2a.kit.pinterest_pin_script) {
(function(doc) {
/** @type {Element} */
var ga = doc.createElement("script");
var insertAt = doc.getElementsByTagName("script")[0];
/** @type {string} */
ga.type = "text/javascript";
/** @type {boolean} */
ga.async = true;
/** @type {string} */
ga.src = "//assets.pinterest.com/js/pinit.js";
insertAt.parentNode.insertBefore(ga, insertAt);
})(document);
}
/** @type {number} */
a2a.kit.pinterest_pin_script = 1;
};
/**
* @return {undefined}
*/
a2a.kit.google_plus = function() {
/**
* @param {(Object|string)} result
* @return {undefined}
*/
window.google_plus_cb_a2a = function(result) {
if (result.state && result.state == "off") {
return;
}
a2a.GA.track("Google +1", "google_plusone", result.href, "pages", "AddToAny Share/Save Button");
init("Google +1", node);
};
settings.href = url;
/** @type {string} */
settings.size = "medium";
/** @type {string} */
settings.annotation = "bubble";
if (prefix == "google_plus_share") {
/** @type {string} */
settings.action = "share";
}
settings = getDataset(node, settings);
var lang = a2a.i18n() || "en-US";
window.___gcfg = window.___gcfg || {
lang : lang
};
for (key in settings) {
optsData += " data-" + key + '="' + settings[key] + '"';
}
/** @type {string} */
node.innerHTML = '<div class="g-plus' + (settings.action == "share" ? "" : "one") + '" data-callback="google_plus_cb_a2a"' + optsData + "></div>";
if (!a2a.kit.google_plus_script) {
(function(doc) {
/** @type {Element} */
var ga = doc.createElement("script");
var insertAt = doc.getElementsByTagName("script")[0];
/** @type {string} */
ga.type = "text/javascript";
/** @type {boolean} */
ga.async = true;
/** @type {string} */
ga.src = "https://apis.google.com/js/platform.js";
insertAt.parentNode.insertBefore(ga, insertAt);
})(document);
/** @type {number} */
a2a.kit.google_plus_script = 1;
}
};
/** @type {function (): undefined} */
a2a.kit.google_plusone = a2a.kit.google_plus_share = a2a.kit.google_plus;
/** @type {number} */
var idx = 0;
for (;idx < len;idx++) {
var node = nodes[idx];
var cls = node.className;
var cons = cls.match(/a2a_button_([\w\.]+)(?:\s|$)/);
/** @type {boolean} */
var c = cls.indexOf("a2a_dd") >= 0;
/** @type {boolean} */
var name = cls.indexOf("a2a_counter") >= 0;
var prefix = cons ? cons[1] : false;
var childNodes = node.childNodes;
var testSource = some(prefix);
var classes = testSource[0];
/** @type {string} */
var target = "_blank";
var value = parentElement && posts[prefix] ? posts[prefix].icon : testSource[1];
var first = testSource[2] || {};
var pos = first.type;
var ref = testSource[3];
/** @type {boolean} */
var w = false;
/** @type {boolean} */
var names = false;
var elem;
var K;
var key;
/** @type {string} */
var optsData = "";
var settings = {};
if (c) {
arg.target = node;
a2a.init(type, arg, 1);
/** @type {string} */
prefix = "a2a";
/** @type {string} */
value = "a2a";
/** @type {(boolean|number)} */
names = name ? 1 : false;
} else {
if (prefix == "feed" || prefix == "print") {
/** @type {string} */
target = "";
} else {
if (name && (prefix && a2a.in_array(prefix, reversed))) {
/** @type {number} */
names = 1;
} else {
if (prefix && a2a.in_array(prefix, stringProps)) {
a2a.kit[prefix]();
/** @type {number} */
w = 1;
}
}
}
}
if (!prefix || w) {
continue;
}
if (!c) {
/** @type {string} */
node.target = target;
if (parentElement && (posts[prefix] || !some(prefix, true))) {
node.href = fn(node, prefix);
} else {
if (prefix == "feed") {
node.href = params.linkurl;
} else {
/** @type {string} */
node.href = "/";
/** @type {function (): undefined} */
node.onmousedown = onEvent;
/** @type {function (): undefined} */
node.onkeydown = onEvent;
/** @type {string} */
node.rel = "nofollow";
}
}
node.a2a = {};
node.a2a.customserviceuri = ref;
node.a2a.stype = pos;
node.a2a.linkurl = params.linkurl;
node.a2a.servicename = classes;
node.a2a.safename = prefix;
if (!node.getAttribute("aria-label")) {
node.setAttribute("aria-label", classes);
}
if (first.src) {
node.a2a.js_src = first.src;
}
if (first.pu) {
/** @type {number} */
node.a2a.popup = 1;
}
if (!parentElement) {
a2a.add_event(node, "click", function(prop, name, url, source, event) {
return function(ev) {
var winHeight = screen.height;
/** @type {number} */
var am = 550;
/** @type {number} */
var height = 450;
/** @type {string} */
var r20 = "event=service_click&url=" + trim(location.href) + "&title=" + trim(document.title || "") + "&ev_service=" + trim(prop) + "&ev_service_type=kit&ev_menu_type=" + type + "&ev_url=" + trim(url) + "&ev_title=" + trim(source).replace(/'/g, "%27");
init(name, event, ev);
if (event.a2a.popup && !a2a.defaultPrevented(ev)) {
a2a.preventDefault(ev);
window.open(event.href, "_blank", "toolbar=0,personalbar=0,resizable,scrollbars,status,width=550,height=450,top=" + (winHeight > height ? Math.round(winHeight / 2 - height / 2) : 40) + ",left=" + Math.round(screen.width / 2 - am / 2));
}
a2a.util_frame_post(type, r20);
a2a.GA.track(name, prop, url, "pages", "AddToAny Share/Save Button");
};
}(prefix, classes, url, title, node));
}
}
if (childNodes.length) {
/** @type {number} */
var i = 0;
var length = childNodes.length;
for (;i < length;i++) {
if (childNodes[i].nodeType == 1) {
/** @type {boolean} */
K = true;
break;
}
}
if (!K) {
/** @type {Element} */
elem = document.createElement("span");
/** @type {string} */
elem.className = className + value + " a2a_img_text";
for (prop_name in options) {
elem.style[prop_name] = options[prop_name];
}
node.insertBefore(elem, childNodes[0]);
}
} else {
/** @type {Element} */
elem = document.createElement("span");
/** @type {string} */
elem.className = className + value;
for (prop_name in options) {
elem.style[prop_name] = options[prop_name];
}
node.appendChild(elem);
}
if (isFixed && (width && width < 20)) {
/** @type {boolean} */
names = false;
}
if (names) {
/** @type {Element} */
elem = document.createElement("span");
/** @type {string} */
elem.className = "a2a_count";
elem.a2a = {};
elem.a2a.kit = el;
for (prop_name in style) {
elem.style[prop_name] = style[prop_name];
}
node.appendChild(elem);
if (c) {
a2a.counters.get("facebook", elem, camelKey);
a2a.counters.get("twitter", elem, camelKey);
/** @type {number} */
elem.a2a.is_a2a_dd_counter = 1;
el.a2a_dd_counter = elem;
} else {
a2a.counters.get(prefix, elem, camelKey);
}
}
if (cls != "a2a_dd") {
a2a.kit_services.push(node);
}
}
if (el.className.indexOf("a2a_default_style") >= 0) {
/** @type {string} */
star.style.clear = "both";
el.appendChild(star);
}
},
counters : {
/**
* @param {string} id
* @param {Element} obj
* @param {string} key
* @return {undefined}
*/
get : function(id, obj, key) {
/** @type {string} */
var query = decodeURIComponent(key);
var o = a2a.counters[id];
var oL = o.api;
var cb = o.cb;
var is_a2a_dd_counter = obj.a2a.is_a2a_dd_counter;
var self;
var suiteView;
self = o[query] = o[query] || {};
if (self.num) {
if (is_a2a_dd_counter) {
a2a.counters.sum(obj, self.num, id);
} else {
a2a.counters.set(obj, self.num, id);
}
return;
}
self.queued = self.queued || [];
self.queued.push(obj);
o.n = o.n || 0;
o.n++;
/**
* @param {Object} rvar
* @return {undefined}
*/
o["cb" + o.n] = function(rvar) {
var i = a2a.counters[id].cb(rvar, obj);
if (typeof i == "undefined") {
return;
}
/** @type {number} */
var c = 0;
var n;
for (;c < self.queued.length;c++) {
queued_count_element = self.queued[c];
self.num = i;
if (queued_count_element.a2a.is_a2a_dd_counter) {
a2a.counters.sum(queued_count_element, i, id);
} else {
a2a.counters.set(queued_count_element, i, id);
}
}
};
if (self.queued.length == 1) {
/** @type {string} */
suiteView = oL[0] + key + (oL[1] || "&callback") + "=a2a.counters." + id + ".cb" + o.n;
a2a.dom.ready(function() {
a2a.loadExtScript(suiteView);
});
}
},
/**
* @param {Element} obj
* @param {?} key
* @param {string} callback
* @return {undefined}
*/
set : function(obj, key, callback) {
/** @type {string} */
obj.innerHTML = "<span>" + a2a.counters.format(key) + "</span>";
if (callback != "a2a") {
a2a.counters.sum(obj, key, callback);
}
},
/**
* @param {Element} var_args
* @param {?} key
* @param {string} callback
* @return {undefined}
*/
sum : function(var_args, key, callback) {
var self = var_args.a2a.kit;
var camelKey = self.a2a_counts_sum || 0;
var steps = self.a2a_counts_summed;
if (callback != "a2a" && (!steps || steps.indexOf(callback) == -1)) {
camelKey = self.a2a_counts_sum = camelKey + key;
steps = self.a2a_counts_summed = steps || [];
steps.push(callback);
}
if (self.a2a_dd_counter) {
a2a.counters.set(self.a2a_dd_counter, camelKey, "a2a");
}
},
/**
* @param {number} num
* @return {?}
*/
format : function(num) {
/** @type {number} */
var base = 1E6;
/** @type {number} */
var den = 1E3;
if (num > 999) {
if (num < base) {
if (num > 1E4) {
/** @type {string} */
num = (num / den).toFixed() + "k";
} else {
/** @type {string} */
num = num + "";
/** @type {string} */
num = num.charAt(0) + "," + num.substring(1);
}
} else {
if (num < 1E9) {
/** @type {string} */
num = (num / base).toFixed(num % base > 94999) + "M";
} else {
/** @type {string} */
num = "1B+";
}
}
}
return num;
},
avail : ["facebook", "linkedin", "pinterest", "reddit", "tumblr", "twitter"],
facebook : {
api : ['https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url="', '"&callback'],
/**
* @param {string} res
* @param {Element} label
* @return {?}
*/
cb : function(res, label) {
if (res && (res.data && (res.data[0] && !isNaN(res.data[0].total_count)))) {
return res.data[0].total_count;
}
}
},
linkedin : {
api : ["https://www.linkedin.com/countserv/count/share?url="],
/**
* @param {Object} res
* @param {Element} label
* @return {?}
*/
cb : function(res, label) {
if (res && !isNaN(res.count)) {
return res.count;
}
}
},
pinterest : {
api : ["https://widgets.pinterest.com/v1/urls/count.json?url="],
/**
* @param {Object} res
* @param {Element} label
* @return {?}
*/
cb : function(res, label) {
if (res && !isNaN(res.count)) {
return res.count;
}
}
},
reddit : {
api : ["https://www.reddit.com/api/info.json?url=", "&jsonp"],
/**
* @param {?} res
* @param {Element} label
* @return {?}
*/
cb : function(res, label) {
var data = res.data;
if (res && (data && data.children)) {
/** @type {number} */
var i = 0;
/** @type {Array} */
var newArguments = [];
var codeSegments = data.children;
var p;
for (;i < codeSegments.length;i++) {
p = codeSegments[i].data;
if (p && !isNaN(p.ups)) {
newArguments.push(p.ups);
}
}
if (newArguments.length > 0) {
return Math.max.apply(null, newArguments);
}
}
}
},
tumblr : {
api : ["https://api.tumblr.com/v2/share/stats?url="],
/**
* @param {Function} res
* @param {Element} label
* @return {?}
*/
cb : function(res, label) {
if (res && (res.response && !isNaN(res.response.note_count))) {
return res.response.note_count;
}
}
},
twitter : {
api : ["https://cdn.api.twitter.com/1/urls/count.json?url="],
/**
* @param {Object} res
* @param {Element} label
* @return {?}
*/
cb : function(res, label) {
if (res && !isNaN(res.count)) {
return res.count;
}
}
}
},
/**
* @return {undefined}
*/
init_show : function() {
var body = a2a_config;
var no_hide = a2a[a2a.type];
var do_body = a2a.show_menu;
if (body.bookmarklet) {
/** @type {number} */
no_hide.no_hide = 1;
do_body();
}
if (body.show_menu) {
/** @type {number} */
no_hide.no_hide = 1;
do_body(false, body.show_menu);
}
},
/**
* @param {Function} $
* @param {boolean} dataAndEvents
* @return {?}
*/
unindexed : function($, dataAndEvents) {
/**
* @param {Array} a
* @return {?}
*/
function enter(a) {
/** @type {number} */
var i = 0;
var aLength = a.length;
var el;
var v;
for (;i < aLength;i++) {
el = a[i];
if ((typeof el.a2a_index === "undefined" || el.a2a_index === "") && (el.className.indexOf("a2a_target") < 0 && el.parentNode.className.indexOf("a2a_kit") < 0)) {
v = $(el);
}
if (v) {
return v;
} else {
continue;
}
}
return null;
}
if (dataAndEvents) {
return enter(a2a.getByClass("a2a_kit", document)) || enter(a2a.HTMLcollToArray(document.getElementsByName("a2a_dd")).concat(a2a.getByClass("a2a_dd", document)));
} else {
enter(a2a.getByClass("a2a_kit", document).concat(a2a.getByClass("a2a_dd", document), a2a.HTMLcollToArray(document.getElementsByName("a2a_dd"))));
}
},
/**
* @param {Element} el
* @return {?}
*/
set_this_index : function(el) {
/**
* @param {Element} el
* @return {?}
*/
function hasClass(el) {
if (el.className.indexOf("a2a_kit") >= 0) {
/** @type {number} */
el.a2a_kit = 1;
} else {
return false;
}
if (el.className.indexOf("a2a_follow") >= 0) {
/** @type {number} */
el.a2a_follow = 1;
}
}
var node = a2a.n;
var c;
if (el) {
el.a2a_index = node;
hasClass(el);
return el;
} else {
return a2a.unindexed(function(el) {
el.a2a_index = node;
hasClass(el);
return el;
}, true);
}
},
/**
* @param {string} elem
* @return {?}
*/
gEl : function(elem) {
return document.getElementById(elem);
},
/**
* @param {string} classToRemove
* @param {?} element
* @param {string} match
* @return {?}
*/
getByClass : function(classToRemove, element, match) {
if (document.getElementsByClassName && Object.prototype.getElementsByClassName === document.getElementsByClassName) {
/**
* @param {string} className
* @param {?} element
* @param {string} tag
* @return {?}
*/
a2a.getByClass = function(className, element, tag) {
element = element || a2a.gEl("a2a" + a2a.type + "_dropdown");
var unmatched = element.getElementsByClassName(className);
/** @type {(RegExp|null)} */
var rfocusable = tag ? new RegExp("\\b" + tag + "\\b", "i") : null;
/** @type {Array} */
var result = [];
var elem;
/** @type {number} */
var i = 0;
var len = unmatched.length;
for (;i < len;i += 1) {
elem = unmatched[i];
if (!rfocusable || rfocusable.test(elem.nodeName)) {
result.push(elem);
}
}
return result;
};
} else {
if (document.evaluate) {
/**
* @param {string} className
* @param {?} element
* @param {string} tag
* @return {?}
*/
a2a.getByClass = function(className, element, tag) {
tag = tag || "*";
element = element || a2a.gEl("a2a" + a2a.type + "_dropdown");
var codeSegments = className.split(" ");
/** @type {string} */
var classesToCheck = "";
/** @type {string} */
var xhtmlNamespace = "http://www.w3.org/1999/xhtml";
/** @type {(null|string)} */
var namespaceResolver = document.documentElement.namespaceURI === xhtmlNamespace ? xhtmlNamespace : null;
/** @type {Array} */
var assigns = [];
var evaluationResults;
var vvar;
/** @type {number} */
var i = 0;
var valuesLen = codeSegments.length;
for (;i < valuesLen;i += 1) {
classesToCheck += "[contains(concat(' ',@class,' '), ' " + codeSegments[i] + " ')]";
}
try {
evaluationResults = document.evaluate(".//" + tag + classesToCheck, element, namespaceResolver, 0, null);
} catch (m) {
evaluationResults = document.evaluate(".//" + tag + classesToCheck, element, null, 0, null);
}
for (;vvar = evaluationResults.iterateNext();) {
assigns.push(vvar);
}
return assigns;
};
} else {
/**
* @param {string} className
* @param {HTMLElement} element
* @param {string} tag
* @return {?}
*/
a2a.getByClass = function(className, element, tag) {
tag = tag || "*";
element = element || a2a.gEl("a2a" + a2a.type + "_dropdown");
var codeSegments = className.split(" ");
/** @type {Array} */
var tests = [];
var seed = tag === "*" && element.all ? element.all : element.getElementsByTagName(tag);
var elem;
/** @type {Array} */
var result = [];
var o;
/** @type {number} */
var i = 0;
var valuesLen = codeSegments.length;
for (;i < valuesLen;i += 1) {
tests.push(new RegExp("(^|\\s)" + codeSegments[i] + "(\\s|$)"));
}
/** @type {number} */
var idx = 0;
var len = seed.length;
for (;idx < len;idx += 1) {
elem = seed[idx];
/** @type {boolean} */
o = false;
/** @type {number} */
var k = 0;
/** @type {number} */
var numrows = tests.length;
for (;k < numrows;k += 1) {
o = tests[k].test(elem.className);
if (!o) {
break;
}
}
if (o) {
result.push(elem);
}
}
return result;
};
}
}
return a2a.getByClass(classToRemove, element, match);
},
/**
* @param {Object} b
* @return {?}
*/
HTMLcollToArray : function(b) {
/** @type {Array} */
var a = [];
var bufferLength = b.length;
/** @type {number} */
var i = 0;
for (;i < bufferLength;i++) {
a[a.length] = b[i];
}
return a;
},
/**
* @param {Object} o
* @param {string} type
* @param {Function} evtHandler
* @param {boolean} useCapture
* @return {?}
*/
add_event : function(o, type, evtHandler, useCapture) {
if (o.addEventListener) {
o.addEventListener(type, evtHandler, useCapture);
return{
/**
* @return {undefined}
*/
destroy : function() {
o.removeEventListener(type, evtHandler, useCapture);
}
};
} else {
o.attachEvent("on" + type, evtHandler);
return{
/**
* @return {undefined}
*/
destroy : function() {
o.detachEvent("on" + type, evtHandler);
}
};
}
},
fast_click : {
/**
* @param {Object} dataAndEvents
* @param {Function} deepDataAndEvents
* @param {boolean} attributes
* @return {undefined}
*/
make : function(dataAndEvents, deepDataAndEvents, attributes) {
this.init();
/**
* @param {Object} dataAndEvents
* @param {Function} deepDataAndEvents
* @param {boolean} attributes
* @return {undefined}
*/
this.make = function(dataAndEvents, deepDataAndEvents, attributes) {
new this.FastButton(dataAndEvents, deepDataAndEvents, attributes);
};
this.make(dataAndEvents, deepDataAndEvents, attributes);
},
/**
* @return {undefined}
*/
init : function() {
/**
* @param {Object} target
* @param {string} type
* @param {Function} listener
* @param {?} useCapture
* @return {?}
*/
function addListener(target, type, listener, useCapture) {
var r20 = target.attachEvent ? function(dataAndEvents) {
listener.handleEvent(window.event, listener);
} : listener;
return a2a.add_event(target, type, r20, useCapture);
}
/**
* @param {Element} element
* @param {Function} handler
* @param {?} useCapture
* @return {undefined}
*/
this.FastButton = function(element, handler, useCapture) {
/** @type {Array} */
this.events = [];
/** @type {Array} */
this.touchEvents = [];
/** @type {Element} */
this.element = element;
/** @type {Function} */
this.handler = handler;
this.useCapture = useCapture;
if (a2a.has_touch) {
this.events.push(addListener(element, "touchstart", this, this.useCapture));
} else {
if (a2a.has_pointer) {
/** @type {string} */
element.style.msTouchAction = "manipulation";
}
}
this.events.push(addListener(element, "click", this, this.useCapture));
};
/**
* @return {undefined}
*/
this.FastButton.prototype.destroy = function() {
/** @type {number} */
var name = this.events.length - 1;
for (;name >= 0;name -= 1) {
this.events[name].destroy();
}
/** @type {null} */
this.events = this.touchEvents = this.element = this.handler = this.fast_click = null;
};
/**
* @param {Event} event
* @return {undefined}
*/
this.FastButton.prototype.handleEvent = function(event) {
switch(event.type) {
case "touchstart":
this.onTouchStart(event);
break;
case "touchmove":
this.onTouchMove(event);
break;
case "touchend":
this.onClick(event);
break;
case "click":
this.onClick(event);
break;
}
};
/**
* @param {Event} event
* @return {undefined}
*/
this.FastButton.prototype.onTouchStart = function(event) {
a2a.stopPropagation(event);
this.touchEvents.push(addListener(this.element, "touchend", this, this.useCapture));
this.touchEvents.push(addListener(document.body, "touchmove", this, this.useCapture));
this.startX = event.touches[0].clientX;
this.startY = event.touches[0].clientY;
};
/**
* @param {Object} event
* @return {undefined}
*/
this.FastButton.prototype.onTouchMove = function(event) {
if (Math.abs(event.touches[0].clientX - this.startX) > 10 || Math.abs(event.touches[0].clientY - this.startY) > 10) {
this.reset();
}
};
/**
* @param {Event} event
* @return {?}
*/
this.FastButton.prototype.onClick = function(event) {
a2a.stopPropagation(event);
this.reset();
var result = this.handler.call(this.element, event);
if (event.type == "touchend") {
a2a.fast_click.clickbuster.preventGhostClick(this.startX, this.startY);
}
return result;
};
/**
* @return {undefined}
*/
this.FastButton.prototype.reset = function() {
/** @type {number} */
var _idx = this.touchEvents.length - 1;
for (;_idx >= 0;_idx -= 1) {
this.touchEvents[_idx].destroy();
}
/** @type {Array} */
this.touchEvents = [];
};
this.clickbuster = {
coordinates : [],
/**
* @param {?} spaceName
* @param {?} y
* @return {undefined}
*/
preventGhostClick : function(spaceName, y) {
this.coordinates.push(spaceName, y);
window.setTimeout(this.pop2, 2500);
},
/**
* @return {undefined}
*/
pop2 : function() {
a2a.fast_click.clickbuster.coordinates.splice(0, 2);
},
/**
* @param {Event} event
* @return {undefined}
*/
onClick : function(event) {
/** @type {number} */
var i = 0;
var x;
var y;
var data = a2a.fast_click.clickbuster;
for (;i < data.coordinates.length;i += 2) {
x = data.coordinates[i];
y = data.coordinates[i + 1];
if (Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
a2a.stopPropagation(event);
a2a.preventDefault(event);
}
}
}
};
if (a2a.has_touch) {
a2a.add_event(document, "click", this.clickbuster.onClick, true);
}
}
},
/**
* @param {Event} event
* @return {undefined}
*/
stopPropagation : function(event) {
if (!event) {
event = window.event;
}
/** @type {boolean} */
event.cancelBubble = true;
if (event.stopPropagation) {
event.stopPropagation();
}
},
/**
* @param {Event} ev
* @return {undefined}
*/
preventDefault : function(ev) {
if (ev.preventDefault) {
ev.preventDefault();
} else {
/** @type {boolean} */
ev.returnValue = false;
}
},
/**
* @param {Event} eventData
* @return {?}
*/
defaultPrevented : function(eventData) {
return eventData.defaultPrevented || (eventData.returnValue === false || typeof eventData.defaultPrevented === "undefined" && (eventData.getPreventDefault && eventData.getPreventDefault())) ? true : false;
},
/**
* @param {Function} callback
* @return {undefined}
*/
onLoad : function(callback) {
/** @type {(function ((Event|null)): ?|null)} */
var prevOnLoad = window.onload;
if (typeof window.onload != "function") {
/** @type {Function} */
window.onload = callback;
} else {
/**
* @return {undefined}
*/
window.onload = function() {
if (prevOnLoad) {
prevOnLoad();
}
callback();
};
}
},
/**
* @param {string} item
* @param {Array} arr
* @param {boolean} recurring
* @param {string} name
* @param {string} i
* @return {?}
*/
in_array : function(item, arr, recurring, name, i) {
if (typeof arr == "object") {
item = item.toLowerCase();
var e = arr.length;
/** @type {number} */
var id = 0;
var l;
for (;id < e;id++) {
l = name ? arr[id][name] : arr[id];
l = i ? l[i] : l;
if (recurring) {
if (item == l.toLowerCase()) {
return arr[id];
}
} else {
if (item.indexOf(l.toLowerCase()) != -1 && l !== "") {
return arr[id];
}
}
}
}
return false;
},
/**
* @param {Object} object
* @param {?} obj
* @return {?}
*/
serialize : function(object, obj) {
/** @type {Array} */
var tagNameArr = [];
var property;
for (property in object) {
if (object.hasOwnProperty(property)) {
/** @type {string} */
var val = obj ? obj + "[" + property + "]" : property;
var value = object[property];
tagNameArr.push(typeof value == "object" ? a2a.serialize(value, val) : encodeURIComponent(val) + "=" + encodeURIComponent(value));
}
}
return tagNameArr.join("&");
},
/**
* @return {undefined}
*/
onMouseOut_delay : function() {
var eventType = a2a.type;
var val = a2a.gEl("a2a" + eventType + "_dropdown").style.display;
if (val != "none" && (val != "" && (!a2a[eventType].find_focused && (!a2a[eventType].service_focused && !a2a.touch_used)))) {
/** @type {number} */
a2a[eventType].out_delay = setTimeout(function() {
a2a.toggle_dropdown("none", eventType);
/** @type {null} */
a2a[eventType].out_delay = null;
}, 501);
}
},
/**
* @return {undefined}
*/
onMouseOver_stay : function() {
if (a2a[a2a.type].out_delay) {
clearTimeout(a2a[a2a.type].out_delay);
}
},
/**
* @param {string} type
* @param {string} key
* @return {undefined}
*/
toggle_dropdown : function(type, key) {
if (type == "none" && a2a[key].no_hide) {
return;
}
var target;
var flag = a2a.gEl;
var obj = flag("a2a" + key + "_dropdown");
var next = flag("a2a" + key + "_shim");
/** @type {string} */
var event = "mousedown";
/** @type {string} */
var name = "mouseup";
var focus = document.activeElement;
/** @type {string} */
obj.style.display = type;
if (next && a2a.getStyle(flag("a2a" + key + "_full"), "display") == "none") {
/** @type {string} */
next.style.display = type;
}
a2a.onMouseOver_stay();
if (type == "none") {
if (!window.addEventListener) {
target = document.detachEvent;
target("on" + event, a2a.doc_mousedown_check_scroll);
target("on" + name, a2a[key].doc_mouseup_toggle_dropdown);
} else {
if (a2a.has_touch) {
/** @type {string} */
event = "touchstart";
/** @type {string} */
name = "touchend";
} else {
if (a2a.has_pointer) {
/** @type {string} */
event = "MSPointerDown";
/** @type {string} */
name = "MSPointerUp";
}
}
document.removeEventListener(event, a2a.doc_mousedown_check_scroll, false);
document.removeEventListener(name, a2a[key].doc_mouseup_toggle_dropdown, false);
/** @type {null} */
a2a.touch_used = null;
}
delete a2a[key].doc_mouseup_toggle_dropdown;
} else {
if (!a2a[key].onclick) {
/** @type {number} */
a2a[key].time_open = setTimeout(function() {
/** @type {string} */
a2a[key].time_open = "OK";
}, 501);
}
}
if (a2a[key].prev_keydown) {
document.onkeydown = a2a[key].prev_keydown;
} else {
/** @type {string} */
document.onkeydown = "";
}
},
/**
* @param {?} node
* @return {?}
*/
getData : function(node) {
if (!node) {
return{};
}
/** @type {number} */
var i = 0;
var valuesLen = node.attributes.length;
var field;
var data = {};
for (;i < valuesLen;i++) {
field = node.attributes[i];
if (field.name && field.name.substr(0, 5) == "data-") {
data[field.name.substr(5)] = field.value;
}
}
return data;
},
/**
* @param {Element} node
* @param {string} style
* @return {?}
*/
getStyle : function(node, style) {
return node.currentStyle ? node.currentStyle[style.replace(/-(\w)/gi, function(dataAndEvents, letter) {
return letter.toUpperCase();
})] : window.getComputedStyle(node, null).getPropertyValue(style);
},
/**
* @param {Element} elm
* @return {?}
*/
getPos : function(elm) {
var otherElementRect;
/** @type {function (*): number} */
var round = Math.round;
if (typeof elm.getBoundingClientRect == "undefined") {
return a2a.getPosOld(elm);
} else {
otherElementRect = elm.getBoundingClientRect();
}
return{
left : round(otherElementRect.left + a2a.getScrollDocDims("w")),
top : round(otherElementRect.top + a2a.getScrollDocDims("h"))
};
},
/**
* @param {Element} elm
* @return {?}
*/
getPosOld : function(elm) {
/** @type {number} */
var pickWinLeft = 0;
/** @type {number} */
var pickWinTop = 0;
do {
pickWinLeft += elm.offsetLeft || 0;
pickWinTop += elm.offsetTop || 0;
elm = elm.offsetParent;
} while (elm);
return{
left : pickWinLeft,
top : pickWinTop
};
},
/**
* @param {string} x
* @return {?}
*/
getDocDims : function(x) {
/** @type {number} */
var viewportwidth = 0;
/** @type {number} */
var viewportheight = 0;
if (typeof window.innerWidth == "number") {
/** @type {number} */
viewportwidth = window.innerWidth;
/** @type {number} */
viewportheight = window.innerHeight;
} else {
if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
/** @type {number} */
viewportwidth = document.documentElement.clientWidth;
/** @type {number} */
viewportheight = document.documentElement.clientHeight;
} else {
if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
/** @type {number} */
viewportwidth = document.body.clientWidth;
/** @type {number} */
viewportheight = document.body.clientHeight;
}
}
}
if (x == "w") {
return viewportwidth;
} else {
return viewportheight;
}
},
/**
* @param {string} x
* @return {?}
*/
getScrollDocDims : function(x) {
/** @type {number} */
var scroll_width = 0;
/** @type {number} */
var s = 0;
if (typeof window.pageYOffset == "number") {
/** @type {number} */
scroll_width = window.pageXOffset;
/** @type {number} */
s = window.pageYOffset;
} else {
if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
/** @type {number} */
scroll_width = document.body.scrollLeft;
/** @type {number} */
s = document.body.scrollTop;
} else {
if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
/** @type {number} */
scroll_width = document.documentElement.scrollLeft;
/** @type {number} */
s = document.documentElement.scrollTop;
}
}
}
if (x == "w") {
return scroll_width;
} else {
return s;
}
},
/**
* @param {number} recurring
* @return {?}
*/
show_more_less : function(recurring) {
a2a.onMouseOver_stay();
var type = a2a.type;
/** @type {string} */
var msg = "a2a" + type;
var toVLQSigned = a2a.gEl;
var vlq = toVLQSigned(msg + "_show_more_less");
a2a.show_full();
a2a.embeds_fix(true);
if (recurring == 0) {
return false;
}
},
/**
* @return {undefined}
*/
focus_find : function() {
var el = a2a.gEl("a2a" + a2a.type + "_find");
if (el.parentNode.style.display != "none") {
el.focus();
}
},
/**
* @param {string} regex
* @return {undefined}
*/
default_services : function(regex) {
var unlock = regex || a2a.type;
var cTaskName1 = a2a[unlock].main_services_col_1;
var numrows = cTaskName1.length;
/** @type {number} */
var k = 0;
for (;k < numrows;k++) {
/** @type {string} */
cTaskName1[k].style.display = "";
}
},
/**
* @return {undefined}
*/
do_find : function() {
var networkState = a2a.type;
var cTaskName1 = a2a[networkState].main_services;
var numrows = cTaskName1.length;
var filter = a2a.gEl("a2a" + networkState + "_find").value;
var reversed;
var hasKey = a2a.in_array;
if (filter !== "") {
reversed = filter.split(" ");
/** @type {number} */
var k = 0;
var result;
for (;k < numrows;k++) {
result = cTaskName1[k].a2a.serviceNameLowerCase;
if (hasKey(result, reversed, false)) {
/** @type {string} */
cTaskName1[k].style.display = "";
} else {
/** @type {string} */
cTaskName1[k].style.display = "none";
}
}
} else {
a2a.default_services();
}
},
/**
* @return {?}
*/
selection : function() {
var title;
/** @type {NodeList} */
var metas = document.getElementsByTagName("meta");
/** @type {number} */
var l = metas.length;
if (window.getSelection) {
/** @type {(Selection|null)} */
title = window.getSelection();
} else {
if (document.selection) {
try {
/** @type {(ControlRange|TextRange|null)} */
title = document.selection.createRange();
} catch (f) {
/** @type {string} */
title = "";
}
title = title.text ? title.text : "";
}
}
if (title && title != "") {
return title;
}
if (a2a["n" + a2a.n].linkurl == location.href) {
/** @type {number} */
var i = 0;
var v;
var pos;
for (;i < l;i++) {
v = metas[i].getAttribute("name");
if (v) {
if (v.toLowerCase() == "description") {
pos = metas[i].getAttribute("content");
break;
}
}
}
}
return pos ? pos.substring(0, 1200) : "";
},
/**
* @param {string} n
* @return {undefined}
*/
collections : function(n) {
var md5_cmn = a2a.gEl;
var a = a2a[n];
/** @type {string} */
var endOffset = "a2a" + n;
a.main_services_col_1 = a2a.getByClass("a2a_i", md5_cmn(endOffset + "_full_services"), "a");
a.main_services = a.main_services_col_1;
a.email_services = a2a.getByClass("a2a_i", md5_cmn(endOffset + "_2_col1", "a"));
a.all_services = a.main_services.concat(a.email_services);
},
/**
* @param {string} name
* @param {?} classProps
* @return {?}
*/
cbs : function(name, classProps) {
var values = a2a.c.callbacks || [];
var old = a2a.c.tracking_callback;
var obj = {};
if (old) {
if (old[name]) {
values.push(old);
} else {
if (old[0] == name) {
obj[name] = old[1];
values.push(obj);
} else {
if (typeof old == "function") {
/** @type {Function} */
obj[name] = old;
values.push(obj);
}
}
}
/** @type {null} */
a2a.c.tracking_callback = null;
}
/** @type {number} */
var i = 0;
var valuesLen = values.length;
var callback;
for (;i < valuesLen;i++) {
callback = values[i][name];
if (typeof callback == "function") {
returned = callback(classProps);
if (name == "ready") {
/** @type {null} */
callback = null;
}
if (typeof returned != "undefined") {
return returned;
}
}
}
},
/**
* @param {Element} a
* @return {?}
*/
linker : function(a) {
/** @type {string} */
var myUrl = location.href;
/** @type {string} */
var html = document.title || myUrl;
var opts = a2a["n" + (a.parentNode.a2a_index || a2a.n)];
var p = opts.node;
var type = opts.type;
var auto = a2a.getData(p)["a2a-url"] || opts.linkurl;
var dir = opts.linkurl_implicit && myUrl != auto ? myUrl : auto;
/** @type {string} */
var guess = encodeURIComponent(dir).replace(/'/g, "%27");
var report = a2a.getData(p)["a2a-title"] || opts.linkname;
var text = opts.linkname_implicit && html != report ? html : report;
/** @type {string} */
var js = encodeURIComponent(text).replace(/'/g, "%27");
/** @type {string} */
var camelKey = encodeURIComponent(a2a.selection()).replace(/'/g, "%27");
/** @type {string} */
var args = opts.track_links && (type == "page" || type == "mail") ? "&linktrack=" + opts.track_links + "&linktrackkey=" + encodeURIComponent(opts.track_links_key) : "";
var unique = a.a2a.customserviceuri || false;
var name = a.a2a.safename;
var op = a.a2a.stype;
var no_in = a.a2a.js_src;
var data;
var item = a2a.c.templates;
if (op && (op == "js" && no_in)) {
/** @type {string} */
a.target = "";
data = no_in.substr(0, 11) == "javascript:" ? no_in : 'javascript:a2a.loadExtScript("' + no_in + '")';
} else {
if (unique && unique != "undefined") {
data = unique.replace(/A2A_LINKNAME_ENC/, js).replace(/A2A_LINKURL_ENC/, guess).replace(/A2A_LINKNOTE_ENC/, camelKey);
}
}
a.href = data || "http://www.addtoany.com/add_to/" + name + "?linkurl=" + guess + "&linkname=" + js + args + (a2a.c.awesm ? "&linktrack_parent=" + a2a.c.awesm : "") + (name == "twitter" && item[name] ? "&template=" + encodeURIComponent(item[name]) : "") + ((name == "email" || op && op == "email") && item.email ? "&" + a2a.serialize({
template : item.email
}) : "") + (type == "feed" ? "&type=feed" : "") + "&linknote=" + camelKey;
return true;
},
/**
* @return {undefined}
*/
show_full : function() {
var value = a2a.type;
/** @type {string} */
var tval = "a2a" + value;
var jqLite = a2a.gEl;
var requestFrame = a2a.getByClass;
var selector = jqLite(tval + "_find");
var elm = jqLite(tval + "_overlay");
var d = jqLite(tval + "_shim");
var element = jqLite(tval + "_full");
var node = requestFrame("a2a_full_header", element)[0];
var select = jqLite(tval + "_full_services");
var p = requestFrame("a2a_full_footer", element)[0];
var animation = element.style.animation;
/** @type {string} */
element.style.animation = elm.style.animation = "none";
element.offsetTop;
elm.offsetTop;
/** @type {string} */
element.style.animation = elm.style.animation = "";
/** @type {string} */
element.style.display = elm.style.display = "block";
if (d) {
/** @type {string} */
d.style.display = "block";
}
if (document.addEventListener) {
element.addEventListener("animationend", function(dataAndEvents) {
/** @type {string} */
element.style.animation = elm.style.animation = "none";
}, false);
}
/** @type {string} */
select.style.cssText = "height:calc(10px)";
if (!!select.style.height.length) {
/** @type {string} */
select.style.height = "calc(100% - " + (node.offsetHeight + p.offsetHeight) + "px)";
}
element.focus();
a2a.show_full.key_listener = a2a.add_event(document, "keydown", function(e) {
e = e || window.event;
var chunkNumber = e.which || e.keyCode;
var focus = document.activeElement;
if (chunkNumber == 27 && selector != focus) {
a2a.hide_full(value);
} else {
if (chunkNumber > 40 && (chunkNumber < 91 && selector != focus)) {
selector.focus();
}
}
});
},
/**
* @param {string} putativeSpy
* @return {undefined}
*/
hide_full : function(putativeSpy) {
var getElement = a2a.gEl;
/** @type {string} */
var cb = "a2a" + putativeSpy;
/** @type {string} */
getElement(cb + "_overlay").style.display = getElement(cb + "_full").style.display = "none";
shim = getElement(cb + "_shim");
if (shim) {
if (a2a.getStyle(getElement(cb + "_dropdown"), "display") == "none") {
/** @type {string} */
shim.style.display = "none";
} else {
a2a.embeds_fix();
getElement(cb + "_show_more_less").focus();
}
}
a2a.show_full.key_listener.destroy();
},
/**
* @param {Element} target
* @param {Object} o
* @return {undefined}
*/
show_menu : function(target, o) {
if (target) {
a2a.n = target.a2a_index;
} else {
a2a.n = a2a.total;
/** @type {number} */
a2a[a2a.type].no_hide = 1;
}
var event = a2a["n" + a2a.n];
var type = a2a.type = event.type;
/** @type {string} */
var key = "a2a" + type;
var popup = a2a.gEl(key + "_dropdown");
/** @type {string} */
var name = "mousedown";
/** @type {string} */
var eventType = "mouseup";
a2a.gEl(key + "_title").value = event.linkname;
a2a.toggle_dropdown("block", type);
/** @type {Array} */
var diff = [popup.clientWidth, popup.clientHeight];
var right = a2a.getDocDims("w");
var i = a2a.getDocDims("h");
var c = a2a.getScrollDocDims("w");
var bHeight = a2a.getScrollDocDims("h");
var e;
var r;
var width;
var h;
if (target) {
e = target.getElementsByTagName("img")[0];
if (e) {
r = a2a.getPos(e);
width = e.clientWidth;
h = e.clientHeight;
} else {
r = a2a.getPos(target);
width = target.offsetWidth;
h = target.offsetHeight;
}
if (r.left - c + diff[0] + width > right) {
/** @type {number} */
r.left = r.left - diff[0] + width - 8;
}
if (event.orientation == "up" || event.orientation != "down" && (r.top - bHeight + diff[1] + h > i && r.top > diff[1])) {
/** @type {number} */
r.top = r.top - diff[1] - h;
}
/** @type {string} */
popup.style.left = (r.left < 0 ? 0 : r.left) + 2 + "px";
/** @type {string} */
popup.style.top = r.top + h + "px";
a2a.embeds_fix();
} else {
if (!o) {
o = {};
}
popup.style.position = o.position || "absolute";
popup.style.left = o.left || right / 2 - diff[0] / 2 + "px";
popup.style.top = o.top || i / 2 - diff[1] / 2 + "px";
}
if (!a2a[type].doc_mouseup_toggle_dropdown && !a2a[type].no_hide) {
/**
* @return {undefined}
*/
a2a.doc_mousedown_check_scroll = function() {
a2a.last_scroll_pos = a2a.getScrollDocDims("h");
};
a2a[type].doc_mouseup_toggle_dropdown = function(events) {
return function() {
if (a2a.last_scroll_pos == a2a.getScrollDocDims("h")) {
if (a2a[type].last_focus) {
a2a[type].last_focus.focus();
}
a2a.toggle_dropdown("none", events);
}
};
}(type);
if (!window.addEventListener) {
document.attachEvent("on" + name, a2a.doc_mousedown_check_scroll);
document.attachEvent("on" + eventType, a2a[type].doc_mouseup_toggle_dropdown);
} else {
if (a2a.has_touch) {
/** @type {string} */
name = "touchstart";
/** @type {string} */
eventType = "touchend";
} else {
if (a2a.has_pointer) {
/** @type {string} */
name = "MSPointerDown";
/** @type {string} */
eventType = "MSPointerUp";
}
}
document.addEventListener(name, a2a.doc_mousedown_check_scroll, false);
document.addEventListener(eventType, a2a[type].doc_mouseup_toggle_dropdown, false);
}
}
a2a.svg_css();
/** @type {function (string): string} */
var getLocation = encodeURIComponent;
/** @type {string} */
var r20 = "event=menu_show&url=" + getLocation(location.href) + "&title=" + getLocation(document.title || "") + "&ev_menu_type=" + type;
a2a.util_frame_post(type, r20);
},
/**
* @param {boolean} dataAndEvents
* @return {undefined}
*/
embeds_fix : function(dataAndEvents) {
var $ = a2a.gEl;
var type = a2a.type;
/** @type {string} */
var prefix = "a2a" + type;
var iframe = $(prefix + "_shim");
var el;
var to;
var newTop;
var w;
var iHeight;
if (!iframe) {
/** @type {Element} */
iframe = document.createElement("iframe");
/** @type {string} */
iframe.className = "a2a_shim";
/** @type {string} */
iframe.id = prefix + "_shim";
/** @type {string} */
iframe.title = "AddToAny Shim";
iframe.setAttribute("frameBorder", "0");
iframe.setAttribute("src", 'javascript:"";');
/** @type {number} */
iframe.tabIndex = -1;
document.body.appendChild(iframe);
}
if (dataAndEvents) {
/** @type {string} */
iframe.style.left = iframe.style.top = "0";
/** @type {string} */
iframe.style.width = "";
/** @type {string} */
iframe.style.height = "";
} else {
el = $(prefix + "_dropdown");
/** @type {number} */
to = parseInt(el.style.left);
/** @type {number} */
newTop = parseInt(el.style.top);
w = el.clientWidth || el.offsetWidth;
iHeight = el.clientHeight || el.offsetHeight;
/** @type {string} */
iframe.style.left = to + "px";
/** @type {string} */
iframe.style.top = newTop + "px";
/** @type {string} */
iframe.style.width = w + "px";
/** @type {string} */
iframe.style.height = iHeight + "px";
}
},
/**
* @param {number} dataAndEvents
* @return {?}
*/
bmBrowser : function(dataAndEvents) {
var Bookmark = a2a.c.localize.Bookmark;
var opts = a2a["n" + a2a.n];
if (document.all) {
if (dataAndEvents == 1) {
Bookmark = a2a.c.localize.AddToYourFavorites;
} else {
window.external.AddFavorite(opts.linkurl, opts.linkname);
}
} else {
if (dataAndEvents != 1) {
/** @type {string} */
a2a.gEl("a2apage_note_BROWSER").innerHTML = '<div class="a2a_note_note">' + a2a.c.localize.BookmarkInstructions + "</div>";
}
}
if (dataAndEvents == 1) {
return Bookmark;
}
},
/**
* @param {string} obj
* @param {Function} successCb
* @param {Function} next_callback
* @return {undefined}
*/
loadExtScript : function(obj, successCb, next_callback) {
/** @type {Element} */
var s = document.createElement("script");
/** @type {string} */
s.charset = "UTF-8";
/** @type {string} */
s.src = obj;
document.body.appendChild(s);
if (typeof successCb == "function") {
/** @type {number} */
var poll = setInterval(function() {
/** @type {boolean} */
var f = false;
try {
f = successCb.call();
} catch (g) {
}
if (f) {
clearInterval(poll);
next_callback.call();
}
}, 100)
}
},
/**
* @param {string} path
* @return {undefined}
*/
track : function(path) {
/** @type {Image} */
var imageElement = new Image(1, 1);
/** @type {string} */
imageElement.src = path;
/** @type {number} */
imageElement.width = 1;
/** @type {number} */
imageElement.height = 1;
},
/**
* @param {boolean} dataAndEvents
* @return {undefined}
*/
GA : function(dataAndEvents) {
/** @type {Window} */
var self = window;
var type = a2a.type;
/**
* @return {undefined}
*/
var walk = function() {
if (typeof urchinTracker == "function") {
/**
* @param {string} keepData
* @param {string} object
* @param {Node} path
* @param {string} fn
* @param {string} category
* @return {undefined}
*/
a2a.GA.track = function(keepData, object, path, fn, category) {
urchinTracker("/addtoany.com/" + fn);
urchinTracker("/addtoany.com/" + fn + "/" + (path || a2a["n" + a2a.n].linkurl));
urchinTracker("/addtoany.com/services/" + object);
};
} else {
if (typeof pageTracker == "object") {
/**
* @param {string} action
* @param {string} object
* @param {string} url
* @param {string} fn
* @param {string} category
* @return {undefined}
*/
a2a.GA.track = function(action, object, url, fn, category) {
if (type != "feed") {
pageTracker._trackSocial("AddToAny", action, url || a2a["n" + a2a.n].linkurl);
}
pageTracker._trackEvent(category, action, url || a2a["n" + a2a.n].linkurl);
};
} else {
if (typeof _gaq == "object") {
/**
* @param {string} url
* @param {string} object
* @param {Node} property
* @param {string} fn
* @param {string} category
* @return {undefined}
*/
a2a.GA.track = function(url, object, property, fn, category) {
if (type != "feed") {
_gaq.push(["_trackSocial", "AddToAny", url, property || a2a["n" + a2a.n].linkurl]);
}
_gaq.push(["_trackEvent", category, url, property || a2a["n" + a2a.n].linkurl]);
};
} else {
if (typeof GoogleAnalyticsObject == "string") {
/**
* @param {string} label
* @param {string} object
* @param {Node} url
* @param {string} fn
* @param {string} category
* @return {undefined}
*/
a2a.GA.track = function(label, object, url, fn, category) {
if (type != "feed") {
self[GoogleAnalyticsObject]("send", "social", "AddToAny", label, {
page : url || a2a["n" + a2a.n].linkurl
});
}
self[GoogleAnalyticsObject]("send", "event", category, label, url || a2a["n" + a2a.n].linkurl);
};
} else {
return;
}
}
}
}
};
/**
* @return {undefined}
*/
a2a.GA.track = function() {
};
if (dataAndEvents || /loaded|complete/.test(document.readyState)) {
walk();
} else {
a2a.onLoad(walk);
}
},
/**
* @return {undefined}
*/
add_services : function() {
var type = a2a.type;
var getParent = a2a.gEl;
/** @type {number} */
var j = parseInt(a2a[type].num_services);
var table = getParent("a2a" + type + "_full_services");
var parent = getParent("a2a" + type + "_mini_services");
var resolveValues;
if (a2a[type].custom_services) {
var models = a2a[type].custom_services;
var l = models.length;
var put = a2a.make_service;
/** @type {number} */
var o = 0;
models.reverse();
/** @type {number} */
var i = 0;
var tr;
for (;i < l;i++) {
if (models[i]) {
o += 1;
tr = put(models[i][0], models[i][0].replace(" ", "_"), false, {}, models[i][1], models[i][2]);
table.insertBefore(tr, table.firstChild);
tr = put(models[i][0], models[i][0].replace(" ", "_"), false, {}, models[i][1], models[i][2]);
parent.insertBefore(tr, parent.firstChild);
}
}
}
if (type == "page" && a2a.c.add_services) {
models = a2a.c.add_services;
l = models.length;
put = a2a.make_service;
/** @type {number} */
o = 0;
var ssl = a2a.c.ssl;
/** @type {number} */
i = 0;
for (;i < l;i++) {
if (models[i]) {
o += 1;
if (ssl) {
/** @type {boolean} */
models[i].icon = false;
}
tr = put(models[i].name, models[i].safe_name, false, {}, false, models[i].icon);
table.insertBefore(tr, table.firstChild);
tr = put(models[i].name, models[i].safe_name, false, {}, false, models[i].icon);
parent.insertBefore(tr, parent.firstChild);
}
}
}
resolveValues = a2a.getByClass("a2a_i", parent, "a");
if (resolveValues.length > j) {
/** @type {number} */
i = 0;
var length = resolveValues.length;
for (;i < length - j;i++) {
parent.removeChild(parent.lastChild);
}
}
},
/**
* @param {string} keepData
* @return {undefined}
*/
util_frame_make : function(keepData) {
/** @type {Element} */
var frame = document.createElement("iframe");
/** @type {Element} */
var el = document.createElement("div");
/** @type {function (string): string} */
var getLocation = encodeURIComponent;
/** @type {string} */
var icon = document.referrer ? getLocation(document.referrer) : "";
/** @type {string} */
var recipient = getLocation(location.href);
/** @type {string} */
var url = getLocation(document.title || "");
/** @type {string} */
var g = navigator.browserLanguage || navigator.language;
/** @type {string} */
frame.id = "a2a" + keepData + "_sm_ifr";
/** @type {number} */
frame.width = frame.height = 1;
/** @type {string} */
frame.style.width = frame.style.height = el.style.width = el.style.height = "1px";
/** @type {number} */
frame.style.top = frame.style.left = frame.frameborder = frame.style.border = 0;
/** @type {string} */
frame.style.position = el.style.position = "absolute";
/** @type {number} */
frame.style.zIndex = el.style.zIndex = 1E5;
/** @type {string} */
frame.title = "AddToAny Utility Frame";
frame.setAttribute("transparency", "true");
frame.setAttribute("allowTransparency", "true");
frame.setAttribute("frameBorder", "0");
/** @type {string} */
frame.src = (a2a.c.ssl ? a2a.c.ssl : "http://static.addtoany.com/menu") + "/sm13.html#type=" + keepData + "&event=load&url=" + recipient + "&referrer=" + icon;
/** @type {string} */
el.style.top = "0";
/** @type {string} */
el.style.visibility = "hidden";
a2a.gEl("a2a" + keepData + "_dropdown").parentNode.insertBefore(el, null);
el.insertBefore(frame, null);
},
/**
* @param {string} key
* @return {undefined}
*/
util_frame_listen : function(key) {
a2a.util_frame_make(key);
if (window.postMessage && !a2a[key].message_event) {
a2a.add_event(window, "message", function(e) {
if (e.origin.substr(e.origin.length - 13) == ".addtoany.com") {
var parts = e.data.split("=");
var selector = parts[0].substr(4);
var parentName = parts[1];
var r20 = selector.substr(0, 4);
if (selector == r20 + "_services") {
parentName = parentName != "" ? parentName.split(",") : false;
a2a.top_services(parentName, r20, " a2a_sss");
a2a.collections(r20);
a2a.default_services(r20);
}
/** @type {string} */
a2a.gEl("a2a" + r20 + "_sm_ifr").style.display = "none";
}
});
/** @type {number} */
a2a[key].message_event = 1;
}
},
/**
* @param {?} keepData
* @param {string} regex
* @return {undefined}
*/
util_frame_post : function(keepData, regex) {
if (window.postMessage) {
a2a.gEl("a2a" + keepData + "_sm_ifr").contentWindow.postMessage(regex, "*");
}
},
/**
* @return {?}
*/
fix_icons : function() {
var ffversion = a2a.ieo();
var el = a2a.getByClass("a2a_s_a2a", document);
el = el[0];
var tryNum = a2a.fix_icons.tryNum || 0;
if (ffversion && ffversion < 9) {
if (el && (!el.a2aFixed && (!el.currentStyle.backgroundImage.split('"')[1] && tryNum < 999))) {
a2a.fix_icons.tryNum = tryNum + 1;
return setTimeout(a2a.fix_icons, 99);
}
/** @type {number} */
var i = 0;
var canvas;
var new_image_url;
var img;
var node;
var nodes = a2a.getByClass("a2a_svg", document);
var len = nodes.length;
for (;i < len;i++) {
node = nodes[i];
canvas = node.currentStyle;
new_image_url = canvas.backgroundImage.split('"')[1];
if (!node.a2aFixed && new_image_url) {
/** @type {Image} */
img = new Image;
/** @type {number} */
img.style.border = 0;
img.style.height = canvas.height;
img.style.width = canvas.width;
img.src = new_image_url;
/** @type {string} */
node.style.background = "none";
node.insertBefore(img, node.firstChild);
}
/** @type {number} */
node.a2aFixed = 1;
}
} else {
/**
* @return {undefined}
*/
fix_icons = function() {
};
}
},
/**
* @return {undefined}
*/
arrange_services : function() {
var r20 = a2a.type;
var parentName = a2a.c.prioritize;
var c;
if (parentName) {
a2a.top_services(parentName, r20);
}
a2a.add_services();
},
/**
* @param {Array} baseName
* @param {(Document|string)} regex
* @param {?} className
* @return {undefined}
*/
top_services : function(baseName, regex, className) {
var unlock = regex || a2a.type;
var makeElement = a2a.in_array;
var template = a2a.make_service;
/** @type {number} */
var j = parseInt(a2a[unlock].num_services);
var container = a2a.gEl("a2a" + unlock + "_full_services");
var wrapper = a2a.gEl("a2a" + unlock + "_mini_services");
var li = a2a.getByClass("a2a_i", container, "a");
var data = a2a.getByClass("a2a_i", wrapper, "a");
/** @type {Array} */
var codeSegments = [];
if (baseName) {
/** @type {number} */
var i = baseName.length - 1;
className = className;
for (;i > -1;i--) {
var div = baseName[i];
var node = makeElement(div, li, true, "a2a", "safename");
if (node) {
if (className) {
node.className = node.className + className;
}
container.insertBefore(node, container.firstChild);
codeSegments.push(node);
}
}
if (codeSegments.length > 0) {
/** @type {number} */
i = 0;
className = className;
var el;
var options;
var element;
for (;i < codeSegments.length;i++) {
if (el = makeElement(codeSegments[i].a2a.safename, data, true, "a2a", "safename")) {
element = el;
} else {
options = codeSegments[i].a2a;
element = template(options.servicename, options.safename, options.serviceIcon, {
type : options.serviceType,
pu : options.popup
});
}
if (className) {
element.className = element.className + className;
}
wrapper.insertBefore(element, wrapper.firstChild);
}
data = a2a.getByClass("a2a_i", wrapper, "a");
if (data.length > j) {
/** @type {number} */
i = 0;
var length = data.length;
for (;i < length - j;i++) {
wrapper.removeChild(wrapper.lastChild);
}
}
}
}
},
/**
* @return {undefined}