From 385420c8f5697b1978ebd1bdfcd138d5ce88b98a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Apr 2014 20:40:21 +0200 Subject: [PATCH 1/6] [ticket/12372] Use jQuery in javascript dE() function PHPBB3-12372 --- phpBB/styles/prosilver/template/forum_fn.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index de51b54e9b..7d114d9593 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -93,19 +93,23 @@ function viewableArea(e, itself) { /** * Set display of page element -* s[-1,0,1] = hide,toggle display,show -* type = string: inline, block, inline-block or other CSS "display" type +* +* @param string id The ID of the element to change +* @param int action Set to 0 if element display should be toggled, -1 for +* hiding the element, and 1 for showing it. +* @param string type Display type that should be used, e.g. inline, block or +* other CSS "display" types */ -function dE(n, s, type) { +function dE(id, action, type) { if (!type) { type = 'block'; } - var e = document.getElementById(n); - if (!s) { - s = (e.style.display === '' || e.style.display === type) ? -1 : 1; + var display = jQuery('#' + id).css('display'); + if (!action) { + action = (display === '' || display === type) ? -1 : 1; } - e.style.display = (s === 1) ? type : 'none'; + jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); } /** From ad98a070c37a66f773851851888f7e98dc447d92 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Apr 2014 20:43:32 +0200 Subject: [PATCH 2/6] [ticket/12372] Unify definition of function dE() across all files PHPBB3-12372 --- phpBB/adm/style/install_header.html | 22 ++++++++++-------- phpBB/adm/style/overall_header.html | 22 ++++++++++-------- phpBB/adm/style/simple_header.html | 22 ++++++++++-------- .../template/ucp_prefs_personal.html | 23 ++++++++++++------- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/phpBB/adm/style/install_header.html b/phpBB/adm/style/install_header.html index 99b98ef068..4980fd36fb 100644 --- a/phpBB/adm/style/install_header.html +++ b/phpBB/adm/style/install_header.html @@ -13,21 +13,23 @@ /** * Set display of page element -* s[-1,0,1] = hide,toggle display,show +* +* @param string id The ID of the element to change +* @param int action Set to 0 if element display should be toggled, -1 for +* hiding the element, and 1 for showing it. +* @param string type Display type that should be used, e.g. inline, block or +* other CSS "display" types */ -function dE(n, s, type) -{ - if (!type) - { +function dE(id, action, type) { + if (!type) { type = 'block'; } - var e = document.getElementById(n); - if (!s) - { - s = (e.style.display == '' || e.style.display == 'block') ? -1 : 1; + var display = jQuery('#' + id).css('display'); + if (!action) { + action = (display === '' || display === type) ? -1 : 1; } - e.style.display = (s == 1) ? type : 'none'; + jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); } // ]]> diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index 7e7f0cecee..668c0f4e92 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -37,21 +37,23 @@ function jumpto() /** * Set display of page element -* s[-1,0,1] = hide,toggle display,show +* +* @param string id The ID of the element to change +* @param int action Set to 0 if element display should be toggled, -1 for +* hiding the element, and 1 for showing it. +* @param string type Display type that should be used, e.g. inline, block or +* other CSS "display" types */ -function dE(n, s, type) -{ - if (!type) - { +function dE(id, action, type) { + if (!type) { type = 'block'; } - var e = document.getElementById(n); - if (!s) - { - s = (e.style.display == '') ? -1 : 1; + var display = jQuery('#' + id).css('display'); + if (!action) { + action = (display === '' || display === type) ? -1 : 1; } - e.style.display = (s == 1) ? type : 'none'; + jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); } /** diff --git a/phpBB/adm/style/simple_header.html b/phpBB/adm/style/simple_header.html index 770b7da8a6..01757f1032 100644 --- a/phpBB/adm/style/simple_header.html +++ b/phpBB/adm/style/simple_header.html @@ -50,21 +50,23 @@ function jumpto() /** * Set display of page element -* s[-1,0,1] = hide,toggle display,show +* +* @param string id The ID of the element to change +* @param int action Set to 0 if element display should be toggled, -1 for +* hiding the element, and 1 for showing it. +* @param string type Display type that should be used, e.g. inline, block or +* other CSS "display" types */ -function dE(n, s, type) -{ - if (!type) - { +function dE(id, action, type) { + if (!type) { type = 'block'; } - var e = document.getElementById(n); - if (!s) - { - s = (e.style.display == '') ? -1 : 1; + var display = jQuery('#' + id).css('display'); + if (!action) { + action = (display === '' || display === type) ? -1 : 1; } - e.style.display = (s == 1) ? type : 'none'; + jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); } /** diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index cd5fc9a13f..3499f5ef9a 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -4,16 +4,23 @@ // Date: Mon, 7 Apr 2014 21:27:48 +0200 Subject: [PATCH 3/6] [ticket/12372] Move dE() function core.js PHPBB3-12372 --- phpBB/adm/style/install_header.html | 28 ------------------- phpBB/adm/style/overall_header.html | 21 -------------- phpBB/adm/style/simple_footer.html | 2 ++ phpBB/adm/style/simple_header.html | 21 -------------- phpBB/assets/javascript/core.js | 21 ++++++++++++++ phpBB/styles/prosilver/template/forum_fn.js | 21 -------------- .../template/ucp_prefs_personal.html | 21 -------------- 7 files changed, 23 insertions(+), 112 deletions(-) diff --git a/phpBB/adm/style/install_header.html b/phpBB/adm/style/install_header.html index 4980fd36fb..a8f7009e4b 100644 --- a/phpBB/adm/style/install_header.html +++ b/phpBB/adm/style/install_header.html @@ -7,34 +7,6 @@ {PAGE_TITLE} - - - diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index 668c0f4e92..774df48917 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -35,27 +35,6 @@ function jumpto() } } -/** -* Set display of page element -* -* @param string id The ID of the element to change -* @param int action Set to 0 if element display should be toggled, -1 for -* hiding the element, and 1 for showing it. -* @param string type Display type that should be used, e.g. inline, block or -* other CSS "display" types -*/ -function dE(id, action, type) { - if (!type) { - type = 'block'; - } - - var display = jQuery('#' + id).css('display'); - if (!action) { - action = (display === '' || display === type) ? -1 : 1; - } - jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); -} - /** * Mark/unmark checkboxes * id = ID of parent container, name = name prefix, state = state [true/false] diff --git a/phpBB/adm/style/simple_footer.html b/phpBB/adm/style/simple_footer.html index a559b25b72..c549a2df4e 100644 --- a/phpBB/adm/style/simple_footer.html +++ b/phpBB/adm/style/simple_footer.html @@ -18,6 +18,8 @@ + + diff --git a/phpBB/adm/style/simple_header.html b/phpBB/adm/style/simple_header.html index 01757f1032..8950c4c394 100644 --- a/phpBB/adm/style/simple_header.html +++ b/phpBB/adm/style/simple_header.html @@ -48,27 +48,6 @@ function jumpto() } } -/** -* Set display of page element -* -* @param string id The ID of the element to change -* @param int action Set to 0 if element display should be toggled, -1 for -* hiding the element, and 1 for showing it. -* @param string type Display type that should be used, e.g. inline, block or -* other CSS "display" types -*/ -function dE(id, action, type) { - if (!type) { - type = 'block'; - } - - var display = jQuery('#' + id).css('display'); - if (!action) { - action = (display === '' || display === type) ? -1 : 1; - } - jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); -} - /** * Mark/unmark checkboxes * id = ID of parent container, name = name prefix, state = state [true/false] diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index aa9dc9af82..ccb031de24 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1061,6 +1061,27 @@ phpbb.registerPalette = function(el) { }); } +/** +* Set display of page element +* +* @param string id The ID of the element to change +* @param int action Set to 0 if element display should be toggled, -1 for +* hiding the element, and 1 for showing it. +* @param string type Display type that should be used, e.g. inline, block or +* other CSS "display" types +*/ +function dE(id, action, type) { + if (!type) { + type = 'block'; + } + + var display = jQuery('#' + id).css('display'); + if (!action) { + action = (display === '' || display === type) ? -1 : 1; + } + jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); +} + /** * Apply code editor to all textarea elements with data-bbcode attribute */ diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 7d114d9593..96f665492d 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -91,27 +91,6 @@ function viewableArea(e, itself) { } } -/** -* Set display of page element -* -* @param string id The ID of the element to change -* @param int action Set to 0 if element display should be toggled, -1 for -* hiding the element, and 1 for showing it. -* @param string type Display type that should be used, e.g. inline, block or -* other CSS "display" types -*/ -function dE(id, action, type) { - if (!type) { - type = 'block'; - } - - var display = jQuery('#' + id).css('display'); - if (!action) { - action = (display === '' || display === type) ? -1 : 1; - } - jQuery('#' + id).css('display', ((action === 1) ? type : 'none')); -} - /** * Alternate display of subPanels */ diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index 3499f5ef9a..47e43cafba 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -2,27 +2,6 @@ From 91a1c3af901f51d79751b733e48e8bcddc81d263 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Apr 2014 21:42:30 +0200 Subject: [PATCH 4/6] [ticket/12372] Rename JS function dE() to phpbb.toggleDisplay() PHPBB3-12372 --- phpBB/adm/style/acp_forums.html | 44 +++++++++---------- phpBB/adm/style/acp_modules.html | 4 +- phpBB/adm/style/acp_ranks.html | 4 +- phpBB/adm/style/acp_send_statistics.html | 12 ++--- phpBB/adm/style/acp_users_overview.html | 4 +- phpBB/adm/style/acp_users_prefs.html | 2 +- phpBB/adm/style/install_update.html | 2 +- phpBB/adm/style/permissions.js | 12 ++--- phpBB/assets/javascript/core.js | 2 +- phpBB/includes/functions_posting.php | 2 +- .../prosilver/template/posting_buttons.html | 2 +- .../template/ucp_prefs_personal.html | 6 +-- .../template/ucp_prefs_personal.html | 2 +- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index 0bb5e10f57..822d1c5f35 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -14,45 +14,45 @@ if (value == {FORUM_POST}) { - dE('type_actions', -1); + phpbb.toggleDisplay('type_actions', -1); } else { - dE('type_actions', 1); + phpbb.toggleDisplay('type_actions', 1); } if (value == {FORUM_LINK}) { - dE('cat_to_link_actions', 1); + phpbb.toggleDisplay('cat_to_link_actions', 1); } else { - dE('cat_to_link_actions', -1); + phpbb.toggleDisplay('cat_to_link_actions', -1); } if (value == {FORUM_POST}) { - dE('forum_post_options', 1); - dE('forum_link_options', -1); - dE('forum_rules_options', 1); - dE('forum_cat_options', -1); + phpbb.toggleDisplay('forum_post_options', 1); + phpbb.toggleDisplay('forum_link_options', -1); + phpbb.toggleDisplay('forum_rules_options', 1); + phpbb.toggleDisplay('forum_cat_options', -1); } else if (value == {FORUM_LINK}) { - dE('forum_post_options', -1); - dE('forum_link_options', 1); - dE('forum_rules_options', -1); - dE('forum_cat_options', -1); + phpbb.toggleDisplay('forum_post_options', -1); + phpbb.toggleDisplay('forum_link_options', 1); + phpbb.toggleDisplay('forum_rules_options', -1); + phpbb.toggleDisplay('forum_cat_options', -1); } else if (value == {FORUM_CAT}) { - dE('forum_post_options', -1); - dE('forum_link_options', -1); - dE('forum_rules_options', 1); - dE('forum_cat_options', 1); + phpbb.toggleDisplay('forum_post_options', -1); + phpbb.toggleDisplay('forum_link_options', -1); + phpbb.toggleDisplay('forum_rules_options', 1); + phpbb.toggleDisplay('forum_cat_options', 1); } } @@ -64,30 +64,30 @@ { - dE('type_actions', -1); + phpbb.toggleDisplay('type_actions', -1); - dE('cat_to_link_actions', -1); + phpbb.toggleDisplay('cat_to_link_actions', -1); - dE('forum_post_options', -1); + phpbb.toggleDisplay('forum_post_options', -1); - dE('forum_cat_options', -1); + phpbb.toggleDisplay('forum_cat_options', -1); - dE('forum_link_options', -1); + phpbb.toggleDisplay('forum_link_options', -1); - dE('forum_rules_options', -1); + phpbb.toggleDisplay('forum_rules_options', -1); } diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index c7688a610c..3c97706e6a 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -10,11 +10,11 @@ { if (value == 'category') { - dE('modoptions', -1); + phpbb.toggleDisplay('modoptions', -1); } else { - dE('modoptions', 1); + phpbb.toggleDisplay('modoptions', 1); } } diff --git a/phpBB/adm/style/acp_ranks.html b/phpBB/adm/style/acp_ranks.html index be68dda695..dd2d07a837 100644 --- a/phpBB/adm/style/acp_ranks.html +++ b/phpBB/adm/style/acp_ranks.html @@ -35,8 +35,8 @@
-
-
+
+