diff options
| -rw-r--r-- | js/matrix.js | 2 | ||||
| -rw-r--r-- | js/tool.js | 1 | ||||
| -rw-r--r-- | js/ui/controls.js | 18 |
3 files changed, 15 insertions, 6 deletions
diff --git a/js/matrix.js b/js/matrix.js index 649321a..f6d7e5a 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -188,7 +188,7 @@ Matrix.prototype.resize_rapper = function(){ var cell = canvas.aa[0][0].span var cw = cell.offsetWidth var ch = cell.offsetHeight - if (canvas.grid) { cw++; ch++ } +// if (canvas.grid) { ch++ } var width = cw * this.aa[0].length var height = ch * this.aa.length if (canvas.grid) { width++; height++ } @@ -33,6 +33,7 @@ var Checkbox = Tool.extend({ update: function(state){ if (state) this.el.innerHTML = "x " + this.name else this.el.innerHTML = "_ " + this.name + if (this.memorable) { localStorage.setItem("ascii.tools." + this.name, !! state) } } }) diff --git a/js/ui/controls.js b/js/ui/controls.js index 1c2a779..d89c7f6 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -89,14 +89,16 @@ var controls = (function(){ } controls.grid = new BlurredCheckbox (grid_el) - controls.grid.use = function(){ - document.body.classList.toggle('grid') - letters.grid = palette.grid = canvas.grid = document.body.classList.contains("grid") + controls.grid.memorable = true + controls.grid.use = function(state){ + state = typeof state == "boolean" ? state : ! document.body.classList.contains("grid") + document.body.classList[ state ? "add" : "remove" ]('grid') + letters.grid = palette.grid = canvas.grid = state canvas.resize_rapper() palette.resize_rapper() letters.resize_rapper() - if (!selection.hidden) selection.reposition() - this.update( document.body.classList.contains("grid") ) + if (! selection.hidden) selection.reposition() + this.update( state ) } ClipboardTool = Tool.extend({ @@ -176,6 +178,7 @@ var controls = (function(){ // controls.rotate = new BlurredCheckbox (rotate_checkbox) + controls.rotate.memorable = true controls.rotate.use = function(state){ canvas.rotated = typeof state == "boolean" ? state : ! canvas.rotated canvas.resize_rapper() @@ -185,6 +188,7 @@ var controls = (function(){ // controls.vertical = new BlurredCheckbox (vertical_checkbox) + controls.vertical.memorable = true controls.vertical.use = function(state){ canvas.vertical = typeof state == "boolean" ? state : ! canvas.vertical controls.vertical.refresh() @@ -246,6 +250,10 @@ var controls = (function(){ tool.span.addEventListener('mousedown', function(e){ tool.focus() }) + if (tool.memorable) { + console.log(tool.name, localStorage.getItem("ascii.tools." + tool.name) ) + tool.use( localStorage.getItem("ascii.tools." + tool.name) == "true" ) + } }) controls.width.key = keys.single_numeral_key(controls.width, brush, "w", 1, 10) |
