mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 23:36:36 +00:00
assets/js/{app,ui/{canvas,controls,tool,util}}.js: remove is_{android,desktop,i{pad,phone},mobile}.
This commit is contained in:
parent
1e46357a6a
commit
07b0380242
@ -49,7 +49,7 @@ function bind () {
|
||||
var ae = document.activeElement
|
||||
|
||||
if (ae !== import_textarea) {
|
||||
if (is_desktop) cursor_input.focus()
|
||||
cursor_input.focus()
|
||||
}
|
||||
|
||||
if (selecting) {
|
||||
@ -61,17 +61,17 @@ function bind () {
|
||||
})
|
||||
window.addEventListener("touchend", function(){
|
||||
if (current_tool.name === "text") {
|
||||
if (is_desktop) cursor_input.focus()
|
||||
cursor_input.focus()
|
||||
}
|
||||
dragging = false
|
||||
})
|
||||
|
||||
window.addEventListener('mousedown', function(e){
|
||||
// if (is_desktop) { cursor_input.focus() }
|
||||
// cursor_input.focus()
|
||||
})
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
if (is_desktop) { cursor_input.focus() }
|
||||
cursor_input.focus()
|
||||
document.body.classList.remove('loading')
|
||||
})
|
||||
|
||||
|
@ -20,7 +20,6 @@ var canvas = current_canvas = (function(){
|
||||
e.preventDefault()
|
||||
})
|
||||
lex.span.addEventListener('mousedown', function(e){
|
||||
if (is_mobile) return
|
||||
e.preventDefault()
|
||||
dragging = true
|
||||
current_canvas = canvas
|
||||
@ -57,7 +56,6 @@ var canvas = current_canvas = (function(){
|
||||
lex.span.addEventListener("mousemove", function(e){
|
||||
mouse.x = x
|
||||
mouse.y = y
|
||||
if (is_mobile) return
|
||||
if (! dragging) return
|
||||
if (drawing) {
|
||||
draw.move(e, lex, point)
|
||||
@ -72,45 +70,6 @@ var canvas = current_canvas = (function(){
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
if (is_mobile) {
|
||||
canvas.rapper.addEventListener('touchstart', function(e){
|
||||
e.preventDefault()
|
||||
var x, y, point, lex
|
||||
x = (e.touches[0].pageX - canvas.rapper.offsetTop) / canvas.aa[0][0].span.offsetWidth
|
||||
y = (e.touches[0].pageY - canvas.rapper.offsetTop) / canvas.aa[0][0].span.offsetHeight
|
||||
x = ~~clamp(x, 0, canvas.aa[0].length-1)
|
||||
y = ~~clamp(y, 0, canvas.aa.length-1)
|
||||
point = [x,y]
|
||||
lex = canvas.aa[y][x]
|
||||
dragging = true
|
||||
if (drawing) {
|
||||
undo.new()
|
||||
draw.down(e, lex, point)
|
||||
}
|
||||
else if (filling) {
|
||||
undo.new()
|
||||
draw.fill(brush, x, y)
|
||||
}
|
||||
canvas.focus(x, y)
|
||||
})
|
||||
canvas.rapper.addEventListener("touchmove", function(e){
|
||||
e.preventDefault()
|
||||
var x, y, point, lex
|
||||
x = (e.touches[0].pageX - canvas.rapper.offsetTop) / canvas.aa[0][0].span.offsetWidth
|
||||
y = (e.touches[0].pageY - canvas.rapper.offsetTop) / canvas.aa[0][0].span.offsetHeight
|
||||
x = ~~clamp(x, 0, canvas.aa[0].length-1)
|
||||
y = ~~clamp(y, 0, canvas.aa.length-1)
|
||||
point = [x,y]
|
||||
lex = canvas.aa[y][x]
|
||||
if (! dragging) return
|
||||
if (drawing) {
|
||||
draw.move(e, lex, point)
|
||||
}
|
||||
canvas.focus(x, y)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
canvas.min = 1
|
||||
|
1
assets/js/ui/controls.js
vendored
1
assets/js/ui/controls.js
vendored
@ -269,7 +269,6 @@ var controls = (function(){
|
||||
].forEach(function(lex){
|
||||
lex.span.addEventListener('mousedown', function(e){
|
||||
lex.focus()
|
||||
if (is_mobile) cursor_input.focus()
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -26,7 +26,7 @@ var Tool = Model({
|
||||
current_tool = this
|
||||
this.el.classList.add('focused')
|
||||
this.use()
|
||||
if (is_desktop) { cursor_input.focus() }
|
||||
cursor_input.focus()
|
||||
},
|
||||
blur: function(){
|
||||
current_tool = null
|
||||
@ -45,7 +45,7 @@ var FileTool = Tool.extend({
|
||||
current_filetool = this
|
||||
this.el.classList.add('focused')
|
||||
this.use()
|
||||
if (is_desktop) { cursor_input.focus() }
|
||||
cursor_input.focus()
|
||||
},
|
||||
blur: function(){
|
||||
current_filetool = null
|
||||
|
@ -190,10 +190,3 @@ function setSelectionRange(input, selectionStart, selectionEnd) {
|
||||
function setCaretToPos(input, pos) {
|
||||
setSelectionRange(input, pos, pos);
|
||||
}
|
||||
|
||||
// Naive useragent detection pattern
|
||||
var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))
|
||||
var is_ipad = (navigator.userAgent.match(/iPad/i))
|
||||
var is_android = (navigator.userAgent.match(/Android/i))
|
||||
var is_mobile = is_iphone || is_ipad || is_android
|
||||
var is_desktop = ! is_mobile;
|
||||
|
@ -7,4 +7,4 @@
|
||||
7) feature: status bar w/ position, etc.
|
||||
8) feature: zoom {in,out}
|
||||
9) reimplement: {save,upload} as PNG & gallery, shaders (possibly)
|
||||
10) releases: merge w/ MiRCARTools (into asciiblaster,) provide signed release APK, set is_{iphone,ipad,android,mobile,desktop}
|
||||
10) releases: merge w/ MiRCARTools (into asciiblaster,) provide signed release APK
|
||||
|
Loading…
Reference in New Issue
Block a user