|
@@ -54,52 +54,53 @@ export default {
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
- let _timer;
|
|
|
- const reference = this.reference || this.$refs.reference;
|
|
|
-
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.trigger === 'click') {
|
|
|
- on(reference, 'click', () => { this.showPopper = !this.showPopper; });
|
|
|
- on(document, 'click', (e) => {
|
|
|
- if (!this.$el ||
|
|
|
- !reference ||
|
|
|
- this.$el.contains(e.target) ||
|
|
|
- reference.contains(e.target)) return;
|
|
|
- this.showPopper = false;
|
|
|
- });
|
|
|
- } else if (this.trigger === 'hover') {
|
|
|
- on(reference, 'mouseenter', () => {
|
|
|
- this.showPopper = true;
|
|
|
- clearTimeout(_timer);
|
|
|
- });
|
|
|
- on(reference, 'mouseleave', () => {
|
|
|
- _timer = setTimeout(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ let _timer;
|
|
|
+ const reference = this.reference || this.$refs.reference;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.trigger === 'click') {
|
|
|
+ on(reference, 'click', () => { this.showPopper = !this.showPopper; });
|
|
|
+ on(document, 'click', (e) => {
|
|
|
+ if (!this.$el ||
|
|
|
+ !reference ||
|
|
|
+ this.$el.contains(e.target) ||
|
|
|
+ reference.contains(e.target)) return;
|
|
|
this.showPopper = false;
|
|
|
- }, 200);
|
|
|
- });
|
|
|
- } else {
|
|
|
- if ([].slice.call(reference.children).length) {
|
|
|
- const children = reference.childNodes;
|
|
|
+ });
|
|
|
+ } else if (this.trigger === 'hover') {
|
|
|
+ on(reference, 'mouseenter', () => {
|
|
|
+ this.showPopper = true;
|
|
|
+ clearTimeout(_timer);
|
|
|
+ });
|
|
|
+ on(reference, 'mouseleave', () => {
|
|
|
+ _timer = setTimeout(() => {
|
|
|
+ this.showPopper = false;
|
|
|
+ }, 200);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if ([].slice.call(reference.children).length) {
|
|
|
+ const children = reference.childNodes;
|
|
|
|
|
|
- for (let i = 0; i < children.length; i++) {
|
|
|
- if (children[i].nodeName === 'INPUT') {
|
|
|
- on(children[i], 'focus', () => { this.showPopper = true; });
|
|
|
- on(children[i], 'blur', () => { this.showPopper = false; });
|
|
|
- break;
|
|
|
+ for (let i = 0; i < children.length; i++) {
|
|
|
+ if (children[i].nodeName === 'INPUT') {
|
|
|
+ on(children[i], 'focus', () => { this.showPopper = true; });
|
|
|
+ on(children[i], 'blur', () => { this.showPopper = false; });
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- } else if (
|
|
|
- reference.nodeName === 'INPUT' ||
|
|
|
- reference.nodeName === 'TEXTAREA'
|
|
|
+ } else if (
|
|
|
+ reference.nodeName === 'INPUT' ||
|
|
|
+ reference.nodeName === 'TEXTAREA'
|
|
|
) {
|
|
|
- on(reference, 'focus', () => { this.showPopper = true; });
|
|
|
- on(reference, 'blur', () => { this.showPopper = false; });
|
|
|
- } else {
|
|
|
- on(reference, 'mousedown', () => { this.showPopper = true; });
|
|
|
- on(reference, 'mouseup', () => { this.showPopper = false; });
|
|
|
+ on(reference, 'focus', () => { this.showPopper = true; });
|
|
|
+ on(reference, 'blur', () => { this.showPopper = false; });
|
|
|
+ } else {
|
|
|
+ on(reference, 'mousedown', () => { this.showPopper = true; });
|
|
|
+ on(reference, 'mouseup', () => { this.showPopper = false; });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }, 100);
|
|
|
},
|
|
|
|
|
|
destroyed() {
|