1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/searchmenu.js

86 lines
2 KiB
JavaScript
Raw Normal View History

2016-03-16 01:33:31 -04:00
define(['jQuery'], function ($) {
function fadeIn(elem, iterations) {
var keyframes = [
{ opacity: '0', offset: 0 },
{ opacity: '1', offset: 1 }];
var timing = { duration: 200, iterations: iterations };
return elem.animate(keyframes, timing);
}
2015-07-10 10:25:18 -04:00
function searchMenu() {
var self = this;
self.show = function () {
2016-03-16 01:33:31 -04:00
require(['css!css/search.css'], function () {
2015-12-14 10:43:03 -05:00
$('.headerSearchInput').val('');
2015-07-10 10:25:18 -04:00
$('.btnCloseSearch').hide();
2015-12-14 10:43:03 -05:00
var elem = $('.viewMenuSearch').removeClass('hide')[0];
fadeIn(elem, 1).onfinish = function () {
$('.headerSearchInput').focus();
$('.btnCloseSearch').show();
};
2015-07-10 10:25:18 -04:00
});
};
self.hide = function () {
var viewMenuSearch = document.querySelector('.viewMenuSearch');
if (!viewMenuSearch) {
return;
}
if (!viewMenuSearch.classList.contains('hide')) {
2015-12-14 10:43:03 -05:00
$('.btnCloseSearch').hide();
viewMenuSearch.classList.add('hide');
2015-07-10 10:25:18 -04:00
}
};
$('.viewMenuSearchForm').on('submit', function () {
return false;
});
$('.btnCloseSearch').on('click', function () {
2015-09-21 13:46:02 -04:00
self.hide();
2015-07-10 10:25:18 -04:00
Events.trigger(self, 'closed');
});
$('.headerSearchInput').on("keyup", function (e) {
// Down key
if (e.keyCode == 40) {
//var first = $('.card', panel)[0];
//if (first) {
// first.focus();
//}
return false;
} else {
Events.trigger(self, 'change', [this.value]);
}
}).on("search", function (e) {
if (!this.value) {
Events.trigger(self, 'change', ['']);
}
});
}
window.SearchMenu = new searchMenu();
2016-03-16 01:33:31 -04:00
return Window.SearchMenu;
});