<commit_before>window.ChannelView = Backbone.View.extend({

  el: $("#main-wrapper"),
  tmpl: $('#channel_overview').html(),
  
  initialize: function(opts) {
    var self = this;
    
    this.subchannels = new SubchannelList({channel: this.model});
    this.subchannels.fetch();
  },
  
  initSubChannels: function() {
    if ( this.el.find('#contained-channel-list') ) {
      this.subchannelView = new SubchannelsView({
        collection: this.subchannels,
        el: this.el.find('#contained-channel-list')
      });
    }
  },
  
  initAddToFact: function() {
    if ( this.el.find('#add_to_channel') && typeof currentUser !== "undefined" ) {
      this.ownChannelView = new OwnChannelCollectionView({
        collection: currentUser.channels,
        el: this.el.find('#follow-channel')
      }).render();
    }
  },

  initMoreButton: function() { 
    var containedChannels = this.el.find('#contained-channels');
    if  ( containedChannels ) {
    this.el.find('.more-button').bind('click', function() { 
        var button = $(this).find(".label");
        containedChannels.slideToggle(function(e) { 
          button.text($(button).text() === 'more' ? 'less' : 'more');
        });
      });
    }
  },

  initSubChannelMenu: function() { 
    if( this.model.get("followable?") ) { 
      var addToChannelButton = this.el.find("#add_to_channel");
      var followChannelMenu = this.el.find("#follow-channel");
      followChannelMenu.css({"left": addToChannelButton.position().left});
      addToChannelButton.hoverIntent(
        function() { followChannelMenu.fadeIn("fast"); }, 
        function() { followChannelMenu.delay(600).fadeOut("fast"); }
      );
      followChannelMenu.on("mouseover", function() { 
        followChannelMenu.stop(true, true).css({"opacity": "1"});
      });
      followChannelMenu.on("mouseout", function() { 
       if (!followChannelMenu.find("input#channel_title").is(":focus")) {
          followChannelMenu.delay(500).fadeOut("fast");
        }
      });
    }
  },

  render: function() { 
    var self = this;

    if ( self.model ) {
      self.model.trigger('loading');
      
      this.el
        .html( Mustache.to_html(this.tmpl, this.model.toJSON() ));
      
      this.initSubChannels();
      this.initSubChannelMenu();
      this.initAddToFact();
      this.initMoreButton(); 
        
      self.model.trigger('loaded')
                  .trigger('activate', self.model);
                  
      $.ajax({
        url: self.model.url() + '/facts',
        method: "GET",
        success: function( data ) {
          self.el.find('#facts_for_channel > div.loading').hide().parent().find('div.facts').html(data);
          self.el.find('.fact-block').factlink();
        }
      });
    }
    
    return this;
  }
});
<commit_msg>No more ajaxing, we're using backbone baby!<commit_after>window.ChannelView = Backbone.View.extend({

  el: $("#main-wrapper"),
  tmpl: $('#channel_overview').html(),
  
  initialize: function(opts) {
    var self = this;
    
    this.subchannels = new SubchannelList({channel: this.model});
    this.subchannels.fetch();
    
    this.factsView = new FactsView({
      collection: new Facts([],{
        rootUrl: self.model.url()
      })
    });
  },
  
  initSubChannels: function() {
    if ( this.el.find('#contained-channel-list') ) {
      this.subchannelView = new SubchannelsView({
        collection: this.subchannels,
        el: this.el.find('#contained-channel-list')
      });
    }
  },
  
  initAddToFact: function() {
    if ( this.el.find('#add_to_channel') && typeof currentUser !== "undefined" ) {
      this.ownChannelView = new OwnChannelCollectionView({
        collection: currentUser.channels,
        el: this.el.find('#follow-channel')
      }).render();
    }
  },

  initMoreButton: function() { 
    var containedChannels = this.el.find('#contained-channels');
    if  ( containedChannels ) {
    this.el.find('.more-button').bind('click', function() { 
        var button = $(this).find(".label");
        containedChannels.slideToggle(function(e) { 
          button.text($(button).text() === 'more' ? 'less' : 'more');
        });
      });
    }
  },

  initSubChannelMenu: function() { 
    if( this.model.get("followable?") ) { 
      var addToChannelButton = this.el.find("#add_to_channel");
      var followChannelMenu = this.el.find("#follow-channel");
      followChannelMenu.css({"left": addToChannelButton.position().left});
      addToChannelButton.hoverIntent(
        function() { followChannelMenu.fadeIn("fast"); }, 
        function() { followChannelMenu.delay(600).fadeOut("fast"); }
      );
      followChannelMenu.on("mouseover", function() { 
        followChannelMenu.stop(true, true).css({"opacity": "1"});
      });
      followChannelMenu.on("mouseout", function() { 
       if (!followChannelMenu.find("input#channel_title").is(":focus")) {
          followChannelMenu.delay(500).fadeOut("fast");
        }
      });
    }
  },

  render: function() { 
    var self = this;

    if ( self.model ) {
      self.model.trigger('loading');
      
      this.el
        .html( Mustache.to_html(this.tmpl, this.model.toJSON() ));
      
      this.initSubChannels();
      this.initSubChannelMenu();
      this.initAddToFact();
      this.initMoreButton();
      
      $( this.el ).find('#facts_for_channel').append(this.factsView.render().el);
        
      self.model.trigger('loaded')
                  .trigger('activate', self.model);
    }
    
    return this;
  }
});

{'fraction_non_alphanumeric': 0.17167149059334297, 'fraction_numerical': 0.002532561505065123, 'mean_word_length': 2.601954397394137, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7655770', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1651, 'n_words': 242}