forked from ChrisWren/touch-input-nav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
touch-input-nav.min.js
1 lines (1 loc) · 1.03 KB
/
touch-input-nav.min.js
1
!function(){"use strict";function a(){return window.navigator.userAgent.match(/iPhone|iPad|iPod/)?"iOSSafari":void 0}var b={iOSSafari:{touchEvent:"touchstart",styles:{input:{opacity:1},textarea:{opacity:1},select:{color:"black"}}}},c=function(c){var d=a();if(!d)return!1;var e=c||"input-disabled",f="";for(var g in b[d].styles){f+=g+":disabled."+e+"{";for(var h in b[d].styles[g])f+=h+":"+b[d].styles[g][h]+";";f+="}"}$("<style>",{id:"touch-input-nav-styles"}).html(f).appendTo("head");var i="input,select,textarea";$(document).on("focus",i,function(){var a=$(this),c=a.closest("form").find(i),f=$(i).not(c);f.prop("disabled",!0).addClass(e+" "+d),a.one("blur",function(){$(i).off(".input-disabled"),f.prop("disabled",!1).removeClass(e+" "+d)}),$(i).one(b[d].touchEvent+".input-disabled",function(){$(this).prop("disabled",!1)})})};"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(["jquery"],function(){return c}):"object"==typeof module&&module.exports?(require("jquery")(window),module.exports=c):window.touchInputNav=c}();