twitter-bootstrap-rails-confirm 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ba7f8b59246c9423a9638868574b5804848b692
4
- data.tar.gz: b050961231c0042715e0002e15c52d0ca1d136eb
3
+ metadata.gz: fe8bd30ec1e2653ab77da911c4a74a28f41e55b6
4
+ data.tar.gz: 989b0d3308c31bc53e408928de07489fd23697f5
5
5
  SHA512:
6
- metadata.gz: d33ffd28ae2866614123985160aca05b99a944a655c57627ce34f088e5b97de4a5b91e55e1970aeef2d7a86b754fb5c9a88a19b41d7ae4e0c1f19402615fef14
7
- data.tar.gz: f5e669f9bd96d87284481bf4181eb22e0700448ac42bfdac607bc5707b0c4f3f282c54d32f950812ecc17ef16cba08729c4614ed422bfbce9f6403dbf3d39f11
6
+ metadata.gz: b753fc8675862f2a51f4d31986b23533ac1d2a188bc1713c0ebf08a523a672ff1ca496e51c654132dc49d88a7a3c65983509c41c42bdd764406a947819207813
7
+ data.tar.gz: c87aa22cc7b9f16c2a5a8927872f6d2f697ffa59beac9eeaafb4da122318c114954eb9faf4a6626661be29969a34d98f20c7b4f97e5c29cadf357c9416e439dc
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Twitter::Bootstrap::Rails::Confirm
2
2
 
3
- This gem adds some javascript to change the default behaviour of data-confirm processing.
3
+ This gem adds some javascript to change the default behaviour of data-confirm processing for both Boostrap 2 and Bootstrap 3.
4
4
 
5
5
  The normal confirm dialog shows a text with buttons 'ok' and 'cancel'. More information is needed here for a user to make the right decision. This gem therefore also adds:
6
6
 
@@ -34,10 +34,6 @@ Add this line to your application's Gemfile:
34
34
 
35
35
  gem 'twitter-bootstrap-rails-confirm'
36
36
 
37
- Or for Bootstrap 3 support:
38
-
39
- gem 'twitter-bootstrap-rails-confirm', github: 'bluerail/twitter-bootstrap-rails-confirm', branch: 'bootstrap3'
40
-
41
37
  And then execute:
42
38
 
43
39
  $ bundle
@@ -73,6 +69,10 @@ Next... nothing. There is nothing you need to do to get this working. A helper c
73
69
 
74
70
  ## Changelog
75
71
 
