summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-07-07 16:34:40 -0400
committerJules Laplace <jules@okfoc.us>2015-07-07 16:34:40 -0400
commit600f28f73e13f5351f870833a0fd0dccba51afed (patch)
tree5fd957d6429cd96d105211b32e06a27170a081c0 /js
parent861b0f4906829c5d83d4f126e2c5f38cd99ee650 (diff)
remember state of certain tools
Diffstat (limited to 'js')
-rw-r--r--js/matrix.js2
-rw-r--r--js/tool.js1
-rw-r--r--js/ui/controls.js18
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++ }
diff --git a/js/tool.js b/js/tool.js
index 9404b1c..360e79f 100644
--- a/js/tool.js
+++ b/js/tool.js
@@ -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)