// ---------------------- Gems ----------------------- //
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require jquery.remotipart
//= require cocoon
//= require isInViewport
//= require turbolinks
//= require paloma
//= require jquery.atwho
//= require social-share-button
//= require codemirror
//= require activestorage
//= require cookies_eu
//= require rails.validations

// --------------------- Vendor ------------------------ //
//= require jQuery-File-Upload
//= require remodal

// ------------------ Vendor / Notebooks --------------- //
// require ansi_up.min
// require es5-shim.min
// require marked.min
// require notebook.min
//= require prism.min

// ---------------------- Modules ---------------------- //
//= require modules/site
//= require modules/subnav_tabs
//= require modules/inline_validations
//= require modules/rangy_inputs
//= require modules/markdown_editor
//= require modules/flash_messages
//= require modules/direct_s3_upload
//= require modules/mentions

// ---------------------- Pages ---------------------- //
// require pages/participants_edit
// require pages/email_preferences_edit

// -------------------- Controllers ------------------- //
//= require controllers/articles_controller
//= require controllers/challenges_controller
//= require controllers/leaderboards_controller
//= require controllers/dataset_files_controller
//= require controllers/task_dataset_files_controller
//= require controllers/participants_controller
// require controllers/email_preferences_controller


// ------------------------ STARTUP -------------------------- //

/*
$(document).on('ajax:error', function(xhr, status, error) {
  console.log(status.responseText);
  console.log(error);
});
*/

$(document).on('turbolinks:load', function() {
  $('[data-remodal-id=modal]').remodal();
});

$(document).on('turbolinks:load', function() {
  Paloma.start();
});

function loadMathJax() {
  window.MathJax = null;
  $.getScript("https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML", function() {
    MathJax.Hub.Config({
      tex2jax: {
            inlineMath: [ ["$","$"],["\\(","\\)"] ],
            displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
            processEscapes: true
      }
    });
  });
};

$(document).on('turbolinks:load', function() {
  loadMathJax();
});

// Remove default Turbolinks loader
Turbolinks.ProgressBar.prototype.refresh = function() {}
Turbolinks.ProgressBar.defaultCSS = ""
var loaderTimer;

$(document).on('turbolinks:click', function() {
  loaderTimer = setTimeout(function(){
    $('#page-content').hide();
    $('#loader-container').show();
  }, 250);
});

$(document).on('turbolinks:load', function() {
  clearTimeout(loaderTimer);
  $('#page-content').show();
  $('#loader-container').hide();
});

@@ -1613,21 +1613,16 @@
 //%0A%0A
-/*%0A$(
 document
 ).on
@@ -1621,140 +1621,27 @@
 ment
-).on('ajax:error', function(xhr, status, error) %7B%0A  console.log(status.responseText);%0A  console.log(error);%0A%7D);%0A*/%0A%0A$(document).on('
+.addEventListener(%22
 turb
@@ -1643,33 +1643,33 @@
 %22turbolinks:load
-'
+%22
 , function() %7B%0A 
@@ -1710,34 +1710,32 @@
 dal();%0A%7D);%0A%0A
-$(
 document
 ).on('turbol
@@ -1714,38 +1714,51 @@
 );%0A%7D);%0A%0Adocument
-).on('
+.addEventListener(%22
 turbolinks:load'
@@ -1748,33 +1748,33 @@
 %22turbolinks:load
-'
+%22
 , function() %7B%0A 
@@ -2393,26 +2393,24 @@
 Timer;%0A%0A
-$(
 document
 ).on('tu
@@ -2393,38 +2393,51 @@
 Timer;%0A%0Adocument
-).on('
+.addEventListener(%22
 turbolinks:click
@@ -2436,17 +2436,17 @@
 ks:click
-'
+%22
 , functi
@@ -2573,26 +2573,24 @@
 );%0A%7D);%0A%0A
-$(
 document
 ).on('tu
@@ -2573,38 +2573,51 @@
 );%0A%7D);%0A%0Adocument
-).on('
+.addEventListener(%22
 turbolinks:load'
@@ -2607,33 +2607,33 @@
 %22turbolinks:load
-'
+%22
 , function() %7B%0A 

fix jquery errors