Prevent blank names from being entered

This commit is contained in:
Dave Pedu 2015-02-08 23:46:05 -08:00
parent 3e1298302b
commit 7143c75df0
2 changed files with 30 additions and 1 deletions

View File

@ -81,6 +81,7 @@ function renderWindow(windowdata, winnum) {
var input = element('input', {
_parent: namestringspan,
value:name,
"data-original":name,
type:"text",
_onblur:function(ev){
if(ev && ev.keyCode) {
@ -88,7 +89,17 @@ function renderWindow(windowdata, winnum) {
return
}
}
if(this.value.trim().length==0) {
this.value = this.getAttribute("data-original")
this.focus()
this.setSelectionRange(0,9999)
this.classList.add("nope")
var theinput = this
setTimeout(function(){
theinput.classList.remove("nope")
}, 450)
return
}
console.log("Rename window #"+winnum+" to "+this.value)
tabbro.ui_rename_window(winnum, this.value)
namestringspan.innerHTML = this.value

View File

@ -72,6 +72,24 @@ body {
max-height: 700px;
overflow-y: auto;
}
@-webkit-keyframes nopenopenope {
0% {
left: 0px;
}
25% {
left: -10px;
}
75% {
left: 10px;
}
100% {
left: 0px;
}
}
.nope {
position: relative;
-webkit-animation: nopenopenope .15s linear 0s 3 normal;
}
/* Options panel appears on hove */