@@ -81,19 +81,26 @@ export default {
81
81
tag : {
82
82
type : String ,
83
83
default : 'a'
84
+ } ,
85
+
86
+ /**
87
+ * Properties to configure the popup window.
88
+ */
89
+ popup : {
90
+ type : Object ,
91
+ default : ( ) => ( {
92
+ width : 626 ,
93
+ height : 436
94
+ } )
84
95
}
85
96
} ,
86
97
87
98
data ( ) {
88
99
return {
89
- popup : {
90
- width : 626 ,
91
- height : 436 ,
92
- top : 0 ,
93
- left : 0 ,
94
- window : undefined ,
95
- interval : null
96
- }
100
+ popupTop : 0 ,
101
+ popupLeft : 0 ,
102
+ popupWindow : undefined ,
103
+ popupInterval : null
97
104
}
98
105
} ,
99
106
@@ -191,8 +198,8 @@ export default {
191
198
const height = $window . innerHeight || ( document . documentElement . clientHeight || $window . screenY )
192
199
const systemZoom = width / $window . screen . availWidth
193
200
194
- this . popup . left = ( width - this . popup . width ) / 2 / systemZoom + ( $window . screenLeft !== undefined ? $window . screenLeft : $window . screenX )
195
- this . popup . top = ( height - this . popup . height ) / 2 / systemZoom + ( $window . screenTop !== undefined ? $window . screenTop : $window . screenY )
201
+ this . popupLeft = ( width - this . popup . width ) / 2 / systemZoom + ( $window . screenLeft !== undefined ? $window . screenLeft : $window . screenX )
202
+ this . popupTop = ( height - this . popup . height ) / 2 / systemZoom + ( $window . screenTop !== undefined ? $window . screenTop : $window . screenY )
196
203
} ,
197
204
198
205
/**
@@ -202,37 +209,37 @@ export default {
202
209
this . resizePopup ( )
203
210
204
211
// If a popup window already exist, we close it and trigger a change event.
205
- if ( this . popup . window && this . popup . interval ) {
206
- clearInterval ( this . popup . interval )
212
+ if ( this . popupWindow && this . popupInterval ) {
213
+ clearInterval ( this . popupInterval )
207
214
208
215
// Force close (for Facebook)
209
- this . popup . window . close ( )
216
+ this . popupWindow . close ( )
210
217
211
218
this . emit ( 'change' )
212
219
}
213
220
214
- this . popup . window = $window . open (
221
+ this . popupWindow = $window . open (
215
222
this . shareLink ,
216
223
'sharer' ,
217
224
',height=' + this . popup . height +
218
225
',width=' + this . popup . width +
219
- ',left=' + this . popup . left +
220
- ',top=' + this . popup . top +
221
- ',screenX=' + this . popup . left +
222
- ',screenY=' + this . popup . top
226
+ ',left=' + this . popupLeft +
227
+ ',top=' + this . popupTop +
228
+ ',screenX=' + this . popupLeft +
229
+ ',screenY=' + this . popupTop
223
230
)
224
231
225
232
// If popup are prevented (AdBlocker, Mobile App context..), popup.window stays undefined and we can't display it
226
- if ( ! this . popup . window ) return
233
+ if ( ! this . popupWindow ) return
227
234
228
- this . popup . window . focus ( )
235
+ this . popupWindow . focus ( )
229
236
230
237
// Create an interval to detect popup closing event
231
- this . popup . interval = setInterval ( ( ) => {
232
- if ( ! this . popup . window || this . popup . window . closed ) {
233
- clearInterval ( this . popup . interval )
238
+ this . popupInterval = setInterval ( ( ) => {
239
+ if ( ! this . popupWindow || this . popupWindow . closed ) {
240
+ clearInterval ( this . popupInterval )
234
241
235
- this . popup . window = null
242
+ this . popupWindow = null
236
243
237
244
this . emit ( 'close' )
238
245
}
0 commit comments