twitter-bootstrap-rails-confirm 1.0.7 → 2.0.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 045cf9e7b41fdb990daa53d717bc949ba7ccde47
|
4
|
+
data.tar.gz: af66568c470fba6bccfeb7e26b03adb54b02c52d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c411fc916c52ce1d48dfdd08d58a9f0831e9869f3ff7766117be27a6024b8e952ef46bcd0371f99bfd32c26db1eb1e5612c9b918bf97a20f6c0fd9d8bcbdf25c
|
7
|
+
data.tar.gz: b6d56c7410b99040b3c548a8c6ad7ce584d8357b468b0fa16ee4a07f4def5fa2a7584add8e017caa0da78edbd71bf2003271a7e81060902014c7a2f83c5e871a
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2012 Rene van Lieshout
|
1
|
+
Copyright (c) 2012 - 2018 Rene van Lieshout
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -67,14 +67,14 @@ of destroy buttons:
|
|
67
67
|
def destroy_link_to(path, options)
|
68
68
|
link_to t('.destroy'), path,
|
69
69
|
:method => :delete,
|
70
|
-
:class =>
|
70
|
+
:class => 'btn',
|
71
71
|
:confirm => t('.destroy_confirm.body', :item => options[:item]),
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
'data-confirm-fade' => true,
|
73
|
+
'data-confirm-title' => t('.destroy_confirm.title', :item => options[:item]),
|
74
|
+
'data-confirm-cancel' => t('.destroy_confirm.cancel', :item => options[:item]),
|
75
|
+
'data-confirm-cancel-class' => 'btn-default'),
|
76
|
+
'data-confirm-proceed' => t('.destroy_confirm.proceed', :item => options[:item]),
|
77
|
+
'data-confirm-proceed-class' => 'btn-danger'
|
78
78
|
end
|
79
79
|
```
|
80
80
|
|
@@ -93,9 +93,13 @@ simple app that loads Bootstrap and this gem.
|
|
93
93
|
|
94
94
|
## Changelog
|
95
95
|
|
96
|
+
### 2.0.0 (April 26, 2018)
|
97
|
+
|
98
|
+
* [(mftaff)](https://github.com/mftaff) [Convert CoffeeScript to JavaScript](https://github.com/bluerail/twitter-bootstrap-rails-confirm/pull/37)
|
99
|
+
|
96
100
|
### 1.0.7 (November 24, 2017)
|
97
101
|
|
98
|
-
* [(thiesp)](https://github.com/thiesp) [Adding template and setting default cancel class to btn-secondary for bootstrap 4](https://github.com/bluerail/twitter-bootstrap-rails-confirm/pull/
|
102
|
+
* [(thiesp)](https://github.com/thiesp) [Adding template and setting default cancel class to btn-secondary for bootstrap 4](https://github.com/bluerail/twitter-bootstrap-rails-confirm/pull/35)
|
99
103
|
|
100
104
|
### 1.0.6 (June 9, 2016)
|
101
105
|
|
@@ -0,0 +1,114 @@
|
|
1
|
+
(function() {
|
2
|
+
var TwitterBootstrapConfirmBox;
|
3
|
+
|
4
|
+
$.fn.twitter_bootstrap_confirmbox = {
|
5
|
+
defaults: {
|
6
|
+
title: null,
|
7
|
+
proceed: "OK",
|
8
|
+
proceed_class: "btn proceed",
|
9
|
+
cancel: "Cancel",
|
10
|
+
cancel_class: "btn cancel",
|
11
|
+
fade: false,
|
12
|
+
modal_class: ""
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
TwitterBootstrapConfirmBox = function(message, element, callback) {
|
17
|
+
var $dialog, bootstrap_version;
|
18
|
+
bootstrap_version = typeof $().emulateTransitionEnd === 'function' ? parseInt($.fn.tooltip.Constructor.VERSION[0]) : 2;
|
19
|
+
|
20
|
+
switch (bootstrap_version) {
|
21
|
+
case 2:
|
22
|
+
$dialog = $('<div class="modal hide" id="confirmation_dialog"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h3 class="modal-title">...</h3> </div> <div class="modal-body"></div> <div class="modal-footer"></div> </div>');
|
23
|
+
break;
|
24
|
+
case 3:
|
25
|
+
$dialog = $('<div class="modal" id="confirmation_dialog" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">...</h4> </div> <div class="modal-body"></div> <div class="modal-footer"></div> </div> </div> </div>');
|
26
|
+
break;
|
27
|
+
default:
|
28
|
+
$dialog = $('<div class="modal" id="confirmation_dialog" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">...</h4> <button type="button" class="close" data-dismiss="modal">×</button> </div> <div class="modal-body"></div> <div class="modal-footer"></div> </div> </div> </div>');
|
29
|
+
}
|
30
|
+
|
31
|
+
$dialog.addClass(element.data("confirm-modal-class") || $.fn.twitter_bootstrap_confirmbox.defaults.modal_class);
|
32
|
+
|
33
|
+
if (element.data("confirm-fade") || $.fn.twitter_bootstrap_confirmbox.defaults.fade) {
|
34
|
+
$dialog.addClass("fade");
|
35
|
+
}
|
36
|
+
|
37
|
+
$dialog.find(".modal-header .modal-title").html(element.data("confirm-title") || $.fn.twitter_bootstrap_confirmbox.defaults.title || window.top.location.origin);
|
38
|
+
|
39
|
+
$dialog.find(".modal-body").html(message.toString().replace(/\n/g, "<br />"));
|
40
|
+
|
41
|
+
var cancel_buton = $("<a />", { href: "#", "data-dismiss": "modal" });
|
42
|
+
cancel_buton.html(element.data("confirm-cancel") || $.fn.twitter_bootstrap_confirmbox.defaults.cancel);
|
43
|
+
cancel_buton.addClass($.fn.twitter_bootstrap_confirmbox.defaults.cancel_class);
|
44
|
+
cancel_buton.addClass(element.data("confirm-cancel-class") || (bootstrap_version === 4 ? "btn-secondary" : void 0) || "btn-default");
|
45
|
+
cancel_buton.click(function(event) {
|
46
|
+
event.preventDefault();
|
47
|
+
return $dialog.modal("hide");
|
48
|
+
});
|
49
|
+
$dialog.find(".modal-footer").append(cancel_buton);
|
50
|
+
|
51
|
+
var confirm_button = $("<a />", { href: "#" });
|
52
|
+
confirm_button.html(element.data("confirm-proceed") || $.fn.twitter_bootstrap_confirmbox.defaults.proceed);
|
53
|
+
confirm_button.addClass($.fn.twitter_bootstrap_confirmbox.defaults.proceed_class);
|
54
|
+
confirm_button.addClass(element.data("confirm-proceed-class") || "btn-primary");
|
55
|
+
confirm_button.click(function(event) {
|
56
|
+
event.preventDefault();
|
57
|
+
$dialog.modal("hide");
|
58
|
+
return callback();
|
59
|
+
});
|
60
|
+
$dialog.find(".modal-footer").append(confirm_button);
|
61
|
+
|
62
|
+
$dialog.on('keypress', function(e) {
|
63
|
+
if (e.keyCode === 13) { return $('.modal-footer a:last').trigger('click'); }
|
64
|
+
}).on("hidden hidden.bs.modal", function() {
|
65
|
+
return $(this).remove();
|
66
|
+
});
|
67
|
+
|
68
|
+
$dialog.modal("show").appendTo(document.body);
|
69
|
+
};
|
70
|
+
|
71
|
+
if (typeof $().modal === 'function') {
|
72
|
+
$.rails.allowAction = function(element) {
|
73
|
+
$(element).blur();
|
74
|
+
|
75
|
+
var message = element.data("confirm");
|
76
|
+
var answer = false;
|
77
|
+
|
78
|
+
if (!message) {
|
79
|
+
return true;
|
80
|
+
}
|
81
|
+
|
82
|
+
if ($.rails.fire(element, "confirm")) {
|
83
|
+
TwitterBootstrapConfirmBox(message, element, function() {
|
84
|
+
if ($.rails.fire(element, "confirm:complete", [answer])) {
|
85
|
+
var allowAction = $.rails.allowAction;
|
86
|
+
|
87
|
+
$.rails.allowAction = function() {
|
88
|
+
return true;
|
89
|
+
};
|
90
|
+
|
91
|
+
if (element.get(0).click) {
|
92
|
+
element.get(0).click();
|
93
|
+
} else if (typeof Event !== "undefined" && Event !== null) {
|
94
|
+
var evt = new Event("click", { bubbles: true, cancelable: true, view: window, detail: 0, screenX: 0,
|
95
|
+
screenY: 0, clientX: 0, clientY: 0, ctrlKey: false, altKey: false,
|
96
|
+
shiftKey: false, metaKey: false, button: 0,
|
97
|
+
relatedTarget: document.body.parentNode });
|
98
|
+
|
99
|
+
element.get(0).dispatchEvent(evt);
|
100
|
+
} else if ($.isFunction(document.createEvent)) {
|
101
|
+
var evt = document.createEvent("MouseEvents");
|
102
|
+
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, document.body.parentNode);
|
103
|
+
|
104
|
+
element.get(0).dispatchEvent(evt);
|
105
|
+
}
|
106
|
+
|
107
|
+
return $.rails.allowAction = allowAction;
|
108
|
+
}
|
109
|
+
});
|
110
|
+
}
|
111
|
+
return false;
|
112
|
+
};
|
113
|
+
}
|
114
|
+
}).call(this);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-bootstrap-rails-confirm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rene van Lieshout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Confirm dialogs using Twitter Bootstrap
|
14
14
|
email:
|
@@ -26,7 +26,7 @@ files:
|
|
26
26
|
- lib/twitter-bootstrap-rails-confirm/engine.rb
|
27
27
|
- lib/twitter-bootstrap-rails-confirm/version.rb
|
28
28
|
- twitter-bootstrap-rails-confirm.gemspec
|
29
|
-
- vendor/assets/javascripts/twitter/bootstrap/rails/confirm.
|
29
|
+
- vendor/assets/javascripts/twitter/bootstrap/rails/confirm.js
|
30
30
|
homepage: https://github.com/bluerail/twitter-bootstrap-rails-confirm
|
31
31
|
licenses: []
|
32
32
|
metadata: {}
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
requirements: []
|
49
49
|
rubyforge_project:
|
50
|
-
rubygems_version: 2.
|
50
|
+
rubygems_version: 2.6.14
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: Applies a custom confirm dialog for elements with a data-confirm attribute.
|
@@ -1,165 +0,0 @@
|
|
1
|
-
$.fn.twitter_bootstrap_confirmbox =
|
2
|
-
defaults:
|
3
|
-
title: null
|
4
|
-
proceed: "OK"
|
5
|
-
proceed_class: "btn proceed"
|
6
|
-
cancel: "Cancel"
|
7
|
-
cancel_class: "btn cancel"
|
8
|
-
fade: false
|
9
|
-
modal_class: ""
|
10
|
-
|
11
|
-
TwitterBootstrapConfirmBox = (message, element, callback) ->
|
12
|
-
bootstrap_version = if (typeof $().emulateTransitionEnd == 'function') then parseInt($.fn.tooltip.Constructor.VERSION[0]) else 2
|
13
|
-
|
14
|
-
switch bootstrap_version
|
15
|
-
when 2
|
16
|
-
$dialog = $('
|
17
|
-
<div class="modal hide" id="confirmation_dialog">
|
18
|
-
<div class="modal-header">
|
19
|
-
<button type="button" class="close" data-dismiss="modal">×</button>
|
20
|
-
<h3 class="modal-title">...</h3>
|
21
|
-
</div>
|
22
|
-
<div class="modal-body"></div>
|
23
|
-
<div class="modal-footer"></div>
|
24
|
-
</div>
|
25
|
-
')
|
26
|
-
when 3
|
27
|
-
$dialog = $('
|
28
|
-
<div class="modal" id="confirmation_dialog" role="dialog">
|
29
|
-
<div class="modal-dialog">
|
30
|
-
<div class="modal-content">
|
31
|
-
<div class="modal-header">
|
32
|
-
<button type="button" class="close" data-dismiss="modal">×</button>
|
33
|
-
<h4 class="modal-title">...</h4>
|
34
|
-
</div>
|
35
|
-
<div class="modal-body"></div>
|
36
|
-
<div class="modal-footer"></div>
|
37
|
-
</div>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
')
|
41
|
-
else # 4
|
42
|
-
$dialog = $('
|
43
|
-
<div class="modal" id="confirmation_dialog" role="dialog">
|
44
|
-
<div class="modal-dialog">
|
45
|
-
<div class="modal-content">
|
46
|
-
<div class="modal-header">
|
47
|
-
<h4 class="modal-title">...</h4>
|
48
|
-
<button type="button" class="close" data-dismiss="modal">×</button>
|
49
|
-
</div>
|
50
|
-
<div class="modal-body"></div>
|
51
|
-
<div class="modal-footer"></div>
|
52
|
-
</div>
|
53
|
-
</div>
|
54
|
-
</div>
|
55
|
-
')
|
56
|
-
|
57
|
-
$dialog.addClass(element.data("confirm-modal-class") || $.fn.twitter_bootstrap_confirmbox.defaults.modal_class)
|
58
|
-
|
59
|
-
$dialog.addClass("fade") if element.data("confirm-fade") || $.fn.twitter_bootstrap_confirmbox.defaults.fade
|
60
|
-
|
61
|
-
$dialog
|
62
|
-
.find(".modal-header")
|
63
|
-
.find(".modal-title")
|
64
|
-
.html(element.data("confirm-title") || $.fn.twitter_bootstrap_confirmbox.defaults.title || window.top.location.origin)
|
65
|
-
.end()
|
66
|
-
.end()
|
67
|
-
|
68
|
-
.find(".modal-body")
|
69
|
-
.html(message.toString().replace(/\n/g, "<br />"))
|
70
|
-
.end()
|
71
|
-
|
72
|
-
.find(".modal-footer")
|
73
|
-
.append(
|
74
|
-
$("<a />", {href: "#", "data-dismiss": "modal"})
|
75
|
-
.html(element.data("confirm-cancel") || $.fn.twitter_bootstrap_confirmbox.defaults.cancel)
|
76
|
-
.addClass($.fn.twitter_bootstrap_confirmbox.defaults.cancel_class)
|
77
|
-
.addClass(element.data("confirm-cancel-class") || ("btn-secondary" if bootstrap_version == 4) || "btn-default")
|
78
|
-
.click((event) ->
|
79
|
-
event.preventDefault()
|
80
|
-
$dialog.modal("hide")
|
81
|
-
)
|
82
|
-
,
|
83
|
-
$("<a />", {href: "#"})
|
84
|
-
.html(element.data("confirm-proceed") || $.fn.twitter_bootstrap_confirmbox.defaults.proceed)
|
85
|
-
.addClass($.fn.twitter_bootstrap_confirmbox.defaults.proceed_class)
|
86
|
-
.addClass(element.data("confirm-proceed-class") || "btn-primary")
|
87
|
-
.click((event) ->
|
88
|
-
event.preventDefault()
|
89
|
-
$dialog.modal("hide")
|
90
|
-
callback()
|
91
|
-
)
|
92
|
-
)
|
93
|
-
.end()
|
94
|
-
|
95
|
-
.on('keypress', (e) ->
|
96
|
-
$('.modal-footer a:last').trigger('click') if e.keyCode == 13 # Enter Key Code
|
97
|
-
)
|
98
|
-
|
99
|
-
.on("hidden hidden.bs.modal", -> $(this).remove())
|
100
|
-
|
101
|
-
.modal("show")
|
102
|
-
|
103
|
-
.appendTo(document.body)
|
104
|
-
|
105
|
-
if (typeof $().modal == 'function') # test if bootstrap is loaded
|
106
|
-
$.rails.allowAction = (element) ->
|
107
|
-
$(element).blur();
|
108
|
-
message = element.data("confirm")
|
109
|
-
answer = false
|
110
|
-
return true unless message
|
111
|
-
|
112
|
-
if $.rails.fire(element, "confirm")
|
113
|
-
TwitterBootstrapConfirmBox message, element, ->
|
114
|
-
if $.rails.fire(element, "confirm:complete", [answer])
|
115
|
-
allowAction = $.rails.allowAction
|
116
|
-
|
117
|
-
$.rails.allowAction = ->
|
118
|
-
true
|
119
|
-
|
120
|
-
if element.get(0).click
|
121
|
-
element.get(0).click()
|
122
|
-
|
123
|
-
else if Event?
|
124
|
-
evt = new Event("click", {
|
125
|
-
bubbles: true,
|
126
|
-
cancelable: true,
|
127
|
-
view: window,
|
128
|
-
detail: 0,
|
129
|
-
screenX: 0,
|
130
|
-
screenY: 0,
|
131
|
-
clientX: 0,
|
132
|
-
clientY: 0,
|
133
|
-
ctrlKey: false,
|
134
|
-
altKey: false,
|
135
|
-
shiftKey: false,
|
136
|
-
metaKey: false,
|
137
|
-
button: 0,
|
138
|
-
relatedTarget: document.body.parentNode
|
139
|
-
})
|
140
|
-
element.get(0).dispatchEvent(evt)
|
141
|
-
|
142
|
-
else if $.isFunction(document.createEvent)
|
143
|
-
evt = document.createEvent "MouseEvents"
|
144
|
-
evt.initMouseEvent(
|
145
|
-
"click",
|
146
|
-
true, # e.bubbles,
|
147
|
-
true, # e.cancelable,
|
148
|
-
window, # e.view,
|
149
|
-
0, # e.detail,
|
150
|
-
0, # e.screenX,
|
151
|
-
0, # e.screenY,
|
152
|
-
0, # e.clientX,
|
153
|
-
0, # e.clientY,
|
154
|
-
false, # e.ctrlKey,
|
155
|
-
false, # e.altKey,
|
156
|
-
false, # e.shiftKey,
|
157
|
-
false, # e.metaKey,
|
158
|
-
0, # e.button,
|
159
|
-
document.body.parentNode # e.relatedTarget
|
160
|
-
)
|
161
|
-
element.get(0).dispatchEvent(evt)
|
162
|
-
|
163
|
-
$.rails.allowAction = allowAction
|
164
|
-
|
165
|
-
false
|