Plugins: Fix browse button on iOS

This commit is contained in:
KatieFrogs 2022-03-16 19:04:51 +03:00
parent a7aee747a8
commit b9d990a643
3 changed files with 26 additions and 10 deletions

View File

@ -452,3 +452,20 @@ kbd{
#dropzone.dragover{
opacity: 1;
}
.plugin-browse-button{
position: relative;
}
#plugin-browse{
position: absolute;
font-size: inherit;
top: -0.1em;
left: -0.1em;
right: -0.1em;
bottom: -0.1em;
border-radius: 0.5em;
opacity: 0;
cursor: pointer;
}
#plugin-browse::-webkit-file-upload-button{
cursor: pointer;
}

View File

@ -97,7 +97,7 @@ var plugins
var noResizeRoot = false
pageEvents.add(root, ["touchstart", "touchmove", "touchend"], event => {
if(event.cancelable && cancelTouch && event.target.tagName !== "SELECT"){
if(event.cancelable && cancelTouch && event.target.tagName !== "SELECT" && (event.target.tagName !== "INPUT" || event.target.type !== "file")){
event.preventDefault()
}
})

View File

@ -384,24 +384,22 @@ class SettingsView{
if(this.customSettings){
var form = document.createElement("form")
this.browse = document.createElement("input")
this.browse.id = "browse"
this.browse.id = "plugin-browse"
this.browse.type = "file"
this.browse.multiple = true
this.browse.accept = ".taikoweb.js"
pageEvents.add(this.browse, "change", this.browseChange.bind(this))
form.appendChild(this.browse)
loader.screen.appendChild(form)
this.browseButton = document.createElement("div")
this.browseButton.classList.add("taibtn", "stroke-sub")
this.browseButton.classList.add("taibtn", "stroke-sub", "plugin-browse-button")
this.browseText = document.createTextNode("")
this.browseButton.appendChild(this.browseText)
this.browseButton.appendChild(form)
this.defaultButton.parentNode.insertBefore(this.browseButton, this.defaultButton)
this.items.push({
id: "browse",
settingBox: this.browseButton
})
this.addTouch(this.browseButton, () => {
this.playSound("se_don")
this.browse.click()
})
}
this.showDefault = !this.customSettings || plugins.allPlugins.filter(obj => obj.plugin.imported).length
if(this.showDefault){
@ -1189,7 +1187,8 @@ class SettingsView{
this.setAltText(this.viewTitle, this.customSettings ? strings.plugins.title : strings.gameSettings)
this.setAltText(this.endButton, strings.settings.ok)
if(this.customSettings){
this.setAltText(this.browseButton, strings.plugins.browse)
this.browseText.data = strings.plugins.browse
this.browseButton.setAttribute("alt", strings.plugins.browse)
}else{
this.setAltText(this.gamepadTitle, strings.settings.gamepadLayout.name)
this.setAltText(this.gamepadEndButton, strings.settings.ok)
@ -1263,9 +1262,9 @@ class SettingsView{
}
if(this.customSettings){
pageEvents.remove(this.browse, "change")
this.removeTouch(this.browseButton)
delete this.browse
delete this.browseButton
delete this.browseText
}else{
this.removeTouch(this.gamepadSettings)
this.removeTouch(this.gamepadEndButton)