diff options
author | Willian Gustavo Veiga <beberveiga@gmail.com> | 2018-10-02 12:55:36 -0300 |
---|---|---|
committer | Willian Gustavo Veiga <beberveiga@gmail.com> | 2018-10-02 12:57:37 -0300 |
commit | 2d4df1349efdf8dd2c8cc4503fd5a871b0066500 (patch) | |
tree | 9f71a297cf1bb30f1d59039997a60f97357d0782 /guides/assets/javascripts/responsive-tables.js | |
parent | 00c50c2b5966fa1d719c8a58564811c672a0e8c6 (diff) | |
parent | cf608ee34dd833b0357ef4eefa692db33242d2aa (diff) | |
download | rails-2d4df1349efdf8dd2c8cc4503fd5a871b0066500.tar.gz rails-2d4df1349efdf8dd2c8cc4503fd5a871b0066500.tar.bz2 rails-2d4df1349efdf8dd2c8cc4503fd5a871b0066500.zip |
Merge branch 'master' into feature/reselect-method
Diffstat (limited to 'guides/assets/javascripts/responsive-tables.js')
-rw-r--r-- | guides/assets/javascripts/responsive-tables.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/guides/assets/javascripts/responsive-tables.js b/guides/assets/javascripts/responsive-tables.js index 24906dddeb..1c0f28c993 100644 --- a/guides/assets/javascripts/responsive-tables.js +++ b/guides/assets/javascripts/responsive-tables.js @@ -3,16 +3,6 @@ var switched = false; - // For old browsers - var each = function(node, callback) { - var array = Array.prototype.slice.call(node); - for(var i = 0; i < array.length; i++) callback(array[i]); - } - - each(document.querySelectorAll(":not(.syntaxhighlighter)>table"), function(element) { - element.classList.add("responsive"); - }); - var updateTables = function() { if (document.documentElement.clientWidth < 767 && !switched) { switched = true; @@ -23,7 +13,13 @@ } } - document.addEventListener("DOMContentLoaded", updateTables); + document.addEventListener("turbolinks:load", function() { + each(document.querySelectorAll(":not(.syntaxhighlighter)>table"), function(element) { + element.classList.add("responsive"); + }); + updateTables(); + }); + window.addEventListener("resize", updateTables); var splitTable = function(original) { |