From 0385d163647f954062ef6ccb511602e8e69fc1d1 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 12 Nov 2013 23:57:27 -0800 Subject: [PATCH 1/4] [ticket/10810] Move the color palette code to core.js. PHPBB3-10810 --- phpBB/assets/javascript/core.js | 57 +++++++++++++++++++++++++++++ phpBB/assets/javascript/editor.js | 61 ------------------------------- 2 files changed, 57 insertions(+), 61 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index a3a6d75dd2..a5931d5e90 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -962,6 +962,55 @@ phpbb.registerDropdown = function(toggle, dropdown, options) toggle.click(phpbb.toggleDropdown); }; +/** +* Get the HTML for a color palette table +*/ +phpbb.colorPalette = function(dir, width, height) { + var r = 0, + g = 0, + b = 0, + numberList = new Array(6), + color = '', + html = ''; + + numberList[0] = '00'; + numberList[1] = '40'; + numberList[2] = '80'; + numberList[3] = 'BF'; + numberList[4] = 'FF'; + + html += ''; + + for (r = 0; r < 5; r++) { + if (dir == 'h') { + html += ''; + } + + for (g = 0; g < 5; g++) { + if (dir == 'v') { + html += ''; + } + + for (b = 0; b < 5; b++) { + color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); + html += ''; + } + + if (dir == 'v') { + html += ''; + } + } + + if (dir == 'h') { + html += ''; + } + } + html += '
'; + html += ''; + html += '
'; + return html; +} + /** * Apply code editor to all textarea elements with data-bbcode attribute */ @@ -977,6 +1026,14 @@ $(document).ready(function() { $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); } }); + + $('#color_palette_placeholder').each(function() { + var orientation = $(this).attr('data-orientation'), + height = $(this).attr('data-height'), + width = $(this).attr('data-width'); + + $(this).html(phpbb.colorPalette(orientation, width, height)); + }); }); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/assets/javascript/editor.js b/phpBB/assets/javascript/editor.js index 418dd163aa..5222de9fee 100644 --- a/phpBB/assets/javascript/editor.js +++ b/phpBB/assets/javascript/editor.js @@ -294,67 +294,6 @@ function storeCaret(textEl) { } } -/** -* Color pallette -*/ -function colorPalette(dir, width, height) { - var r = 0, - g = 0, - b = 0, - numberList = new Array(6), - color = '', - html = ''; - - numberList[0] = '00'; - numberList[1] = '40'; - numberList[2] = '80'; - numberList[3] = 'BF'; - numberList[4] = 'FF'; - - html += ''; - - for (r = 0; r < 5; r++) { - if (dir == 'h') { - html += ''; - } - - for (g = 0; g < 5; g++) { - if (dir == 'v') { - html += ''; - } - - for (b = 0; b < 5; b++) { - color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); - html += ''; - } - - if (dir == 'v') { - html += ''; - } - } - - if (dir == 'h') { - html += ''; - } - } - html += '
'; - html += ''; - html += '
'; - return html; -} - -(function($) { - $(document).ready(function() { - $('#color_palette_placeholder').each(function() { - var orientation = $(this).attr('data-orientation'), - height = $(this).attr('data-height'), - width = $(this).attr('data-width'); - - $(this).html(colorPalette(orientation, width, height)); - }); - }); -})(jQuery); - /** * Caret Position object */ From 9a9669bebd3edcb3dde7459660eece3a73856cf6 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 13 Nov 2013 00:14:35 -0800 Subject: [PATCH 2/4] [ticket/10810] Make the color palette usable outside of the editor context. PHPBB3-10810 --- phpBB/assets/javascript/core.js | 50 +++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index a5931d5e90..69a09427fe 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -963,7 +963,11 @@ phpbb.registerDropdown = function(toggle, dropdown, options) }; /** -* Get the HTML for a color palette table +* Get the HTML for a color palette table. +* +* @param string dir Palette direction - either v or h +* @param int width Palette cell width. +* @param int height Palette cell height. */ phpbb.colorPalette = function(dir, width, height) { var r = 0, @@ -979,7 +983,7 @@ phpbb.colorPalette = function(dir, width, height) { numberList[3] = 'BF'; numberList[4] = 'FF'; - html += ''; + html += '
'; for (r = 0; r < 5; r++) { if (dir == 'h') { @@ -994,7 +998,7 @@ phpbb.colorPalette = function(dir, width, height) { for (b = 0; b < 5; b++) { color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); html += ''; } @@ -1011,6 +1015,40 @@ phpbb.colorPalette = function(dir, width, height) { return html; } +/** +* Register a color palette. +* +* @param object el jQuery object for the palette container. +*/ +phpbb.registerPalette = function(el) { + var orientation = el.attr('data-orientation'), + height = el.attr('data-height'), + width = el.attr('data-width'), + target = el.attr('data-target'), + bbcode = el.attr('data-bbcode'); + + // Insert the palette HTML into the container. + el.html(phpbb.colorPalette(orientation, width, height)); + + // Add toggle control. + $('#color_palette_toggle').click(function(e) { + el.toggle(); + e.preventDefault(); + }); + + // Attach event handler when a palette cell is clicked. + $(el).on('click', 'a', function(e) { + var color = $(this).attr('data-color'); + + if (bbcode) { + bbfontstyle('[color=#' + color + ']', '[/color]'); + } else { + $(target).val(color); + } + e.preventDefault(); + }); +} + /** * Apply code editor to all textarea elements with data-bbcode attribute */ @@ -1028,11 +1066,7 @@ $(document).ready(function() { }); $('#color_palette_placeholder').each(function() { - var orientation = $(this).attr('data-orientation'), - height = $(this).attr('data-height'), - width = $(this).attr('data-width'); - - $(this).html(phpbb.colorPalette(orientation, width, height)); + phpbb.registerPalette($(this)); }); }); From c5680ca8227915ff7fc5f56bb4c4e9fd42b08e20 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 13 Nov 2013 01:24:37 -0800 Subject: [PATCH 3/4] [ticket/10810] Update all palettes. PHPBB3-10810 --- phpBB/adm/style/acp_groups.html | 7 ++++++- phpBB/adm/style/acp_users_signature.html | 2 +- phpBB/styles/prosilver/template/posting_buttons.html | 2 +- phpBB/styles/prosilver/template/ucp_groups_manage.html | 7 ++++++- phpBB/styles/prosilver/theme/common.css | 5 +++++ phpBB/styles/prosilver/theme/forms.css | 5 ----- phpBB/styles/subsilver2/template/posting_body.html | 2 +- phpBB/styles/subsilver2/template/ucp_groups_manage.html | 6 +++++- phpBB/styles/subsilver2/template/ucp_main_drafts.html | 2 +- 9 files changed, 26 insertions(+), 12 deletions(-) diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index a77010b636..925d24f3a3 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -92,7 +92,12 @@

