File tree Expand file tree Collapse file tree 7 files changed +127
-5
lines changed
Expand file tree Collapse file tree 7 files changed +127
-5
lines changed Original file line number Diff line number Diff line change 3535 >
3636 Target area
3737
38- <q-context-menu ref = " context " >
38+ <q-context-menu >
3939 <q-list link separator no-border style =" min-width : 150px ; max-height : 300px ;" >
4040 <q-item
4141 v-for =" n in 10"
4242 :key =" n"
43- @click =" showNotify(), $refs.context.hide()"
43+ v-close-overlay
44+ @click.native =" showNotify()"
4445 >
4546 <q-item-main label =" Label" sublabel =" Value" />
4647 </q-item >
Original file line number Diff line number Diff line change 1515 <q-item
1616 v-for =" n in 20"
1717 :key =" n"
18- @click.native =" showNotify(), $refs.popover1.hide()"
18+ v-close-overlay
19+ @click.native =" showNotify()"
1920 >
2021 <q-item-main label =" Label" sublabel =" Click me" />
2122 </q-item >
2223 </q-list >
2324 </q-popover >
2425 </q-btn >
2526
27+ <q-btn color =" primary" icon =" map" >
28+ <q-popover >
29+ <q-list link separator class =" scroll" style =" min-width : 100px " >
30+ <q-item
31+ v-for =" n in 20"
32+ :key =" n"
33+ v-close-overlay
34+ @click.native =" showNotify()"
35+ >
36+ <q-item-main label =" X Label" sublabel =" X Click me" />
37+ </q-item >
38+ </q-list >
39+ </q-popover >
40+ </q-btn >
41+
2642 <q-btn ref =" target4" color =" negative" label =" Disabled Popover" >
2743 <q-popover disable >
2844 This Popover content won't be shown because of "disable"
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" layout-padding" >
3+ <!--
4+ This is for fast tests.
5+ Use this page but don't add it into your commits (leave it outside
6+ of your commit).
7+
8+ For some test that you think it should be persistent,
9+ make a new *.vue file here or in another folder under /dev/components.
10+ -->
11+ <q-btn color =" primary" icon =" map" >
12+ <q-popover >
13+ <q-list link separator class =" scroll" style =" min-width : 100px " >
14+ <!-- <q-item
15+ v-close-overlay
16+ @click.native="showNotify"
17+ >
18+ <q-item-main label="Closable" sublabel="Closes" />
19+ </q-item>-->
20+ <q-btn color =" primary" v-close-overlay label =" Shut up" icon =" map" />
21+ <q-item
22+ @click.native =" showNotify"
23+ >
24+ <q-item-main label =" Does nothing" sublabel =" sublabel" />
25+ </q-item >
26+ </q-list >
27+ </q-popover >
28+ </q-btn >
29+
30+ <q-btn color =" primary" icon =" map" :label =" popover ? 'yes' : 'no'" >
31+ <q-popover v-model =" popover" >
32+ <q-list link separator class =" scroll" style =" min-width : 100px " >
33+ <q-btn color =" primary" v-close-overlay label =" X Shut up" icon =" map" @click.native =" showNotify" />
34+ <q-item @click.native =" showNotify" >
35+ <q-item-main label =" X Does nothing" sublabel =" sublabel" />
36+ </q-item >
37+ </q-list >
38+ </q-popover >
39+ </q-btn >
40+
41+
42+
43+
44+ </div >
45+ </template >
46+
47+ <script >
48+ export default {
49+ data () {
50+ return {
51+ popover: false
52+ }
53+ },
54+ methods: {
55+ showNotify () {
56+ console .log (' @click' )
57+ }
58+ }
59+ }
60+ </script >
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ export default {
175175 this . min ,
176176 this . max
177177 )
178-
178+
179179 if ( this . computedDecimals ) {
180180 value = parseFloat ( value . toFixed ( this . computedDecimals ) )
181181 }
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ export default {
117117
118118 this . hide ( evt )
119119 } ,
120- __hide ( evt ) {
120+ __hide ( ) {
121121 clearTimeout ( this . timer )
122122
123123 document . body . removeEventListener ( 'click' , this . __bodyHide , true )
Original file line number Diff line number Diff line change 11import BackToTop from './directives/back-to-top'
2+ import CloseOverlay from './directives/close-overlay'
23import GoBack from './directives/go-back'
34import Move from './directives/move'
45import Ripple from './directives/ripple'
@@ -10,6 +11,7 @@ import TouchSwipe from './directives/touch-swipe'
1011
1112export {
1213 BackToTop ,
14+ CloseOverlay ,
1315 GoBack ,
1416 Move ,
1517 Ripple ,
Original file line number Diff line number Diff line change 1+
2+ /* function updateBinding (el, { value, modifiers }) {
3+ const ctx = el.__qclose
4+ } */
5+
6+ /* ,
7+ update (el, binding) {
8+ if (binding.oldValue !== binding.value) {
9+ updateBinding(el, binding)
10+ }
11+ } */
12+
13+ export default {
14+ name : 'close-overlay' ,
15+ bind ( el , binding , vnode ) {
16+ console . log ( 'bind' )
17+
18+ let vm = vnode . componentInstance
19+ while ( ( vm = vm . $parent ) ) {
20+ const name = vm . $options . name
21+ if ( name === 'q-popover' || name === 'q-modal' ) {
22+ break
23+ }
24+ }
25+
26+ el . __qclose = {
27+ handler ( ) {
28+ vm && vm . hide ( )
29+ }
30+ }
31+ } ,
32+ inserted ( el ) {
33+ console . log ( 'inserted' )
34+ let ctx = el . __qclose
35+ el . addEventListener ( 'click' , ctx . handler )
36+ } ,
37+ unbind ( el ) {
38+ console . log ( 'unbind' )
39+ let ctx = el . __qclose
40+ el . removeEventListener ( 'click' , ctx . handler )
41+ delete el . __qclose
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments