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
   box.parentNode.insertBefore(bar, box)
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
   Load(+el.attributes['data-load-report'].value);
225
   Load(+el.attributes['data-load-report'].value);
226
 })
226
 })
227
 
227
 
228
-var ReportSelectorInited = false;
229
 function ReportSelectorInit() {
228
 function ReportSelectorInit() {
230
-  if (!ReportSelectorInited && document.querySelector('.change_report_type')) {
229
+  if (document.querySelector('.change_report_type')) {
231
     document.querySelector('.change_report_type').addEventListener('change', ChangeReportType);
230
     document.querySelector('.change_report_type').addEventListener('change', ChangeReportType);
232
     ChangeReportType();
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