pixel-editor/js/_palettes.js

63 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-03-27 02:20:54 +03:00
//populate palettes list in new pixel menu
Object.keys(palettes).forEach(function(paletteName,index) {
2020-04-04 10:41:56 +03:00
var palettesMenu = document.getElementById('palette-menu');
2019-03-27 02:20:54 +03:00
//create button
2020-04-04 10:41:56 +03:00
var button = document.createElement('button');
2019-03-27 02:20:54 +03:00
button.appendChild(document.createTextNode(paletteName));
2020-04-04 10:41:56 +03:00
//insert new element
palettesMenu.appendChild(button);
//if the palette was specified by the user, change the dropdown to it
if (palettes[paletteName].specified == true) {
setText('palette-button', paletteName);
//Show empty palette option
document.getElementById('no-palette-button').style.display = 'block';
}
on('click', button, function() {
//hide the dropdown menu
deselect('palette-menu');
deselect('palette-button');
//show empty palette option
document.getElementById('no-palette-button').style.display = 'block';
//set the text of the dropdown to the newly selected preset
setText('palette-button', paletteName);
});
2019-03-27 02:20:54 +03:00
});
//select no palette
on('click', 'no-palette-button', function () {
2020-04-04 10:41:56 +03:00
document.getElementById('no-palette-button').style.display = 'none';
setText('palette-button', 'Choose a palette...');
2019-03-27 02:20:54 +03:00
});
//select load palette
on('click', 'load-palette-button', function () {
2020-04-04 10:41:56 +03:00
document.getElementById('load-palette-browse-holder').click();
2019-03-27 02:20:54 +03:00
});
on('click', 'palette-button', function (e){
2020-04-04 10:41:56 +03:00
toggle('palette-button');
toggle('palette-menu');
deselect('preset-button');
deselect('preset-menu');
e.stopPropagation();
2019-03-27 02:20:54 +03:00
});
on('click', 'new-pixel', function (){
deselect('editor-mode-menu');
2020-04-04 10:41:56 +03:00
deselect('preset-button');
deselect('preset-menu');
deselect('palette-button');
deselect('palette-menu');
});