{L_GROUP_COLOR_EXPLAIN}
-
      [ {L_COLOUR_SWATCH} ]
+
+ +        + [ {L_COLOUR_SWATCH} ] + +
diff --git a/phpBB/adm/style/acp_users_signature.html b/phpBB/adm/style/acp_users_signature.html index cfcab155bd..0a04c411d2 100644 --- a/phpBB/adm/style/acp_users_signature.html +++ b/phpBB/adm/style/acp_users_signature.html @@ -86,7 +86,7 @@
-
+
diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html index aa269058cc..c5cdfad156 100644 --- a/phpBB/styles/prosilver/template/posting_buttons.html +++ b/phpBB/styles/prosilver/template/posting_buttons.html @@ -55,7 +55,7 @@ diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html index 019b5aa3e1..eb431e9f3f 100644 --- a/phpBB/styles/prosilver/template/ucp_groups_manage.html +++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html @@ -54,7 +54,12 @@

{L_GROUP_COLOR_EXPLAIN}
-
    [ {L_COLOUR_SWATCH} ]
+
+ +     + [ {L_COLOUR_SWATCH} ] + +
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 225673a932..de55b8188f 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -631,6 +631,11 @@ table.info tbody th { margin: 0 -1px; } +#color_palette_placeholder table { + border-collapse: separate; + border-spacing: 1px; +} + /* Misc layout styles ---------------------------------------- */ /* column[1-2] styles are containers for two column layouts diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css index 1ee364ce93..755ce4a19d 100644 --- a/phpBB/styles/prosilver/theme/forms.css +++ b/phpBB/styles/prosilver/theme/forms.css @@ -235,11 +235,6 @@ fieldset.submit-buttons input { /* Posting page styles ----------------------------------------*/ -#colour_palette table { - border-collapse: separate; - border-spacing: 1px; -} - /* Buttons used in the editor */ #format-buttons { margin: 15px 0 2px 0; diff --git a/phpBB/styles/subsilver2/template/posting_body.html b/phpBB/styles/subsilver2/template/posting_body.html index 79c0fa2dbb..b501c4146a 100644 --- a/phpBB/styles/subsilver2/template/posting_body.html +++ b/phpBB/styles/subsilver2/template/posting_body.html @@ -207,7 +207,7 @@
- diff --git a/phpBB/styles/subsilver2/template/ucp_groups_manage.html b/phpBB/styles/subsilver2/template/ucp_groups_manage.html index b8e7e29481..1499f90eaf 100644 --- a/phpBB/styles/subsilver2/template/ucp_groups_manage.html +++ b/phpBB/styles/subsilver2/template/ucp_groups_manage.html @@ -49,7 +49,11 @@ - + diff --git a/phpBB/styles/subsilver2/template/ucp_main_drafts.html b/phpBB/styles/subsilver2/template/ucp_main_drafts.html index 0206c7c613..d63d678250 100644 --- a/phpBB/styles/subsilver2/template/ucp_main_drafts.html +++ b/phpBB/styles/subsilver2/template/ucp_main_drafts.html @@ -75,7 +75,7 @@
'; - html += ''; + html += ''; html += '
+

