Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Introduce namespace.

  • Loading branch information...
commit 51db1ca9c67c39e4e71bf52cc233d0b4ad19d633 1 parent 956b279
@mileskin authored
Showing with 32 additions and 18 deletions.
  1. +32 −18 application/public/js/application.js
View
50 application/public/js/application.js
@@ -1,20 +1,34 @@
+$.fooTwitterClient = (function($) {
+ function initTrendsBehavior() {
+ $('.actions .showTrends').live('click', function(event) {
+ event.preventDefault()
+ if ($('.trends .trend').length === 0) {
+ $.ajax({
+ url: 'http://api.twitter.com/1/trends/current.json',
+ type: 'GET',
+ dataType: 'jsonp',
+ success: function(data) {
+ var trends = _(data.trends).chain().map(function(v, k){ return v }).first().flatten().value()
+ _.forEach(trends, function(t) {
+ $('.trends').append('<li class="trend">' + t.name + '</li>')
+ })
+ }
+ })
+ } else {
+ $('.trends').empty()
+ }
+ })
+ }
+
+ function initBehavior() {
+ initTrendsBehavior()
+ }
+
+ return {
+ initBehavior: initBehavior
+ }
+}(jQuery))
+
$(document).ready(function() {
- $('.actions .showTrends').live('click', function(event) {
- event.preventDefault()
- if ($('.trends .trend').length === 0) {
- $.ajax({
- url: 'http://api.twitter.com/1/trends/current.json',
- type: 'GET',
- dataType: 'jsonp',
- success: function(data) {
- var trends = _(data.trends).chain().map(function(v, k){ return v }).first().flatten().value()
- _.forEach(trends, function(t) {
- $('.trends').append('<li class="trend">' + t.name + '</li>')
- })
- }
- })
- } else {
- $('.trends').empty()
- }
- })
+ $.fooTwitterClient.initBehavior()
})
Please sign in to comment.
Something went wrong with that request. Please try again.