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 b08e45150..0b1f9227b 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 d4c11f22a..2ddfc2988 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 d3b090d53..9c5c1823d 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 04e391ed6..477bd44c0 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 4f7329b1b..a4a975880 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 c44e6d074..9ef66e220 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 fcc4f9925..0dbbd47cc 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 96aae5711..4e7190dbf 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);