Skip to content

Commit

Permalink
Check for presence of jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
grezniczek committed Feb 18, 2020
1 parent 836d025 commit 9363a71
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 24 deletions.
38 changes: 25 additions & 13 deletions UITrimmerExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ function redcap_every_page_top($project_id = null) {
}

// Reveal
echo "<script>$(function() { $('body').show() })</script>";
echo "<script>
(function() {
var callback = function() {
document.body.style.display = 'block'
}
if (document.readyState === 'complete' || (document.readyState !== 'loading' && !document.documentElement.doScroll)) {
callback()
}
else {
document.addEventListener('DOMContentLoaded', callback)
}
})()
</script>";
}

private function addScriptlets() {
$this->scriptlets[ActionsEnum::remove_current_users] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('div#user_list')
if (eltoremove.length == 1) {
const parent = eltoremove.parent()
Expand All @@ -101,7 +113,7 @@ private function addScriptlets() {
}
})";
$this->scriptlets[ActionsEnum::remove_upcoming_events] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('div#cal_table')
if (eltoremove.length == 1) {
const parent = eltoremove.parent()
Expand All @@ -112,7 +124,7 @@ private function addScriptlets() {
}
})";
$this->scriptlets[ActionsEnum::remove_codebook_link] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('div.menubox a[href*=\"Design/data_dictionary_codebook\"]').parent()
if (eltoremove.length == 1) {
const elbefore = eltoremove.first().prev('span')
Expand All @@ -123,12 +135,12 @@ private function addScriptlets() {
}
})";
$this->scriptlets[ActionsEnum::remove_help_link] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('div.menubox a[onclick*=\"helpPopup\"]').parent()
if (eltoremove.length === 1) eltoremove.remove()
})";
$this->scriptlets[ActionsEnum::modify_help_link] =
"$(function() {
"if ($) $(function() {
const elToModify = $('div.menubox a[onclick*=\"helpPopup\"]')
if (elToModify.length === 1) {
const text = " . json_encode($this->settings->modifiedHelpLinkText) . "
Expand All @@ -142,34 +154,34 @@ private function addScriptlets() {
}
})";
$this->scriptlets[ActionsEnum::remove_videotutorials_link] =
"$(function() {
"if ($) $(function() {
let eltoremove = $('div.menubox a[onclick*=\"#menuvids\"]').parent()
if (eltoremove.length === 1) eltoremove.remove()
eltoremove = $('#menuvids')
if (eltoremove.length === 1) eltoremove.remove()
})";
$this->scriptlets[ActionsEnum::remove_suggestfeature_link] =
"$(function() {
"if ($) $(function() {
let eltoremove = $('div.menubox a[href*=\"vanderbilt.edu/enduser_survey\"]').parent()
if (eltoremove.length === 1) eltoremove.remove()
})";
$this->scriptlets[ActionsEnum::remove_empty_menu_sections] =
"$(function() {
"if ($) $(function() {
$('div#west div.x-panel-body').each(function() {
if ($(this).text().length == 0) {
$(this).parent().parent().hide()
}
})
})";
$this->scriptlets[ActionsEnum::remove_top_actions] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('div#dataEntryTopOptionsButtons')
if (eltoremove.length == 1) {
eltoremove.remove();
}
})";
$this->scriptlets[ActionsEnum::remove_forgot_password] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('a[href*=\"Authentication/password_recovery\"')
if (eltoremove.length == 1) {
const parent = eltoremove.parent()
Expand All @@ -180,14 +192,14 @@ private function addScriptlets() {
}
})";
$this->scriptlets[ActionsEnum::remove_items_below_login] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('div#left_col').siblings('div.row')
if (eltoremove.length == 1) {
eltoremove.remove()
}
})";
$this->scriptlets[ActionsEnum::remove_myprojects_link] =
"$(function() {
"if ($) $(function() {
const eltoremove = $('div.menubox a[href*=\"index.php?action=myprojects\"]')
eltoremove.each(function() {
let el = $(this)
Expand Down
2 changes: 1 addition & 1 deletion js/remove_codebook_link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
const eltoremove = $('div.menubox a[href*="Design/data_dictionary_codebook"]').parent()
if (eltoremove.length == 1) {
const elbefore = eltoremove.first().prev('span')
Expand Down
2 changes: 1 addition & 1 deletion js/remove_current_users.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
const eltoremove = $('div#user_list')
if (eltoremove.length == 1) {
const parent = eltoremove.parent()
Expand Down
2 changes: 1 addition & 1 deletion js/remove_empty_menu_sections.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
$('div#west div.x-panel-body').each(function() {
if ($(this).text().length == 0) {
$(this).parent().parent().hide()
Expand Down
2 changes: 1 addition & 1 deletion js/remove_forgot_password.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
const eltoremove = $('a[href*="Authentication/password_recovery"')
if (eltoremove.length == 1) {
const parent = eltoremove.parent()
Expand Down
2 changes: 1 addition & 1 deletion js/remove_help_link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) if ($) $(function() {
const eltoremove = $('div.menubox a[onclick*="helpPopup"]').parent()
if (eltoremove.length === 1) eltoremove.remove()
})
2 changes: 1 addition & 1 deletion js/remove_items_below_login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
const eltoremove = $('div#left_col').siblings('div.row')
if (eltoremove.length == 1) {
eltoremove.remove()
Expand Down
2 changes: 1 addition & 1 deletion js/remove_myprojects_link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
const eltoremove = $('div.menubox a[href*="index.php?action=myprojects"]')
eltoremove.each(function() {
let el = $(this)
Expand Down
2 changes: 1 addition & 1 deletion js/remove_suggestfeature_link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
let eltoremove = $('div.menubox a[href*="vanderbilt.edu/enduser_survey"]').parent()
if (eltoremove.length === 1) eltoremove.remove()
})
2 changes: 1 addition & 1 deletion js/remove_top_actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
const eltoremove = $('div#dataEntryTopOptionsButtons')
if (eltoremove.length == 1) {
eltoremove.remove();
Expand Down
2 changes: 1 addition & 1 deletion js/remove_upcoming_events.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
const eltoremove = $('div#cal_table')
if (eltoremove.length == 1) {
const parent = eltoremove.parent()
Expand Down
2 changes: 1 addition & 1 deletion js/remove_videotutorials_link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
$(function() {
if ($) $(function() {
let eltoremove = $('div.menubox a[onclick*="#menuvids"]').parent()
if (eltoremove.length === 1) eltoremove.remove()
eltoremove = $('#menuvids')
Expand Down

0 comments on commit 9363a71

Please sign in to comment.