clean fake input

This commit is contained in:
bordun 2016-06-17 16:21:56 +02:00
parent 498ba4a06a
commit 340500fb84

View file

@ -1,4 +1,3 @@
var startEvent = 'ontouchstart' in window ?'touchstart':'mousedown'
;(function ($) {
$.fn.fakeInput = function(options) {
@ -58,7 +57,7 @@ var startEvent = 'ontouchstart' in window ?'touchstart':'mousedown'
}
self.on('click focus',function(){
self.on('focus',function(){
self.attr('tabindex','-1')
var i = $('<input></input>')
.prependTo(self)
@ -74,8 +73,10 @@ var startEvent = 'ontouchstart' in window ?'touchstart':'mousedown'
i.remove()
$(document).off('.fakeInput')
})
$(document).on(startEvent+'.fakeInput',function(){
i.blur()
$(document).on('touchstart.fakeInput mousedown.fakeInput',function(e){
if (e.originalEvent.target!=i[0]) {
i.blur()
}
})
})