UNPKG

jquery-inputsearch

Version:

jQuery plugin for automagically transforming input[type="text"] elements into input[type="search"]-like elements

73 lines (59 loc) 4.49 kB
// modules are defined as an array // [ module function, map of requires ] // // map of requires is short require name -> numeric require // // anything defined in a previous bundle is accessed via the // orig method which is the require for previous bundles require = (function (modules, cache, entry) { // Save the require from previous bundle to this closure if any var previousRequire = typeof require === "function" && require; function newRequire(name, jumped) { if (!cache[name]) { if (!modules[name]) { // if we cannot find the module within our internal map or // cache jump to the current global require ie. the last bundle // that was added to the page. var currentRequire = typeof require === "function" && require; if (!jumped && currentRequire) { return currentRequire(name, true); } // If there are other bundles on this page the require from the // previous one is saved to 'previousRequire'. Repeat this as // many times as there are bundles until the module is found or // we exhaust the require chain. if (previousRequire) { return previousRequire(name, true); } var err = new Error('Cannot find module \'' + name + '\''); err.code = 'MODULE_NOT_FOUND'; throw err; } localRequire.resolve = resolve; var module = cache[name] = new newRequire.Module; modules[name][0].call(module.exports, localRequire, module, module.exports); } return cache[name].exports; function localRequire(x){ return newRequire(localRequire.resolve(x)); } function resolve(x){ return modules[name][1][x] || x; } } function Module() { this.bundle = newRequire; this.exports = {}; } newRequire.Module = Module; newRequire.modules = modules; newRequire.cache = cache; newRequire.parent = previousRequire; for (var i = 0; i < entry.length; i++) { newRequire(entry[i]); } // Override the current require with this new one return newRequire; })({1:[function(require,module,exports) { "use strict";var i=Object.assign||function(i){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(i[e]=s[e])}return i};!function(t){t.fn.inputSearch=function(s){var e="\n data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAASkl\n EQVR42mNwZcAPGeitQMn1PxwqYVMAktAHQxALqwJ9V15XDiDWx62AA0hzYFegjt8ESajjcLhB\n Csn9WH0BEdTBHQ4gackBigsAp89pbWKQMm4AAAAASUVORK5CYII=\n ",r="\n data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAdkl\n EQVR42pWRPQ7AIAiFuVknFk9hwuxZXBwdvCkFa9X607R5Azzel6gICO+C74DBhFyUxA2Aq+Et\n 1wNmilWmATEPSDqtIJ3W2AAugUb0nPQAl5CqnwCbnd0BV2hXR4TlJUMDcPlM7BdFU0zjqg/0N\n fTi/n/WRic9QaXT/imcNgAAAABJRU5ErkJggg==\n ",n=i({},t.fn.inputSearch.defaults,s),a=void 0;return window.MutationObserver&&(a=new MutationObserver(function(i){i.forEach(function(i){t(i.target).data().refreshWrapperVisibility()})})),this.filter("input").each(function(i,s){var c=t("<div>").addClass("jqis-input-wrapper").css({display:"inline-block",position:"relative"}),A=t("<img>").addClass("jqis-icon-search").attr({src:e}).css({position:"absolute",width:16,height:16,visibility:n.searchIconVisible?"visible":"hidden"}).on("click",function(i){t(i.currentTarget).hasClass("jqis-icon-clear")&&(l.val("").focus().triggerHandler("input"),n.onClear())}),l=t(s).data({refreshWrapperVisibility:function(){l.parent(".jqis-input-wrapper").css({display:l.css("display"),visibility:l.css("visibility"),opacity:l.css("opacity")})}}).on("input",function(i){var s=t(i.currentTarget).val(),a=A.attr("src");s.length>0?a!==r&&A.attr("src",r).toggleClass("jqis-icon-search",!1).toggleClass("jqis-icon-clear",!0).css({cursor:"pointer",visibility:"visible"}):a!==e&&A.attr("src",e).toggleClass("jqis-icon-search",!0).toggleClass("jqis-icon-clear",!1).css({cursor:"auto",visibility:n.searchIconVisible?"visible":"hidden"})}).wrap(c).after(A).show(),o=A.outerWidth()+4,p=parseFloat(l.css("width"))-o,g=l.position(),u=g.top,h=g.left;l.css({paddingRight:o,width:p}),A.css({top:u+2,left:h+p+4}),a?a.observe(l[0],{attributeFilter:["style"]}):setInterval(function(){return l.data().refreshWrapperVisibility()},200),l.is(":visible")||l.hide(),l.triggerHandler("input")})},t.fn.inputSearch.defaults={searchIconVisible:!0,onClear:t.noop}}(jQuery); },{}]},{},[1])