twitter-bootstrap-rails-confirm 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,29 +4,28 @@ This gem adds some javascript to change the default behaviour of data-confirm pr
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
 
7
+ * data-confirm-fade (default: false)
7
8
  * data-confirm-title (default: window.top.location.origin)
8
9
  * data-confirm-cancel (default: 'cancel')
9
10
  * data-confirm-proceed (default: 'ok')
10
11
  * data-confirm-proceed-class (default: 'brn-primary')
11
12
 
12
- This behaviour is similar to that of a "regular" confirm box in ways that it uses the same title and button labels. Defaults are set when the DOM has been loaded and can be changed in two ways:
13
+ This behaviour is similar to that of a "regular" confirm box in ways that it uses the same title and button labels. Defaults can be changed in two ways:
13
14
 
14
15
  Changing all default values:
15
16
 
16
- $(document).ready(function() {
17
- $.fn.twitter_bootstrap_confirmbox.defaults = {
18
- title: null, // if title equals null window.top.location.origin is used
19
- cancel: "Cancel",
20
- proceed: "OK",
21
- proceed_class: "btn proceed btn-primary"
22
- }
23
- });
17
+ $.fn.twitter_bootstrap_confirmbox.defaults = {
18
+ fade: false,
19
+ title: null, // if title equals null window.top.location.origin is used
20
+ cancel: "Cancel",
21
+ proceed: "OK",
22
+ proceed_class: "btn proceed btn-primary"
23
+ };
24
24
 
25
- Only changing the proceed_class default:
25
+ Only changing one default value:
26
+
27
+ $.fn.twitter_bootstrap_confirmbox.defaults.proceed_class = "btn proceed btn-success";
26
28
 
27
- $(document).ready(function() {
28
- $.fn.twitter_bootstrap_confirmbox.defaults.proceed_class = "btn proceed btn-success"
29
- });
30
29
 
31
30
  ## Installation
32
31
 
@@ -44,7 +43,7 @@ Or install it yourself as:
44
43
 
45
44
  ## Usage
46
45
 
47
- Add it to your application.js:
46
+ Add it to your application.js, anywhere after you require jquery_ujs:
48
47
 
49
48
  //= require twitter/bootstrap/rails/confirm
50
49
 
@@ -55,6 +54,7 @@ Next... nothing. There is nothing you need to do to get this working. A helper c
55
54
  :method => :delete,
56
55
  :class => "btn",
57
56
  :confirm => t('.destroy_confirm.body', :item => options[:item]),
57
+ "data-confirm-fade" => true,
58
58
  "data-confirm-title" => t('.destroy_confirm.title', :item => options[:item]),
59
59
  "data-confirm-cancel" => t('.destroy_confirm.cancel', :item => options[:item]),
60
60
  "data-confirm-proceed" => t('.destroy_confirm.proceed', :item => options[:item]),
@@ -68,3 +68,16 @@ Next... nothing. There is nothing you need to do to get this working. A helper c
68
68
  3. Commit your changes (`git commit -am 'Added some feature'`)
69
69
  4. Push to the branch (`git push origin my-new-feature`)
70
70
  5. Create new Pull Request
71
+
72
+ ## Changelog
73
+
74
+ ### 1.0.1 (April 23, 2013)
75
+
76
+ * (kramerc) Add an option for including the fade class.
77
+ * (taavo) update docs to remove DOM load requirement when setting defaults
78
+ * (taavo) don't wait for dom to load
79
+
80
+ ### 1.0.0 (February 22, 2013)
81
+
82
+ * First 'official' release
83
+ * Many thanks to taavo for his contributions
@@ -2,7 +2,7 @@ module Twitter
2
2
  module Bootstrap
3
3
  module Rails
4
4
  module Confirm
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
8
8
  end
@@ -1,75 +1,78 @@
1
- $ ->
2
- $.fn.twitter_bootstrap_confirmbox =
3
- defaults:
4
- title: null
5
- cancel: "Cancel"
6
- proceed: "OK"
7
- proceed_class: "btn proceed btn-primary"
1
+ $.fn.twitter_bootstrap_confirmbox =
2
+ defaults:
3
+ fade: false
4
+ title: null
5
+ cancel: "Cancel"
6
+ proceed: "OK"
7
+ proceed_class: "btn proceed btn-primary"
8
8
 
