mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 07:16:38 +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
301a003549
commit
0f2a234ec4
@ -49,7 +49,7 @@ function bind () {
|
|||||||
var ae = document.activeElement
|
var ae = document.activeElement
|
||||||
|
|
||||||
if (ae !== import_textarea) {
|
if (ae !== import_textarea) {
|
||||||
if (is_desktop) cursor_input.focus()
|
cursor_input.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selecting) {
|
if (selecting) {
|
||||||
@ -61,17 +61,17 @@ function bind () {
|
|||||||
})
|
})
|
||||||
window.addEventListener("touchend", function(){
|
window.addEventListener("touchend", function(){
|
||||||
if (current_tool.name === "text") {
|
if (current_tool.name === "text") {
|
||||||
if (is_desktop) cursor_input.focus()
|
cursor_input.focus()
|
||||||
}
|
}
|
||||||
dragging = false
|
dragging = false
|
||||||
})
|
})
|
||||||
|
|
||||||
window.addEventListener('mousedown', function(e){
|
window.addEventListener('mousedown', function(e){
|
||||||
// if (is_desktop) { cursor_input.focus() }
|
// cursor_input.focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function(){
|
document.addEventListener('DOMContentLoaded', function(){
|
||||||
if (is_desktop) { cursor_input.focus() }
|
cursor_input.focus()
|
||||||
document.body.classList.remove('loading')
|
document.body.classList.remove('loading')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ var canvas = current_canvas = (function(){
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
lex.span.addEventListener('mousedown', function(e){
|
lex.span.addEventListener('mousedown', function(e){
|
||||||
if (is_mobile) return
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
dragging = true
|
dragging = true
|
||||||
current_canvas = canvas
|
current_canvas = canvas
|
||||||
@ -57,7 +56,6 @@ var canvas = current_canvas = (function(){
|
|||||||
lex.span.addEventListener("mousemove", function(e){
|
lex.span.addEventListener("mousemove", function(e){
|
||||||
mouse.x = x
|
mouse.x = x
|
||||||
mouse.y = y
|
mouse.y = y
|
||||||
if (is_mobile) return
|
|
||||||
if (! dragging) return
|
if (! dragging) return
|
||||||
if (drawing) {
|
if (drawing) {
|
||||||
draw.move(e, lex, point)
|
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
|
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){
|
].forEach(function(lex){
|
||||||
lex.span.addEventListener('mousedown', function(e){
|
lex.span.addEventListener('mousedown', function(e){
|
||||||
lex.focus()
|
lex.focus()
|
||||||
if (is_mobile) cursor_input.focus()
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ var Tool = Model({
|
|||||||
current_tool = this
|
current_tool = this
|
||||||
this.el.classList.add('focused')
|
this.el.classList.add('focused')
|
||||||
this.use()
|
this.use()
|
||||||
if (is_desktop) { cursor_input.focus() }
|
cursor_input.focus()
|
||||||
},
|
},
|
||||||
blur: function(){
|
blur: function(){
|
||||||
current_tool = null
|
current_tool = null
|
||||||
@ -45,7 +45,7 @@ var FileTool = Tool.extend({
|
|||||||
current_filetool = this
|
current_filetool = this
|
||||||
this.el.classList.add('focused')
|
this.el.classList.add('focused')
|
||||||
this.use()
|
this.use()
|
||||||
if (is_desktop) { cursor_input.focus() }
|
cursor_input.focus()
|
||||||
},
|
},
|
||||||
blur: function(){
|
blur: function(){
|
||||||
current_filetool = null
|
current_filetool = null
|
||||||
|
@ -190,10 +190,3 @@ function setSelectionRange(input, selectionStart, selectionEnd) {
|
|||||||
function setCaretToPos(input, pos) {
|
function setCaretToPos(input, pos) {
|
||||||
setSelectionRange(input, pos, 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.
|
7) feature: status bar w/ position, etc.
|
||||||
8) feature: zoom {in,out}
|
8) feature: zoom {in,out}
|
||||||
9) reimplement: {save,upload} as PNG & gallery, shaders (possibly)
|
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