Skip to content

Commit b3d85db

Browse files
committed
Commit mixins
1 parent 9684944 commit b3d85db

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/plugin/js/mixins/btn-mixin.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Created by Emmy on 3/5/2018.
3+
*/
4+
5+
import {DIALOG_TYPES, CONFIRM_TYPES} from '../constants'
6+
7+
export default {
8+
computed: {
9+
cancelBtnDisabled(){
10+
return (this.options.window === DIALOG_TYPES.ALERT)
11+
},
12+
okBtnDisabled(){
13+
return (this.options.window === DIALOG_TYPES.CONFIRM)
14+
&& (this.options.type === CONFIRM_TYPES.HARD)
15+
&& (this.input !== this.options.verification)
16+
},
17+
leftBtnEnabled(){
18+
return (this.cancelBtnDisabled === false) || (this.options.reverse === true)
19+
},
20+
rightBtnEnabled(){
21+
return (this.cancelBtnDisabled === false) || (this.options.reverse === false)
22+
},
23+
leftBtnFocus(){
24+
return !this.isHardConfirm && (this.options.reverse === true)
25+
},
26+
rightBtnFocus(){
27+
return !this.isHardConfirm && (this.options.reverse === false)
28+
},
29+
leftBtnText(){
30+
return this.options.reverse ? this.options.okText : this.options.cancelText
31+
},
32+
rightBtnText(){
33+
return this.options.reverse ? this.options.cancelText : this.options.okText
34+
}
35+
}
36+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Created by Emmy on 3/5/2018.
3+
*/
4+
5+
export default {
6+
computed: {
7+
messageHasTitle(){
8+
let m = this.options.message
9+
return (typeof m === 'object' && m !== null) && m.title
10+
},
11+
messageTitle(){
12+
return this.messageHasTitle ? this.options.message.title : null
13+
},
14+
messageBody(){
15+
let m = this.options.message
16+
return (typeof m === 'string') ? m : (m.body || '')
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)