From ecd86ec29661da4fccac060ca487a70beac5304c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 9 Jan 2017 11:34:41 +1100 Subject: [PATCH] Check for existing element in openMenu() - Removed useless val() call in the various insertFormatting() declarations --- js/main.js | 10 ++++++++-- view/theme/duepuntozero/theme.php | 1 - view/theme/frio/js/textedit.js | 1 - view/theme/frost-mobile/js/theme.js | 1 - view/theme/frost/js/theme.js | 1 - view/theme/quattro/js/quattro.js | 1 - view/theme/smoothly/theme.php | 1 - view/theme/vier/theme.php | 1 - 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index b08e451509..0b1f9227b3 100644 --- a/js/main.js +++ b/js/main.js @@ -25,11 +25,17 @@ } function openMenu(theID) { - document.getElementById(theID).style.display = "block" + var el = document.getElementById(theID) + if (el) { + el.style.display = "block"; + } } function closeMenu(theID) { - document.getElementById(theID).style.display = "none" + var el = document.getElementById(theID) + if (el) { + el.style.display = "none"; + } } function decodeHtml(html) { diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index d4c11f22a2..2ddfc29884 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -29,7 +29,6 @@ function insertFormatting(BBcode, id) { $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); } textarea = document.getElementById("comment-edit-text-" +id); diff --git a/view/theme/frio/js/textedit.js b/view/theme/frio/js/textedit.js index d3b090d537..9c5c1823d1 100644 --- a/view/theme/frio/js/textedit.js +++ b/view/theme/frio/js/textedit.js @@ -9,7 +9,6 @@ function insertFormatting(BBcode,id) { $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); } textarea = document.getElementById("comment-edit-text-" +id); diff --git a/view/theme/frost-mobile/js/theme.js b/view/theme/frost-mobile/js/theme.js index 04e391ed6c..477bd44c03 100644 --- a/view/theme/frost-mobile/js/theme.js +++ b/view/theme/frost-mobile/js/theme.js @@ -430,7 +430,6 @@ function insertFormatting(BBcode,id) { $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); } textarea = document.getElementById("comment-edit-text-" +id); diff --git a/view/theme/frost/js/theme.js b/view/theme/frost/js/theme.js index 4f7329b1be..a4a9758803 100644 --- a/view/theme/frost/js/theme.js +++ b/view/theme/frost/js/theme.js @@ -794,7 +794,6 @@ function insertFormatting(BBcode, id) { $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); } textarea = document.getElementById("comment-edit-text-" +id); diff --git a/view/theme/quattro/js/quattro.js b/view/theme/quattro/js/quattro.js index c44e6d0740..9ef66e220e 100644 --- a/view/theme/quattro/js/quattro.js +++ b/view/theme/quattro/js/quattro.js @@ -65,7 +65,6 @@ function insertFormatting(BBcode, id) { $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); } textarea = document.getElementById("comment-edit-text-" +id); diff --git a/view/theme/smoothly/theme.php b/view/theme/smoothly/theme.php index fcc4f99252..0dbbd47cc3 100644 --- a/view/theme/smoothly/theme.php +++ b/view/theme/smoothly/theme.php @@ -25,7 +25,6 @@ function insertFormatting(BBcode, id) { $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); } textarea = document.getElementById("comment-edit-text-" +id); diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 96aae57111..4e7190dbfb 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -42,7 +42,6 @@ function insertFormatting(BBcode, id) { $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); } textarea = document.getElementById("comment-edit-text-" +id);