debian-mirror-gitlab/app/assets/javascripts/header_search/index.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-11-11 11:23:49 +05:30
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import HeaderSearchApp from './components/app.vue';
import createStore from './store';
Vue.use(Translate);
2022-05-07 20:08:51 +05:30
export const initHeaderSearchApp = (search = '') => {
2021-11-11 11:23:49 +05:30
const el = document.getElementById('js-header-search');
2022-07-16 23:28:13 +05:30
let navBarEl = null;
2021-11-11 11:23:49 +05:30
if (!el) {
return false;
}
2021-11-18 22:05:49 +05:30
const { searchPath, issuesPath, mrPath, autocompletePath } = el.dataset;
2021-11-11 11:23:49 +05:30
let { searchContext } = el.dataset;
searchContext = JSON.parse(searchContext);
return new Vue({
el,
2022-05-07 20:08:51 +05:30
store: createStore({ searchPath, issuesPath, mrPath, autocompletePath, searchContext, search }),
2022-07-16 23:28:13 +05:30
mounted() {
navBarEl = document.querySelector('.header-content');
},
2021-11-11 11:23:49 +05:30
render(createElement) {
2022-07-16 23:28:13 +05:30
return createElement(HeaderSearchApp, {
on: {
2022-08-27 11:52:29 +05:30
expandSearchBar: () => {
navBarEl?.classList.add('header-search-is-active');
},
collapseSearchBar: () => {
navBarEl?.classList.remove('header-search-is-active');
2022-07-16 23:28:13 +05:30
},
},
});
2021-11-11 11:23:49 +05:30
},
});
};