Advertisement
Guest User

customTwitterSearch

a guest
May 8th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     $t.customTwitterSearch = $t.createClass(null, {
  3.        
  4.         init : function(requestOptions) {
  5.             this.__requestOptions = $.extend({}, requestOptions);
  6.         },
  7.        
  8.         process : function(settings) {
  9.             this.settings = settings;
  10.            
  11.             if (this.__requestOptions.echo) {
  12.                 settings.success(this.__requestOptions.echo);
  13.             } else {
  14.                 $.ajax({
  15.                     url: "http://search.twitter.com/search.json?q=help",
  16.                     context: this,
  17.                     dataType: "jsonp"
  18.                 }).done(this.onAjaxDone).error(this.onAjaxError);
  19.                 showSpinner();
  20.             }
  21.         },
  22.        
  23.         onAjaxDone: function(data) {
  24.             //You can filter "data" here
  25.             this.settings.success(data);
  26.             this.settings.complete('success');
  27.             hideSpinner();
  28.         },
  29.        
  30.         onAjaxError: function(jqXHR, textStatus, errorThrown) {
  31.             this.settings.error(jqXHR, textStatus, errorThrown);
  32.             this.settings.complete('error');
  33.             hideSpinner();
  34.         }
  35.  
  36.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement