blob: c3fc67c65d06640bb7f26e493fa53d05faeae915 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
var Tool = Model({
init: function (span) {
this.el = span
this.lex = new Lex (span)
this.name = span.innerHTML
this.span = span
},
use: function(){},
done: function(){},
focus: function(){
// focused && focused.blur()
current_tool && current_tool.blur()
current_tool = this
this.span.classList.add('focused')
this.use()
if (this.name != 'shader' && is_desktop) { cursor_input.focus() }
},
blur: function(){
current_tool = null
this.span.classList.remove('focused')
this.done()
}
})
var FileTool = Tool.extend({
focus: function(){
if (current_filetool === this) {
this.blur()
return
}
current_filetool && current_filetool.blur()
current_filetool = this
this.span.classList.add('focused')
this.use()
console.log("focus")
if (this.name != 'shader' && is_desktop) { cursor_input.focus() }
},
blur: function(){
current_filetool = null
this.span.classList.remove('focused')
this.done()
}
})
var Checkbox = Tool.extend({
init: function (span){
this.__init(span)
var name = this.name.replace(/^[x_] /,"")
var state = localStorage.getItem("ascii." + name) || this.name[0] == "x"
this.name = name
this.update(state)
},
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) }
}
})
var BlurredCheckbox = Checkbox.extend({
focus: function(){
// if (current_filetool && current_filetool.name == "shader") {
// shader.toggle(false)
// current_tool.blur()
// current_tool = controls.circle
// }
this.use()
// if (this.name != 'shader' && is_desktop) { cursor_input.focus() }
},
blur: function(){
this.span.classList.remove('focused')
this.done()
}
})
var BlurredTool = Tool.extend({
focus: function(){
// if (current_filetool && current_filetool.name == "shader") {
// shader.toggle(false)
// current_tool.blur()
// current_tool = controls.circle
// }
this.use()
// if (this.name != 'shader' && is_desktop) { cursor_input.focus() }
},
blur: function(){
this.span.classList.remove('focused')
this.done()
}
})
var HiddenCheckbox = BlurredCheckbox.extend({
init: function (span){
this.el = span
this.lex = new Lex (span)
this.name = span.innerHTML
this.span = span
var state = this.name[0] == "o"
this.update(state)
},
update: function(state){
this.el.innerHTML = state ? "o" : "."
}
})
|