1!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Share=e()}}(function(){var define,module,exports; 2function getStyles(config){ return ""+config.selector+"{width:91px;height:20px}"+config.selector+" [class*=entypo-]:before{font-family:entypo,sans-serif}"+config.selector+" label{font-size:12px;cursor:pointer;margin:0;padding:5px 0 5px 10px;border-radius:5px;background:"+config.ui.button_background+";color:"+config.ui.button_color+";-webkit-transition:all .3s ease;transition:all .3s ease}"+config.selector+" label:hover{opacity:.8}"+config.selector+" label span{text-transform:none;font-size:12px;font-family:'Roboto';font-weight:300;-webkit-font-smoothing:antialiased;padding-left:6px}"+config.selector+" .social{-webkit-transform-origin:50% 0;-ms-transform-origin:50% 0;transform-origin:50% 0;-webkit-transform:scale(0) translateY(-190px);-ms-transform:scale(0) translateY(-190px);transform:scale(0) translateY(-190px);opacity:0;-webkit-transition:all .4s ease;transition:all .4s ease;margin-left:-15px}"+config.selector+" .social.active{opacity:1;-webkit-transition:all .4s ease;transition:all .4s ease}"+config.selector+" .social.active.center{margin-left:-45px}"+config.selector+" .social.active.left{margin-left:-58px}"+config.selector+" .social.active.right{margin-left:10px}"+config.selector+" .social.active.top{-webkit-transform:scale(1) translateY(-90px);-ms-transform:scale(1) translateY(-90px);transform:scale(1) translateY(-90px)}"+config.selector+" .social.active.top.center ul:after{margin:35px auto;border-top:20px solid #3b5998}"+config.selector+" .social.active.top.left ul:after{margin:35px 0 0 105px;border-top:20px solid #e34429}"+config.selector+" .social.active.top.right ul:after{margin:35px 0 0 10px;border-top:20px solid #6cdfea}"+config.selector+" .social.active.bottom{-webkit-transform:scale(1) translateY(45px);-ms-transform:scale(1) translateY(45px);transform:scale(1) translateY(45px);margin-top:-14px}"+config.selector+" .social.active.bottom.center ul:after{margin:-10px auto;border-bottom:20px solid #3b5998}"+config.selector+" .social.active.bottom.left ul:after{margin:-10px 0 0 129px;border-bottom:20px solid #e34429}"+config.selector+" .social.active.bottom.right ul:after{margin:-10px 0 0 10px;border-bottom:20px solid #6cdfea}"+config.selector+" .social ul{position:relative;left:0;right:0;width:150px;height:51px;color:#fff;background:#3b5998;margin:auto;padding:0;list-style:none; }"+config.selector+" .social ul li{font-size:20px;cursor:pointer;width:50px;margin:0;padding:12px 0;text-align:center;float:left;display:block;height:27px;position:relative;z-index:2;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-transition:all .3s ease;transition:all .3s ease}"+config.selector+" .social ul li:hover{color:rgba(0,0,0,.5)}"+config.selector+" .social ul:after{content:'';display:block;width:0;height:0;position:absolute;left:0;right:0;border-left:20px solid transparent;border-right:20px solid transparent}"+config.selector+" .social li[class*=twitter]{background:#6cdfea;padding:12px 0}"+config.selector+" .social li[class*=gplus]{background:#e34429;padding:12px 0}"};var ShareUtils; 3 4if ((!("classList" in document.documentElement)) && Object.defineProperty && typeof HTMLElement !== "undefined") { 5 Object.defineProperty(HTMLElement.prototype, "classList", { 6 get: function() { 7 var ret, self, update; 8 update = function(fn) { 9 return function(value) { 10 var classes, index; 11 classes = self.className.split(/\s+/); 12 index = classes.indexOf(value); 13 fn(classes, index, value); 14 self.className = classes.join(" "); 15 }; 16 }; 17 self = this; 18 ret = { 19 add: update(function(classes, index, value) { 20 ~index || classes.push(value); 21 }), 22 remove: update(function(classes, index) { 23 ~index && classes.splice(index, 1); 24 }),
25 toggle: update(function(classes, index, value) { 26 if (~index) { 27 classes.splice(index, 1); 28 } else { 29 classes.push(value); 30 } 31 }), 32 contains: function(value) { 33 return !!~self.className.split(/\s+/).indexOf(value); 34 }, 35 item: function(i) { 36 return self.className.split(/\s+/)[i] || null; 37 } 38 }; 39 Object.defineProperty(ret, "length", { 40 get: function() { 41 return self.className.split(/\s+/).length; 42 } 43 }); 44 return ret; 45 } 46 }); 47} 48 49ShareUtils = (function() { 50 function ShareUtils() {} 51 52 ShareUtils.prototype.extend = function(to, from, overwrite) { 53 var hasProp, prop; 54 for (prop in from) { 55 hasProp = to[prop] !== undefined; 56 if (hasProp && typeof from[prop] === "object") { 57 this.extend(to[prop], from[prop], overwrite); 58 } else { 59 if (overwrite || !hasProp) { 60 to[prop] = from[prop]; 61 } 62 } 63 } 64 }; 65 66 ShareUtils.prototype.hide = function(el) { 67 return el.style.display = "none"; 68 }; 69 70 ShareUtils.prototype.show = function(el) { 71 return el.style.display = "block"; 72 }; 73 74 ShareUtils.prototype.has_class = function(el, class_name) { 75 return el.classList.contains(class_name); 76 }; 77 78 ShareUtils.prototype.add_class = function(el, class_name) { 79 return el.classList.add(class_name); 80 }; 81 82 ShareUtils.prototype.remove_class = function(el, class_name) { 83 return el.classList.remove(class_name); 84 }; 85 86 ShareUtils.prototype.is_encoded = function(str) { 87 return decodeURIComponent(str) !== str; 88 }; 89 90 ShareUtils.prototype.encode = function(str) { 91 if (this.is_encoded(str)) { 92 return str; 93 } else { 94 return encodeURIComponent(str); 95 } 96 }; 97 98 ShareUtils.prototype.popup = function(url, params) { 99 var k, popup, qs, v; 100 if (params == null) { 101 params = {}; 102 } 103 popup = { 104 width: 500, 105 height: 350 106 }; 107 popup.top = (screen.height / 2) - (popup.height / 2); 108 popup.left = (screen.width / 2) - (popup.width / 2); 109 qs = ((function() { 110 var _results; 111 _results = []; 112 for (k in params) { 113 v = params[k]; 114 _results.push("" + k + "=" + (this.encode(v))); 115 } 116 return _results; 117 }).call(this)).join('&'); 118 if (qs) { 119 qs = "?" + qs; 120 } 121 122 return window.open(url + qs, 'targetWindow', "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=" + popup.left + ",top=" + popup.top + ",width=" + popup.width + ",height=" + popup.height); 123 }; 124 125 return ShareUtils; 126 127})(); 128var Share, 129 __hasProp = {}.hasOwnProperty, 130 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 131 132Share = (function(_super) { 133 __extends(Share, _super); 134 135 function Share(element, options) { 136 var content; 137 this.element = element; 138 this.el = { 139 head: document.getElementsByTagName('head')[0], 140 body: document.getElementsByTagName('body')[0] 141 }; 142 this.config = { 143 protocol: ['http', 'https'].indexOf(window.location.href.split(':')[0]) === -1 ? 'https://' : '//', 144 url: window.location.href, 145 caption: null, 146 title: (content = document.querySelector('meta[property="og:title"]') || document.querySelector('meta[name="twitter:title"]')) ? content.getAttribute('content') : void 0, 147 image: (content = document.querySelector('meta[property="og:image"]') || document.querySelector('meta[name="twitter:image"]')) ? content.getAttribute('content') : void 0, 148 text: (content = document.querySelector('meta[property="og:description"]') || document.querySelector('meta[name="twitter:description"]') || document.querySelector('meta[name="description"]')) ? content.getAttribute('content') : '', 149 ui: { 150 flyout: 'top center', 151 button_font: true, 152 button_color: '#333333', 153 button_background: '#a29baa', 154 button_icon: 'export', 155 button_text: 'Share' 156 }, 157 networks: { 158 google_plus: { 159 enabled: true, 160 url: null 161 }, 162 twitter: { 163 enabled: true, 164 url: null, 165 text: null 166 }, 167 facebook: { 168 enabled: true, 169 load_sdk: false, 170 url: null, 171 app_id: null, 172 title: null, 173 caption: null, 174 text: null, 175 image: null 176 } 177 } 178 }; 179 this.setup(element, options); 180 return this; 181 } 182 183 Share.prototype.setup = function(element, opts) { 184 var index, instance, instances, _i, _len; 185 instances = document.querySelectorAll(element); 186 this.extend(this.config, opts, true); 187 this.set_global_configuration(); 188 this.normalize_network_configuration(); 189 this.inject_icons(); 190 if (this.config.ui.button_font) { 191 this.inject_fonts(); 192 } 193 if (this.config.networks.facebook.enabled && this.config.networks.facebook.load_sdk) { 194 this.inject_facebook_sdk(); 195 } 196 for (index = _i = 0, _len = instances.length; _i < _len; index = ++_i) { 197 instance = instances[index]; 198 this.setup_instance(element, index); 199 } 200 }; 201 202 Share.prototype.setup_instance = function(element, index) { 203 var button, instance, label, network, networks, _i, _len, _results, 204 _this = this; 205 instance = document.querySelectorAll(element)[index]; 206 this.hide(instance); 207 this.add_class(instance, "sharer-" + index); 208 instance = document.querySelectorAll(element)[index]; 209 this.inject_css(instance); 210 this.inject_html(instance); 211 this.show(instance); 212 label = instance.getElementsByTagName("label")[0]; 213 button = instance.getElementsByClassName("social")[0]; 214 networks = instance.getElementsByTagName('li'); 215 label.addEventListener("click", function() { 216 return _this.event_toggle(button); 217 }); 218 _this = this; 219 _results = []; 220 for (index = _i = 0, _len = networks.length; _i < _len; index = ++_i) { 221 network = networks[index]; 222 _results.push(network.addEventListener("click", function() { 223 _this.event_network(instance, this); 224 return _this.event_close(button); 225 })); 226 } 227 return _results; 228 }; 229 230 Share.prototype.event_toggle = function(button) { 231 if (this.has_class(button, "active")) { 232 return this.event_close(button); 233 } else { 234 return this.event_open(button); 235 } 236 }; 237 238 Share.prototype.event_open = function(button) { 239 return this.add_class(button, "active"); 240 }; 241 242 Share.prototype.event_close = function(button) { 243 return this.remove_class(button, "active"); 244 }; 245 246 Share.prototype.event_network = function(instance, network) { 247 var name; 248 name = network.getAttribute("data-network"); 249 this.hook("before", name, instance);
250 this["network_" + name](); 251 return this.hook("after", name, instance); 252 }; 253 254 Share.prototype.open = function() { 255 return this["public"]("open"); 256 }; 257 258 Share.prototype.close = function() { 259 return this["public"]("close"); 260 }; 261 262 Share.prototype.toggle = function() { 263 return this["public"]("toggle"); 264 }; 265 266 Share.prototype["public"] = function(action) { 267 var button, index, instance, _i, _len, _ref, _results; 268 _ref = document.querySelectorAll(this.element); 269 _results = []; 270 for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) { 271 instance = _ref[index]; 272 button = instance.getElementsByClassName("social")[0]; 273 _results.push(this["event_" + action](button)); 274 } 275 return _results; 276 }; 277 278 Share.prototype.network_facebook = function() { 279 if (this.config.networks.facebook.load_sdk) { 280 if (!window.FB) { 281 return console.error("The Facebook JS SDK hasn't loaded yet."); 282 } 283 return FB.ui({ 284 method: 'feed', 285 name: this.config.networks.facebook.title, 286 link: this.config.networks.facebook.url, 287 picture: this.config.networks.facebook.image, 288 caption: this.config.networks.facebook.caption, 289 description: this.config.networks.facebook.description 290 }); 291 } else { 292 return this.popup('https://www.facebook.com/sharer/sharer.php', { 293 u: this.config.networks.facebook.url 294 }); 295 } 296 }; 297 298 Share.prototype.network_twitter = function() { 299 return this.popup('https://twitter.com/intent/tweet', { 300 text: this.config.networks.twitter.text, 301 url: this.config.networks.twitter.url 302 }); 303 }; 304 305 Share.prototype.network_google_plus = function() { 306 return this.popup('https://plus.google.com/share', { 307 url: this.config.networks.google_plus.url 308 }); 309 }; 310 311 Share.prototype.inject_icons = function() { 312 return this.inject_stylesheet("https://www.sharebutton.co/fonts/v2/entypo.min.css"); 313 }; 314 315 Share.prototype.inject_fonts = function() { 316 return this.inject_stylesheet("http://fonts.googleapis.com/css?family=Lato:900&text=" + this.config.ui.button_text); 317 }; 318 319 Share.prototype.inject_stylesheet = function(url) { 320 var link; 321 if (!this.el.head.querySelector("link[href=\"" + url + "\"]")) { 322 link = document.createElement("link"); 323 link.setAttribute("rel", "stylesheet"); 324 link.setAttribute("href", url); 325 return this.el.head.appendChild(link); 326 } 327 }; 328 329 Share.prototype.inject_css = function(instance) { 330 var css, meta, selector, style; 331 selector = "." + (instance.getAttribute('class').split(" ").join(".")); 332 if (!this.el.head.querySelector("meta[name='sharer" + selector + "']")) { 333 this.config.selector = selector; 334 css = getStyles(this.config); 335 style = document.createElement("style"); 336 style.type = "text/css"; 337 if (style.styleSheet) { 338 style.styleSheet.cssText = css; 339 } else { 340 style.appendChild(document.createTextNode(css)); 341 } 342 this.el.head.appendChild(style); 343 delete this.config.selector; 344 meta = document.createElement("meta"); 345 meta.setAttribute("name", "sharer" + selector); 346 return this.el.head.appendChild(meta); 347 } 348 }; 349 350 Share.prototype.inject_html = function(instance) { 351 return instance.innerHTML = "<label class='entypo-" + this.config.ui.button_icon + "'><span>" + this.config.ui.button_text + "</span></label><div class='social " + this.config.ui.flyout + "'><ul><li class='entypo-twitter' data-network='twitter'></li><li class='entypo-facebook' data-network='facebook'></li><li class='entypo-gplus' data-network='google_plus'></li></ul></div>"; 352 }; 353 354 355 Share.prototype.inject_facebook_sdk = function() { 356 var fb_root, script; 357 if (!window.FB && this.config.networks.facebook.app_id && !this.el.body.querySelector('#fb-root')) { 358 script = document.createElement("script"); 359 script.text = "window.fbAsyncInit=function(){FB.init({appId:'" + this.config.networks.facebook.app_id + "',status:true,xfbml:true})};(function(e,t,n){var r,i=e.getElementsByTagName(t)[0];if(e.getElementById(n)){return}r=e.createElement(t);r.id=n;r.src='" + this.config.protocol + "connect.facebook.net/en_US/all.js';i.parentNode.insertBefore(r,i)})(document,'script','facebook-jssdk')"; 360 fb_root = document.createElement("div"); 361 fb_root.id = "fb-root"; 362 this.el.body.appendChild(fb_root); 363 return this.el.body.appendChild(script); 364 } 365 }; 366 367 Share.prototype.hook = function(type, network, instance) { 368 var fn, opts; 369 fn = this.config.networks[network][type]; 370 if (typeof fn === "function") { 371 opts = fn.call(this.config.networks[network], instance); 372 if (opts !== void 0) { 373 opts = this.normalize_filter_config_updates(opts); 374 this.extend(this.config.networks[network], opts, true); 375 this.normalize_network_configuration(); 376 } 377 } 378 }; 379 380 Share.prototype.set_global_configuration = function() { 381 var network, option, options, _ref, _results; 382 _ref = this.config.networks; 383 _results = []; 384 for (network in _ref) { 385 options = _ref[network]; 386 _results.push((function() { 387 var _results1; 388 _results1 = []; 389 for (option in options) { 390 if (this.config.networks[network][option] == null) { 391 _results1.push(this.config.networks[network][option] = this.config[option]); 392 } else { 393 _results1.push(void 0); 394 } 395 } 396 return _results1; 397 }).call(this)); 398 } 399 return _results; 400 }; 401 402 Share.prototype.normalize_network_configuration = function() { 403 if (!this.is_encoded(this.config.networks.twitter.text)) { 404 this.config.networks.twitter.text = encodeURIComponent(this.config.networks.twitter.text); 405 } 406 if (typeof this.config.networks.facebook.app_id === 'integer') { 407 return this.config.networks.facebook.app_id = this.config.networks.facebook.app_id.toString(); 408 } 409 }; 410 411 Share.prototype.normalize_filter_config_updates = function(opts) { 412 if (this.config.networks.facebook.app_id !== opts.app_id) { 413 console.warn("You are unable to change the Facebook app_id after the button has been initialized. Please update your Facebook filters accordingly."); 414 delete opts.app_id; 415 } 416 if (this.config.networks.facebook.load_sdk !== opts.load_sdk) { 417 console.warn("You are unable to change the Facebook load_sdk option after the button has been initialized. Please update your Facebook filters accordingly."); 418 delete opts.app_id; 419 } 420 return opts; 421 }; 422 423 return Share; 424 425})(ShareUtils); 426 return Share; 427});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.