forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel-toggle.js
More file actions
127 lines (105 loc) · 2.71 KB
/
model-toggle.js
File metadata and controls
127 lines (105 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { isSSR } from '../plugins/Platform.js'
import TimeoutMixin from './timeout.js'
import ListenersMixin from './listeners.js'
export default {
mixins: [ TimeoutMixin, ListenersMixin ],
props: {
value: {
type: Boolean,
default: void 0
}
},
data () {
return {
showing: false
}
},
watch: {
value (val) {
this.__processModelChange(val)
},
$route () {
this.hideOnRouteChange === true && this.showing === true && this.hide()
}
},
methods: {
toggle (evt) {
this[this.showing === true ? 'hide' : 'show'](evt)
},
show (evt) {
if (this.disable === true || (this.__showCondition !== void 0 && this.__showCondition(evt) !== true)) {
return
}
if (this.qListeners.input !== void 0 && isSSR === false) {
this.$emit('input', true)
this.payload = evt
this.$nextTick(() => {
if (this.payload === evt) {
this.payload = void 0
}
})
}
if (this.value === void 0 || this.qListeners.input === void 0 || isSSR === true) {
this.__processShow(evt)
}
},
__processShow (evt) {
if (this.showing === true) {
return
}
// need to call it before setting showing to true
// in order to not ruin the animation
this.__preparePortal !== void 0 && this.__preparePortal()
this.showing = true
this.$emit('before-show', evt)
if (this.__show !== void 0) {
this.__clearTick()
this.__show(evt)
this.__prepareTick()
}
else {
this.$emit('show', evt)
}
},
hide (evt) {
if (this.disable === true) {
return
}
if (this.qListeners.input !== void 0 && isSSR === false) {
this.$emit('input', false)
this.payload = evt
this.$nextTick(() => {
if (this.payload === evt) {
this.payload = void 0
}
})
}
if (this.value === void 0 || this.qListeners.input === void 0 || isSSR === true) {
this.__processHide(evt)
}
},
__processHide (evt) {
if (this.showing === false) {
return
}
this.showing = false
this.$emit('before-hide', evt)
if (this.__hide !== void 0) {
this.__clearTick()
this.__hide(evt)
this.__prepareTick()
}
else {
this.$emit('hide', evt)
}
},
__processModelChange (val) {
if (this.disable === true && val === true) {
this.qListeners.input !== void 0 && this.$emit('input', false)
}
else if ((val === true) !== this.showing) {
this[`__process${val === true ? 'Show' : 'Hide'}`](this.payload)
}
}
}
}