mirror of https://github.com/Requarks/wiki.git
NGPixel
8 years ago
12 changed files with 171 additions and 65 deletions
Split View
Diff Options
-
2README.md
-
2assets/css/app.css
-
2assets/js/app.js
-
50assets/js/libs.js
-
24client/js/app.js
-
78client/js/components/search.js
-
6client/scss/layout/_base.scss
-
11client/scss/layout/_header.scss
-
1gulpfile.js
-
35models/search.js
-
7package.json
-
18views/common/header.pug
2
assets/css/app.css
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
assets/js/app.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
50
assets/js/libs.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,78 @@ |
|||
"use strict"; |
|||
|
|||
jQuery( document ).ready(function( $ ) { |
|||
|
|||
if($('#search-input').length) { |
|||
|
|||
$('#search-input').focus(); |
|||
|
|||
Vue.transition('slide', { |
|||
enterClass: 'slideInDown', |
|||
leaveClass: 'fadeOutUp' |
|||
}); |
|||
|
|||
$('.searchresults').css('display', 'block'); |
|||
|
|||
var vueHeader = new Vue({ |
|||
el: '#header-container', |
|||
data: { |
|||
searchq: '', |
|||
searchres: [], |
|||
searchsuggest: [], |
|||
searchload: 0, |
|||
searchactive: false, |
|||
searchmoveidx: 0, |
|||
searchmovekey: '', |
|||
searchmovearr: [] |
|||
}, |
|||
watch: { |
|||
searchq: (val, oldVal) => { |
|||
searchmoveidx: 0; |
|||
if(val.length >= 3) { |
|||
vueHeader.searchactive = true; |
|||
vueHeader.searchload++; |
|||
socket.emit('search', { terms: val }, (data) => { |
|||
vueHeader.searchres = data.match; |
|||
vueHeader.searchsuggest = data.suggest; |
|||
if(vueHeader.searchload > 0) { vueHeader.searchload--; } |
|||
}); |
|||
} else { |
|||
vueHeader.searchactive = false; |
|||
vueHeader.searchres = []; |
|||
vueHeader.searchsuggest = []; |
|||
vueHeader.searchload = 0; |
|||
} |
|||
}, |
|||
searchmoveidx: (val, oldVal) => { |
|||
|
|||
} |
|||
}, |
|||
methods: { |
|||
useSuggestion: (sug) => { |
|||
vueHeader.searchq = sug; |
|||
}, |
|||
closeSearch: () => { |
|||
vueHeader.searchq = ''; |
|||
vueHeader.searchactive = false; |
|||
}, |
|||
moveSelectSearch: () => { |
|||
|
|||
}, |
|||
moveDownSearch: () => { |
|||
if(vueHeader.searchmoveidx < vueHeader.searchmovearr) { |
|||
vueHeader.searchmoveidx++; |
|||
} |
|||
}, |
|||
moveUpSearch: () => { |
|||
if(vueHeader.searchmoveidx > 0) { |
|||
vueHeader.searchmoveidx--; |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
|
|||
$('main').on('click', vueHeader.closeSearch); |
|||
|
|||
} |
|||
|
|||
}); |
Write
Preview
Loading…
Cancel
Save