From 7a34c7eabe4712333e3a96754a836949ecfe4306 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 11:55:04 +0300 Subject: [PATCH] [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 @@ - - -