From 0385d163647f954062ef6ccb511602e8e69fc1d1 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 12 Nov 2013 23:57:27 -0800 Subject: [PATCH] [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 */