/
Demo.vue
113 lines (100 loc) · 2.42 KB
/
Demo.vue
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
<template>
<md-app
v-cloak
md-waterfall
md-mode="fixed"
>
<md-app-toolbar class="md-primary md-dense md-layout md-alignment-center-space-between">
<div class="md-layout-item md-title">
<md-dialog v-autofocus> demo
</div>
<md-button
id="focus-none"
class="md-raised"
@click="show({ enabled: false })"
>
No focus
</md-button>
<md-button
id="focus-input"
class="md-raised"
@click="show({ selector: 'input' })"
>
Input
</md-button>
<md-button
id="focus-cancel"
class="md-raised"
@click="show({ selector: '.cancel' })"
>
Cancel button
</md-button>
<md-button
id="focus-ok"
class="md-raised"
@click="show({ selector: '.ok' })"
>
OK button
</md-button>
</md-app-toolbar>
<md-app-content>
<h3>
The buttons open a dialog, setting the focus on <span class="focused">the coloured element</span>
</h3>
<div>
<md-dialog
v-autofocus="options"
:md-active.sync="showDialog"
>
<md-dialog-title>Test dialog</md-dialog-title>
<md-dialog-content>
<md-field>
<label>First focusable</label>
<md-input
id="input"
v-model="text"
type="text"
/>
</md-field>
</md-dialog-content>
<md-dialog-actions>
<md-button
id="cancel"
class="md-raised cancel"
@click="showDialog = false"
>
Cancel
</md-button>
<md-button
id="ok"
class="md-raised ok"
@click="showDialog = false"
>
OK
</md-button>
</md-dialog-actions>
</md-dialog>
</div>
</md-app-content>
</md-app>
</template>
<script>
export default {
name: "App",
data() {
return {
showDialog: false,
options: undefined,
text: undefined,
}
},
methods: {
show(options) {
this.options = Object.assign({ on: 'md-opened'}, options)
this.showDialog = true
},
}
}
</script>
<style scoped>
</style>