72
+ ### 1.0.4 (November 25, 2014)
73
+
74
+ * [(rvanlieshout)](https://github.com/rvanlieshout) Added bootstrap 3 support
75
+
76
76
  ### 1.0.3 (September 4, 2014)
77
77
 
78
78
  * [(rvanlieshout)](https://github.com/rvanlieshout) [Problems with using event constructors](https://github.com/bluerail/twitter-bootstrap-rails-confirm/issues/18)
@@ -2,7 +2,7 @@ module Twitter
2
2
  module Bootstrap
3
3
  module Rails
4
4
  module Confirm
5
- VERSION = "1.0.3"
5
+ VERSION = "1.0.4"
6
6
  end
7
7
  end
8
8
  end
@@ -8,22 +8,40 @@ $.fn.twitter_bootstrap_confirmbox =
8
8
  fade: false
9
9
 
10
10
  TwitterBootstrapConfirmBox = (message, element, callback) ->
11
- $dialog = $('
12
- <div class="modal hide" id="confirmation_dialog">
13
- <div class="modal-header">
14
- <button type="button" class="close" data-dismiss="modal">×</button>
15
- <h3>...</h3>
11
+ bootstrap_version = if (typeof $().emulateTransitionEnd == 'function') then 3 else 2
12
+
13
+ if bootstrap_version == 2
14
+ $dialog = $('
15
+ <div class="modal hide" id="confirmation_dialog">
16
+ <div class="modal-header">
17
+ <button type="button" class="close" data-dismiss="modal">×</button>
18
+ <h3 class="modal-title">...</h3>
19
+ </div>
20
+ <div class="modal-body"></div>
21
+ <div class="modal-footer"></div>
22
+ </div>
23
+ ')
24
+ else
25
+ $dialog = $('
26
+ <div class="modal" id="confirmation_dialog" role="dialog">
27
+ <div class="modal-dialog">
28
+ <div class="modal-content">
29
+ <div class="modal-header">
30
+ <button type="button" class="close" data-dismiss="modal">×</button>
31
+ <h4 class="modal-title">...</h4>
32
+ </div>
33
+ <div class="modal-body"></div>
34
+ <div class="modal-footer"></div>
35
+ </div>
36
+ </div>
16
37
  </div>
17
- <div class="modal-body"></div>
18
- <div class="modal-footer"></div>
19
- </div>
20
- ')
38
+ ')
21
39
 
22
40
  $dialog.addClass("fade") if element.data("confirm-fade") || $.fn.twitter_bootstrap_confirmbox.defaults.fade
23
41
 
24
42
  $dialog
25
43
  .find(".modal-header")
26
- .find("h3")
44
+ .find(".modal-title")
27
45
  .html(element.data("confirm-title") || $.fn.twitter_bootstrap_confirmbox.defaults.title || window.top.location.origin)
28
46
  .end()
29
47
  .end()
@@ -37,7 +55,7 @@ TwitterBootstrapConfirmBox = (message, element, callback) ->
37
55
  $("<a />", {href: "#", "data-dismiss": "modal"})
38
56
  .html(element.data("confirm-cancel") || $.fn.twitter_bootstrap_confirmbox.defaults.cancel)
39
57
  .addClass($.fn.twitter_bootstrap_confirmbox.defaults.cancel_class)
40
- .addClass(element.data("confirm-cancel-class"))
58
+ .addClass(element.data("confirm-cancel-class") || "btn-default")
41
59
  .click((event) ->
42
60
  event.preventDefault()
43
61
  $dialog.modal("hide")
@@ -61,62 +79,63 @@ TwitterBootstrapConfirmBox = (message, element, callback) ->
61
79
 
62
80
  .appendTo(document.body)
63
81
 
64
- $.rails.allowAction = (element) ->
65
- message = element.data("confirm")
66
- answer = false
67
- return true unless message
82
+ if (typeof $().modal == 'function') # test if bootstrap is loaded
83
+ $.rails.allowAction = (element) ->
84
+ message = element.data("confirm")
85
+ answer = false
86
+ return true unless message
68
87
 
69
- if $.rails.fire(element, "confirm")
70
- TwitterBootstrapConfirmBox message, element, ->
71
- if $.rails.fire(element, "confirm:complete", [answer])
72
- allowAction = $.rails.allowAction
88
+ if $.rails.fire(element, "confirm")
89
+ TwitterBootstrapConfirmBox message, element, ->
90
+ if $.rails.fire(element, "confirm:complete", [answer])
91
+ allowAction = $.rails.allowAction
73
92
 
74
- $.rails.allowAction = ->
75
- true
76
-
77
- if element.get(0).click
78
- element.get(0).click()
93
+ $.rails.allowAction = ->
94
+ true
79
95
 
80
- else if Event?
81
- evt = new Event("click", {
82
- bubbles: true,
83
- cancelable: true,
84
- view: window,
85
- detail: 0,
86
- screenX: 0,
87
- screenY: 0,
88
- clientX: 0,
89
- clientY: 0,
90
- ctrlKey: false,
91
- altKey: false,
92
- shiftKey: false,
93
- metaKey: false,
94
- button: 0,
95
- relatedTarget: document.body.parentNode
96
- })
97
- element.get(0).dispatchEvent(evt)
96
+ if element.get(0).click
97
+ element.get(0).click()
98
+
99
+ else if Event?
100
+ evt = new Event("click", {
101
+ bubbles: true,
102
+ cancelable: true,
103
+ view: window,
104
+ detail: 0,
105
+ screenX: 0,
106
+ screenY: 0,
107
+ clientX: 0,
108
+ clientY: 0,
109
+ ctrlKey: false,
110
+ altKey: false,
111
+ shiftKey: false,
112
+ metaKey: false,
113
+ button: 0,
114
+ relatedTarget: document.body.parentNode
115
+ })
116
+ element.get(0).dispatchEvent(evt)
98
117
 
99
- else if $.isFunction(document.createEvent)
100
- evt = document.createEvent "MouseEvents"
101
- evt.initMouseEvent(
102
- "click",
103
- true, # e.bubbles,
104
- true, # e.cancelable,
105
- window, # e.view,
106
- 0, # e.detail,
107
- 0, # e.screenX,
108
- 0, # e.screenY,
109
- 0, # e.clientX,
110
- 0, # e.clientY,
111
- false, # e.ctrlKey,
112
- false, # e.altKey,
113
- false, # e.shiftKey,
114
- false, # e.metaKey,
115
- 0, # e.button,
116
- document.body.parentNode # e.relatedTarget
117
- )
118
- element.get(0).dispatchEvent(evt)
118
+ else if $.isFunction(document.createEvent)
119
+ evt = document.createEvent "MouseEvents"
120
+ evt.initMouseEvent(
121
+ "click",
122
+ true, # e.bubbles,
123
+ true, # e.cancelable,
124
+ window, # e.view,
125
+ 0, # e.detail,
126
+ 0, # e.screenX,
127
+ 0, # e.screenY,
128
+ 0, # e.clientX,
129
+ 0, # e.clientY,
130
+ false, # e.ctrlKey,
131
+ false, # e.altKey,
132
+ false, # e.shiftKey,
133
+ false, # e.metaKey,
134
+ 0, # e.button,
135
+ document.body.parentNode # e.relatedTarget
136
+ )
137
+ element.get(0).dispatchEvent(evt)
119
138
 
120
- $.rails.allowAction = allowAction
121
-
122
- false
139
+ $.rails.allowAction = allowAction
140
+
141
+ false
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: 1.0.3
4
+ version: 1.0.4
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: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Confirm dialogs using Twitter Bootstrap
14
14
  email: