if (typeof (itsmo) == 'undefined') { var itsmo = {}; } if (typeof (itsmo.history) == 'undefined') { itsmo.history = {}; } itsmo.history.templateHistoryItem = "
  • \ \ \ [historyName]\ \
  • \ "; itsmo.history.selecting = false; itsmo.history.setFreewordInputBox = function (idInput, nameClassBox, callbacks) { var eInput = $('div #' + idInput); var eSuggestBox = $('div form div.' + nameClassBox); eInput.bind('focus', function () { if ($.trim(eInput.val()).length > 0) { itsmo.suggest.getSuggestion(); } else { itsmo.history.setHistorySearch(eSuggestBox); } }).blur(function () { if (!itsmo.history.selecting) { eSuggestBox.fadeOut('fast'); if (null != callbacks && undefined != callbacks && (typeof callbacks.blur != 'undefined')) { callbacks.blur(); } } }).bind('input',function (e) { if ($.trim(eInput.val()).length > 0) { if (itsmo.suggest.saveRequestSgt != null) { itsmo.suggest.saveRequestSgt.abort(); } itsmo.suggest.getSuggestion(); } else { itsmo.history.setHistorySearch(eSuggestBox); } return false; }).keydown(function (e){ if(e.keyCode == 40){ itsmo.history.selecting = true; $('div.suggestion ul').focus(); $('div.suggestion li:first-child').addClass('active'); } else if (e.keyCode == 38){ return false; } }); $('div.suggestion').on('keydown', 'ul', function (e) { if (e.keyCode == 40) { var lastActive = $(this).find('li.active'); if (lastActive.is(':last-child')){ return false; } lastActive.removeClass('active'); lastActive.next().addClass('active'); return false; } else if (e.keyCode == 38) { var lastActive = $(this).find('li.active'); if (lastActive.is(':first-child')){ return false; } lastActive.removeClass('active'); lastActive.prev().addClass('active'); return false; } }).on('keyup', 'ul', function (e) { if (e.keyCode == 13) { $(this).find('li.active').find('a').click(); return false; } }).on('blur', 'ul', function () { eSuggestBox.fadeOut('fast'); if (null != callbacks && undefined != callbacks && (typeof callbacks.blur != 'undefined')) { callbacks.blur(); } itsmo.history.selecting = false; }); }; //cookie => localstorage フォーマットも変更 itsmo.history.setHistorySearch = function (eSuggestBox) { var ulHtml = '"; eSuggestBox.html(ulHtml); if (ls_history.length > 0) { eSuggestBox.fadeIn('fast'); } else { eSuggestBox.hide(); } }else{ eSuggestBox.hide(); } }; itsmo.history.clickHistory = function(word, url, key, eInput){ $('#' + eInput).val(word); if(url != ''){ location.href = url; }else{ location.href = '/search/freeword/' + word ; } };