Browse Source

BBcode toolbar: ensure toolbar isn't added until page is loaded

spaghetti 8 years ago
parent
commit
04040cca86
2 changed files with 13 additions and 5 deletions
  1. 7
    1
      static/functions/bbcode.js
  2. 6
    4
      static/functions/reportsv2.js

+ 7
- 1
static/functions/bbcode.js View File

@@ -71,4 +71,10 @@ function BBEditor(box) {
71 71
   box.parentNode.insertBefore(bar, box)
72 72
 }
73 73
 
74
-$('.bbcode_editor').each(function(i, el) { BBEditor(el) })
74
+if (document.readyState == 'complete') {
75
+  $('.bbcode_editor').each(function(i, el) { BBEditor(el) })
76
+} else {
77
+  document.addEventListener("DOMContentLoaded", function() {
78
+    $('.bbcode_editor').each(function(i, el) { BBEditor(el) })
79
+  })
80
+}

+ 6
- 4
static/functions/reportsv2.js View File

@@ -225,13 +225,15 @@ document.querySelectorAll('[data-load-report]').forEach(function(el) {
225 225
   Load(+el.attributes['data-load-report'].value);
226 226
 })
227 227
 
228
-var ReportSelectorInited = false;
229 228
 function ReportSelectorInit() {
230
-  if (!ReportSelectorInited && document.querySelector('.change_report_type')) {
229
+  if (document.querySelector('.change_report_type')) {
231 230
     document.querySelector('.change_report_type').addEventListener('change', ChangeReportType);
232 231
     ChangeReportType();
233 232
   }
234 233
 }
235 234
 
236
-document.addEventListener("DOMContentLoaded", ReportSelectorInit);
237
-ReportSelectorInit();
235
+if (document.readyState == 'complete') {
236
+  ReportSelectorInit();
237
+} else {
238
+  document.addEventListener("DOMContentLoaded", ReportSelectorInit);
239
+}

Loading…
Cancel
Save