Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Remove twitter hover cards. Refine twitter search API query.
Browse files Browse the repository at this point in the history
  • Loading branch information
pifantastic committed Nov 29, 2011
1 parent 614e221 commit 5f27d04
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h1>Explore</h1>
</ul>
</div>
<section class="getinvolved">
<div class="col-b">
<div class="col-b">
<h2 class="subhed">Can you do this?</h2>
<div class="task" data-hashtag="#explore">
<p>If you want to be counted among those brave enough to attempt to do this.</p>
Expand Down Expand Up @@ -141,7 +141,7 @@ <h2 id="answer_questions_and_participate_in_conversations_on_irc">Answer questio
<p><a href="http://richard.esplins.org/siwi/2011/07/08/getting-started-freenode-irc/">How to get started with freenode and irc</a></p>
<ul>
<li><b>Freenode irc channels:</b> #html5 / #css / #javascript / #whatwg / #jquery / #webkit</li>
<li><b>Mozilla IRC channels (irc://irc.mozilla.org):</b> #css / #js / #introduction / #developers</li>
<li><b>Mozilla IRC channels (irc://irc.mozilla.org):</b> #css / #js / #introduction / #developers</li>
</ul>

<h2 id="how_to_ask_for_help">How to ask for help</h2>
Expand Down Expand Up @@ -288,7 +288,7 @@ <h1>File bugs</h1>
</ul>
</div>
<section class="getinvolved">
<div class="col-b">
<div class="col-b">
<h2 class="subhed">Can you do this?</h2>
<div class="task" data-hashtag="#filebugs">
<p>If you want to be counted among those brave enough to attempt to do this.</p>
Expand Down Expand Up @@ -352,7 +352,6 @@ <h2 class="subhed">Can you do this?</h2>
<p><a href=https://github.com/h5bp/igotmybeanie>Contribute to this project</a></p>
</footer>

<script src="http://platform.twitter.com/anywhere.js?id=wjANCxjyXtdRjYv8KAGIkA&amp;v=1"></script>
<script>
/*
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview'],['_trackPageLoadTime']];
Expand Down
5 changes: 3 additions & 2 deletions js/init.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
(function( $ ){
var tweet = "This is the tweet.";

$(".task")
.append('<a href="http://twitter.com/intent/tweet?text=' + encodeURIComponent(tweet) + '" class="pledge">Yes, I want to do this.</a><p>Here are some developers who want to do this too:</p><div class="pledges"></div>')
.hashTask({
message : tweet,
linkSelector : function() { return this.find('.pledge') },
avatarsSelector : function() { return this.find('.pledges') },
hashtag : function() { return this.data('hashtag') || '#igotmybeanie' }
hashtag : function() { return this.data('hashtag') || '#igotmybeanie' },
searchPrefix : '(ivegotmybluebeanieonnowwhat.com OR movethewebforward.com) AND '
});

})( jQuery );
27 changes: 15 additions & 12 deletions js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
hashtag: undefined,
message: 'oh yeah!',
linkSelector: 'a',
avatarsSelector: 'div'
avatarsSelector: 'div',
searchPrefix: ''
};

var options = $.extend({}, defaults, o);
Expand Down Expand Up @@ -38,7 +39,16 @@
return JSON.parse(value);
}

function cacheDel(key) {
window.localStorage.removeItem(key);
window.localStorage.removeItem(key + '__expires');
}

function twitterSearch(query, callback) {
if (options.searchPrefix) {
query = options.searchPrefix + query;
}

var searchUrl = 'http://search.twitter.com/search.json?callback=?&q=';
var results = cacheGet(query);
if (results) {
Expand All @@ -65,8 +75,7 @@
? options.avatarsSelector.call($elem)
: $elem.find(options.avatarsSelector);

// The hashtag used to pre-fill twitter and to search twitter
// for users.
// The hashtag used to pre-fill twitter and to search twitter for users.
var hashtag = $.isFunction(options.hashtag)
? options.hashtag.call($elem)
: $elem.data('hashtag');
Expand All @@ -79,7 +88,9 @@
// A URL that will pre-fill a twitter status message.
var prefillUrl = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(hashtag + ' ' + message);

linkElem.attr('href', prefillUrl);
linkElem.attr('href', prefillUrl).click(function() {
cacheDel(hashtag);
});

if (hashtag) {
twitterSearch(hashtag, function(json) {
Expand All @@ -104,14 +115,6 @@

users[this.from_user] = true;
});

twttr.anywhere(function(T) {
T('img', avatarsElem).hovercards({
username: function(node) {
return node.title
}
});
});
});
}

Expand Down

0 comments on commit 5f27d04

Please sign in to comment.