Twitter @anywhere & Web Intents
Web Intents @donboulton
Web Intents javascript, .css and latest Twitter module changes.
Working to fully incorporate it into Latest Twitter Module. A working example with code is below with the links to all the external .js, Change @donboulton to your twitter name and place login.js and tw-widget.js in your Lastest Twitter module Scripts file.
Tutorial to build the Latest Twitter module for Orchard, is at: http://blog.maartenballiauw.be/post/2011/01/21/Writing-an-Orchard-widget-LatestTwitter.aspx
Latest Twitter - View, the code below:
Tweet Intent, with Google Analytics, working on this script to get it to append the latest tweet with web intents, fully working except for intents div.
Maybe someone could help with this.
There are no posts anywhere on this reguarding anything but .php based sites.
$(document).ready(function(){ $.getJSON('../Contracts/ITweetRetrievalService.cs', function (data) { $.each(data, function(index, item){ $('#tweetintent').append('<div><p>' + item.text.linkify() + '</p></div>' + '<div id="web_intent">' + '<span class="latest-twitter-timestamp">' + relative_time(item.created_at) + '</span>' + '<img src="https://s3.amazonaws.com/mansbooks_images/retweet_mini.png" width="16" height="16" alt="Retweet">' + '<a href="http://twitter.com/intent/retweet?tweet_id=' + item.id_str + '">' + 'Retweet</a>' + '<img src="https://s3.amazonaws.com/mansbooks_images/reply_mini.png" width="16" height="16" alt="Reply">' + '<a href="http://twitter.com/intent/tweet?in_reply_to=' + item.id_str + '">' + 'Reply</a>' + '<img src="https://s3.amazonaws.com/mansbooks_images/favorite_mini.png" width="16" height="16" alt="Favorite">' + '<a href="http://twitter.com/intent/favorite?tweet_id=' + item.id_str + '">' + 'Favorite</a>' + '</div>'); }); String.prototype.linkify = function () { return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function (m) { return m.link(m); }); }; twttr.events.bind('follow', function (event) { var followed_user_id = event.data.user_id; var followed_screen_name = event.data.screen_name; }); twttr.events.bind('favorite', function(event) { var favorited_tweet_id = event.data.tweet_id; }); twttr.events.bind('retweet', function (event) { var retweeted_tweet_id = event.data.source_tweet_id; }); twttr.events.bind('click', function (event) { var click_type = event.region; }); function clickEventToAnalytics(intent_event) { if (intent_event) { var label = intent_event.region; pageTracker._trackEvent('twitter_web_intents', intent_event.type, label); }; } function tweetIntentToAnalytics(intent_event) { if (intent_event) { var label = "tweet"; pageTracker._trackEvent('twitter_web_intents', intent_event.type, label); }; } function favIntentToAnalytics(intent_event) { tweetIntentToAnalytics(intent_event); } function retweetIntentToAnalytics(intent_event) { if (intent_event) { var label = intent_event.data.source_tweet_id; pageTracker._trackEvent('twitter_web_intents', intent_event.type, label); }; } function followIntentToAnalytics(intent_event) { if (intent_event) { var label = intent_event.data.user_id + " (" + intent_event.data.screen_name + ")"; pageTracker._trackEvent('twitter_web_intents', intent_event.type, label); }; } twttr.events.bind('click', clickEventToAnalytics); twttr.events.bind('tweet', tweetIntentToAnalytics); twttr.events.bind('retweet', retweetIntentToAnalytics); twttr.events.bind('favorite', favIntentToAnalytics); twttr.events.bind('follow', followIntentToAnalytics); }); (function () { if (window.__twitterIntentHandler) return; var intentRegex = /twitter\.com(\:\d{2,4})?\/intent\/(\w+)/, windowOptions = 'scrollbars=yes,resizable=yes,toolbar=no,location=yes', width = 550, height = 420, winHeight = screen.height, winWidth = screen.width; function handleIntent(e) { e = e || window.event; var target = e.target || e.srcElement, m, left, top; while (target && target.nodeName.toLowerCase() !== 'a') { target = target.parentNode; } if (target && target.nodeName.toLowerCase() === 'a' && target.href) { m = target.href.match(intentRegex); if (m) { left = Math.round((winWidth / 2) - (width / 2)); top = 0; if (winHeight > height) { top = Math.round((winHeight / 2) - (height / 2)); } window.open(target.href, 'intent', windowOptions + ',width=' + width + ',height=' + height + ',left=' + left + ',top=' + top); e.returnValue = false; e.preventDefault && e.preventDefault(); } } } if (document.addEventListener) { document.addEventListener('click', handleIntent, false); } else if (document.attachEvent) { document.attachEvent('onclick', handleIntent); } window.__twitterIntentHandler = true; } () ); });
Login-out script: external login.js
jQuery(function () { twttr.anywhere(function (T) { if (T.isConnected()) { $("#login-logout").append('<button id="signout" type="button">Sign out of Twitter</button>'); $("#signout").bind("click", function () { twttr.anywhere.signOut(); }); } else { T("#login-logout").connectButton(); } }); });
The .css for Site.css
.reply{width:16px;height:16px;}.reply:hover{width: 16px;height: 16px;background:url('reply_hover.png');background-repeat: no-repeat;}.retweet{width:16px;height:16px;}.retweet:hover{width: 16px;height: 16px;background:url('retweet_hover.png'); background-repeat: no-repeat;}.favorite{width:16px;height:16px;}.favorite:hover, .favorite:on {background:url('favorite_hover.png'); background-repeat:no-repeat;width:16px;height:16px;border:none;}.latest-twitter-avatar{vertical-align: middle !important;border: thin solid #262626;-moz-border-radius: 3px;-webkit-border-radius: 3px;-o-border-radius: 5px;-ms-border-radius: 5px;-khtml-border-radius: 5px;border-radius: 3px;-moz-box-shadow: 1px 1px 3px #000;-webkit-box-shadow: 1px 1px 3px #000;box-shadow: 1px 1px 3px #000;margin: 5px 0 0 10px;text-align: left;}.latest-twitter-list{color:#C0C0C0;}.latest-twitter-timestamp{color:#8B9D53;}.tweet-text{width: 200px;padding: 3px 3px 16px;line-height: 1.3em;color:#C0C0C0;}.latest-twitter-timestamp{padding: 3px 3px 16px;line-height: 1.3em;color:#8B9D53;}



