canvas input: add disabled option
This commit is contained in:
parent
909df06bd7
commit
2403ad2336
1 changed files with 26 additions and 22 deletions
|
|
@ -62,31 +62,35 @@
|
|||
|
||||
}
|
||||
|
||||
self.on('focus',function(){
|
||||
self.attr('tabindex','-1')
|
||||
var i = $('<input></input>')
|
||||
.prependTo(self)
|
||||
.val(self.value)
|
||||
.focus()
|
||||
.change(function(){
|
||||
self.val($(this).val())
|
||||
if (!options.disabled) {
|
||||
|
||||
self.on('focus',function(){
|
||||
self.attr('tabindex','-1')
|
||||
var i = $('<input></input>')
|
||||
.prependTo(self)
|
||||
.val(self.value)
|
||||
.focus()
|
||||
.change(function(){
|
||||
self.val($(this).val())
|
||||
i.blur()
|
||||
})
|
||||
i.blur(function(){
|
||||
self.attr('tabindex','0')
|
||||
i.remove()
|
||||
$(document).off('.fakeInput')
|
||||
})
|
||||
$(document).on('touchstart.fakeInput mousedown.fakeInput',function(e){
|
||||
if (e.originalEvent.target!=i[0] && !(e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents)) {
|
||||
i.blur()
|
||||
})
|
||||
i.blur(function(){
|
||||
self.attr('tabindex','0')
|
||||
i.remove()
|
||||
$(document).off('.fakeInput')
|
||||
})
|
||||
$(document).on('touchstart.fakeInput mousedown.fakeInput',function(e){
|
||||
if (e.originalEvent.target!=i[0] && !(e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents)) {
|
||||
i.blur()
|
||||
}
|
||||
}).on('keydown.fakeInput', function(e){
|
||||
if (e.keyCode==13) i.change()
|
||||
if (e.keyCode==27) i.off('change').blur()
|
||||
}
|
||||
}).on('keydown.fakeInput', function(e){
|
||||
if (e.keyCode==13) i.change()
|
||||
if (e.keyCode==27) i.off('change').blur()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
return self
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue