From 0a2e2217c9724ed4f174203a9780a50663c823c6 Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Thu, 6 Sep 2012 23:10:02 +0200 Subject: [PATCH 1/3] Fixed regression on color-picker --- js/Palette.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/Palette.js b/js/Palette.js index e0ff02a8..07afa45e 100644 --- a/js/Palette.js +++ b/js/Palette.js @@ -53,10 +53,10 @@ pskl.Palette = (function() { var onPaletteColorClick_ = function (event) { var selectedColor = $(event.target).data("color"); if (event.which == 1) { // left button - updateColorPicker(selectedColor, $('#color-picker')[0]); + updateColorPicker(selectedColor, $('#color-picker')); $.publish(Events.COLOR_SELECTED, [selectedColor, true]); } else if (event.which == 3) { // right button - updateColorPicker(selectedColor, $('#secondary-color-picker')[0]); + updateColorPicker(selectedColor, $('#secondary-color-picker')); $.publish(Events.COLOR_SELECTED, [selectedColor, false]); } }; @@ -72,10 +72,10 @@ pskl.Palette = (function() { // The colorpicker can't be set to a transparent state. // We set its background to white and insert the // string "TRANSPARENT" to mimic this state: - colorPicker.color.fromString("#fff"); + colorPicker[0].color.fromString("#fff"); colorPicker.val(Constants.TRANSPARENT_COLOR); } else { - colorPicker.color.fromString(color); + colorPicker[0].color.fromString(color); } } From 9f36462d96a786bda5aa09ac527ea694a948f09d Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Thu, 6 Sep 2012 23:12:35 +0200 Subject: [PATCH 2/3] Fixed small bug with transparent color in palette --- js/Palette.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/Palette.js b/js/Palette.js index 07afa45e..7f1ffb6c 100644 --- a/js/Palette.js +++ b/js/Palette.js @@ -36,7 +36,7 @@ pskl.Palette = (function() { * @private */ var addColorToPalette_ = function (color) { - if (paletteColors.indexOf(color) == -1) { + if (paletteColors.indexOf(color) == -1 && color != Constants.TRANSPARENT_COLOR) { var colorEl = document.createElement("li"); colorEl.className = "palette-color"; colorEl.setAttribute("data-color", color); From 14bf3f97c50c1ed4005fb1f0d735439a28086cf1 Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Fri, 7 Sep 2012 00:56:31 +0200 Subject: [PATCH 3/3] fixed bug when reaching stage 0 --- js/model/Frame.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/model/Frame.js b/js/model/Frame.js index 346ea412..19e52064 100644 --- a/js/model/Frame.js +++ b/js/model/Frame.js @@ -3,7 +3,7 @@ ns.Frame = function (pixels) { this.pixels = pixels; - this.previousStates = [pixels]; + this.previousStates = [this._clonePixels()]; this.stateIndex = 0; }; @@ -56,7 +56,7 @@ }; ns.Frame.prototype.containsPixel = function (col, row) { - return col >= 0 && row >= 0 && col <= this.pixels.length && row <= this.pixels[0].length; + return col >= 0 && row >= 0 && col < this.pixels.length && row < this.pixels[0].length; }; ns.Frame.prototype.saveState = function () { @@ -69,10 +69,10 @@ }; ns.Frame.prototype.loadPreviousState = function () { - if (this.stateIndex >= 0) { + if (this.stateIndex > 0) { this.stateIndex--; this.pixels = this.previousStates[this.stateIndex]; - } + } }; ns.Frame.prototype.loadNextState = function () {