2022-09-01 21:51:48 +02:00
|
|
|
import size from Config;
|
2022-07-24 11:20:22 +02:00
|
|
|
import * as Dom from UnitJS.Dom;
|
|
|
|
|
2022-07-26 19:39:06 +02:00
|
|
|
var toolbox;
|
2022-07-25 13:43:47 +02:00
|
|
|
var tool;
|
|
|
|
var colors;
|
2022-07-24 11:20:22 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
init: init,
|
2022-07-28 17:39:51 +02:00
|
|
|
get: get,
|
|
|
|
color: color,
|
|
|
|
tool: tool
|
2022-07-24 11:20:22 +02:00
|
|
|
};
|
|
|
|
|
2022-09-01 21:51:48 +02:00
|
|
|
function init(elementId) {
|
2022-07-26 19:39:06 +02:00
|
|
|
toolbox = document.getElementById(elementId || 'toolbox');
|
|
|
|
colors = toolbox.querySelector('#colors');
|
2022-07-25 13:43:47 +02:00
|
|
|
for(var i = 0; i < size; i++) {
|
|
|
|
colors.appendChild(Dom.make('option', {class: 'color' + i}));
|
2022-07-24 11:20:22 +02:00
|
|
|
}
|
2022-07-25 13:43:47 +02:00
|
|
|
colors.addEventListener('change', function() {
|
|
|
|
colors.className = color();
|
2022-07-24 11:20:22 +02:00
|
|
|
});
|
2022-07-26 19:39:06 +02:00
|
|
|
tool = toolbox.querySelector('#tool');
|
2022-07-24 11:20:22 +02:00
|
|
|
}
|
|
|
|
|
2022-07-28 17:39:51 +02:00
|
|
|
function get() {
|
|
|
|
return toolbox;
|
|
|
|
}
|
|
|
|
|
2022-07-25 13:43:47 +02:00
|
|
|
function tool() {
|
|
|
|
return tool.value;
|
2022-07-24 11:20:22 +02:00
|
|
|
}
|
|
|
|
|
2022-07-25 13:43:47 +02:00
|
|
|
function color() {
|
2022-08-04 22:32:43 +02:00
|
|
|
return colors.selectedIndex;
|
2022-07-24 11:20:22 +02:00
|
|
|
}
|