From disqus.com, 3 Weeks ago, written in JavaScript.
This paste is a reply to config.js from disqus.com
- view diff
Embed
  1. define('home/main',[  // eslint-disable-line requirejs/amd-function-arity
  2.     'home/config',
  3.     'home/utils/layoutUtils',
  4.     'Router',
  5.     'home/models/Session',
  6.     'core/config/urls',
  7.  
  8.     'jquery',
  9.     'backbone',
  10.  
  11.     'home/mixins/asEmbedApp',
  12.     'home/utils/sidebarUtils',
  13.     'home/utils/navigationUtils',
  14.  
  15.     // imported for side effects
  16.     'bootstrap/dropdown',
  17.     'bootstrap/tooltip',
  18.     'bootstrap/modal',
  19.     'bootstrap/collapse',
  20.     'jquery.trunk8',
  21. ], function (
  22.     config,
  23.     layoutUtils,
  24.  
  25.     Router,
  26.     Session,
  27.     urls,
  28.  
  29.     $,
  30.     Backbone,
  31.  
  32.     asEmbedApp,
  33.     sidebarUtils,
  34.     navigationUtils
  35. ) {
  36.     'use strict';
  37.  
  38.     var initFixtures = function (callback) {
  39.         if (window.IS_DEV)
  40.             require(['fixtures/fixtures'], callback);
  41.         else
  42.             callback();
  43.     };
  44.  
  45.     /**
  46.      * Backwards compatibility layer to support old #-based routes
  47.      * e.g., /home/#account
  48.      */
  49.     function transitionUrl() {
  50.         var location = window.location;
  51.  
  52.         // If we are at the /home/ prefix and we happen to also have a
  53.         // hash that matches one of our routes, then we should try to
  54.         // direct the user to that route instead of just going to /home/.
  55.         // NOTE: this hash routing feature is only to support a few legacy
  56.         //       urls like disqus.com/home/#account.
  57.         if (location.hash.length > 1 && (location.pathname === '/home' || location.pathname === '/home/')) {
  58.             // Construct a new location object that contains the hash's route
  59.             // as well as search params, etc.
  60.             var loc = {
  61.                 pathname: '/home/' + location.hash.slice(1).replace(/^\//, ''),
  62.                 search: location.search,
  63.                 hash: '',
  64.                 host: location.host,
  65.             };
  66.  
  67.             if (navigationUtils.matchesRoute(loc))
  68.                 return navigationUtils.navigate(loc, true);
  69.         }
  70.  
  71.         return Backbone.history.loadUrl();
  72.     }
  73.  
  74.     return {
  75.         _init: function (options) {
  76.             var app = new Router(options);
  77.  
  78.             // Start
  79.             app.bootstrap();
  80.  
  81.             // overwrite tooltip support so they don't show
  82.             if (layoutUtils.isNarrowLayout())
  83.                 $.fn.tooltip = $.noop;
  84.  
  85.             window.DISQUS = window.DISQUS || {};
  86.             window.DISQUS.home = {
  87.                 app: app,
  88.             };
  89.  
  90.             // Wait for fixtures to initialize (for dev) before beginning navigation
  91.             initFixtures(function () {
  92.                 Backbone.history.start({
  93.                     pushState: true,
  94.                     hashChange: false,
  95.                     root: config.appRoot,
  96.                     silent: true,
  97.                 });
  98.  
  99.                 // If we don't have a matching route, call notFound
  100.                 if (!transitionUrl())
  101.                     app.notFound();
  102.             });
  103.         },
  104.  
  105.         init: function (options) {
  106.             urls.cdn = options.CDN_ROOT;
  107.             var self = this;
  108.  
  109.             if (sidebarUtils.isSidebar())
  110.                 asEmbedApp(Router.prototype, Session.prototype);
  111.  
  112.             $(function () {
  113.                 self._init(options);
  114.             });
  115.         },
  116.     };
  117. });
  118.  
  119. // https://c.disquscdn.com/next/16dccc7/home/js/main.js

Replies to main.js rss

Title Name Language When
Router.js disqus.com javascript 3 Weeks ago.