Update top nav search input to open new window on shift click/enter (#2427)
* * Update search input shift click to open new window * - Remove unused import Probably auto added by IDE...
This commit is contained in:
parent
b6740acc37
commit
cb63b12caf
|
@ -95,13 +95,13 @@ export default Vue.extend({
|
||||||
setTimeout(this.addListener, 200)
|
setTimeout(this.addListener, 200)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClick: function () {
|
handleClick: function (e) {
|
||||||
// No action if no input text
|
// No action if no input text
|
||||||
if (!this.inputDataPresent) { return }
|
if (!this.inputDataPresent) { return }
|
||||||
|
|
||||||
this.searchState.showOptions = false
|
this.searchState.showOptions = false
|
||||||
this.$emit('input', this.inputData)
|
this.$emit('input', this.inputData)
|
||||||
this.$emit('click', this.inputData)
|
this.$emit('click', this.inputData, { event: e })
|
||||||
},
|
},
|
||||||
|
|
||||||
handleInput: function (val) {
|
handleInput: function (val) {
|
||||||
|
@ -185,7 +185,7 @@ export default Vue.extend({
|
||||||
if (inputElement !== null) {
|
if (inputElement !== null) {
|
||||||
inputElement.addEventListener('keydown', (event) => {
|
inputElement.addEventListener('keydown', (event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
this.handleClick()
|
this.handleClick(event)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,9 @@ export default Vue.extend({
|
||||||
this.debounceSearchResults = debounce(this.getSearchSuggestions, 200)
|
this.debounceSearchResults = debounce(this.getSearchSuggestions, 200)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goToSearch: async function (query) {
|
goToSearch: async function (query, { event }) {
|
||||||
const appWidth = $(window).width()
|
const appWidth = $(window).width()
|
||||||
|
const doCreateNewWindow = event && event.shiftKey
|
||||||
|
|
||||||
if (appWidth <= 680) {
|
if (appWidth <= 680) {
|
||||||
const searchContainer = $('.searchContainer').get(0)
|
const searchContainer = $('.searchContainer').get(0)
|
||||||
|
@ -133,9 +134,10 @@ export default Vue.extend({
|
||||||
if (playlistId && playlistId.length > 0) {
|
if (playlistId && playlistId.length > 0) {
|
||||||
query.playlistId = playlistId
|
query.playlistId = playlistId
|
||||||
}
|
}
|
||||||
this.$router.push({
|
this.openInternalPath({
|
||||||
path: `/watch/${videoId}`,
|
path: `/watch/${videoId}`,
|
||||||
query: query
|
query,
|
||||||
|
doCreateNewWindow
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -153,9 +155,10 @@ export default Vue.extend({
|
||||||
case 'search': {
|
case 'search': {
|
||||||
const { searchQuery, query } = result
|
const { searchQuery, query } = result
|
||||||
|
|
||||||
this.$router.push({
|
this.openInternalPath({
|
||||||
path: `/search/${encodeURIComponent(searchQuery)}`,
|
path: `/search/${encodeURIComponent(searchQuery)}`,
|
||||||
query
|
query,
|
||||||
|
doCreateNewWindow
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -176,23 +179,25 @@ export default Vue.extend({
|
||||||
case 'channel': {
|
case 'channel': {
|
||||||
const { channelId, idType, subPath } = result
|
const { channelId, idType, subPath } = result
|
||||||
|
|
||||||
this.$router.push({
|
this.openInternalPath({
|
||||||
path: `/channel/${channelId}/${subPath}`,
|
path: `/channel/${channelId}/${subPath}`,
|
||||||
query: { idType }
|
query: { idType },
|
||||||
|
doCreateNewWindow
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'invalid_url':
|
case 'invalid_url':
|
||||||
default: {
|
default: {
|
||||||
this.$router.push({
|
this.openInternalPath({
|
||||||
path: `/search/${encodeURIComponent(query)}`,
|
path: `/search/${encodeURIComponent(query)}`,
|
||||||
query: {
|
query: {
|
||||||
sortBy: this.searchSettings.sortBy,
|
sortBy: this.searchSettings.sortBy,
|
||||||
time: this.searchSettings.time,
|
time: this.searchSettings.time,
|
||||||
type: this.searchSettings.type,
|
type: this.searchSettings.type,
|
||||||
duration: this.searchSettings.duration
|
duration: this.searchSettings.duration
|
||||||
}
|
},
|
||||||
|
doCreateNewWindow
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,6 +323,27 @@ export default Vue.extend({
|
||||||
this.$store.commit('toggleSideNav')
|
this.$store.commit('toggleSideNav')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
openInternalPath: function({ path, doCreateNewWindow, query = {} }) {
|
||||||
|
if (this.usingElectron && doCreateNewWindow) {
|
||||||
|
const { ipcRenderer } = require('electron')
|
||||||
|
|
||||||
|
// Combine current document path and new "hash" as new window startup URL
|
||||||
|
const newWindowStartupURL = [
|
||||||
|
window.location.href.split('#')[0],
|
||||||
|
`#${path}?${(new URLSearchParams(query)).toString()}`
|
||||||
|
].join('')
|
||||||
|
ipcRenderer.send(IpcChannels.CREATE_NEW_WINDOW, {
|
||||||
|
windowStartupUrl: newWindowStartupURL
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// Web
|
||||||
|
this.$router.push({
|
||||||
|
path,
|
||||||
|
query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
createNewWindow: function () {
|
createNewWindow: function () {
|
||||||
if (this.usingElectron) {
|
if (this.usingElectron) {
|
||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron')
|
||||||
|
|
Loading…
Reference in New Issue