sweetalert2-rails 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0b5760e3016188515b80f5b2be4193f488b53db
4
+ data.tar.gz: dd3d1e7a3a153eebc5e28974c2037cfd11a1cedf
5
+ SHA512:
6
+ metadata.gz: fcf13b128d24dac517027e8a4072ad1f2a526a54bc3745246982d118985a78249fb23b2625163efdfa20769ad3eb33b44718a136fa18ae2f90a6b23fb2ca46f9
7
+ data.tar.gz: c16068797428f37863db86a161c8ab2231e66ce280e272052186735b49de13a33b52a6896d4aad80bdb271ed262950a906edcd6733ac416eab89be49118bbd09
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at carl@givecampus.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sweetalert2-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Carl Weis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # sweetalert2-rails
2
+
3
+ A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies.
4
+ https://limonte.github.io/sweetalert2/
5
+
6
+ This gem will override the rails default confirm dialog with SweetAlert2.
7
+
8
+ ![Alt text](/screenshot.png?raw=true "Screenshot of Alert")
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'sweetalert2-rails'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install sweetalert2-rails
25
+
26
+ ## Usage
27
+
28
+ Add the following to your application.scss file.
29
+ ```
30
+ @import "sweetalert2-rails";
31
+ ```
32
+
33
+ Add the following to your application.js file.
34
+
35
+ ```
36
+ //= require sweetalert2-rails
37
+ ```
38
+
39
+ Now when you use data confirm in rails, it will use sweetalert.
40
+
41
+ ```
42
+ link_to 'Delete', delete_path, data: { confirm: 'Are you sure?', text: 'Will
43
+ show up as the dialog text'}
44
+ ```
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/carlweis/sweetalert2-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
60
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sweetalert2/rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ require "sweetalert2/rails/version"
2
+
3
+ module Sweetalert2
4
+ module Rails
5
+ class Engine < ::Rails::Engine; end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Sweetalert2
2
+ module Rails
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
data/screenshot.png ADDED
Binary file
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sweetalert2/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sweetalert2-rails"
8
+ spec.version = Sweetalert2::Rails::VERSION
9
+ spec.authors = ["Carl Weis"]
10
+ spec.email = ["carlweis@icloud.com"]
11
+
12
+ spec.summary = %q{Replaces default javascript confirms with SweetAlert2.}
13
+ spec.description = %q{Replaces default javascript confirms with SweetAlert2.}
14
+ spec.homepage = "http://github.com/carlweis/sweetalert2-rails"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
@@ -0,0 +1,1655 @@
1
+ /*!
2
+ * sweetalert2 v6.6.2
3
+ * Released under the MIT License.
4
+ */
5
+ (function (global, factory) {
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7
+ typeof define === 'function' && define.amd ? define(factory) :
8
+ (global.Sweetalert2 = factory());
9
+ }(this, (function () { 'use strict';
10
+
11
+ var defaultParams = {
12
+ title: '',
13
+ titleText: '',
14
+ text: '',
15
+ html: '',
16
+ type: null,
17
+ customClass: '',
18
+ target: 'body',
19
+ animation: true,
20
+ allowOutsideClick: true,
21
+ allowEscapeKey: true,
22
+ allowEnterKey: true,
23
+ showConfirmButton: true,
24
+ showCancelButton: false,
25
+ preConfirm: null,
26
+ confirmButtonText: 'OK',
27
+ confirmButtonColor: '#3085d6',
28
+ confirmButtonClass: null,
29
+ cancelButtonText: 'Cancel',
30
+ cancelButtonColor: '#aaa',
31
+ cancelButtonClass: null,
32
+ buttonsStyling: true,
33
+ reverseButtons: false,
34
+ focusCancel: false,
35
+ showCloseButton: false,
36
+ showLoaderOnConfirm: false,
37
+ imageUrl: null,
38
+ imageWidth: null,
39
+ imageHeight: null,
40
+ imageClass: null,
41
+ timer: null,
42
+ width: 500,
43
+ padding: 20,
44
+ background: '#fff',
45
+ input: null,
46
+ inputPlaceholder: '',
47
+ inputValue: '',
48
+ inputOptions: {},
49
+ inputAutoTrim: true,
50
+ inputClass: null,
51
+ inputAttributes: {},
52
+ inputValidator: null,
53
+ progressSteps: [],
54
+ currentProgressStep: null,
55
+ progressStepsDistance: '40px',
56
+ onOpen: null,
57
+ onClose: null
58
+ };
59
+
60
+ var swalPrefix = 'swal2-';
61
+
62
+ var prefix = function prefix(items) {
63
+ var result = {};
64
+ for (var i in items) {
65
+ result[items[i]] = swalPrefix + items[i];
66
+ }
67
+ return result;
68
+ };
69
+
70
+ var swalClasses = prefix(['container', 'shown', 'iosfix', 'modal', 'overlay', 'fade', 'show', 'hide', 'noanimation', 'close', 'title', 'content', 'buttonswrapper', 'confirm', 'cancel', 'icon', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea', 'inputerror', 'validationerror', 'progresssteps', 'activeprogressstep', 'progresscircle', 'progressline', 'loading', 'styled']);
71
+
72
+ var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
73
+
74
+ /*
75
+ * Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
76
+ */
77
+ var colorLuminance = function colorLuminance(hex, lum) {
78
+ // Validate hex string
79
+ hex = String(hex).replace(/[^0-9a-f]/gi, '');
80
+ if (hex.length < 6) {
81
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
82
+ }
83
+ lum = lum || 0;
84
+
85
+ // Convert to decimal and change luminosity
86
+ var rgb = '#';
87
+ for (var i = 0; i < 3; i++) {
88
+ var c = parseInt(hex.substr(i * 2, 2), 16);
89
+ c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
90
+ rgb += ('00' + c).substr(c.length);
91
+ }
92
+
93
+ return rgb;
94
+ };
95
+
96
+ var uniqueArray = function uniqueArray(arr) {
97
+ var result = [];
98
+ for (var i in arr) {
99
+ if (result.indexOf(arr[i]) === -1) {
100
+ result.push(arr[i]);
101
+ }
102
+ }
103
+ return result;
104
+ };
105
+
106
+ /* global MouseEvent */
107
+
108
+ // Remember state in cases where opening and handling a modal will fiddle with it.
109
+ var states = {
110
+ previousWindowKeyDown: null,
111
+ previousActiveElement: null,
112
+ previousBodyPadding: null
113
+ };
114
+
115
+ /*
116
+ * Add modal + overlay to DOM
117
+ */
118
+ var init = function init(params) {
119
+ if (typeof document === 'undefined') {
120
+ console.error('SweetAlert2 requires document to initialize');
121
+ return;
122
+ }
123
+
124
+ var container = document.createElement('div');
125
+ container.className = swalClasses.container;
126
+ container.innerHTML = sweetHTML;
127
+
128
+ var targetElement = document.querySelector(params.target);
129
+ if (!targetElement) {
130
+ console.warn('SweetAlert2: Can\'t find the target "' + params.target + '"');
131
+ targetElement = document.body;
132
+ }
133
+ targetElement.appendChild(container);
134
+
135
+ var modal = getModal();
136
+ var input = getChildByClass(modal, swalClasses.input);
137
+ var file = getChildByClass(modal, swalClasses.file);
138
+ var range = modal.querySelector('.' + swalClasses.range + ' input');
139
+ var rangeOutput = modal.querySelector('.' + swalClasses.range + ' output');
140
+ var select = getChildByClass(modal, swalClasses.select);
141
+ var checkbox = modal.querySelector('.' + swalClasses.checkbox + ' input');
142
+ var textarea = getChildByClass(modal, swalClasses.textarea);
143
+
144
+ input.oninput = function () {
145
+ sweetAlert.resetValidationError();
146
+ };
147
+
148
+ input.onkeydown = function (event) {
149
+ setTimeout(function () {
150
+ if (event.keyCode === 13 && params.allowEnterKey) {
151
+ event.stopPropagation();
152
+ sweetAlert.clickConfirm();
153
+ }
154
+ }, 0);
155
+ };
156
+
157
+ file.onchange = function () {
158
+ sweetAlert.resetValidationError();
159
+ };
160
+
161
+ range.oninput = function () {
162
+ sweetAlert.resetValidationError();
163
+ rangeOutput.value = range.value;
164
+ };
165
+
166
+ range.onchange = function () {
167
+ sweetAlert.resetValidationError();
168
+ range.previousSibling.value = range.value;
169
+ };
170
+
171
+ select.onchange = function () {
172
+ sweetAlert.resetValidationError();
173
+ };
174
+
175
+ checkbox.onchange = function () {
176
+ sweetAlert.resetValidationError();
177
+ };
178
+
179
+ textarea.oninput = function () {
180
+ sweetAlert.resetValidationError();
181
+ };
182
+
183
+ return modal;
184
+ };
185
+
186
+ /*
187
+ * Manipulate DOM
188
+ */
189
+
190
+ var sweetHTML = ('\n <div role="dialog" aria-labelledby="' + swalClasses.title + '" aria-describedby="' + swalClasses.content + '" class="' + swalClasses.modal + '" tabindex="-1">\n <ul class="' + swalClasses.progresssteps + '"></ul>\n <div class="' + swalClasses.icon + ' ' + iconTypes.error + '">\n <span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>\n </div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.question + '">?</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.warning + '">!</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.info + '">i</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.success + '">\n <div class="swal2-success-circular-line-left"></div>\n <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>\n <div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>\n <div class="swal2-success-circular-line-right"></div>\n </div>\n <img class="' + swalClasses.image + '">\n <h2 class="' + swalClasses.title + '" id="' + swalClasses.title + '"></h2>\n <div id="' + swalClasses.content + '" class="' + swalClasses.content + '"></div>\n <input class="' + swalClasses.input + '">\n <input type="file" class="' + swalClasses.file + '">\n <div class="' + swalClasses.range + '">\n <output></output>\n <input type="range">\n </div>\n <select class="' + swalClasses.select + '"></select>\n <div class="' + swalClasses.radio + '"></div>\n <label for="' + swalClasses.checkbox + '" class="' + swalClasses.checkbox + '">\n <input type="checkbox">\n </label>\n <textarea class="' + swalClasses.textarea + '"></textarea>\n <div class="' + swalClasses.validationerror + '"></div>\n <div class="' + swalClasses.buttonswrapper + '">\n <button type="button" class="' + swalClasses.confirm + '">OK</button>\n <button type="button" class="' + swalClasses.cancel + '">Cancel</button>\n </div>\n <button type="button" class="' + swalClasses.close + '" aria-label="Close this dialog">&times;</button>\n </div>\n').replace(/(^|\n)\s*/g, '');
191
+
192
+ var getContainer = function getContainer() {
193
+ return document.body.querySelector('.' + swalClasses.container);
194
+ };
195
+
196
+ var getModal = function getModal() {
197
+ return getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null;
198
+ };
199
+
200
+ var getIcons = function getIcons() {
201
+ var modal = getModal();
202
+ return modal.querySelectorAll('.' + swalClasses.icon);
203
+ };
204
+
205
+ var elementByClass = function elementByClass(className) {
206
+ return getContainer() ? getContainer().querySelector('.' + className) : null;
207
+ };
208
+
209
+ var getTitle = function getTitle() {
210
+ return elementByClass(swalClasses.title);
211
+ };
212
+
213
+ var getContent = function getContent() {
214
+ return elementByClass(swalClasses.content);
215
+ };
216
+
217
+ var getImage = function getImage() {
218
+ return elementByClass(swalClasses.image);
219
+ };
220
+
221
+ var getButtonsWrapper = function getButtonsWrapper() {
222
+ return elementByClass(swalClasses.buttonswrapper);
223
+ };
224
+
225
+ var getProgressSteps = function getProgressSteps() {
226
+ return elementByClass(swalClasses.progresssteps);
227
+ };
228
+
229
+ var getValidationError = function getValidationError() {
230
+ return elementByClass(swalClasses.validationerror);
231
+ };
232
+
233
+ var getConfirmButton = function getConfirmButton() {
234
+ return elementByClass(swalClasses.confirm);
235
+ };
236
+
237
+ var getCancelButton = function getCancelButton() {
238
+ return elementByClass(swalClasses.cancel);
239
+ };
240
+
241
+ var getCloseButton = function getCloseButton() {
242
+ return elementByClass(swalClasses.close);
243
+ };
244
+
245
+ var getFocusableElements = function getFocusableElements(focusCancel) {
246
+ var buttons = [getConfirmButton(), getCancelButton()];
247
+ if (focusCancel) {
248
+ buttons.reverse();
249
+ }
250
+ var focusableElements = buttons.concat(Array.prototype.slice.call(getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, *[tabindex]:not([tabindex="-1"])')));
251
+ return uniqueArray(focusableElements);
252
+ };
253
+
254
+ var hasClass = function hasClass(elem, className) {
255
+ if (elem.classList) {
256
+ return elem.classList.contains(className);
257
+ }
258
+ return false;
259
+ };
260
+
261
+ var focusInput = function focusInput(input) {
262
+ input.focus();
263
+
264
+ // place cursor at end of text in text input
265
+ if (input.type !== 'file') {
266
+ // http://stackoverflow.com/a/2345915/1331425
267
+ var val = input.value;
268
+ input.value = '';
269
+ input.value = val;
270
+ }
271
+ };
272
+
273
+ var addClass = function addClass(elem, className) {
274
+ if (!elem || !className) {
275
+ return;
276
+ }
277
+ var classes = className.split(/\s+/).filter(Boolean);
278
+ classes.forEach(function (className) {
279
+ elem.classList.add(className);
280
+ });
281
+ };
282
+
283
+ var removeClass = function removeClass(elem, className) {
284
+ if (!elem || !className) {
285
+ return;
286
+ }
287
+ var classes = className.split(/\s+/).filter(Boolean);
288
+ classes.forEach(function (className) {
289
+ elem.classList.remove(className);
290
+ });
291
+ };
292
+
293
+ var getChildByClass = function getChildByClass(elem, className) {
294
+ for (var i = 0; i < elem.childNodes.length; i++) {
295
+ if (hasClass(elem.childNodes[i], className)) {
296
+ return elem.childNodes[i];
297
+ }
298
+ }
299
+ };
300
+
301
+ var show = function show(elem, display) {
302
+ if (!display) {
303
+ display = 'block';
304
+ }
305
+ elem.style.opacity = '';
306
+ elem.style.display = display;
307
+ };
308
+
309
+ var hide = function hide(elem) {
310
+ elem.style.opacity = '';
311
+ elem.style.display = 'none';
312
+ };
313
+
314
+ var empty = function empty(elem) {
315
+ while (elem.firstChild) {
316
+ elem.removeChild(elem.firstChild);
317
+ }
318
+ };
319
+
320
+ // borrowed from jqeury $(elem).is(':visible') implementation
321
+ var isVisible = function isVisible(elem) {
322
+ return elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length;
323
+ };
324
+
325
+ var removeStyleProperty = function removeStyleProperty(elem, property) {
326
+ if (elem.style.removeProperty) {
327
+ elem.style.removeProperty(property);
328
+ } else {
329
+ elem.style.removeAttribute(property);
330
+ }
331
+ };
332
+
333
+ var fireClick = function fireClick(node) {
334
+ if (!isVisible(node)) {
335
+ return false;
336
+ }
337
+
338
+ // Taken from http://www.nonobtrusive.com/2011/11/29/programatically-fire-crossbrowser-click-event-with-javascript/
339
+ // Then fixed for today's Chrome browser.
340
+ if (typeof MouseEvent === 'function') {
341
+ // Up-to-date approach
342
+ var mevt = new MouseEvent('click', {
343
+ view: window,
344
+ bubbles: false,
345
+ cancelable: true
346
+ });
347
+ node.dispatchEvent(mevt);
348
+ } else if (document.createEvent) {
349
+ // Fallback
350
+ var evt = document.createEvent('MouseEvents');
351
+ evt.initEvent('click', false, false);
352
+ node.dispatchEvent(evt);
353
+ } else if (document.createEventObject) {
354
+ node.fireEvent('onclick');
355
+ } else if (typeof node.onclick === 'function') {
356
+ node.onclick();
357
+ }
358
+ };
359
+
360
+ var animationEndEvent = function () {
361
+ var testEl = document.createElement('div');
362
+ var transEndEventNames = {
363
+ 'WebkitAnimation': 'webkitAnimationEnd',
364
+ 'OAnimation': 'oAnimationEnd oanimationend',
365
+ 'msAnimation': 'MSAnimationEnd',
366
+ 'animation': 'animationend'
367
+ };
368
+ for (var i in transEndEventNames) {
369
+ if (transEndEventNames.hasOwnProperty(i) && testEl.style[i] !== undefined) {
370
+ return transEndEventNames[i];
371
+ }
372
+ }
373
+
374
+ return false;
375
+ }();
376
+
377
+ // Reset previous window keydown handler and focued element
378
+ var resetPrevState = function resetPrevState() {
379
+ window.onkeydown = states.previousWindowKeyDown;
380
+ if (states.previousActiveElement && states.previousActiveElement.focus) {
381
+ var x = window.scrollX;
382
+ var y = window.scrollY;
383
+ states.previousActiveElement.focus();
384
+ if (x && y) {
385
+ // IE has no scrollX/scrollY support
386
+ window.scrollTo(x, y);
387
+ }
388
+ }
389
+ };
390
+
391
+ // Measure width of scrollbar
392
+ // https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
393
+ var measureScrollbar = function measureScrollbar() {
394
+ var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
395
+ if (supportsTouch) {
396
+ return 0;
397
+ }
398
+ var scrollDiv = document.createElement('div');
399
+ scrollDiv.style.width = '50px';
400
+ scrollDiv.style.height = '50px';
401
+ scrollDiv.style.overflow = 'scroll';
402
+ document.body.appendChild(scrollDiv);
403
+ var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
404
+ document.body.removeChild(scrollDiv);
405
+ return scrollbarWidth;
406
+ };
407
+
408
+ // JavaScript Debounce Function
409
+ // Simplivied version of https://davidwalsh.name/javascript-debounce-function
410
+ var debounce = function debounce(func, wait) {
411
+ var timeout = void 0;
412
+ return function () {
413
+ var later = function later() {
414
+ timeout = null;
415
+ func();
416
+ };
417
+ clearTimeout(timeout);
418
+ timeout = setTimeout(later, wait);
419
+ };
420
+ };
421
+
422
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
423
+ return typeof obj;
424
+ } : function (obj) {
425
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
426
+ };
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+ var _extends = Object.assign || function (target) {
449
+ for (var i = 1; i < arguments.length; i++) {
450
+ var source = arguments[i];
451
+
452
+ for (var key in source) {
453
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
454
+ target[key] = source[key];
455
+ }
456
+ }
457
+ }
458
+
459
+ return target;
460
+ };
461
+
462
+ var modalParams = _extends({}, defaultParams);
463
+ var queue = [];
464
+ var swal2Observer = void 0;
465
+
466
+ /*
467
+ * Set type, text and actions on modal
468
+ */
469
+ var setParameters = function setParameters(params) {
470
+ var modal = getModal() || init(params);
471
+
472
+ for (var param in params) {
473
+ if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
474
+ console.warn('SweetAlert2: Unknown parameter "' + param + '"');
475
+ }
476
+ }
477
+
478
+ // Set modal width
479
+ modal.style.width = typeof params.width === 'number' ? params.width + 'px' : params.width;
480
+
481
+ modal.style.padding = params.padding + 'px';
482
+ modal.style.background = params.background;
483
+ var successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
484
+ for (var i = 0; i < successIconParts.length; i++) {
485
+ successIconParts[i].style.background = params.background;
486
+ }
487
+
488
+ var title = getTitle();
489
+ var content = getContent();
490
+ var buttonsWrapper = getButtonsWrapper();
491
+ var confirmButton = getConfirmButton();
492
+ var cancelButton = getCancelButton();
493
+ var closeButton = getCloseButton();
494
+
495
+ // Title
496
+ if (params.titleText) {
497
+ title.innerText = params.titleText;
498
+ } else {
499
+ title.innerHTML = params.title.split('\n').join('<br>');
500
+ }
501
+
502
+ // Content
503
+ if (params.text || params.html) {
504
+ if (_typeof(params.html) === 'object') {
505
+ content.innerHTML = '';
506
+ if (0 in params.html) {
507
+ for (var _i = 0; _i in params.html; _i++) {
508
+ content.appendChild(params.html[_i].cloneNode(true));
509
+ }
510
+ } else {
511
+ content.appendChild(params.html.cloneNode(true));
512
+ }
513
+ } else if (params.html) {
514
+ content.innerHTML = params.html;
515
+ } else if (params.text) {
516
+ content.textContent = params.text;
517
+ }
518
+ show(content);
519
+ } else {
520
+ hide(content);
521
+ }
522
+
523
+ // Close button
524
+ if (params.showCloseButton) {
525
+ show(closeButton);
526
+ } else {
527
+ hide(closeButton);
528
+ }
529
+
530
+ // Custom Class
531
+ modal.className = swalClasses.modal;
532
+ if (params.customClass) {
533
+ addClass(modal, params.customClass);
534
+ }
535
+
536
+ // Progress steps
537
+ var progressStepsContainer = getProgressSteps();
538
+ var currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10);
539
+ if (params.progressSteps.length) {
540
+ show(progressStepsContainer);
541
+ empty(progressStepsContainer);
542
+ if (currentProgressStep >= params.progressSteps.length) {
543
+ console.warn('SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
544
+ }
545
+ params.progressSteps.forEach(function (step, index) {
546
+ var circle = document.createElement('li');
547
+ addClass(circle, swalClasses.progresscircle);
548
+ circle.innerHTML = step;
549
+ if (index === currentProgressStep) {
550
+ addClass(circle, swalClasses.activeprogressstep);
551
+ }
552
+ progressStepsContainer.appendChild(circle);
553
+ if (index !== params.progressSteps.length - 1) {
554
+ var line = document.createElement('li');
555
+ addClass(line, swalClasses.progressline);
556
+ line.style.width = params.progressStepsDistance;
557
+ progressStepsContainer.appendChild(line);
558
+ }
559
+ });
560
+ } else {
561
+ hide(progressStepsContainer);
562
+ }
563
+
564
+ // Icon
565
+ var icons = getIcons();
566
+ for (var _i2 = 0; _i2 < icons.length; _i2++) {
567
+ hide(icons[_i2]);
568
+ }
569
+ if (params.type) {
570
+ var validType = false;
571
+ for (var iconType in iconTypes) {
572
+ if (params.type === iconType) {
573
+ validType = true;
574
+ break;
575
+ }
576
+ }
577
+ if (!validType) {
578
+ console.error('SweetAlert2: Unknown alert type: ' + params.type);
579
+ return false;
580
+ }
581
+ var icon = modal.querySelector('.' + swalClasses.icon + '.' + iconTypes[params.type]);
582
+ show(icon);
583
+
584
+ // Animate icon
585
+ if (params.animation) {
586
+ switch (params.type) {
587
+ case 'success':
588
+ addClass(icon, 'swal2-animate-success-icon');
589
+ addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip');
590
+ addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long');
591
+ break;
592
+ case 'error':
593
+ addClass(icon, 'swal2-animate-error-icon');
594
+ addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark');
595
+ break;
596
+ default:
597
+ break;
598
+ }
599
+ }
600
+ }
601
+
602
+ // Custom image
603
+ var image = getImage();
604
+ if (params.imageUrl) {
605
+ image.setAttribute('src', params.imageUrl);
606
+ show(image);
607
+
608
+ if (params.imageWidth) {
609
+ image.setAttribute('width', params.imageWidth);
610
+ } else {
611
+ image.removeAttribute('width');
612
+ }
613
+
614
+ if (params.imageHeight) {
615
+ image.setAttribute('height', params.imageHeight);
616
+ } else {
617
+ image.removeAttribute('height');
618
+ }
619
+
620
+ image.className = swalClasses.image;
621
+ if (params.imageClass) {
622
+ addClass(image, params.imageClass);
623
+ }
624
+ } else {
625
+ hide(image);
626
+ }
627
+
628
+ // Cancel button
629
+ if (params.showCancelButton) {
630
+ cancelButton.style.display = 'inline-block';
631
+ } else {
632
+ hide(cancelButton);
633
+ }
634
+
635
+ // Confirm button
636
+ if (params.showConfirmButton) {
637
+ removeStyleProperty(confirmButton, 'display');
638
+ } else {
639
+ hide(confirmButton);
640
+ }
641
+
642
+ // Buttons wrapper
643
+ if (!params.showConfirmButton && !params.showCancelButton) {
644
+ hide(buttonsWrapper);
645
+ } else {
646
+ show(buttonsWrapper);
647
+ }
648
+
649
+ // Edit text on cancel and confirm buttons
650
+ confirmButton.innerHTML = params.confirmButtonText;
651
+ cancelButton.innerHTML = params.cancelButtonText;
652
+
653
+ // Set buttons to selected background colors
654
+ if (params.buttonsStyling) {
655
+ confirmButton.style.backgroundColor = params.confirmButtonColor;
656
+ cancelButton.style.backgroundColor = params.cancelButtonColor;
657
+ }
658
+
659
+ // Add buttons custom classes
660
+ confirmButton.className = swalClasses.confirm;
661
+ addClass(confirmButton, params.confirmButtonClass);
662
+ cancelButton.className = swalClasses.cancel;
663
+ addClass(cancelButton, params.cancelButtonClass);
664
+
665
+ // Buttons styling
666
+ if (params.buttonsStyling) {
667
+ addClass(confirmButton, swalClasses.styled);
668
+ addClass(cancelButton, swalClasses.styled);
669
+ } else {
670
+ removeClass(confirmButton, swalClasses.styled);
671
+ removeClass(cancelButton, swalClasses.styled);
672
+
673
+ confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = '';
674
+ cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = '';
675
+ }
676
+
677
+ // CSS animation
678
+ if (params.animation === true) {
679
+ removeClass(modal, swalClasses.noanimation);
680
+ } else {
681
+ addClass(modal, swalClasses.noanimation);
682
+ }
683
+ };
684
+
685
+ /*
686
+ * Animations
687
+ */
688
+ var openModal = function openModal(animation, onComplete) {
689
+ var container = getContainer();
690
+ var modal = getModal();
691
+
692
+ if (animation) {
693
+ addClass(modal, swalClasses.show);
694
+ addClass(container, swalClasses.fade);
695
+ removeClass(modal, swalClasses.hide);
696
+ } else {
697
+ removeClass(modal, swalClasses.fade);
698
+ }
699
+ show(modal);
700
+
701
+ // scrolling is 'hidden' until animation is done, after that 'auto'
702
+ container.style.overflowY = 'hidden';
703
+ if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
704
+ modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
705
+ modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
706
+ container.style.overflowY = 'auto';
707
+ });
708
+ } else {
709
+ container.style.overflowY = 'auto';
710
+ }
711
+
712
+ addClass(document.documentElement, swalClasses.shown);
713
+ addClass(document.body, swalClasses.shown);
714
+ addClass(container, swalClasses.shown);
715
+ fixScrollbar();
716
+ iOSfix();
717
+ states.previousActiveElement = document.activeElement;
718
+ if (onComplete !== null && typeof onComplete === 'function') {
719
+ setTimeout(function () {
720
+ onComplete(modal);
721
+ });
722
+ }
723
+ };
724
+
725
+ var fixScrollbar = function fixScrollbar() {
726
+ // for queues, do not do this more than once
727
+ if (states.previousBodyPadding !== null) {
728
+ return;
729
+ }
730
+ // if the body has overflow
731
+ if (document.body.scrollHeight > window.innerHeight) {
732
+ // add padding so the content doesn't shift after removal of scrollbar
733
+ states.previousBodyPadding = document.body.style.paddingRight;
734
+ document.body.style.paddingRight = measureScrollbar() + 'px';
735
+ }
736
+ };
737
+
738
+ var undoScrollbar = function undoScrollbar() {
739
+ if (states.previousBodyPadding !== null) {
740
+ document.body.style.paddingRight = states.previousBodyPadding;
741
+ states.previousBodyPadding = null;
742
+ }
743
+ };
744
+
745
+ // Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
746
+ var iOSfix = function iOSfix() {
747
+ var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
748
+ if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
749
+ var offset = document.body.scrollTop;
750
+ document.body.style.top = offset * -1 + 'px';
751
+ addClass(document.body, swalClasses.iosfix);
752
+ }
753
+ };
754
+
755
+ var undoIOSfix = function undoIOSfix() {
756
+ if (hasClass(document.body, swalClasses.iosfix)) {
757
+ var offset = parseInt(document.body.style.top, 10);
758
+ removeClass(document.body, swalClasses.iosfix);
759
+ document.body.style.top = '';
760
+ document.body.scrollTop = offset * -1;
761
+ }
762
+ };
763
+
764
+ // SweetAlert entry point
765
+ var sweetAlert = function sweetAlert() {
766
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
767
+ args[_key] = arguments[_key];
768
+ }
769
+
770
+ if (args[0] === undefined) {
771
+ console.error('SweetAlert2 expects at least 1 attribute!');
772
+ return false;
773
+ }
774
+
775
+ var params = _extends({}, modalParams);
776
+
777
+ switch (_typeof(args[0])) {
778
+ case 'string':
779
+ params.title = args[0];
780
+ params.html = args[1];
781
+ params.type = args[2];
782
+
783
+ break;
784
+
785
+ case 'object':
786
+ _extends(params, args[0]);
787
+ params.extraParams = args[0].extraParams;
788
+
789
+ if (params.input === 'email' && params.inputValidator === null) {
790
+ params.inputValidator = function (email) {
791
+ return new Promise(function (resolve, reject) {
792
+ var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
793
+ if (emailRegex.test(email)) {
794
+ resolve();
795
+ } else {
796
+ reject('Invalid email address');
797
+ }
798
+ });
799
+ };
800
+ }
801
+
802
+ if (params.input === 'url' && params.inputValidator === null) {
803
+ params.inputValidator = function (url) {
804
+ return new Promise(function (resolve, reject) {
805
+ var urlRegex = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/;
806
+ if (urlRegex.test(url)) {
807
+ resolve();
808
+ } else {
809
+ reject('Invalid URL');
810
+ }
811
+ });
812
+ };
813
+ }
814
+ break;
815
+
816
+ default:
817
+ console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + _typeof(args[0]));
818
+ return false;
819
+ }
820
+
821
+ setParameters(params);
822
+
823
+ var container = getContainer();
824
+ var modal = getModal();
825
+
826
+ return new Promise(function (resolve, reject) {
827
+ // Close on timer
828
+ if (params.timer) {
829
+ modal.timeout = setTimeout(function () {
830
+ sweetAlert.closeModal(params.onClose);
831
+ reject('timer');
832
+ }, params.timer);
833
+ }
834
+
835
+ // Get input element by specified type or, if type isn't specified, by params.input
836
+ var getInput = function getInput(inputType) {
837
+ inputType = inputType || params.input;
838
+ if (!inputType) {
839
+ return null;
840
+ }
841
+ switch (inputType) {
842
+ case 'select':
843
+ case 'textarea':
844
+ case 'file':
845
+ return getChildByClass(modal, swalClasses[inputType]);
846
+ case 'checkbox':
847
+ return modal.querySelector('.' + swalClasses.checkbox + ' input');
848
+ case 'radio':
849
+ return modal.querySelector('.' + swalClasses.radio + ' input:checked') || modal.querySelector('.' + swalClasses.radio + ' input:first-child');
850
+ case 'range':
851
+ return modal.querySelector('.' + swalClasses.range + ' input');
852
+ default:
853
+ return getChildByClass(modal, swalClasses.input);
854
+ }
855
+ };
856
+
857
+ // Get the value of the modal input
858
+ var getInputValue = function getInputValue() {
859
+ var input = getInput();
860
+ if (!input) {
861
+ return null;
862
+ }
863
+ switch (params.input) {
864
+ case 'checkbox':
865
+ return input.checked ? 1 : 0;
866
+ case 'radio':
867
+ return input.checked ? input.value : null;
868
+ case 'file':
869
+ return input.files.length ? input.files[0] : null;
870
+ default:
871
+ return params.inputAutoTrim ? input.value.trim() : input.value;
872
+ }
873
+ };
874
+
875
+ // input autofocus
876
+ if (params.input) {
877
+ setTimeout(function () {
878
+ var input = getInput();
879
+ if (input) {
880
+ focusInput(input);
881
+ }
882
+ }, 0);
883
+ }
884
+
885
+ var confirm = function confirm(value) {
886
+ if (params.showLoaderOnConfirm) {
887
+ sweetAlert.showLoading();
888
+ }
889
+
890
+ if (params.preConfirm) {
891
+ params.preConfirm(value, params.extraParams).then(function (preConfirmValue) {
892
+ sweetAlert.closeModal(params.onClose);
893
+ resolve(preConfirmValue || value);
894
+ }, function (error) {
895
+ sweetAlert.hideLoading();
896
+ if (error) {
897
+ sweetAlert.showValidationError(error);
898
+ }
899
+ });
900
+ } else {
901
+ sweetAlert.closeModal(params.onClose);
902
+ resolve(value);
903
+ }
904
+ };
905
+
906
+ // Mouse interactions
907
+ var onButtonEvent = function onButtonEvent(event) {
908
+ var e = event || window.event;
909
+ var target = e.target || e.srcElement;
910
+ var confirmButton = getConfirmButton();
911
+ var cancelButton = getCancelButton();
912
+ var targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target));
913
+ var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));
914
+
915
+ switch (e.type) {
916
+ case 'mouseover':
917
+ case 'mouseup':
918
+ if (params.buttonsStyling) {
919
+ if (targetedConfirm) {
920
+ confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
921
+ } else if (targetedCancel) {
922
+ cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
923
+ }
924
+ }
925
+ break;
926
+ case 'mouseout':
927
+ if (params.buttonsStyling) {
928
+ if (targetedConfirm) {
929
+ confirmButton.style.backgroundColor = params.confirmButtonColor;
930
+ } else if (targetedCancel) {
931
+ cancelButton.style.backgroundColor = params.cancelButtonColor;
932
+ }
933
+ }
934
+ break;
935
+ case 'mousedown':
936
+ if (params.buttonsStyling) {
937
+ if (targetedConfirm) {
938
+ confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
939
+ } else if (targetedCancel) {
940
+ cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
941
+ }
942
+ }
943
+ break;
944
+ case 'click':
945
+ // Clicked 'confirm'
946
+ if (targetedConfirm && sweetAlert.isVisible()) {
947
+ sweetAlert.disableButtons();
948
+ if (params.input) {
949
+ var inputValue = getInputValue();
950
+
951
+ if (params.inputValidator) {
952
+ sweetAlert.disableInput();
953
+ params.inputValidator(inputValue, params.extraParams).then(function () {
954
+ sweetAlert.enableButtons();
955
+ sweetAlert.enableInput();
956
+ confirm(inputValue);
957
+ }, function (error) {
958
+ sweetAlert.enableButtons();
959
+ sweetAlert.enableInput();
960
+ if (error) {
961
+ sweetAlert.showValidationError(error);
962
+ }
963
+ });
964
+ } else {
965
+ confirm(inputValue);
966
+ }
967
+ } else {
968
+ confirm(true);
969
+ }
970
+
971
+ // Clicked 'cancel'
972
+ } else if (targetedCancel && sweetAlert.isVisible()) {
973
+ sweetAlert.disableButtons();
974
+ sweetAlert.closeModal(params.onClose);
975
+ reject('cancel');
976
+ }
977
+ break;
978
+ default:
979
+ }
980
+ };
981
+
982
+ var buttons = modal.querySelectorAll('button');
983
+ for (var i = 0; i < buttons.length; i++) {
984
+ buttons[i].onclick = onButtonEvent;
985
+ buttons[i].onmouseover = onButtonEvent;
986
+ buttons[i].onmouseout = onButtonEvent;
987
+ buttons[i].onmousedown = onButtonEvent;
988
+ }
989
+
990
+ // Closing modal by close button
991
+ getCloseButton().onclick = function () {
992
+ sweetAlert.closeModal(params.onClose);
993
+ reject('close');
994
+ };
995
+
996
+ // Closing modal by overlay click
997
+ container.onclick = function (e) {
998
+ if (e.target !== container) {
999
+ return;
1000
+ }
1001
+ if (params.allowOutsideClick) {
1002
+ sweetAlert.closeModal(params.onClose);
1003
+ reject('overlay');
1004
+ }
1005
+ };
1006
+
1007
+ var buttonsWrapper = getButtonsWrapper();
1008
+ var confirmButton = getConfirmButton();
1009
+ var cancelButton = getCancelButton();
1010
+
1011
+ // Reverse buttons (Confirm on the right side)
1012
+ if (params.reverseButtons) {
1013
+ confirmButton.parentNode.insertBefore(cancelButton, confirmButton);
1014
+ } else {
1015
+ confirmButton.parentNode.insertBefore(confirmButton, cancelButton);
1016
+ }
1017
+
1018
+ // Focus handling
1019
+ var setFocus = function setFocus(index, increment) {
1020
+ var focusableElements = getFocusableElements(params.focusCancel);
1021
+ // search for visible elements and select the next possible match
1022
+ for (var _i3 = 0; _i3 < focusableElements.length; _i3++) {
1023
+ index = index + increment;
1024
+
1025
+ // rollover to first item
1026
+ if (index === focusableElements.length) {
1027
+ index = 0;
1028
+
1029
+ // go to last item
1030
+ } else if (index === -1) {
1031
+ index = focusableElements.length - 1;
1032
+ }
1033
+
1034
+ // determine if element is visible
1035
+ var el = focusableElements[index];
1036
+ if (isVisible(el)) {
1037
+ return el.focus();
1038
+ }
1039
+ }
1040
+ };
1041
+
1042
+ var handleKeyDown = function handleKeyDown(event) {
1043
+ var e = event || window.event;
1044
+ var keyCode = e.keyCode || e.which;
1045
+
1046
+ if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
1047
+ // Don't do work on keys we don't care about.
1048
+ return;
1049
+ }
1050
+
1051
+ var targetElement = e.target || e.srcElement;
1052
+
1053
+ var focusableElements = getFocusableElements(params.focusCancel);
1054
+ var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.
1055
+ for (var _i4 = 0; _i4 < focusableElements.length; _i4++) {
1056
+ if (targetElement === focusableElements[_i4]) {
1057
+ btnIndex = _i4;
1058
+ break;
1059
+ }
1060
+ }
1061
+
1062
+ // TAB
1063
+ if (keyCode === 9) {
1064
+ if (!e.shiftKey) {
1065
+ // Cycle to the next button
1066
+ setFocus(btnIndex, 1);
1067
+ } else {
1068
+ // Cycle to the prev button
1069
+ setFocus(btnIndex, -1);
1070
+ }
1071
+ e.stopPropagation();
1072
+ e.preventDefault();
1073
+
1074
+ // ARROWS - switch focus between buttons
1075
+ } else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
1076
+ // focus Cancel button if Confirm button is currently focused
1077
+ if (document.activeElement === confirmButton && isVisible(cancelButton)) {
1078
+ cancelButton.focus();
1079
+ // and vice versa
1080
+ } else if (document.activeElement === cancelButton && isVisible(confirmButton)) {
1081
+ confirmButton.focus();
1082
+ }
1083
+
1084
+ // ENTER/SPACE
1085
+ } else if (keyCode === 13 || keyCode === 32) {
1086
+ if (btnIndex === -1 && params.allowEnterKey) {
1087
+ // ENTER/SPACE clicked outside of a button.
1088
+ if (params.focusCancel) {
1089
+ fireClick(cancelButton, e);
1090
+ } else {
1091
+ fireClick(confirmButton, e);
1092
+ }
1093
+ e.stopPropagation();
1094
+ e.preventDefault();
1095
+ }
1096
+
1097
+ // ESC
1098
+ } else if (keyCode === 27 && params.allowEscapeKey === true) {
1099
+ sweetAlert.closeModal(params.onClose);
1100
+ reject('esc');
1101
+ }
1102
+ };
1103
+
1104
+ states.previousWindowKeyDown = window.onkeydown;
1105
+ window.onkeydown = handleKeyDown;
1106
+
1107
+ // Loading state
1108
+ if (params.buttonsStyling) {
1109
+ confirmButton.style.borderLeftColor = params.confirmButtonColor;
1110
+ confirmButton.style.borderRightColor = params.confirmButtonColor;
1111
+ }
1112
+
1113
+ /**
1114
+ * Show spinner instead of Confirm button and disable Cancel button
1115
+ */
1116
+ sweetAlert.showLoading = sweetAlert.enableLoading = function () {
1117
+ show(buttonsWrapper);
1118
+ show(confirmButton, 'inline-block');
1119
+ addClass(buttonsWrapper, swalClasses.loading);
1120
+ addClass(modal, swalClasses.loading);
1121
+ confirmButton.disabled = true;
1122
+ cancelButton.disabled = true;
1123
+ };
1124
+
1125
+ /**
1126
+ * Show spinner instead of Confirm button and disable Cancel button
1127
+ */
1128
+ sweetAlert.hideLoading = sweetAlert.disableLoading = function () {
1129
+ if (!params.showConfirmButton) {
1130
+ hide(confirmButton);
1131
+ if (!params.showCancelButton) {
1132
+ hide(getButtonsWrapper());
1133
+ }
1134
+ }
1135
+ removeClass(buttonsWrapper, swalClasses.loading);
1136
+ removeClass(modal, swalClasses.loading);
1137
+ confirmButton.disabled = false;
1138
+ cancelButton.disabled = false;
1139
+ };
1140
+
1141
+ sweetAlert.getTitle = function () {
1142
+ return getTitle();
1143
+ };
1144
+ sweetAlert.getContent = function () {
1145
+ return getContent();
1146
+ };
1147
+ sweetAlert.getInput = function () {
1148
+ return getInput();
1149
+ };
1150
+ sweetAlert.getImage = function () {
1151
+ return getImage();
1152
+ };
1153
+ sweetAlert.getButtonsWrapper = function () {
1154
+ return getButtonsWrapper();
1155
+ };
1156
+ sweetAlert.getConfirmButton = function () {
1157
+ return getConfirmButton();
1158
+ };
1159
+ sweetAlert.getCancelButton = function () {
1160
+ return getCancelButton();
1161
+ };
1162
+
1163
+ sweetAlert.enableButtons = function () {
1164
+ confirmButton.disabled = false;
1165
+ cancelButton.disabled = false;
1166
+ };
1167
+
1168
+ sweetAlert.disableButtons = function () {
1169
+ confirmButton.disabled = true;
1170
+ cancelButton.disabled = true;
1171
+ };
1172
+
1173
+ sweetAlert.enableConfirmButton = function () {
1174
+ confirmButton.disabled = false;
1175
+ };
1176
+
1177
+ sweetAlert.disableConfirmButton = function () {
1178
+ confirmButton.disabled = true;
1179
+ };
1180
+
1181
+ sweetAlert.enableInput = function () {
1182
+ var input = getInput();
1183
+ if (!input) {
1184
+ return false;
1185
+ }
1186
+ if (input.type === 'radio') {
1187
+ var radiosContainer = input.parentNode.parentNode;
1188
+ var radios = radiosContainer.querySelectorAll('input');
1189
+ for (var _i5 = 0; _i5 < radios.length; _i5++) {
1190
+ radios[_i5].disabled = false;
1191
+ }
1192
+ } else {
1193
+ input.disabled = false;
1194
+ }
1195
+ };
1196
+
1197
+ sweetAlert.disableInput = function () {
1198
+ var input = getInput();
1199
+ if (!input) {
1200
+ return false;
1201
+ }
1202
+ if (input && input.type === 'radio') {
1203
+ var radiosContainer = input.parentNode.parentNode;
1204
+ var radios = radiosContainer.querySelectorAll('input');
1205
+ for (var _i6 = 0; _i6 < radios.length; _i6++) {
1206
+ radios[_i6].disabled = true;
1207
+ }
1208
+ } else {
1209
+ input.disabled = true;
1210
+ }
1211
+ };
1212
+
1213
+ // Set modal min-height to disable scrolling inside the modal
1214
+ sweetAlert.recalculateHeight = debounce(function () {
1215
+ var modal = getModal();
1216
+ if (!modal) {
1217
+ return;
1218
+ }
1219
+ var prevState = modal.style.display;
1220
+ modal.style.minHeight = '';
1221
+ show(modal);
1222
+ modal.style.minHeight = modal.scrollHeight + 1 + 'px';
1223
+ modal.style.display = prevState;
1224
+ }, 50);
1225
+
1226
+ // Show block with validation error
1227
+ sweetAlert.showValidationError = function (error) {
1228
+ var validationError = getValidationError();
1229
+ validationError.innerHTML = error;
1230
+ show(validationError);
1231
+
1232
+ var input = getInput();
1233
+ if (input) {
1234
+ focusInput(input);
1235
+ addClass(input, swalClasses.inputerror);
1236
+ }
1237
+ };
1238
+
1239
+ // Hide block with validation error
1240
+ sweetAlert.resetValidationError = function () {
1241
+ var validationError = getValidationError();
1242
+ hide(validationError);
1243
+ sweetAlert.recalculateHeight();
1244
+
1245
+ var input = getInput();
1246
+ if (input) {
1247
+ removeClass(input, swalClasses.inputerror);
1248
+ }
1249
+ };
1250
+
1251
+ sweetAlert.getProgressSteps = function () {
1252
+ return params.progressSteps;
1253
+ };
1254
+
1255
+ sweetAlert.setProgressSteps = function (progressSteps) {
1256
+ params.progressSteps = progressSteps;
1257
+ setParameters(params);
1258
+ };
1259
+
1260
+ sweetAlert.showProgressSteps = function () {
1261
+ show(getProgressSteps());
1262
+ };
1263
+
1264
+ sweetAlert.hideProgressSteps = function () {
1265
+ hide(getProgressSteps());
1266
+ };
1267
+
1268
+ sweetAlert.enableButtons();
1269
+ sweetAlert.hideLoading();
1270
+ sweetAlert.resetValidationError();
1271
+
1272
+ // inputs
1273
+ var inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
1274
+ var input = void 0;
1275
+ for (var _i7 = 0; _i7 < inputTypes.length; _i7++) {
1276
+ var inputClass = swalClasses[inputTypes[_i7]];
1277
+ var inputContainer = getChildByClass(modal, inputClass);
1278
+ input = getInput(inputTypes[_i7]);
1279
+
1280
+ // set attributes
1281
+ if (input) {
1282
+ for (var j in input.attributes) {
1283
+ if (input.attributes.hasOwnProperty(j)) {
1284
+ var attrName = input.attributes[j].name;
1285
+ if (attrName !== 'type' && attrName !== 'value') {
1286
+ input.removeAttribute(attrName);
1287
+ }
1288
+ }
1289
+ }
1290
+ for (var attr in params.inputAttributes) {
1291
+ input.setAttribute(attr, params.inputAttributes[attr]);
1292
+ }
1293
+ }
1294
+
1295
+ // set class
1296
+ inputContainer.className = inputClass;
1297
+ if (params.inputClass) {
1298
+ addClass(inputContainer, params.inputClass);
1299
+ }
1300
+
1301
+ hide(inputContainer);
1302
+ }
1303
+
1304
+ var populateInputOptions = void 0;
1305
+ switch (params.input) {
1306
+ case 'text':
1307
+ case 'email':
1308
+ case 'password':
1309
+ case 'number':
1310
+ case 'tel':
1311
+ case 'url':
1312
+ input = getChildByClass(modal, swalClasses.input);
1313
+ input.value = params.inputValue;
1314
+ input.placeholder = params.inputPlaceholder;
1315
+ input.type = params.input;
1316
+ show(input);
1317
+ break;
1318
+ case 'file':
1319
+ input = getChildByClass(modal, swalClasses.file);
1320
+ input.placeholder = params.inputPlaceholder;
1321
+ input.type = params.input;
1322
+ show(input);
1323
+ break;
1324
+ case 'range':
1325
+ var range = getChildByClass(modal, swalClasses.range);
1326
+ var rangeInput = range.querySelector('input');
1327
+ var rangeOutput = range.querySelector('output');
1328
+ rangeInput.value = params.inputValue;
1329
+ rangeInput.type = params.input;
1330
+ rangeOutput.value = params.inputValue;
1331
+ show(range);
1332
+ break;
1333
+ case 'select':
1334
+ var select = getChildByClass(modal, swalClasses.select);
1335
+ select.innerHTML = '';
1336
+ if (params.inputPlaceholder) {
1337
+ var placeholder = document.createElement('option');
1338
+ placeholder.innerHTML = params.inputPlaceholder;
1339
+ placeholder.value = '';
1340
+ placeholder.disabled = true;
1341
+ placeholder.selected = true;
1342
+ select.appendChild(placeholder);
1343
+ }
1344
+ populateInputOptions = function populateInputOptions(inputOptions) {
1345
+ for (var optionValue in inputOptions) {
1346
+ var option = document.createElement('option');
1347
+ option.value = optionValue;
1348
+ option.innerHTML = inputOptions[optionValue];
1349
+ if (params.inputValue === optionValue) {
1350
+ option.selected = true;
1351
+ }
1352
+ select.appendChild(option);
1353
+ }
1354
+ show(select);
1355
+ select.focus();
1356
+ };
1357
+ break;
1358
+ case 'radio':
1359
+ var radio = getChildByClass(modal, swalClasses.radio);
1360
+ radio.innerHTML = '';
1361
+ populateInputOptions = function populateInputOptions(inputOptions) {
1362
+ for (var radioValue in inputOptions) {
1363
+ var radioInput = document.createElement('input');
1364
+ var radioLabel = document.createElement('label');
1365
+ var radioLabelSpan = document.createElement('span');
1366
+ radioInput.type = 'radio';
1367
+ radioInput.name = swalClasses.radio;
1368
+ radioInput.value = radioValue;
1369
+ if (params.inputValue === radioValue) {
1370
+ radioInput.checked = true;
1371
+ }
1372
+ radioLabelSpan.innerHTML = inputOptions[radioValue];
1373
+ radioLabel.appendChild(radioInput);
1374
+ radioLabel.appendChild(radioLabelSpan);
1375
+ radioLabel.for = radioInput.id;
1376
+ radio.appendChild(radioLabel);
1377
+ }
1378
+ show(radio);
1379
+ var radios = radio.querySelectorAll('input');
1380
+ if (radios.length) {
1381
+ radios[0].focus();
1382
+ }
1383
+ };
1384
+ break;
1385
+ case 'checkbox':
1386
+ var checkbox = getChildByClass(modal, swalClasses.checkbox);
1387
+ var checkboxInput = getInput('checkbox');
1388
+ checkboxInput.type = 'checkbox';
1389
+ checkboxInput.value = 1;
1390
+ checkboxInput.id = swalClasses.checkbox;
1391
+ checkboxInput.checked = Boolean(params.inputValue);
1392
+ var label = checkbox.getElementsByTagName('span');
1393
+ if (label.length) {
1394
+ checkbox.removeChild(label[0]);
1395
+ }
1396
+ label = document.createElement('span');
1397
+ label.innerHTML = params.inputPlaceholder;
1398
+ checkbox.appendChild(label);
1399
+ show(checkbox);
1400
+ break;
1401
+ case 'textarea':
1402
+ var textarea = getChildByClass(modal, swalClasses.textarea);
1403
+ textarea.value = params.inputValue;
1404
+ textarea.placeholder = params.inputPlaceholder;
1405
+ show(textarea);
1406
+ break;
1407
+ case null:
1408
+ break;
1409
+ default:
1410
+ console.error('SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "' + params.input + '"');
1411
+ break;
1412
+ }
1413
+
1414
+ if (params.input === 'select' || params.input === 'radio') {
1415
+ if (params.inputOptions instanceof Promise) {
1416
+ sweetAlert.showLoading();
1417
+ params.inputOptions.then(function (inputOptions) {
1418
+ sweetAlert.hideLoading();
1419
+ populateInputOptions(inputOptions);
1420
+ });
1421
+ } else if (_typeof(params.inputOptions) === 'object') {
1422
+ populateInputOptions(params.inputOptions);
1423
+ } else {
1424
+ console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + _typeof(params.inputOptions));
1425
+ }
1426
+ }
1427
+
1428
+ openModal(params.animation, params.onOpen);
1429
+
1430
+ // Focus the first element (input or button)
1431
+ if (params.allowEnterKey) {
1432
+ setFocus(-1, 1);
1433
+ } else {
1434
+ if (document.activeElement) {
1435
+ document.activeElement.blur();
1436
+ }
1437
+ }
1438
+
1439
+ // fix scroll
1440
+ getContainer().scrollTop = 0;
1441
+
1442
+ // Observe changes inside the modal and adjust height
1443
+ if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
1444
+ swal2Observer = new MutationObserver(sweetAlert.recalculateHeight);
1445
+ swal2Observer.observe(modal, { childList: true, characterData: true, subtree: true });
1446
+ }
1447
+ });
1448
+ };
1449
+
1450
+ /*
1451
+ * Global function to determine if swal2 modal is shown
1452
+ */
1453
+ sweetAlert.isVisible = function () {
1454
+ return !!getModal();
1455
+ };
1456
+
1457
+ /*
1458
+ * Global function for chaining sweetAlert modals
1459
+ */
1460
+ sweetAlert.queue = function (steps) {
1461
+ queue = steps;
1462
+ var resetQueue = function resetQueue() {
1463
+ queue = [];
1464
+ document.body.removeAttribute('data-swal2-queue-step');
1465
+ };
1466
+ var queueResult = [];
1467
+ return new Promise(function (resolve, reject) {
1468
+ (function step(i, callback) {
1469
+ if (i < queue.length) {
1470
+ document.body.setAttribute('data-swal2-queue-step', i);
1471
+
1472
+ sweetAlert(queue[i]).then(function (result) {
1473
+ queueResult.push(result);
1474
+ step(i + 1, callback);
1475
+ }, function (dismiss) {
1476
+ resetQueue();
1477
+ reject(dismiss);
1478
+ });
1479
+ } else {
1480
+ resetQueue();
1481
+ resolve(queueResult);
1482
+ }
1483
+ })(0);
1484
+ });
1485
+ };
1486
+
1487
+ /*
1488
+ * Global function for getting the index of current modal in queue
1489
+ */
1490
+ sweetAlert.getQueueStep = function () {
1491
+ return document.body.getAttribute('data-swal2-queue-step');
1492
+ };
1493
+
1494
+ /*
1495
+ * Global function for inserting a modal to the queue
1496
+ */
1497
+ sweetAlert.insertQueueStep = function (step, index) {
1498
+ if (index && index < queue.length) {
1499
+ return queue.splice(index, 0, step);
1500
+ }
1501
+ return queue.push(step);
1502
+ };
1503
+
1504
+ /*
1505
+ * Global function for deleting a modal from the queue
1506
+ */
1507
+ sweetAlert.deleteQueueStep = function (index) {
1508
+ if (typeof queue[index] !== 'undefined') {
1509
+ queue.splice(index, 1);
1510
+ }
1511
+ };
1512
+
1513
+ /*
1514
+ * Global function to close sweetAlert
1515
+ */
1516
+ sweetAlert.close = sweetAlert.closeModal = function (onComplete) {
1517
+ var container = getContainer();
1518
+ var modal = getModal();
1519
+ if (!modal) {
1520
+ return;
1521
+ }
1522
+ removeClass(modal, swalClasses.show);
1523
+ addClass(modal, swalClasses.hide);
1524
+ clearTimeout(modal.timeout);
1525
+
1526
+ resetPrevState();
1527
+
1528
+ var removeModalAndResetState = function removeModalAndResetState() {
1529
+ if (container.parentNode) {
1530
+ container.parentNode.removeChild(container);
1531
+ }
1532
+ removeClass(document.documentElement, swalClasses.shown);
1533
+ removeClass(document.body, swalClasses.shown);
1534
+ undoScrollbar();
1535
+ undoIOSfix();
1536
+ };
1537
+
1538
+ // If animation is supported, animate
1539
+ if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
1540
+ modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
1541
+ modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
1542
+ if (hasClass(modal, swalClasses.hide)) {
1543
+ removeModalAndResetState();
1544
+ }
1545
+ });
1546
+ } else {
1547
+ // Otherwise, remove immediately
1548
+ removeModalAndResetState();
1549
+ }
1550
+ if (onComplete !== null && typeof onComplete === 'function') {
1551
+ setTimeout(function () {
1552
+ onComplete(modal);
1553
+ });
1554
+ }
1555
+ };
1556
+
1557
+ /*
1558
+ * Global function to click 'Confirm' button
1559
+ */
1560
+ sweetAlert.clickConfirm = function () {
1561
+ return getConfirmButton().click();
1562
+ };
1563
+
1564
+ /*
1565
+ * Global function to click 'Cancel' button
1566
+ */
1567
+ sweetAlert.clickCancel = function () {
1568
+ return getCancelButton().click();
1569
+ };
1570
+
1571
+ /**
1572
+ * Set default params for each popup
1573
+ * @param {Object} userParams
1574
+ */
1575
+ sweetAlert.setDefaults = function (userParams) {
1576
+ if (!userParams || (typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') {
1577
+ return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object');
1578
+ }
1579
+
1580
+ for (var param in userParams) {
1581
+ if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
1582
+ console.warn('SweetAlert2: Unknown parameter "' + param + '"');
1583
+ delete userParams[param];
1584
+ }
1585
+ }
1586
+
1587
+ _extends(modalParams, userParams);
1588
+ };
1589
+
1590
+ /**
1591
+ * Reset default params for each popup
1592
+ */
1593
+ sweetAlert.resetDefaults = function () {
1594
+ modalParams = _extends({}, defaultParams);
1595
+ };
1596
+
1597
+ sweetAlert.noop = function () {};
1598
+
1599
+ sweetAlert.version = '6.6.2';
1600
+
1601
+ sweetAlert.default = sweetAlert;
1602
+
1603
+ return sweetAlert;
1604
+
1605
+ })));
1606
+ if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2;
1607
+
1608
+ //Override the default confirm dialog by rails
1609
+ $.rails.allowAction = function(link){
1610
+ if (link.data("confirm") == undefined){
1611
+ return true;
1612
+ }
1613
+ this.showConfirmationDialog(link);
1614
+ return false;
1615
+ }
1616
+
1617
+ //User click confirm button
1618
+ $.rails.confirmed = function(link){
1619
+ link.data("confirm", null);
1620
+ link.trigger("click.rails");
1621
+ }
1622
+
1623
+ //Display the confirmation dialog
1624
+ $.rails.showConfirmationDialog = function(link){
1625
+ var title = link.data("confirm");
1626
+ var text = link.data("text");
1627
+ var type = link.data("type");
1628
+ var custom_image = link.data("custom-image");
1629
+ var response_title = link.data("response-title");
1630
+ var response_text = link.data("response-text");
1631
+ var response_type = link.data("response-type");
1632
+
1633
+ swal({
1634
+ title: title,
1635
+ text: text !== undefined ? text : "",
1636
+ type: type !== undefined ? type : "warning",
1637
+ showCancelButton: true,
1638
+ confirmButtonColor: "#3085d6",
1639
+ cancelButtonColor: "#d33",
1640
+ confirmButtonText: "Yes"
1641
+ }).then(function () {
1642
+ swal(
1643
+ response_title !== undefined ? response_title : "Success",
1644
+ response_text !== undefined ? response_text : "",
1645
+ response_type !== undefined ? response_type : "success"
1646
+ );
1647
+ link.data("confirm", null);
1648
+ link.trigger("click.rails");
1649
+ }, function (dismiss) {
1650
+ if (dismiss == "cancel") {
1651
+ link.data("confirm", null);
1652
+ link.trigger("click.rails");
1653
+ }
1654
+ });
1655
+ }