2020-06-06 03:15:44 +00:00
|
|
|
import Vue from 'vue'
|
2020-09-20 23:15:59 +00:00
|
|
|
import $ from 'jquery'
|
2020-06-06 03:15:44 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'FtIconButton',
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: 'ellipsis-v'
|
|
|
|
},
|
|
|
|
theme: {
|
|
|
|
type: String,
|
|
|
|
default: 'base'
|
|
|
|
},
|
2020-06-11 00:21:31 +00:00
|
|
|
useShadow: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
2020-06-23 15:47:19 +00:00
|
|
|
padding: {
|
|
|
|
type: Number,
|
|
|
|
default: 10
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: Number,
|
|
|
|
default: 20
|
|
|
|
},
|
2020-06-17 03:01:13 +00:00
|
|
|
forceDropdown: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
dropdownPositionX: {
|
2020-06-06 03:15:44 +00:00
|
|
|
type: String,
|
|
|
|
default: 'center'
|
|
|
|
},
|
2020-06-17 03:01:13 +00:00
|
|
|
dropdownPositionY: {
|
|
|
|
type: String,
|
|
|
|
default: 'bottom'
|
|
|
|
},
|
2020-06-06 03:15:44 +00:00
|
|
|
dropdownNames: {
|
|
|
|
type: Array,
|
|
|
|
default: () => { return [] }
|
|
|
|
},
|
|
|
|
dropdownValues: {
|
|
|
|
type: Array,
|
|
|
|
default: () => { return [] }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
2020-09-20 23:15:59 +00:00
|
|
|
showDropdown: false,
|
|
|
|
id: ''
|
2020-06-06 03:15:44 +00:00
|
|
|
}
|
|
|
|
},
|
2020-09-20 23:15:59 +00:00
|
|
|
mounted: function () {
|
|
|
|
this.id = `iconButton${this._uid}`
|
|
|
|
},
|
2020-06-06 03:15:44 +00:00
|
|
|
methods: {
|
|
|
|
toggleDropdown: function () {
|
2020-09-20 23:15:59 +00:00
|
|
|
$(`#${this.id}`)[0].style.display = 'inline'
|
|
|
|
$(`#${this.id}`).focus()
|
|
|
|
|
|
|
|
$(`#${this.id}`).focusout(() => {
|
|
|
|
const shareLinks = $(`#${this.id}`).find('.shareLinks')
|
|
|
|
|
|
|
|
if (shareLinks.length > 0) {
|
|
|
|
if (!shareLinks[0].parentNode.matches(':hover')) {
|
|
|
|
$(`#${this.id}`)[0].style.display = 'none'
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$(`#${this.id}`)[0].style.display = 'none'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
focusOut: function () {
|
|
|
|
$(`#${this.id}`).focusout()
|
|
|
|
$(`#${this.id}`)[0].style.display = 'none'
|
2020-06-06 03:15:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleIconClick: function () {
|
2020-06-17 03:01:13 +00:00
|
|
|
if (this.forceDropdown || (this.dropdownNames.length > 0 && this.dropdownValues.length > 0)) {
|
2020-06-06 03:15:44 +00:00
|
|
|
this.toggleDropdown()
|
|
|
|
} else {
|
|
|
|
this.$emit('click')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleDropdownClick: function (index) {
|
|
|
|
this.$emit('click', this.dropdownValues[index])
|
2020-09-20 23:15:59 +00:00
|
|
|
this.focusOut()
|
2020-06-06 03:15:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|