1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,97 @@ |
1 |
+/** |
|
2 |
+ * jBox Confirm plugin: Add a confirm dialog to links, buttons, etc. |
|
3 |
+ * |
|
4 |
+ * Author: Stephan Wagner <stephanwagner.me@gmail.com> (https://stephanwagner.me) |
|
5 |
+ * |
|
6 |
+ * License: MIT (https://opensource.org/licenses/MIT) |
|
7 |
+ * |
|
8 |
+ * Requires: jBox (https://cdn.jsdelivr.net/gh/StephanWagner/jBox@latest/dist/jBox.min.js) |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+function jBoxConfirmWrapper(jBox, jQuery) { |
|
12 |
+ |
|
13 |
+ new jBox.plugin('Confirm', { |
|
14 |
+ |
|
15 |
+ |
|
16 |
+ // Options (https://stephanwagner.me/jBox/options#options-confirm) |
|
17 |
+ |
|
18 |
+ confirmButton: 'Submit', // Text for the submit button |
|
19 |
+ cancelButton: 'Cancel', // Text for the cancel button |
|
20 |
+ confirm: null, // Function to execute when clicking the submit button. By default jBox will use the onclick or href attribute in that order if found |
|
21 |
+ cancel: null, // Function to execute when clicking the cancel button |
|
22 |
+ closeOnConfirm: true, // Close jBox when the user clicks the confirm button |
|
23 |
+ target: window, |
|
24 |
+ fixed: true, |
|
25 |
+ attach: '[data-confirm]', |
|
26 |
+ getContent: 'data-confirm', |
|
27 |
+ content: 'Do you really want to do this?', |
|
28 |
+ minWidth: 360, |
|
29 |
+ maxWidth: 500, |
|
30 |
+ blockScroll: true, |
|
31 |
+ closeOnEsc: true, |
|
32 |
+ closeOnClick: false, |
|
33 |
+ closeButton: false, |
|
34 |
+ overlay: true, |
|
35 |
+ animation: 'zoomIn', |
|
36 |
+ preventDefault: true, |
|
37 |
+ |
|
38 |
+ |
|
39 |
+ // Triggered when jBox is attached to the element |
|
40 |
+ |
|
41 |
+ _onAttach: function (el) |
|
42 |
+ { |
|
43 |
+ // Extract the href or the onclick event if no submit event is passed |
|
44 |
+ if (!this.options.confirm) { |
|
45 |
+ var submit = el.attr('onclick') ? el.attr('onclick') : ( |
|
46 |
+ el.attr('href') ? ( |
|
47 |
+ el.attr('target') ? 'window.open("' + el.attr('href') + '", "' + el.attr('target') + '");' : 'window.location.href = "' + el.attr('href') + '";' |
|
48 |
+ ) : ''); |
|
49 |
+ el.prop('onclick', null).data('jBox-Confirm-submit', submit); |
|
50 |
+ } |
|
51 |
+ }, |
|
52 |
+ |
|
53 |
+ |
|
54 |
+ // Triggered when jBox was created |
|
55 |
+ |
|
56 |
+ _onCreated: function () |
|
57 |
+ { |
|
58 |
+ // Add modal class to mimic jBox modal |
|
59 |
+ this.wrapper.addClass('jBox-Modal'); |
|
60 |
+ |
|
61 |
+ // Add a footer to the jBox container |
|
62 |
+ this.footer = jQuery('<div class="jBox-Confirm-footer"/>'); |
|
63 |
+ |
|
64 |
+ jQuery('<div class="jBox-Confirm-button jBox-Confirm-button-cancel"/>') |
|
65 |
+ .html(this.options.cancelButton) |
|
66 |
+ .on('click tap', function () { |
|
67 |
+ this.options.cancel && this.options.cancel(this.source); |
|
68 |
+ this.close(); |
|
69 |
+ }.bind(this)) |
|
70 |
+ .appendTo(this.footer); |
|
71 |
+ |
|
72 |
+ this.submitButton = jQuery('<div class="jBox-Confirm-button jBox-Confirm-button-submit"/>') |
|
73 |
+ .html(this.options.confirmButton) |
|
74 |
+ .appendTo(this.footer); |
|
75 |
+ |
|
76 |
+ this.footer.appendTo(this.container); |
|
77 |
+ }, |
|
78 |
+ |
|
79 |
+ |
|
80 |
+ // Triggered when jBox is opened |
|
81 |
+ |
|
82 |
+ _onOpen: function () |
|
83 |
+ { |
|
84 |
+ // Set the new action for the submit button |
|
85 |
+ this.submitButton |
|
86 |
+ .off('click.jBox-Confirm' + this.id + ' tap.jBox-Confirm' + this.id) |
|
87 |
+ .on('click.jBox-Confirm' + this.id + ' tap.jBox-Confirm' + this.id, function () { |
|
88 |
+ this.options.confirm ? this.options.confirm(this.source) : eval(this.source.data('jBox-Confirm-submit')); |
|
89 |
+ this.options.closeOnConfirm && this.close(); |
|
90 |
+ }.bind(this)); |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ }); |
|
94 |
+ |
|
95 |
+}; |
|
96 |
+ |
|
97 |
+//# sourceMappingURL=jBox.Confirm.js.map |
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,97 +0,0 @@ |
1 |
-/** |
|
2 |
- * jBox Confirm plugin: Add a confirm dialog to links, buttons, etc. |
|
3 |
- * |
|
4 |
- * Author: Stephan Wagner <stephanwagner.me@gmail.com> (https://stephanwagner.me) |
|
5 |
- * |
|
6 |
- * License: MIT (https://opensource.org/licenses/MIT) |
|
7 |
- * |
|
8 |
- * Requires: jBox (https://cdn.jsdelivr.net/gh/StephanWagner/jBox@latest/dist/jBox.min.js) |
|
9 |
- */ |
|
10 |
- |
|
11 |
-function jBoxConfirmWrapper(jBox, jQuery) { |
|
12 |
- |
|
13 |
- new jBox.plugin('Confirm', { |
|
14 |
- |
|
15 |
- |
|
16 |
- // Options (https://stephanwagner.me/jBox/options#options-confirm) |
|
17 |
- |
|
18 |
- confirmButton: 'Submit', // Text for the submit button |
|
19 |
- cancelButton: 'Cancel', // Text for the cancel button |
|
20 |
- confirm: null, // Function to execute when clicking the submit button. By default jBox will use the onclick or href attribute in that order if found |
|
21 |
- cancel: null, // Function to execute when clicking the cancel button |
|
22 |
- closeOnConfirm: true, // Close jBox when the user clicks the confirm button |
|
23 |
- target: window, |
|
24 |
- fixed: true, |
|
25 |
- attach: '[data-confirm]', |
|
26 |
- getContent: 'data-confirm', |
|
27 |
- content: 'Do you really want to do this?', |
|
28 |
- minWidth: 360, |
|
29 |
- maxWidth: 500, |
|
30 |
- blockScroll: true, |
|
31 |
- closeOnEsc: true, |
|
32 |
- closeOnClick: false, |
|
33 |
- closeButton: false, |
|
34 |
- overlay: true, |
|
35 |
- animation: 'zoomIn', |
|
36 |
- preventDefault: true, |
|
37 |
- |
|
38 |
- |
|
39 |
- // Triggered when jBox is attached to the element |
|
40 |
- |
|
41 |
- _onAttach: function (el) |
|
42 |
- { |
|
43 |
- // Extract the href or the onclick event if no submit event is passed |
|
44 |
- if (!this.options.confirm) { |
|
45 |
- var submit = el.attr('onclick') ? el.attr('onclick') : ( |
|
46 |
- el.attr('href') ? ( |
|
47 |
- el.attr('target') ? 'window.open("' + el.attr('href') + '", "' + el.attr('target') + '");' : 'window.location.href = "' + el.attr('href') + '";' |
|
48 |
- ) : ''); |
|
49 |
- el.prop('onclick', null).data('jBox-Confirm-submit', submit); |
|
50 |
- } |
|
51 |
- }, |
|
52 |
- |
|
53 |
- |
|
54 |
- // Triggered when jBox was created |
|
55 |
- |
|
56 |
- _onCreated: function () |
|
57 |
- { |
|
58 |
- // Add modal class to mimic jBox modal |
|
59 |
- this.wrapper.addClass('jBox-Modal'); |
|
60 |
- |
|
61 |
- // Add a footer to the jBox container |
|
62 |
- this.footer = jQuery('<div class="jBox-Confirm-footer"/>'); |
|
63 |
- |
|
64 |
- jQuery('<div class="jBox-Confirm-button jBox-Confirm-button-cancel"/>') |
|
65 |
- .html(this.options.cancelButton) |
|
66 |
- .on('click tap', function () { |
|
67 |
- this.options.cancel && this.options.cancel(this.source); |
|
68 |
- this.close(); |
|
69 |
- }.bind(this)) |
|
70 |
- .appendTo(this.footer); |
|
71 |
- |
|
72 |
- this.submitButton = jQuery('<div class="jBox-Confirm-button jBox-Confirm-button-submit"/>') |
|
73 |
- .html(this.options.confirmButton) |
|
74 |
- .appendTo(this.footer); |
|
75 |
- |
|
76 |
- this.footer.appendTo(this.container); |
|
77 |
- }, |
|
78 |
- |
|
79 |
- |
|
80 |
- // Triggered when jBox is opened |
|
81 |
- |
|
82 |
- _onOpen: function () |
|
83 |
- { |
|
84 |
- // Set the new action for the submit button |
|
85 |
- this.submitButton |
|
86 |
- .off('click.jBox-Confirm' + this.id + ' tap.jBox-Confirm' + this.id) |
|
87 |
- .on('click.jBox-Confirm' + this.id + ' tap.jBox-Confirm' + this.id, function () { |
|
88 |
- this.options.confirm ? this.options.confirm(this.source) : eval(this.source.data('jBox-Confirm-submit')); |
|
89 |
- this.options.closeOnConfirm && this.close(); |
|
90 |
- }.bind(this)); |
|
91 |
- } |
|
92 |
- |
|
93 |
- }); |
|
94 |
- |
|
95 |
-}; |
|
96 |
- |
|
97 |
-//# sourceMappingURL=jBox.Confirm.js.map |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,97 @@ |
1 |
+/** |
|
2 |
+ * jBox Confirm plugin: Add a confirm dialog to links, buttons, etc. |
|
3 |
+ * |
|
4 |
+ * Author: Stephan Wagner <stephanwagner.me@gmail.com> (https://stephanwagner.me) |
|
5 |
+ * |
|
6 |
+ * License: MIT (https://opensource.org/licenses/MIT) |
|
7 |
+ * |
|
8 |
+ * Requires: jBox (https://cdn.jsdelivr.net/gh/StephanWagner/jBox@latest/dist/jBox.min.js) |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+function jBoxConfirmWrapper(jBox, jQuery) { |
|
12 |
+ |
|
13 |
+ new jBox.plugin('Confirm', { |
|
14 |
+ |
|
15 |
+ |
|
16 |
+ // Options (https://stephanwagner.me/jBox/options#options-confirm) |
|
17 |
+ |
|
18 |
+ confirmButton: 'Submit', // Text for the submit button |
|
19 |
+ cancelButton: 'Cancel', // Text for the cancel button |
|
20 |
+ confirm: null, // Function to execute when clicking the submit button. By default jBox will use the onclick or href attribute in that order if found |
|
21 |
+ cancel: null, // Function to execute when clicking the cancel button |
|
22 |
+ closeOnConfirm: true, // Close jBox when the user clicks the confirm button |
|
23 |
+ target: window, |
|
24 |
+ fixed: true, |
|
25 |
+ attach: '[data-confirm]', |
|
26 |
+ getContent: 'data-confirm', |
|
27 |
+ content: 'Do you really want to do this?', |
|
28 |
+ minWidth: 360, |
|
29 |
+ maxWidth: 500, |
|
30 |
+ blockScroll: true, |
|
31 |
+ closeOnEsc: true, |
|
32 |
+ closeOnClick: false, |
|
33 |
+ closeButton: false, |
|
34 |
+ overlay: true, |
|
35 |
+ animation: 'zoomIn', |
|
36 |
+ preventDefault: true, |
|
37 |
+ |
|
38 |
+ |
|
39 |
+ // Triggered when jBox is attached to the element |
|
40 |
+ |
|
41 |
+ _onAttach: function (el) |
|
42 |
+ { |
|
43 |
+ // Extract the href or the onclick event if no submit event is passed |
|
44 |
+ if (!this.options.confirm) { |
|
45 |
+ var submit = el.attr('onclick') ? el.attr('onclick') : ( |
|
46 |
+ el.attr('href') ? ( |
|
47 |
+ el.attr('target') ? 'window.open("' + el.attr('href') + '", "' + el.attr('target') + '");' : 'window.location.href = "' + el.attr('href') + '";' |
|
48 |
+ ) : ''); |
|
49 |
+ el.prop('onclick', null).data('jBox-Confirm-submit', submit); |
|
50 |
+ } |
|
51 |
+ }, |
|
52 |
+ |
|
53 |
+ |
|
54 |
+ // Triggered when jBox was created |
|
55 |
+ |
|
56 |
+ _onCreated: function () |
|
57 |
+ { |
|
58 |
+ // Add modal class to mimic jBox modal |
|
59 |
+ this.wrapper.addClass('jBox-Modal'); |
|
60 |
+ |
|
61 |
+ // Add a footer to the jBox container |
|
62 |
+ this.footer = jQuery('<div class="jBox-Confirm-footer"/>'); |
|
63 |
+ |
|
64 |
+ jQuery('<div class="jBox-Confirm-button jBox-Confirm-button-cancel"/>') |
|
65 |
+ .html(this.options.cancelButton) |
|
66 |
+ .on('click tap', function () { |
|
67 |
+ this.options.cancel && this.options.cancel(this.source); |
|
68 |
+ this.close(); |
|
69 |
+ }.bind(this)) |
|
70 |
+ .appendTo(this.footer); |
|
71 |
+ |
|
72 |
+ this.submitButton = jQuery('<div class="jBox-Confirm-button jBox-Confirm-button-submit"/>') |
|
73 |
+ .html(this.options.confirmButton) |
|
74 |
+ .appendTo(this.footer); |
|
75 |
+ |
|
76 |
+ this.footer.appendTo(this.container); |
|
77 |
+ }, |
|
78 |
+ |
|
79 |
+ |
|
80 |
+ // Triggered when jBox is opened |
|
81 |
+ |
|
82 |
+ _onOpen: function () |
|
83 |
+ { |
|
84 |
+ // Set the new action for the submit button |
|
85 |
+ this.submitButton |
|
86 |
+ .off('click.jBox-Confirm' + this.id + ' tap.jBox-Confirm' + this.id) |
|
87 |
+ .on('click.jBox-Confirm' + this.id + ' tap.jBox-Confirm' + this.id, function () { |
|
88 |
+ this.options.confirm ? this.options.confirm(this.source) : eval(this.source.data('jBox-Confirm-submit')); |
|
89 |
+ this.options.closeOnConfirm && this.close(); |
|
90 |
+ }.bind(this)); |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ }); |
|
94 |
+ |
|
95 |
+}; |
|
96 |
+ |
|
97 |
+//# sourceMappingURL=jBox.Confirm.js.map |