var SuperSearch = (function ($) { 'use strict'; var me = { config: { inputBuffer: 300 // in milliseconds }, storage: { $input: null, $overlay: null, $details: null, $results: null, $lastUpdate: null, debounceBuffer: null, hasResults: false, isOpen: false }, init: function () { me.storage.$input = $('#supersearch-input'); if (me.storage.$input.length === 0) { return; } me.registerEvents(); }, registerEvents: function () { me.storage.$input.on('keyup.SuperSearch', me.onKeyUpSearchInput); // Overlay anzeigen bei Focus in das Such-Eingabefeld; nur wenn es schon mal geöffnet war me.storage.$input.on('focus.SuperSearch', me.onFocusSearchInput); // Overlay mit ESC schließen $(document).bind('keydown', function(e) { if (me.storage.$overlay === null) { return; } if (me.storage.isOpen !== true) { return; } // ESC if (e.keyCode === 27) { me.hideOverlay(); } }); }, /** * @return {jQuery} */ getOverlay: function () { if (typeof me.storage.$overlay === 'undefined' || me.storage.$overlay === null) { me.storage.$overlay = me.createOverlay(); me.storage.$details = me.storage.$overlay.find('section.detail'); me.storage.$results = me.storage.$overlay.find('section.result'); me.storage.$lastUpdate = me.storage.$overlay.find('section.last-update'); } return me.storage.$overlay; }, showOverlay: function () { var $overlay = me.getOverlay(); $overlay.show(); me.storage.isOpen = true; me.showDetails(); }, hideOverlay: function () { me.getOverlay().hide(); me.storage.isOpen = false; }, /** * @return {jQuery} */ createOverlay: function () { var overlaySelector = '#supersearch-overlay'; if ($(overlaySelector).length > 0) { return $(overlaySelector); } var overlayTemplate = '' + '