/***********************************************/ /* DON'T FORGET TO COMPLETE THE CHANGELOG FILE */ /***********************************************/ (function(){ var SM_A1_0_config = window.SM_A1_0_config || {}, /* * Basic mixin function */ mergeObject = function(to, from){ if(!to || !from){ return; } for (var prop in from) { to[prop] = from[prop]; } }, /* * Function which will be called by the Facebook SDK after is initialization */ fbInitCallBack = function(){ if(window.OFB_InitParam){ window.FB.init(window.OFB_InitParam); window.OFB_InitParam = null; } var settings = {onlike: onFBLike, ondislike: onFBDislike}, events = { onlike: 'edge.create', ondislike: 'edge.remove', onrender: 'xfbml.render'}; for (var e in events) { if (typeof settings[e] === functionStr) { window.FB.Event.subscribe(events[e], settings[e]); } } }, /* * Facebook SDK parameters */ fbInitParam = { channelUrl : SM_A1_0_config.channelUrl, // Path to your Channel File xfbml : false }, /* * Searches the first node according to its tag name and css class * * @param tag: the tag name of the node to search * @param clazz: the className of the node to search * @param node: on of the ancestor of the node to search */ searchNode = function(tag, clazz, node){ var _nodes = node.getElementsByTagName(tag); for(var i=0; i<_nodes.length; i++){ if(_nodes[i].className == clazz){ return _nodes[i]; } } return null; }, /* * Creates the mail popin object */ mail = {}, isIE7 = false, /* * Declare every string used in the code in order to spare code weight */ widgetClass = 'SM_A1_0', emptyLink = 'javascript:;', hrefStr = 'href', fbRootStr = 'fb-root', functionStr = 'function', buttonStr = 'button', divStr = 'div', aStr = 'a', clickStr = 'click', dataHrefStr = 'data-href', noneStr = 'none', tweetStr = 'tweet', scriptStr = 'script', facebookStr = 'facebook', twitterStr = 'twitter', gplusStr = 'gplus', pinterestStr = 'pinterest', shareStr = 'share', likeStr = 'like', likeAndShareStr = 'likeAndShare', recommendStr = 'recommend', recommendAndShareStr = 'recommendAndShare', dataTwCountUrl = 'data-counturl', dataTwTextStr = 'data-tw-text', dataTwViaStr = 'data-tw-via', noCountStr = 'noCount', dataPinImgStr = 'data-pin-img', dataPinDescStr = 'data-pin-desc', dataEmailSubjectStr = 'data-email-subject', dataEmailBodyStr = 'data-email-body', dataEmailTopInfosStr = 'data-email-topInfos', dataEmailPositionStr = 'data-email-position', activatedStr = ' activated', emailStr = 'email', deliciousStr = 'delicious', plusStr = 'plus', textareaStr = 'textarea', linkedinStr = 'linkedin', popupParams = ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0', dataUrlStr = 'data-url', favoritesStr = 'favorites', dataTextStr = 'data-text', bloggerStr = 'blogger', stumbleuponStr = 'stumbleupon', redditStr = 'reddit', dataTitleStr = 'data-title', diggStr = 'digg', googleStr = 'google', netlogStr = 'netlog', tumblrStr = 'tumblr', /* * To synchronize the render of widgets when js scripts load */ renderSynchro = function(elt, func1, func2, func3, networkStr){ /* * Dans le cas où il y a une SocialBar et une FollowBar sur la même page : * Comme ces composants testent la présence du script sdk du réseau, ils savent s'il est présent dans * la page ou non mais ne sont pas au courant s'il a fini de se charger ou pas, d'où problème * de rendu car l'appel est lancé sans que les méthodes ne soient encore dispo, du coup on passe par une variable * globale qui va sauvegarder les éléments à afficher une fois le script sdk téléchargé pour chaque réseau * */ var obj = window.osb_toRender || {}, item, isGoogle = (networkStr == googleStr); if(window[func1] && window[func1][func2]){ window[func1][func2][func3](elt); if(obj && obj[networkStr]){ for(var i=0; i" + "" + "
envoyer à un ami
" + "" + "
" + "
" + "
à: (adresse courriel)
" + "" + "
de: (adresse courriel)
" + "" + "
message: (facultatif)
" + "" + "
" + "
" + "" + "" + "
" + "
" + "plus d'options : " + "
" + "
" + "
" + "
" + ""; var plusTemplate = "
" + ""; function openMail(subject, body, href, popupText, container, node){ if(mail.opened && mail.opened == node){ return; } closeMail(); var emailPosition = node.getAttribute(dataEmailPositionStr) || 'bottom'; mail.container = container; mail.opened = node; subject = subject || ""; body = body || ""; popupText = popupText || ""; if(!mail.node){ var _node = document.createElement(divStr); _node.innerHTML = mail.template; mail.node = _node.children[0]; mail.baseClass = mail.node.className; // Workaround for IE... var mainNode = mail.node, closeButton = searchNode(aStr, 'sb_popupClose', mainNode); mail.toTextNode = searchNode(textareaStr, 'sb_popupToText', mainNode); mail.contentTextNode= searchNode(textareaStr, 'sb_popupContentText', mainNode); mail.fromTextNode = searchNode('input', 'sb_popupFromText', mainNode); mail.cancelNode = searchNode(buttonStr, 'sb_cancel', mainNode); mail.sendNode = searchNode(buttonStr, 'sb_send', mainNode); mail.topTextNode = searchNode(divStr, 'sb_popupTopText', mainNode); mail.yahooNode = searchNode(divStr, 'sb_yahoo', mainNode); mail.gmailNode = searchNode(divStr, 'sb_gmail', mainNode); mail.cancelNode.onclick = closeMail; closeButton.onclick = closeMail; mail.sendNode.onclick = validateMail; mail.gmailNode.onclick = function(){ window.open("https://mail.google.com/mail/?view=cm&fs=1&to&su=" + subject + "&body=" + body + "&ui=2&tf=1"); closeMail(); }; mail.yahooNode.onclick = function(){ window.open("http://us-mg.mail.yahoo.com/neo/launch?action=compose&To=&Subj=" + subject + "&Body=" + body + "#mail"); closeMail(); }; } mail.subject = subject; mail.node.className = mail.baseClass + " " + emailPosition; mail.topTextNode.innerHTML = popupText; mail.toTextNode.value = ""; mail.fromTextNode.value = ""; mail.contentTextNode.value = body.replace(/%0A/img, "\n"); container.appendChild(mail.node); } function closeMail(e){ if(e){ e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; } if(mail.node && mail.node.parentNode){ mail.node.parentNode.removeChild(mail.node); } mail.container = mail.opened = null; } function validateMail(e){ if(e){ e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; } SM_A1_0_config.email && SM_A1_0_config.email.onPopupValidate(mail.toTextNode.value, mail.fromTextNode.value, mail.subject, mail.contentTextNode.value); onEmailSend(); closeMail(); } function closeMorePopIn(node){ node.parentNode.parentNode.style.display = noneStr; //Close the 'plus' PopIn after clicking a social network } /* * Object describing the available social networks */ var widgets = { 'facebook': { //FACEBOOK - LIKE scriptSrc: 'https://connect.facebook.net/'+ SM_A1_0_config.locale +'/all.js', scriptID: 'facebook-jssdk', onlineSharer: 'http://www.facebook.com/sharer/sharer.php', append: function(){ var fb = document.getElementById(fbRootStr); if(!fb){ fb = document.createElement(divStr) fb.id = fbRootStr; document.body.appendChild(fb); } }, className: facebookStr, init: function(elt) { var hrefAttribute = elt.getAttribute(dataHrefStr) || elt.parentNode.getAttribute(dataHrefStr), el = document.createElement(divStr); //Check if action is share (dedicated button) if(SM_A1_0.hasClass(elt, shareStr)){ el.className = 'fb-share-button'; if(SM_A1_0.hasClass(elt, noCountStr)){ el.setAttribute('data-type', 'button'); }else{ el.setAttribute('data-type', 'button_count'); } } else{ el.className = 'fb-like'; //Check if action is recommend if(SM_A1_0.hasClass(elt, recommendStr) || SM_A1_0.hasClass(elt, recommendAndShareStr)){ el.setAttribute('data-action', recommendStr); el.setAttribute('data-share', SM_A1_0.hasClass(elt, recommendAndShareStr) ? 'true':'false'); } //Action is like (default) else{ el.setAttribute('data-action', likeStr); el.setAttribute('data-share', SM_A1_0.hasClass(elt, likeAndShareStr) ? 'true':'false'); } if(SM_A1_0.hasClass(elt, noCountStr)){ el.setAttribute('data-layout', 'button'); }else{ el.setAttribute('data-layout', 'button_count'); } el.setAttribute('data-show-faces', 'false'); } if(hrefAttribute){ el.setAttribute(dataHrefStr, hrefAttribute); } return el; }, activate: function(elt){ renderSynchro(elt, 'FB', 'XFBML', 'parse', facebookStr); } }, 'twitter': { //TWITTER - SHARE scriptSrc: '//platform.twitter.com/widgets.js', scriptID: 'twitter-wjs', onlineSharer: 'https://twitter.com/intent/tweet', append: function(){ var notwttr = (typeof window.twttr !== 'object'), settings = {onclick: onTWClick, ontweet: onTWTweet}, events = [clickStr, tweetStr], bind = function(){ for (var i = 0; i < events.length; i++) { var e = events[i]; if (typeof settings['on' + e] === 'function') { twttr.events && twttr.events.bind(e, settings['on' + e]); } } } if (notwttr) { var t; window.twttr = (t = { _e: [], ready: function(f) { t._e.push(f); } }); window.twttr.ready(function(twttr){ bind(); }); }else{ bind(); } return notwttr; }, className: twitterStr, init: function(elt) { var hrefAttribute = elt.getAttribute(dataHrefStr) || elt.parentNode.getAttribute(dataHrefStr), tempURL = hrefAttribute ? hrefAttribute : location.href, txtAttribute = elt.getAttribute(dataTwTextStr) || '', viaAttribute = elt.getAttribute(dataTwViaStr) || '', countUrlAttribute = elt.getAttribute(dataTwCountUrl) || '', lang = SM_A1_0_config.locale.split('_')[0], bitlyURL = SM_A1_0.bitlyURL[tempURL], locationURL = bitlyURL ? bitlyURL : tempURL, el; el = document.createElement(aStr); el.className = 'twitter-share-button'; el.setAttribute(hrefStr, 'https://twitter.com/share'); el.setAttribute('data-lang', lang); if(txtAttribute){ el.setAttribute(dataTextStr, txtAttribute); } if(viaAttribute){ el.setAttribute('data-via', viaAttribute); } if(bitlyURL){ el.setAttribute('data-counturl', tempURL); //URL that the shorten's one resolves } el.setAttribute(dataUrlStr, locationURL); if(SM_A1_0.hasClass(elt, noCountStr)){ el.setAttribute('data-count', noneStr); } if(countUrlAttribute){ el.setAttribute("data-counturl", countUrlAttribute); } return el; }, activate: function(elt) { //No need to use the renderSynchro here because Twitter automatically parse the document when js sdk is loaded if (twttr && twttr.widgets) { twttr.widgets.load(elt); } } }, 'gplus': { //GOOGLEPLUS - ONE scriptSrc: '//apis.google.com/js/plusone.js', scriptID: 'gplusone-js', onlineSharer: 'http://plus.google.com/share', append: function(network) { if (window.gapi) { return false; } window.___gcfg = { lang: SM_A1_0_config.locale, parsetags: 'explicit' } }, className: gplusStr, init: function(elt) { var el = document.createElement(divStr), hrefAttribute = elt.getAttribute(dataHrefStr) || elt.parentNode.getAttribute(dataHrefStr), elContainer = document.createElement(divStr); elContainer.className = 'gplusoneContainer'; el.className = 'g-plusone'; el.setAttribute('data-size', 'medium'); el.setAttribute('data-callback', 'SM_A1_0_onGPlusClick'); if(hrefAttribute){ el.setAttribute(dataHrefStr, hrefAttribute); } if(SM_A1_0.hasClass(elt, noCountStr)){ el.setAttribute('data-annotation', noneStr); } elContainer.appendChild(el); return el; }, activate: function(elt) { renderSynchro(elt, 'gapi', 'plusone', 'go', googleStr); } }, 'pinterest': { //PINTEREST scriptSrc: '//assets.pinterest.com/js/pinit.js', scriptID: 'pinterest_js', onlineSharer: 'http://pinterest.com/pin/create/button', className: pinterestStr, init: function(elt) { var el = document.createElement(aStr), hrefAttribute = elt.getAttribute(dataHrefStr) || elt.parentNode.getAttribute(dataHrefStr) || location.href, imageAttribute = elt.getAttribute(dataPinImgStr), descriptionAttribute = elt.getAttribute(dataPinDescStr) || '', url, img; if(!imageAttribute){ return null; } url = this.onlineSharer + '?url=' + encodeURIComponent(hrefAttribute) + "&media=" + encodeURIComponent(imageAttribute) + "&description=" + encodeURIComponent(descriptionAttribute); img = document.createElement('img'); el.setAttribute('data-pin-do', 'buttonPin'); el.className = 'pint-it-button'; el.setAttribute(hrefStr, url); el.setAttribute('data-pin-config', SM_A1_0.hasClass(elt, noCountStr) ? noneStr : 'beside'); img.border = "0"; img.src = "//assets.pinterest.com/images/PinExt.png"; img.title = "Pin It"; el.appendChild(img); return el; } }, 'linkedin': { //LINKEDIN scriptSrc: '//platform.linkedin.com/in.js', scriptID: 'linkedin_js', scriptInnerHTML: 'lang:' + SM_A1_0_config.locale, onlineSharer: 'http://www.linkedin.com/cws/share', className: linkedinStr, init: function(elt) { var hrefAttribute = elt.getAttribute(dataHrefStr) || elt.parentNode.getAttribute(dataHrefStr), el; el = document.createElement(scriptStr); el.setAttribute('type', 'IN/Share'); el.setAttribute('data-onsuccess', 'SM_A1_0_onLinkedInClick'); el.setAttribute('data-showzero', true); if(hrefAttribute){ el.setAttribute(dataUrlStr, hrefAttribute); } if(!SM_A1_0.hasClass(elt, noCountStr)){ el.setAttribute('data-counter', 'right'); } return el; }, activate: function(elt) { if (window.IN && window.IN.parse) { window.IN.parse(elt); } } }, 'email': { //EMAIL - SEND className: emailStr, init: function(elt) { var hrefAttribute = elt.getAttribute(dataHrefStr) || elt.parentNode.getAttribute(dataHrefStr), subjectAttribute = elt.getAttribute(dataEmailSubjectStr), bodyAttribute = elt.getAttribute(dataEmailBodyStr), infoAttribute = elt.getAttribute(dataEmailTopInfosStr), openMode = elt.getAttribute(dataEmailPositionStr), el = document.createElement(openMode ? divStr : aStr); el.className = 'email-send'; if(!openMode){ el.setAttribute(hrefStr, 'mailto:?' + (subjectAttribute ? (bodyAttribute ? "subject="+ subjectAttribute + "&body=" + bodyAttribute : "subject="+ subjectAttribute) : (bodyAttribute ? "body=" + bodyAttribute : ""))); }else{ el.onclick= function(e){ openMail(subjectAttribute, bodyAttribute, hrefAttribute, infoAttribute, el, elt); }; } if (el.addEventListener){ el.addEventListener(clickStr, onEmailClick, false); } else if (el.attachEvent){ el.attachEvent('on' + clickStr, onEmailClick); } return el; } }, 'plus': { className: plusStr, 'facebook': function(url, elt){ var node = document.createElement(aStr), href = widgets[facebookStr].onlineSharer + '?u=' + encodeURIComponent(url); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, facebookStr, 'height=400, width=550' + popupParams); closeMorePopIn(node); onSocialEvent(facebookStr, clickStr, url); } node.title = facebookStr; node.className = facebookStr; return node; }, 'gplus': function(url, elt){ var node = document.createElement(aStr), href = widgets[gplusStr].onlineSharer + '?url=' + encodeURIComponent(url); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, gplusStr, 'height=500, width=550' + popupParams); closeMorePopIn(node); onSocialEvent(gplusStr, clickStr, url); } node.title = "google plus"; node.className = gplusStr; return node; }, 'twitter': function(url, elt){ var node = document.createElement(aStr), text = elt.getAttribute(dataTwTextStr) || '', url = SM_A1_0.bitlyURL[url] ? SM_A1_0.bitlyURL[url] : url, href = widgets[twitterStr].onlineSharer + "?url="+ encodeURIComponent(url) + "&text=" + encodeURIComponent(text), viaAttribute = elt.getAttribute(dataTwViaStr); if(viaAttribute){ href += '&via=' + viaAttribute; } node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, twitterStr, 'height=450, width=550' + popupParams); closeMorePopIn(node); onSocialEvent(twitterStr, clickStr, url); } node.title = twitterStr; node.className = twitterStr; return node; }, 'pinterest': function(url, elt){ var node = document.createElement(aStr), media = elt.getAttribute(dataPinImgStr) || '', desc = elt.getAttribute(dataPinDescStr) || '', href = widgets[pinterestStr].onlineSharer + "?url=" + encodeURIComponent(url) + "&media=" + encodeURIComponent(media) + "&description=" + encodeURIComponent(desc); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, pinterestStr, 'height=350, width=800' + popupParams); closeMorePopIn(node); onSocialEvent(pinterestStr, clickStr, url); } node.title = pinterestStr; node.className = pinterestStr; return node; }, 'linkedin': function(url, elt){ var node = document.createElement(aStr), href = widgets[linkedinStr].onlineSharer + "?url="+ encodeURIComponent(url); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, linkedinStr, 'height=370, width=570' + popupParams); closeMorePopIn(node); onSocialEvent(linkedinStr, clickStr, url); } node.title = linkedinStr; node.className = linkedinStr; return node; }, 'delicious': function(url, elt){ var node = document.createElement(aStr), title = elt.getAttribute(dataTitleStr) || '', href = 'https://delicious.com/post?url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, deliciousStr, 'height=450, width=750' + popupParams); closeMorePopIn(node); onSocialEvent(deliciousStr, clickStr, url); } node.title = deliciousStr; node.className = deliciousStr; return node; }, 'email': function(url, elt){ var node = document.createElement(aStr), subjectAttribute = elt.getAttribute(dataEmailSubjectStr), bodyAttribute = elt.getAttribute(dataEmailBodyStr), infoAttribute = elt.getAttribute(dataEmailTopInfosStr), openMode = elt.getAttribute(dataEmailPositionStr); if(!openMode){ node.setAttribute(hrefStr, 'mailto:?' + (subjectAttribute ? (bodyAttribute ? "subject="+ subjectAttribute + "&body=" + bodyAttribute : "subject="+ subjectAttribute) : (bodyAttribute ? "body=" + bodyAttribute : ""))); }else{ node.setAttribute(hrefStr, emptyLink); node.onclick= function(e){ openMail(subjectAttribute, bodyAttribute, url, infoAttribute, node, elt); }; } //TODO refermer la popin ? //closeMorePopIn(node); if (node.addEventListener){ node.addEventListener(clickStr, onEmailClick, false); } else if (node.attachEvent){ node.attachEvent('on' + clickStr, onEmailClick); } node.title = emailStr; node.className = emailStr; return node; }, 'favorites': function(url, elt){ var node = document.createElement(aStr); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ var title = document.title, browser = navigator.userAgent.toLowerCase(), defaultTxt = elt.getAttribute('data-defaultTxt') || 'Your browser cannot add bookmarks using this link. Please add this link manually by CTRL+D or Command+D for macs'; if(window.sidebar){ // Mozilla, Firefox, Netscape window.sidebar.addPanel(title, url,""); } else if(window.external){ // IE or chrome if (browser.indexOf('chrome') == -1){ // ie window.external.AddFavorite( url, title); } else { // chrome alert(defaultTxt); } } else if(window.opera && window.print){ // Opera - automatically adds to sidebar if rel=sidebar in the tag //Do nothing node.title = title; node.href = url; node.rel = 'sidebar'; } else if(browser.indexOf('webkit') != -1){ // safari alert(defaultTxt); } else { alert(defaultTxt); } closeMorePopIn(node); onSocialEvent(favoritesStr, clickStr, url); } node.title = elt.getAttribute('data-tooltip') || 'favorites'; node.className = favoritesStr; return node; }, 'blogger': function(url, elt){ var node = document.createElement(aStr), text = elt.getAttribute(dataTextStr) || '', title = elt.getAttribute(dataTitleStr) || '', href = 'http://blogger.com/blog-this.g?t=' + encodeURIComponent(text) + '&n=' + encodeURIComponent(title) + '&u=' + encodeURIComponent(url); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, bloggerStr, 'height=600, width=740' + popupParams); closeMorePopIn(node); onSocialEvent(bloggerStr, clickStr, url); } node.title = bloggerStr; node.className = bloggerStr; return node; }, 'stumbleupon': function(url, elt){ var node = document.createElement(aStr), href = 'http://www.stumbleupon.com/submit?url=' + encodeURIComponent(url); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, stumbleuponStr, 'height=600, width=800' + popupParams); closeMorePopIn(node); onSocialEvent(stumbleuponStr, clickStr, url); } node.title = stumbleuponStr; node.className = stumbleuponStr; return node; }, 'reddit': function(url, elt){ var node = document.createElement(aStr), title = elt.getAttribute(dataTitleStr) || '', href = 'http://www.reddit.com/submit?url=' + encodeURIComponent(url) + "&title=" + title; node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, redditStr, 'height=820, width=900' + popupParams); closeMorePopIn(node); onSocialEvent(redditStr, clickStr, url); } node.title = redditStr; node.className = redditStr; return node; }, 'digg': function(url, elt){ var node = document.createElement(aStr), href = 'http://digg.com/submit?url=' + encodeURIComponent(url); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, diggStr, 'height=680, width=1070' + popupParams); closeMorePopIn(node); onSocialEvent(diggStr, clickStr, url); } node.title = diggStr; node.className = diggStr; return node; }/*, 'netlog': function(url, elt){ var node = document.createElement(aStr), href = 'http://www.netlog.com/go/logs/shouts/view=friends&origin=external&message=' + encodeURIComponent(elt.getAttribute('data-message')); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, netlogStr, 'height=680, width=1070' + popupParams); closeMorePopIn(node); onSocialEvent(netlogStr, clickStr, url); } node.title = netlogStr; node.className = netlogStr; return node; }*//*, 'tumblr': function(url, elt){ var node = document.createElement(aStr), href = 'http://www.tumblr.com/share/photo?url=' + encodeURIComponent(url); node.setAttribute(hrefStr, emptyLink); node.onclick = function(){ window.open(href, tumblrStr, 'height=680, width=1070' + popupParams); closeMorePopIn(node); onSocialEvent(tumblrStr, clickStr, url); } node.title = tumblrStr; node.className = tumblrStr; return node; }*/, init: function(elt) { var el = document.createElement(divStr), position = elt.getAttribute('data-plus-position') || 'top left', plusContainer, plusClose, hrefAttribute; el.className = 'sb_plus_popup ' + position; el.innerHTML = plusTemplate; plusContainer = searchNode(divStr, 'sb_plus_container', el); plusClose = searchNode(aStr, 'sb_plus_close', el); var currentNetwork, currentNode, createdNode, nbChildren = elt.children.length; for(var i = 0; i= nodes.length){ SM_A1_0.init(nodes); return; } var currentURL, xhr, currentNode = nodes[idx], _twitter = SM_A1_0.getElements(currentNode, twitterStr); if(_twitter && _twitter[0]){ if(_twitter[0].getAttribute(dataHrefStr)){ currentNode = _twitter[0]; } } currentURL = currentNode.getAttribute(dataHrefStr); currentURL = currentURL ? currentURL : location.href; if(!SM_A1_0.twUn && !SM_A1_0.twAk){ SM_A1_0.bitlyURL[currentURL] = currentURL; callBitly(idx+1); }else if(currentURL && !SM_A1_0.bitlyURL[currentURL]){ if (window.XDomainRequest) { //IE for cross domain AJAX call xhr = new XDomainRequest(); } else if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } if(xhr && window.JSON && (typeof window.JSON.parse === functionStr) && !isIE7){ xhr.onload = function() { var resp = window.JSON.parse(xhr.responseText); if(resp && resp.data && resp.data.url){ SM_A1_0.bitlyURL[currentURL] = resp.data.url; }else{ console.log("Error bitly", resp); //For example rate limit exceeded } callBitly(idx+1); }; xhr.onerror = function(){ callBitly(idx+1); }; xhr.open("GET", "//api-ssl.bitly.com/v3/shorten?longUrl="+encodeURIComponent(currentURL)+"&login="+SM_A1_0.twUn+"&apiKey="+SM_A1_0.twAk, true); xhr.send(); } else{ callBitly(idx+1); } } else{ callBitly(idx+1); } }; //To detect IE7 and lower if (document.all && !document.querySelector) { isIE7 = true; } callBitly(0); }, /* * Loads the social bars * * @param nodes: the nodes of the social bars to load * if nodes is null all the social bar into the page * will be loaded */ init: function(nodes){ if(!nodes){ var nodes = SM_A1_0.getElements(document, widgetClass); } var isLoaded, node; for(var i=0; i= node.children.length) { return; } var widgetNode = node.children[widgetIdx], networkName = widgetNode.className.split(' ')[0], // in case of 'noCount' layout css class added network = widgets[networkName]; if(!network){ SM_A1_0.loadWidgets(node, widgetIdx + 1); return; } var element = network && network.init(widgetNode); if(element){ widgetNode.appendChild(element); if(!network.toActivate){ network.toActivate = []; } network.toActivate.push(widgetNode); SM_A1_0.loadNetworks(networkName, element); } // load the next element in the social bar SM_A1_0.loadWidgets(node, widgetIdx + 1); }, /* * Recursive function: loads a single network. once the network is loaded activate every related widgets * then ask for loading the next network * * caution: We need to load one network at a time to prevent networks script to interfere with each other */ loadNextNetwork: function(){ if(SM_A1_0.loadingNetwork){ return; } if(SM_A1_0.toLoad.length == 0){ return; } var network = SM_A1_0.toLoad.shift(), networkActivation = function(){ network.loaded = true; network.loading = false; SM_A1_0.loadingNetwork = false; if(network.toActivate){ for(var i=0; i