From 7a34c7eabe4712333e3a96754a836949ecfe4306 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 11:55:04 +0300 Subject: [PATCH 1/4] [ticket/11563] Fix subPanels() Fix subPanels() code Modernize subPanels() with jQuery Use HTML5 data attributes instead of including JS PHPBB3-11563 --- phpBB/styles/prosilver/template/forum_fn.js | 56 ++++++++++++------- .../styles/prosilver/template/mcp_topic.html | 23 +++----- .../prosilver/template/posting_editor.html | 8 +-- .../prosilver/template/posting_layout.html | 7 --- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index bb29f00490..d4a4f3e83d 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -106,32 +106,48 @@ function dE(n, s, type) { /** * Alternate display of subPanels */ -function subPanels(p) { - var i, e, t; +jQuery(document).ready(function() { + jQuery('.sub-panels').each(function() { - if (typeof(p) === 'string') { - show_panel = p; - } + var panels = this.getAttribute('data-panels').split(','), + show_panel = this.getAttribute('data-show-panel'); - for (i = 0; i < panels.length; i++) { - e = document.getElementById(panels[i]); - t = document.getElementById(panels[i] + '-tab'); + if (panels.length) { + subPanels(show_panel); + jQuery('a[data-subpanel]', this).click(function () { + subPanels(this.getAttribute('data-subpanel')); + return false; + }); + } - if (e) { - if (panels[i] === show_panel) { - e.style.display = 'block'; - if (t) { - t.className = 'activetab'; - } - } else { - e.style.display = 'none'; - if (t) { - t.className = ''; + function subPanels(p) { + var i, e, t; + + if (typeof(p) === 'string') { + show_panel = p; + } + + for (i = 0; i < panels.length; i++) { + e = document.getElementById(panels[i]); + t = document.getElementById(panels[i] + '-tab'); + + if (e) { + if (panels[i] === show_panel) { + e.style.display = 'block'; + if (t) { + t.className = 'activetab'; + } + } else { + e.style.display = 'none'; + if (t) { + t.className = ''; + } + } } } } - } -} + }); +}); /** * Call print preview diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 8dfee55cbf..130824b7b3 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -3,33 +3,24 @@

{L_TOPIC}{L_COLON} {TOPIC_TITLE}

- - -
+ diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 3eac8fb03a..c381cfe0ed 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -193,11 +193,11 @@ -
+ diff --git a/phpBB/styles/prosilver/template/posting_layout.html b/phpBB/styles/prosilver/template/posting_layout.html index 4e9954ef81..c0bd0225de 100644 --- a/phpBB/styles/prosilver/template/posting_layout.html +++ b/phpBB/styles/prosilver/template/posting_layout.html @@ -79,12 +79,5 @@ - - - From 6599cabed7b52fd1822846e7fdc1e647058f9135 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 12:10:08 +0300 Subject: [PATCH 2/4] [ticket/11563] Remove unused JS variables Remove unused JS variables from posting_buttons PHPBB3-11563 --- phpBB/styles/prosilver/template/posting_buttons.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html index fadbc9b3ca..2e96a404f3 100644 --- a/phpBB/styles/prosilver/template/posting_buttons.html +++ b/phpBB/styles/prosilver/template/posting_buttons.html @@ -32,9 +32,6 @@ } - var panels = new Array('options-panel', 'attach-panel', 'poll-panel'); - var show_panel = 'options-panel'; - function change_palette() { dE('colour_palette'); From a9259b12aa07057c3b9e3575b1429b16bfdb9509 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 11 Jul 2013 10:58:18 -0400 Subject: [PATCH 3/4] [ticket/11563] Dynamically generate panels list PHPBB3-11563 --- phpBB/styles/prosilver/template/forum_fn.js | 5 ++++- phpBB/styles/prosilver/template/mcp_topic.html | 2 +- phpBB/styles/prosilver/template/posting_editor.html | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index d4a4f3e83d..0f11fd7b7a 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -109,7 +109,10 @@ function dE(n, s, type) { jQuery(document).ready(function() { jQuery('.sub-panels').each(function() { - var panels = this.getAttribute('data-panels').split(','), + var panels = [], + childNodes = jQuery('a[data-subpanel]', this).each(function() { + panels.push(this.getAttribute('data-subpanel')); + }), show_panel = this.getAttribute('data-show-panel'); if (panels.length) { diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 130824b7b3..5d4270c2d3 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -11,7 +11,7 @@ -
+
  • class="activetab"> {L_DISPLAY_OPTIONS} diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index c381cfe0ed..2e6f291913 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -193,7 +193,7 @@ -
    +
    • {L_OPTIONS}
    • {L_ADD_ATTACHMENT}
    • From 1d9794559354d7c52da7751e5d1fdcb17fe949e5 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 11 Jul 2013 11:00:04 -0400 Subject: [PATCH 4/4] [ticket/11563] Remove duplicate code PHPBB3-11563 --- phpBB/styles/prosilver/template/forum_fn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 0f11fd7b7a..1ab1387d10 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -117,7 +117,7 @@ jQuery(document).ready(function() { if (panels.length) { subPanels(show_panel); - jQuery('a[data-subpanel]', this).click(function () { + childNodes.click(function () { subPanels(this.getAttribute('data-subpanel')); return false; });