mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge pull request #90 from grosbouddha/clean-framesheet-reset
Fix broken palette when switching tiles
This commit is contained in:
commit
f18a9114fc
@ -17,12 +17,19 @@
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ns.PaletteController.prototype.createPalette_ = function (colors) {
|
||||
ns.PaletteController.prototype.createPaletteMarkup_ = function (colors) {
|
||||
// Always adding transparent color
|
||||
this.paletteRoot.html('<span class="palette-color transparent-color" data-color="TRANSPARENT" title="Transparent"></span>');
|
||||
for(var color in colors) {
|
||||
|
||||
for(var i=0, l=this.paletteColors.length; i<l; i++) {
|
||||
if(color != Constants.TRANSPARENT_COLOR) {
|
||||
this.addColorToPalette_(color);
|
||||
var color = this.paletteColors[i];
|
||||
var colorEl = document.createElement("li");
|
||||
colorEl.className = "palette-color";
|
||||
colorEl.setAttribute("data-color", color);
|
||||
colorEl.setAttribute("title", color);
|
||||
colorEl.style.background = color;
|
||||
this.paletteRoot.append(colorEl);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -32,16 +39,19 @@
|
||||
*/
|
||||
ns.PaletteController.prototype.addColorToPalette_ = function (color) {
|
||||
if (this.paletteColors.indexOf(color) == -1 && color != Constants.TRANSPARENT_COLOR) {
|
||||
var colorEl = document.createElement("li");
|
||||
colorEl.className = "palette-color";
|
||||
colorEl.setAttribute("data-color", color);
|
||||
colorEl.setAttribute("title", color);
|
||||
colorEl.style.background = color;
|
||||
this.paletteRoot.append(colorEl);
|
||||
this.paletteColors.push(color);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ns.PaletteController.prototype.addColorsToPalette_ = function (colors) {
|
||||
for(var color in colors) {
|
||||
this.addColorToPalette_(color);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@ -86,16 +96,19 @@
|
||||
this.framesheet = framesheet;
|
||||
|
||||
// Initialize palette:
|
||||
this.createPalette_(this.framesheet.getUsedColors());
|
||||
this.addColorsToPalette_(this.framesheet.getUsedColors());
|
||||
this.createPaletteMarkup_();
|
||||
|
||||
$.subscribe(Events.FRAMESHEET_RESET, $.proxy(function(evt) {
|
||||
this.createPalette_(this.framesheet.getUsedColors());
|
||||
this.addColorsToPalette_(this.framesheet.getUsedColors());
|
||||
this.createPaletteMarkup_();
|
||||
}, this));
|
||||
|
||||
this.paletteRoot.mouseup($.proxy(this.onPaletteColorClick_, this));
|
||||
|
||||
$.subscribe(Events.COLOR_SELECTED, $.proxy(function(evt, color) {
|
||||
this.addColorToPalette_(color);
|
||||
this.createPaletteMarkup_();
|
||||
}, this));
|
||||
|
||||
// Initialize colorpickers:
|
||||
|
Loading…
Reference in New Issue
Block a user