9
- TwitterBootstrapConfirmBox = (message, element, callback) ->
10
- $(document.body).append(
11
- $(
12
- '<div class="modal hide" id="confirmation_dialog">
13
- <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h3>...</h3></div>
14
- <div class="modal-body"></div>
15
- <div class="modal-footer"><a href="#" class="btn cancel" data-dismiss="modal">...</a><a href="#" class="btn proceed btn-primary">...</a></div>
16
- </div>'
17
- )
9
+ TwitterBootstrapConfirmBox = (message, element, callback) ->
10
+ $(document.body).append(
11
+ $(
12
+ '<div class="modal hide" id="confirmation_dialog">
13
+ <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h3>...</h3></div>
14
+ <div class="modal-body"></div>
15
+ <div class="modal-footer"><a href="#" class="btn cancel" data-dismiss="modal">...</a><a href="#" class="btn proceed btn-primary">...</a></div>
16
+ </div>'
18
17
  )
18
+ )
19
19
 
20
- $("#confirmation_dialog .modal-body").html(message)
21
- $("#confirmation_dialog .modal-header h3").html(element.data("confirm-title") || $.fn.twitter_bootstrap_confirmbox.defaults.title || window.top.location.origin)
22
- $("#confirmation_dialog .modal-footer .cancel").html(element.data("confirm-cancel") || $.fn.twitter_bootstrap_confirmbox.defaults.cancel)
23
- $("#confirmation_dialog .modal-footer .proceed").html(element.data("confirm-proceed") || $.fn.twitter_bootstrap_confirmbox.defaults.proceed).attr("class", $.fn.twitter_bootstrap_confirmbox.defaults.proceed_class).addClass(element.data("confirm-proceed-class"))
24
- $("#confirmation_dialog").modal "show"
20
+ $("#confirmation_dialog").addClass("fade") if element.data("confirm-fade") || $.fn.twitter_bootstrap_confirmbox.defaults.fade
21
+ $("#confirmation_dialog .modal-body").html(message)
22
+ $("#confirmation_dialog .modal-header h3").html(element.data("confirm-title") || $.fn.twitter_bootstrap_confirmbox.defaults.title || window.top.location.origin)
23
+ $("#confirmation_dialog .modal-footer .cancel").html(element.data("confirm-cancel") || $.fn.twitter_bootstrap_confirmbox.defaults.cancel)
24
+ $("#confirmation_dialog .modal-footer .proceed").html(element.data("confirm-proceed") || $.fn.twitter_bootstrap_confirmbox.defaults.proceed).attr("class", $.fn.twitter_bootstrap_confirmbox.defaults.proceed_class).addClass(element.data("confirm-proceed-class"))
25
+ $("#confirmation_dialog").modal("show").on("hidden", ->
26
+ $(this).remove()
27
+ )
25
28
 
26
- $("#confirmation_dialog .proceed").click ->
27
- $("#confirmation_dialog").modal("hide").remove()
28
- callback()
29
- true
29
+ $("#confirmation_dialog .proceed").click ->
30
+ $("#confirmation_dialog").modal("hide")
31
+ callback()
32
+ true
30
33
 
31
- $("#confirmation_dialog .cancel").click ->
32
- $("#confirmation_dialog").modal("hide").remove()
33
- false
34
+ $("#confirmation_dialog .cancel").click ->
35
+ $("#confirmation_dialog").modal("hide")
36
+ false
34
37
 
35
- $.rails.allowAction = (element) ->
36
- message = element.data("confirm")
37
- answer = false
38
- return true unless message
38
+ $.rails.allowAction = (element) ->
39
+ message = element.data("confirm")
40
+ answer = false
41
+ return true unless message
39
42
 
40
- if $.rails.fire(element, "confirm")
41
- TwitterBootstrapConfirmBox message, element, ->
42
- if $.rails.fire(element, "confirm:complete", [answer])
43
- allowAction = $.rails.allowAction
43
+ if $.rails.fire(element, "confirm")
44
+ TwitterBootstrapConfirmBox message, element, ->
45
+ if $.rails.fire(element, "confirm:complete", [answer])
46
+ allowAction = $.rails.allowAction
44
47
 
45
- $.rails.allowAction = ->
46
- true
47
-
48
- if element.get(0).click
49
- element.get(0).click()
50
- else if $.isFunction(document.createEvent)
51
- evt = document.createEvent "MouseEvents"
52
- evt.initMouseEvent(
53
- "click",
54
- true, # e.bubbles,
55
- true, #e.cancelable,
56
- window, #e.view,
57
- 0, #e.detail,
58
- 0, #e.screenX,
59
- 0, #e.screenY,
60
- 0, #e.clientX,
61
- 0, #e.clientY,
62
- false, #e.ctrlKey,
63
- false, #e.altKey,
64
- false, #e.shiftKey,
65
- false, #e.metaKey,
66
- 0, #e.button,
67
- document.body.parentNode #e.relatedTarget
68
- )
69
- element.get(0).dispatchEvent(evt)
70
- else
71
- element.trigger "click"
48
+ $.rails.allowAction = ->
49
+ true
50
+
51
+ if element.get(0).click
52
+ element.get(0).click()
53
+ else if $.isFunction(document.createEvent)
54
+ evt = document.createEvent "MouseEvents"
55
+ evt.initMouseEvent(
56
+ "click",
57
+ true, # e.bubbles,
58
+ true, #e.cancelable,
59
+ window, #e.view,
60
+ 0, #e.detail,
61
+ 0, #e.screenX,
62
+ 0, #e.screenY,
63
+ 0, #e.clientX,
64
+ 0, #e.clientY,
65
+ false, #e.ctrlKey,
66
+ false, #e.altKey,
67
+ false, #e.shiftKey,
68
+ false, #e.metaKey,
69
+ 0, #e.button,
70
+ document.body.parentNode #e.relatedTarget
71
+ )
72
+ element.get(0).dispatchEvent(evt)
73
+ else
74
+ element.trigger "click"
72
75
 
73
- $.rails.allowAction = allowAction
74
-
75
- false
76
+ $.rails.allowAction = allowAction
77
+
78
+ false
metadata CHANGED
@@ -1,23 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: twitter-bootstrap-rails-confirm
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Rene van Lieshout
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
17
+
18
+ date: 2013-04-23 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description: Confirm dialogs using Twitter Bootstrap
15
- email:
22
+ email:
16
23
  - rene@bluerail.nl
17
24
  executables: []
25
+
18
26
  extensions: []
27
+
19
28
  extra_rdoc_files: []
20
- files:
29
+
30
+ files:
21
31
  - .gitignore
22
32
  - Gemfile
23
33
  - LICENSE
@@ -30,33 +40,37 @@ files:
30
40
  - vendor/assets/javascripts/twitter/bootstrap/rails/confirm.coffee
31
41
  homepage: https://github.com/bluerail/twitter-bootstrap-rails-confirm
32
42
  licenses: []
43
+
33
44
  post_install_message:
34
45
  rdoc_options: []
35
- require_paths:
46
+
47
+ require_paths:
36
48
  - lib
37
49
  - vendor
38
- required_ruby_version: !ruby/object:Gem::Requirement
50
+ required_ruby_version: !ruby/object:Gem::Requirement
39
51
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- segments:
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
45
57
  - 0
46
- hash: 624208733835673147
47
- required_rubygems_version: !ruby/object:Gem::Requirement
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
60
  none: false
49
- requirements:
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- segments:
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
54
66
  - 0
55
- hash: 624208733835673147
67
+ version: "0"
56
68
  requirements: []
69
+
57
70
  rubyforge_project:
58
- rubygems_version: 1.8.24
71
+ rubygems_version: 1.8.25
59
72
  signing_key:
60
73
  specification_version: 3
61
74
  summary: Applies a custom confirm dialog for elements with a data-confirm attribute.
62
75
  test_files: []
76
+