Replace jquery in top-nav component (#2620)
This commit is contained in:
parent
c1a78d878e
commit
8e72e7fe5f
|
@ -3,7 +3,6 @@ import { mapActions } from 'vuex'
|
||||||
import FtInput from '../ft-input/ft-input.vue'
|
import FtInput from '../ft-input/ft-input.vue'
|
||||||
import FtSearchFilters from '../ft-search-filters/ft-search-filters.vue'
|
import FtSearchFilters from '../ft-search-filters/ft-search-filters.vue'
|
||||||
import FtProfileSelector from '../ft-profile-selector/ft-profile-selector.vue'
|
import FtProfileSelector from '../ft-profile-selector/ft-profile-selector.vue'
|
||||||
import $ from 'jquery'
|
|
||||||
import debounce from 'lodash.debounce'
|
import debounce from 'lodash.debounce'
|
||||||
import ytSuggest from 'youtube-suggest'
|
import ytSuggest from 'youtube-suggest'
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ export default Vue.extend({
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
component: this,
|
component: this,
|
||||||
windowWidth: 0,
|
showSearchContainer: true,
|
||||||
showFilters: false,
|
showFilters: false,
|
||||||
searchFilterValueChanged: false,
|
searchFilterValueChanged: false,
|
||||||
historyIndex: 1,
|
historyIndex: 1,
|
||||||
|
@ -77,11 +76,8 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
const appWidth = $(window).width()
|
if (window.innerWidth <= 680) {
|
||||||
|
this.showSearchContainer = false
|
||||||
if (appWidth <= 680) {
|
|
||||||
const searchContainer = $('.searchContainer').get(0)
|
|
||||||
searchContainer.style.display = 'none'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store is not up-to-date when the component mounts, so we use timeout.
|
// Store is not up-to-date when the component mounts, so we use timeout.
|
||||||
|
@ -91,31 +87,21 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|
||||||
window.addEventListener('resize', function (event) {
|
window.addEventListener('resize', () => {
|
||||||
const width = event.srcElement.innerWidth
|
this.showSearchContainer = window.innerWidth > 680
|
||||||
const searchContainer = $('.searchContainer').get(0)
|
|
||||||
|
|
||||||
if (width > 680) {
|
|
||||||
searchContainer.style.display = ''
|
|
||||||
} else {
|
|
||||||
searchContainer.style.display = 'none'
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.debounceSearchResults = debounce(this.getSearchSuggestions, 200)
|
this.debounceSearchResults = debounce(this.getSearchSuggestions, 200)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goToSearch: async function (query, { event }) {
|
goToSearch: async function (query, { event }) {
|
||||||
const appWidth = $(window).width()
|
|
||||||
const doCreateNewWindow = event && event.shiftKey
|
const doCreateNewWindow = event && event.shiftKey
|
||||||
|
|
||||||
if (appWidth <= 680) {
|
if (window.innerWidth <= 680) {
|
||||||
const searchContainer = $('.searchContainer').get(0)
|
this.$refs.searchContainer.blur()
|
||||||
searchContainer.blur()
|
this.showSearchContainer = false
|
||||||
searchContainer.style.display = 'none'
|
|
||||||
} else {
|
} else {
|
||||||
const searchInput = $('.searchInput input').get(0)
|
this.searchInput.blur()
|
||||||
searchInput.blur()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getYoutubeUrlInfo(query).then((result) => {
|
this.getYoutubeUrlInfo(query).then((result) => {
|
||||||
|
@ -204,7 +190,9 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
focusSearch: function () {
|
focusSearch: function () {
|
||||||
this.searchInput.focus()
|
if (!this.hideSearchBar) {
|
||||||
|
this.searchInput.focus()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getSearchSuggestionsDebounce: function (query) {
|
getSearchSuggestionsDebounce: function (query) {
|
||||||
|
@ -263,14 +251,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleSearchContainer: function () {
|
toggleSearchContainer: function () {
|
||||||
const searchContainer = $('.searchContainer').get(0)
|
this.showSearchContainer = !this.showSearchContainer
|
||||||
|
|
||||||
if (searchContainer.style.display === 'none') {
|
|
||||||
searchContainer.style.display = ''
|
|
||||||
} else {
|
|
||||||
searchContainer.style.display = 'none'
|
|
||||||
}
|
|
||||||
|
|
||||||
this.showFilters = false
|
this.showFilters = false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -281,8 +262,8 @@ export default Vue.extend({
|
||||||
navigateHistory: function() {
|
navigateHistory: function() {
|
||||||
if (!this.isForwardOrBack) {
|
if (!this.isForwardOrBack) {
|
||||||
this.historyIndex = window.history.length
|
this.historyIndex = window.history.length
|
||||||
$('#historyArrowBack').removeClass('fa-arrow-left')
|
this.$refs.historyArrowBack.classList.remove('fa-arrow-left')
|
||||||
$('#historyArrowForward').addClass('fa-arrow-right')
|
this.$refs.historyArrowForward.classList.add('fa-arrow-right')
|
||||||
} else {
|
} else {
|
||||||
this.isForwardOrBack = false
|
this.isForwardOrBack = false
|
||||||
}
|
}
|
||||||
|
@ -294,9 +275,9 @@ export default Vue.extend({
|
||||||
|
|
||||||
if (this.historyIndex > 1) {
|
if (this.historyIndex > 1) {
|
||||||
this.historyIndex--
|
this.historyIndex--
|
||||||
$('#historyArrowForward').removeClass('fa-arrow-right')
|
this.$refs.historyArrowForward.classList.remove('fa-arrow-right')
|
||||||
if (this.historyIndex === 1) {
|
if (this.historyIndex === 1) {
|
||||||
$('#historyArrowBack').addClass('fa-arrow-left')
|
this.$refs.historyArrowBack.classList.add('fa-arrow-left')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -307,10 +288,10 @@ export default Vue.extend({
|
||||||
|
|
||||||
if (this.historyIndex < window.history.length) {
|
if (this.historyIndex < window.history.length) {
|
||||||
this.historyIndex++
|
this.historyIndex++
|
||||||
$('#historyArrowBack').removeClass('fa-arrow-left')
|
this.$refs.historyArrowBack.classList.remove('fa-arrow-left')
|
||||||
|
|
||||||
if (this.historyIndex === window.history.length) {
|
if (this.historyIndex === window.history.length) {
|
||||||
$('#historyArrowForward').addClass('fa-arrow-right')
|
this.$refs.historyArrowForward.classList.add('fa-arrow-right')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
@keypress="toggleSideNav"
|
@keypress="toggleSideNav"
|
||||||
/>
|
/>
|
||||||
<font-awesome-icon
|
<font-awesome-icon
|
||||||
id="historyArrowBack"
|
ref="historyArrowBack"
|
||||||
class="navBackIcon navIcon fa-arrow-left"
|
class="navBackIcon navIcon fa-arrow-left"
|
||||||
:icon="['fas', 'arrow-left']"
|
:icon="['fas', 'arrow-left']"
|
||||||
role="button"
|
role="button"
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
@keypress="historyBack"
|
@keypress="historyBack"
|
||||||
/>
|
/>
|
||||||
<font-awesome-icon
|
<font-awesome-icon
|
||||||
id="historyArrowForward"
|
ref="historyArrowForward"
|
||||||
class="navForwardIcon navIcon fa-arrow-right"
|
class="navForwardIcon navIcon fa-arrow-right"
|
||||||
:icon="['fas', 'arrow-right']"
|
:icon="['fas', 'arrow-right']"
|
||||||
role="button"
|
role="button"
|
||||||
|
@ -65,9 +65,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="middle">
|
<div class="middle">
|
||||||
<div class="searchContainer">
|
<div
|
||||||
|
v-if="!hideSearchBar"
|
||||||
|
v-show="showSearchContainer"
|
||||||
|
ref="searchContainer"
|
||||||
|
class="searchContainer"
|
||||||
|
>
|
||||||
<ft-input
|
<ft-input
|
||||||
v-if="!hideSearchBar"
|
|
||||||
ref="searchInput"
|
ref="searchInput"
|
||||||
:placeholder="$t('Search / Go to URL')"
|
:placeholder="$t('Search / Go to URL')"
|
||||||
class="searchInput"
|
class="searchInput"
|
||||||
|
@ -80,7 +84,6 @@
|
||||||
@click="goToSearch"
|
@click="goToSearch"
|
||||||
/>
|
/>
|
||||||
<font-awesome-icon
|
<font-awesome-icon
|
||||||
v-if="!hideSearchBar"
|
|
||||||
class="navFilterIcon navIcon"
|
class="navFilterIcon navIcon"
|
||||||
:class="{ filterChanged: searchFilterValueChanged }"
|
:class="{ filterChanged: searchFilterValueChanged }"
|
||||||
:icon="['fas', 'filter']"
|
:icon="['fas', 'filter']"
|
||||||
|
|
Loading…
Reference in New Issue