aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/assets/javascript
diff options
context:
space:
mode:
authorCesar G <prototech91@gmail.com>2013-11-12 23:57:27 -0800
committerCesar G <prototech91@gmail.com>2013-11-12 23:57:27 -0800
commit0385d163647f954062ef6ccb511602e8e69fc1d1 (patch)
treeb1b90ba0ffbd8e9db74d97aec6df7469142ba020 /phpBB/assets/javascript
parent37f73f86e2c332fdaa89a6fe015e45f65c068a6f (diff)
downloadforums-0385d163647f954062ef6ccb511602e8e69fc1d1.tar
forums-0385d163647f954062ef6ccb511602e8e69fc1d1.tar.gz
forums-0385d163647f954062ef6ccb511602e8e69fc1d1.tar.bz2
forums-0385d163647f954062ef6ccb511602e8e69fc1d1.tar.xz
forums-0385d163647f954062ef6ccb511602e8e69fc1d1.zip
[ticket/10810] Move the color palette code to core.js.
PHPBB3-10810
Diffstat (limited to 'phpBB/assets/javascript')
-rw-r--r--phpBB/assets/javascript/core.js57
-rw-r--r--phpBB/assets/javascript/editor.js61
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
@@ -963,6 +963,55 @@ phpbb.registerDropdown = function(toggle, dropdown, options)
};
/**
+* 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 += '<table>';
+
+ for (r = 0; r < 5; r++) {
+ if (dir == 'h') {
+ html += '<tr>';
+ }
+
+ for (g = 0; g < 5; g++) {
+ if (dir == 'v') {
+ html += '<tr>';
+ }
+
+ for (b = 0; b < 5; b++) {
+ color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
+ html += '<td style="background-color: #' + color + '; width: ' + width + 'px; height: ' + height + 'px;">';
+ html += '<a href="#" onclick="bbfontstyle(\'[color=#' + color + ']\', \'[/color]\'); return false;" style="display: block; width: ' + width + 'px; height: ' + height + 'px; " alt="#' + color + '" title="#' + color + '"></a>';
+ html += '</td>';
+ }
+
+ if (dir == 'v') {
+ html += '</tr>';
+ }
+ }
+
+ if (dir == 'h') {
+ html += '</tr>';
+ }
+ }
+ html += '</table>';
+ return html;
+}
+
+/**
* Apply code editor to all textarea elements with data-bbcode attribute
*/
$(document).ready(function() {
@@ -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
@@ -295,67 +295,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 += '<table>';
-
- for (r = 0; r < 5; r++) {
- if (dir == 'h') {
- html += '<tr>';
- }
-
- for (g = 0; g < 5; g++) {
- if (dir == 'v') {
- html += '<tr>';
- }
-
- for (b = 0; b < 5; b++) {
- color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
- html += '<td style="background-color: #' + color + '; width: ' + width + 'px; height: ' + height + 'px;">';
- html += '<a href="#" onclick="bbfontstyle(\'[color=#' + color + ']\', \'[/color]\'); return false;" style="display: block; width: ' + width + 'px; height: ' + height + 'px; " alt="#' + color + '" title="#' + color + '"></a>';
- html += '</td>';
- }
-
- if (dir == 'v') {
- html += '</tr>';
- }
- }
-
- if (dir == 'h') {
- html += '</tr>';
- }
- }
- html += '</table>';
- 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
*/
function caretPosition() {