2016-03-16 13:38:01 -07:00
|
|
|
|
define([], function () {
|
2016-03-15 22:33:31 -07:00
|
|
|
|
|
|
|
|
|
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 07:25:18 -07:00
|
|
|
|
|
|
|
|
|
function searchMenu() {
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
self.show = function () {
|
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
require(['css!css/search.css'], function () {
|
2015-07-10 07:25:18 -07:00
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
document.querySelector('.headerSearchInput').value = '';
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
document.querySelector('.btnCloseSearch').classList.add('hide');
|
|
|
|
|
var elem = document.querySelector('.viewMenuSearch');
|
|
|
|
|
|
|
|
|
|
elem.classList.remove('hide');
|
|
|
|
|
|
|
|
|
|
var onFinish = function() {
|
|
|
|
|
document.querySelector('.headerSearchInput').focus();
|
|
|
|
|
document.querySelector('.btnCloseSearch').classList.remove('hide');
|
2015-12-14 08:43:03 -07:00
|
|
|
|
};
|
2016-03-16 13:38:01 -07:00
|
|
|
|
|
|
|
|
|
if (elem.animate) {
|
|
|
|
|
fadeIn(elem, 1).onfinish = onFinish;
|
|
|
|
|
} else {
|
|
|
|
|
onFinish();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-10 07:25:18 -07:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.hide = function () {
|
|
|
|
|
|
|
|
|
|
var viewMenuSearch = document.querySelector('.viewMenuSearch');
|
|
|
|
|
|
|
|
|
|
if (!viewMenuSearch) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!viewMenuSearch.classList.contains('hide')) {
|
2016-03-16 13:38:01 -07:00
|
|
|
|
document.querySelector('.btnCloseSearch').classList.add('hide');
|
2015-12-14 08:43:03 -07:00
|
|
|
|
viewMenuSearch.classList.add('hide');
|
2015-07-10 07:25:18 -07:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
document.querySelector('.viewMenuSearchForm').addEventListener('submit', function (e) {
|
|
|
|
|
e.preventDefault();
|
2015-07-10 07:25:18 -07:00
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
document.querySelector('.btnCloseSearch').addEventListener('click', function () {
|
2015-09-21 10:46:02 -07:00
|
|
|
|
self.hide();
|
2015-07-10 07:25:18 -07:00
|
|
|
|
Events.trigger(self, 'closed');
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
document.querySelector('.headerSearchInput').addEventListener('keyup', function (e) {
|
2015-07-10 07:25:18 -07:00
|
|
|
|
|
|
|
|
|
// Down key
|
|
|
|
|
if (e.keyCode == 40) {
|
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
e.preventDefault();
|
2015-07-10 07:25:18 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Events.trigger(self, 'change', [this.value]);
|
|
|
|
|
}
|
2016-03-16 13:38:01 -07:00
|
|
|
|
});
|
2015-07-10 07:25:18 -07:00
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
document.querySelector('.headerSearchInput').addEventListener('search', function (e) {
|
2015-07-10 07:25:18 -07:00
|
|
|
|
if (!this.value) {
|
|
|
|
|
Events.trigger(self, 'change', ['']);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.SearchMenu = new searchMenu();
|
2016-03-15 22:33:31 -07:00
|
|
|
|
return Window.SearchMenu;
|
|
|
|
|
});
|