diff --git a/README.md b/README.md index f4860d6..82c787c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A lot of stuff isn't done yet: * Magnification * Free-Form Selection * Color Replacement with the "Eraser/Color Eraser" tool -* Lots of menu items +* Some menu items * Copying the selection to the clipboard (You can paste, though!) There's [a lot to do.](TODO.md) diff --git a/TODO.md b/TODO.md index 4bc8111..c0d6cca 100644 --- a/TODO.md +++ b/TODO.md @@ -36,13 +36,11 @@ * Flip / Rotate * Stretch / Skew * Draw Opaque - * Colors - * Edit Colors... * Help * Help Topics ✓ um... * About paint ✓ um...... * Enable items (Repeat, Clear Selection, Copy To...) when they are applicable - * Animation + * Sliding animation / transition effects * Image operations should apply to the selection if there is one @@ -88,7 +86,7 @@ * Scroll Wheel draws line down and to the right (um, this is a bug, though) -* CSS: buttons shouldn't need a class `.jspaint-button` +* CSS: buttons shouldn't need a class `.jspaint-button`; color cells shouldn't be buttons * JS: chill down on the global event handlers; they're interfering with inputs diff --git a/src/functions.js b/src/functions.js index 6512732..08e0eef 100644 --- a/src/functions.js +++ b/src/functions.js @@ -1,6 +1,7 @@ function reset_colors(){ - colors = ["black", "white", ""]; + // note: these need to be in the same format as in the palette to be counted as the same as the colors in the palette for Colors > Edit Colors... + colors = ["#000000", "#ffffff", ""]; $colorbox && $colorbox.update_colors(); } diff --git a/src/menus.js b/src/menus.js index 35d88e2..eafc4a3 100644 --- a/src/menus.js +++ b/src/menus.js @@ -346,7 +346,26 @@ $.each({ "&Colors": [ { item: "&Edit Colors...", - action: function(){} + action: function(){ + var input; + + // Note: MS Paint uses the last color cell selected as the foreground color, + // where I am instead finding color cells that match the current foreground color. + // If you select a color with the color picker that isn't in the palette it will fail. + // This implementation is therefore inferior. + + $(".jspaint-color-button input").each(function(){ + var button = this.parentElement; + var cs = document.querySelector(".jspaint-color-selection"); + if(getComputedStyle(button).backgroundColor === getComputedStyle(cs).backgroundColor){ + input = this; + return false;//break each loop + } + }); + + $(input).parent().trigger({type: "mousedown", ctrlKey: false, button: 0}); + $(input).trigger("click", "synthetic"); + } } ], "&Help": [ @@ -359,7 +378,7 @@ $.each({ $msgbox.$content.html( "

Sorry, no help is available at this time.

" + "
You can however try searching for tutorials for MS Paint." + - "
There will be differences, but it could help." + "
There will be differences, but the basics are there." ).css({padding: "15px"}); $msgbox.center(); }