mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-28 12:30:42 +02:00
[ticket/10810] Move the color palette code to core.js.
PHPBB3-10810
This commit is contained in:
@@ -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 += '<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
|
||||
*/
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user