{L_GROUP_COLOR_EXPLAIN}
  [ {L_COLOUR_SWATCH} ] +    + [ {L_COLOUR_SWATCH} ] + +
-
+
From 97915b467ed2a0f15805b43155eb24ac8b326c35 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 13 Nov 2013 01:27:24 -0800 Subject: [PATCH 4/4] [ticket/10810] Remove obsolete swatch code. PHPBB3-10810 --- phpBB/adm/style/colour_swatch.html | 82 ------------------------------ phpBB/adm/swatch.php | 50 ------------------ phpBB/includes/acp/acp_groups.php | 1 - phpBB/includes/ucp/ucp_groups.php | 1 - 4 files changed, 134 deletions(-) delete mode 100644 phpBB/adm/style/colour_swatch.html delete mode 100644 phpBB/adm/swatch.php diff --git a/phpBB/adm/style/colour_swatch.html b/phpBB/adm/style/colour_swatch.html deleted file mode 100644 index e692a8bd91..0000000000 --- a/phpBB/adm/style/colour_swatch.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - -{L_COLOUR_SWATCH} - - - - - - - - - - diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php deleted file mode 100644 index e9d46d65b5..0000000000 --- a/phpBB/adm/swatch.php +++ /dev/null @@ -1,50 +0,0 @@ -session_begin(false); -$auth->acl($user->data); -$user->setup(); - -// Set custom template for admin area -$template->set_custom_style('adm', $phpbb_admin_path . 'style'); - -$template->set_filenames(array( - 'body' => 'colour_swatch.html') -); - -$form = request_var('form', ''); -$name = request_var('name', ''); - -// We validate form and name here, only id/class allowed -$form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; -$name = (!preg_match('/^[a-z0-9_-]+$/i', $name)) ? '' : $name; - -$template->assign_vars(array( - 'OPENER' => $form, - 'NAME' => $name, - 'T_IMAGES_PATH' => "{$phpbb_root_path}images/", - - 'S_USER_LANG' => $user->lang['USER_LANG'], - 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], - 'S_CONTENT_ENCODING' => 'UTF-8', -)); - -$template->display('body'); - -garbage_collection(); diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index ad29a5521b..6ad1f12813 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -657,7 +657,6 @@ class acp_groups 'GROUP_HIDDEN' => $type_hidden, 'U_BACK' => $u_back, - 'U_SWATCH' => append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=settings&name=group_colour'), 'U_ACTION' => "{$this->u_action}&action=$action&g=$group_id", 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), )); diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index a75d2e9bfc..1d08a8263b 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -699,7 +699,6 @@ class ucp_groups 'GROUP_CLOSED' => $type_closed, 'GROUP_HIDDEN' => $type_hidden, - 'U_SWATCH' => append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=ucp&name=group_colour'), 'S_UCP_ACTION' => $this->u_action . "&action=$action&g=$group_id", 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), ));