<commit_before>define([
    'backbone',
    'backbone.marionette',
    'hbs!../templates/module',
    'underscore',
    'localforage',
    './BiddingStatsView',
    'bootstrap/tooltip'
  ],
  function (Backbone, Marionette, template, _, localforage, BiddingStatsView) {
    'use strict';

    var searchPreferences = {};

    return Marionette.LayoutView.extend({
      template: template,
      regions: {
        biddingStatsRegion: '#bidding-stats'
      },
      initialize: function () {

        if (this.model.get('section') === 'corspedia') {
          var formElements = {
            'faculty': '#faculty',
            'account': '#account',
            'student': 'input:radio[name="student-radios"]'
          };

          var defaults = {
            'faculty': 'default',
            'account': 'P',
            'student': 'true'
          };

          var that = this;
          var loadedItems = 0;
          _.each(formElements, function (selector, item) {
            localforage.getItem(item, function (value) {
              if (!value) {
                value = defaults[item];
                localforage.setItem(item, value);
              }
              $(selector).val([value]);
              searchPreferences[item] = value;
              loadedItems++;
              if (loadedItems === _.keys(formElements).length) {
                that.showBiddingStatsRegion(true);
              }
            });
          });
        }
      },
      events: {
        'change #faculty, input:radio[name="student-radios"], #account': 'updateCorspedia',
        'click .show-full-desc': 'showFullDescription',
        'click #show-all-stats': 'showAllStats'
      },
      onShow: function () {
        var module = this.model.get('module');
        var code = module.ModuleCode;

        var disqusShortname = 'nusmods';

        (function () {
          if (typeof disqus_domain !== 'undefined') {
            DISQUSWIDGETS.domain = 'disqus.com';
          }
          DISQUSWIDGETS.forum = disqusShortname;
          DISQUSWIDGETS.getCount();
        })();

        if (this.model.get('section') === 'reviews') {
          // Only reset Disqus when showing reviews section
          DISQUS.reset({
            reload: true,
            config: function () {
              this.page.identifier = code;
              this.page.title = code + ' ' + module.ModuleTitle + ' · Reviews';
              this.page.url = 'http://nusmods.com/modules/' + code + '/reviews';
            }
          });
        }
        $('.nm-help').tooltip();

        // So that users can use keyboard shortcuts immediately after the page loads
        $('input').blur();
      },
      showFullDescription: function () {
        $('.module-desc').addClass('module-desc-more');
        return false;
      },<commit_msg>Hide search bar results after selecting module<commit_after>define([
    'backbone',
    'backbone.marionette',
    'hbs!../templates/module',
    'underscore',
    'localforage',
    './BiddingStatsView',
    'bootstrap/tooltip'
  ],
  function (Backbone, Marionette, template, _, localforage, BiddingStatsView) {
    'use strict';

    var searchPreferences = {};

    return Marionette.LayoutView.extend({
      template: template,
      regions: {
        biddingStatsRegion: '#bidding-stats'
      },
      initialize: function () {

        if (this.model.get('section') === 'corspedia') {
          var formElements = {
            'faculty': '#faculty',
            'account': '#account',
            'student': 'input:radio[name="student-radios"]'
          };

          var defaults = {
            'faculty': 'default',
            'account': 'P',
            'student': 'true'
          };

          var that = this;
          var loadedItems = 0;
          _.each(formElements, function (selector, item) {
            localforage.getItem(item, function (value) {
              if (!value) {
                value = defaults[item];
                localforage.setItem(item, value);
              }
              $(selector).val([value]);
              searchPreferences[item] = value;
              loadedItems++;
              if (loadedItems === _.keys(formElements).length) {
                that.showBiddingStatsRegion(true);
              }
            });
          });
        }
      },
      events: {
        'change #faculty, input:radio[name="student-radios"], #account': 'updateCorspedia',
        'click .show-full-desc': 'showFullDescription',
        'click #show-all-stats': 'showAllStats'
      },
      onShow: function () {
        var module = this.model.get('module');
        var code = module.ModuleCode;

        var disqusShortname = 'nusmods';

        (function () {
          if (typeof disqus_domain !== 'undefined') {
            DISQUSWIDGETS.domain = 'disqus.com';
          }
          DISQUSWIDGETS.forum = disqusShortname;
          DISQUSWIDGETS.getCount();
        })();

        if (this.model.get('section') === 'reviews') {
          // Only reset Disqus when showing reviews section
          DISQUS.reset({
            reload: true,
            config: function () {
              this.page.identifier = code;
              this.page.title = code + ' ' + module.ModuleTitle + ' · Reviews';
              this.page.url = 'http://nusmods.com/modules/' + code + '/reviews';
            }
          });
        }
        $('.nm-help').tooltip();
      },
      showFullDescription: function () {
        $('.module-desc').addClass('module-desc-more');
        return false;
      },
{'fraction_non_alphanumeric': 0.1436036036036036, 'fraction_numerical': 0.00036036036036036037, 'mean_word_length': 1.7331363860167406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2219355', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1542, 'n_words': 295}