/** | |
* RD Search | |
* @version 1.0.0 | |
* @author Evgeniy Gusarov (Stmechanus | Diversant) | |
* @license CC3.0 Non-Comercial License | |
*/ | |
!function (t, e, a, n) { | |
var r = function (e, a) { | |
this.$element = t(e), this.options = t.extend({}, r.Defaults, a), this.initialize() | |
}; | |
r.Defaults = {handler: "bat/rd-search.php", maxLive: 5}, r.prototype.initialize = function () { | |
function e(t) { | |
n.html(t) | |
} | |
var a = this, n = t(".rd-navbar-search-results"); | |
if (t(".rd-navbar-search-form-input").find("input").val("").on("keyup input propertychange", function () { | |
var e = t(this).val().trim(); | |
"" !== e ? t.get(a.options.handler, { | |
s: e, | |
liveSearch: "true", | |
liveCount: a.options.maxLive, | |
dataType: "html" | |
}, function (e) { | |
t(".rd-navbar-live-search-results").html(e).addClass("not-empty") | |
}) : t(".rd-navbar-live-search-results").html("").removeClass("not-empty") | |
}), n.length) { | |
var r = location.search.replace(/^\?.*s=([^&]+)/, "$1"); | |
t.get(a.options.handler, {s: decodeURI(r), liveSearch: "false", dataType: "html"}, e) | |
} | |
}, t.fn.RDSearch = function (e) { | |
return this.each(function () { | |
t(this).data("rdsearch") || t(this).data("rdsearch", new r(this, e)) | |
}) | |
}, t.fn.RDSearch.Constructor = r | |
}(window.jQuery, window, document); |