[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
kerjasama
/
assets
/
js
/
core
/
source
/
[
Home
]
File: AppNavSearch.js
(function (namespace, $) { "use strict"; var AppNavSearch = function () { // Create reference to this instance var o = this; // Initialize app when document is ready $(document).ready(function () { o.initialize(); }); }; var p = AppNavSearch.prototype; // ========================================================================= // MEMBERS // ========================================================================= p._clearSearchTimer = null; // ========================================================================= // INIT // ========================================================================= p.initialize = function () { this._enableEvents(); }; // ========================================================================= // EVENTS // ========================================================================= // events p._enableEvents = function () { var o = this; // Listen for the nav search button click $('.navbar-search .btn').on('click', function (e) { o._handleButtonClick(e); }); // When the search field loses focus $('.navbar-search input').on('blur', function (e) { o._handleFieldBlur(e); }); }; // ========================================================================= // NAV SEARCH // ========================================================================= p._handleButtonClick = function (e) { e.preventDefault(); var form = $(e.currentTarget).closest('form'); var input = form.find('input'); var keyword = input.val(); if ($.trim(keyword) === '') { // When there is no keyword, just open the bar form.addClass('expanded'); input.focus(); } else { // When there is a keyword, submit the keyword form.addClass('expanded'); form.submit(); // Clear the timer that removes the keyword clearTimeout(this._clearSearchTimer); } }; // ========================================================================= // FIELD BLUR // ========================================================================= p._handleFieldBlur = function (e) { // When the search field loses focus var input = $(e.currentTarget); var form = input.closest('form'); // Collapse the search field form.removeClass('expanded'); // Clear the textfield after 300 seconds (the time it takes to collapse the field) clearTimeout(this._clearSearchTimer); this._clearSearchTimer = setTimeout(function () { input.val(''); }, 300); }; // ========================================================================= // DEFINE NAMESPACE // ========================================================================= window.materialadmin.AppNavSearch = new AppNavSearch; }(this.materialadmin, jQuery)); // pass in (namespace, jQuery):