11'use strict'
22
3- import Vue from 'vue'
43import DialogComponent from './components/dialog.vue'
54import { TYPES , DEFAULT_OPTIONS } from './js/utilities/constants'
65
76
8- let Plugin = function ( globalOptions ) {
7+ let Plugin = function ( Vue , globalOptions ) {
98 this . globalOptions = globalOptions
10- this . mount ( )
9+ this . mount ( Vue )
1110}
1211
13- Plugin . prototype . mount = function ( ) {
12+ Plugin . prototype . mount = function ( Vue ) {
1413 this . Dialog = ( ( ) => {
1514 let AppConstructor = Vue . extend ( DialogComponent )
1615 let node = document . createElement ( "div" )
@@ -40,7 +39,7 @@ Plugin.prototype.confirm = function(message = 'Are you sure?', localOptions = {}
4039}
4140
4241Plugin . install = function ( Vue , options ) {
43- Vue . dialog = new Plugin ( )
42+ Vue . dialog = new Plugin ( Vue , options )
4443
4544 Object . defineProperties ( Vue . prototype , {
4645 $dialog : {
@@ -55,42 +54,4 @@ export default Plugin
5554
5655if ( typeof window !== 'undefined' && window . Vue ) {
5756 window . Vue . use ( Plugin )
58- }
59-
60-
61-
62- /* BASIC USAGE *
63- vm.$dialog.confirm('Please confirm to continue')
64- .then(function () {
65- console.log('Clicked on proceed')
66- })
67- .catch(function () {
68- console.log('Clicked on cancel')
69- })
70- */
71-
72- /* AJAX LOADER *
73- vm.$dialog.confirm("If you delete this record, it'll be gone forever.", {
74- loader: true // default: false - when set to true, the proceed button shows a loader when clicked.
75- // And a dialog object will be passed to the then() callback
76- })
77- .then((dialog) => {
78- // Triggered when proceed button is clicked
79-
80- // dialog.loading(false) // stops the proceed button's loader
81- // dialog.loading(true) // starts the proceed button's loader again
82- // dialog.close() // stops the loader and close the dialog
83-
84- // do some stuff like ajax request.
85- setTimeout(() => {
86- console.log('Delete action completed ')
87- dialog.close()
88- }, 2500)
89-
90- })
91- .catch(() => {
92- // Triggered when cancel button is clicked
93-
94- console.log('Delete aborted')
95- })
96- */
57+ }
0 commit comments