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');
|
2021-02-17 20:59:49 +03:00
|
|
|
var splashPalettes = document.getElementById('palette-menu-splash');
|
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
|
|
|
|
|
|
|
//if the palette was specified by the user, change the dropdown to it
|
|
|
|
if (palettes[paletteName].specified == true) {
|
|
|
|
setText('palette-button', paletteName);
|
2021-02-17 20:59:49 +03:00
|
|
|
setText('palette-button-splash', paletteName)
|
2020-04-04 10:41:56 +03:00
|
|
|
//Show empty palette option
|
|
|
|
document.getElementById('no-palette-button').style.display = 'block';
|
|
|
|
}
|
|
|
|
|
2021-02-17 20:59:49 +03:00
|
|
|
var buttonEvent = function() {
|
2020-04-04 10:41:56 +03:00
|
|
|
|
|
|
|
//hide the dropdown menu
|
|
|
|
deselect('palette-menu');
|
|
|
|
deselect('palette-button');
|
2021-02-17 20:59:49 +03:00
|
|
|
deselect('palette-menu-splash');
|
|
|
|
deselect('palette-button-splash');
|
2020-04-04 10:41:56 +03:00
|
|
|
|
|
|
|
//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);
|
2021-02-17 20:59:49 +03:00
|
|
|
setText('palette-button-splash', paletteName);
|
|
|
|
};
|
|
|
|
|
|
|
|
on('click', button, buttonEvent);
|
|
|
|
|
|
|
|
//insert new element
|
|
|
|
palettesMenu.appendChild(button);
|
|
|
|
|
|
|
|
// Making a copy for the splash page too
|
|
|
|
var copyButton = button.cloneNode(true);
|
|
|
|
// Attaching the same event
|
|
|
|
on('click', copyButton, buttonEvent);
|
|
|
|
// Appending it to the splash palette menu
|
|
|
|
splashPalettes.appendChild(copyButton);
|
2019-03-27 02:20:54 +03:00
|
|
|
});
|
|
|
|
|
2021-02-19 00:28:52 +03:00
|
|
|
var noPaletteButtonClickEvent = function () {
|
2020-04-04 10:41:56 +03:00
|
|
|
document.getElementById('no-palette-button').style.display = 'none';
|
|
|
|
setText('palette-button', 'Choose a palette...');
|
2021-02-19 00:28:52 +03:00
|
|
|
}
|
2021-02-17 20:59:49 +03:00
|
|
|
|
2021-02-19 00:28:52 +03:00
|
|
|
var loadPaletteButtonEvent = function () {
|
2020-04-04 10:41:56 +03:00
|
|
|
document.getElementById('load-palette-browse-holder').click();
|
2021-02-19 00:28:52 +03:00
|
|
|
}
|
2019-03-27 02:20:54 +03:00
|
|
|
|
2021-02-19 00:28:52 +03:00
|
|
|
var clickPaletteButtonEvent = function (e){
|
2020-04-04 10:41:56 +03:00
|
|
|
toggle('palette-button');
|
|
|
|
toggle('palette-menu');
|
|
|
|
|
|
|
|
deselect('preset-button');
|
|
|
|
deselect('preset-menu');
|
2021-02-17 20:59:49 +03:00
|
|
|
|
|
|
|
// Splash version
|
|
|
|
toggle('palette-button-splash');
|
|
|
|
toggle('palette-menu-splash');
|
|
|
|
|
2020-04-04 10:41:56 +03:00
|
|
|
e.stopPropagation();
|
2021-02-19 00:28:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//select no palette
|
|
|
|
on('click', 'no-palette-button', noPaletteButtonClickEvent);
|
|
|
|
|
|
|
|
//select load palette
|
|
|
|
on('click', 'load-palette-button', loadPaletteButtonEvent);
|
|
|
|
//select load palette
|
|
|
|
on('click', 'load-palette-button-splash', loadPaletteButtonEvent);
|
|
|
|
|
|
|
|
// Palette menu click
|
|
|
|
on('click', 'palette-button', clickPaletteButtonEvent);
|
|
|
|
on('click', 'palette-button-splash', clickPaletteButtonEvent);
|
2019-03-27 02:20:54 +03:00
|
|
|
|
|
|
|
on('click', 'new-pixel', function (){
|
2020-07-20 13:59:04 +03:00
|
|
|
deselect('editor-mode-menu');
|
2020-04-04 10:41:56 +03:00
|
|
|
deselect('preset-button');
|
|
|
|
deselect('preset-menu');
|
|
|
|
deselect('palette-button');
|
|
|
|
deselect('palette-menu');
|
2021-02-17 20:59:49 +03:00
|
|
|
|
|
|
|
// Splash version
|
|
|
|
deselect('palette-button-splash');
|
|
|
|
deselect('palette-menu-splash');
|
2021-02-19 00:28:52 +03:00
|
|
|
});
|