twitter-bootstrap-rails-confirm 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in twitter-bootstrap-confirm.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Rene van Lieshout
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Twitter::Bootstrap::Rails::Confirm
2
+
3
+ This gem adds some javascript to change the default behaviour of data-confirm processing.
4
+
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
+
7
+ * data-confirm-title (default: window.top.location.origin)
8
+ * data-confirm-cancel (default: 'cancel')
9
+ * data-confirm-proceed (default: 'ok')
10
+ * data-confirm-proceed-class (default: 'brn-primary')
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'twitter-bootstrap-rails-confirm'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install twitter-bootstrap-rails-confirm
25
+
26
+ ## Usage
27
+
28
+ There is nothing you need to do to get this working. A helper could be useful for handling large amount of destroy buttons:
29
+
30
+ def destroy_link_to(path, options)
31
+ link_to t('.destroy'), path,
32
+ :method => :delete,
33
+ :class => "btn",
34
+ :confirm => t('.destroy_confirm.body', :item => options[:item]),
35
+ "data-confirm-title" => t('.destroy_confirm.title', :item => options[:item]),
36
+ "data-confirm-cancel" => t('.destroy_confirm.cancel', :item => options[:item]),
37
+ "data-confirm-proceed" => t('.destroy_confirm.proceed', :item => options[:item]),
38
+ "data-confirm-proceed-class" => "btn-danger"
39
+ end
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ require "twitter-bootstrap-rails-confirm/version"
2
+
3
+ module Twitter
4
+ module Bootstrap
5
+ module Rails
6
+ module Confirm
7
+ require 'twitter-bootstrap-rails-confirm/engine' if defined?(Rails)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'rails'
2
+
3
+ module Twitter
4
+ module Bootstrap
5
+ module Rails
6
+ module Confirm
7
+ class Engine < ::Rails::Engine
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module Twitter
2
+ module Bootstrap
3
+ module Rails
4
+ module Confirm
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/twitter-bootstrap-rails-confirm/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Rene van Lieshout"]
6
+ gem.email = ["rene@bluerail.nl"]
7
+ gem.description = %q{Confirm dialogs using Twitter Bootstrap}
8
+ gem.summary = %q{Applies a custom confirm dialog for elements with a data-confirm attribute.}
9
+ gem.homepage = "http://www.bluerail.nl"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "twitter-bootstrap-rails-confirm"
15
+ gem.require_paths = ["lib", "vendor"]
16
+ gem.version = Twitter::Bootstrap::Rails::Confirm::VERSION
17
+ end
File without changes
@@ -0,0 +1,43 @@
1
+ $(window).load ->
2
+ TwitterBootstrapConfirmBox = (message, element, callback) ->
3
+ $(document.body).append($('
4
+ <div class="modal hide" id="confirmation_dialog">
5
+ <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h3>...</h3></div>
6
+ <div class="modal-body"></div>
7
+ <div class="modal-footer"><a href="#" class="btn cancel" data-dismiss="modal">...</a><a href="#" class="btn proceed btn-primary">...</a></div>
8
+ </div>
9
+ '))
10
+
11
+ $("#confirmation_dialog .modal-body").html(message)
12
+ $("#confirmation_dialog .modal-header h3").html(element.data("confirm-title") || window.top.location.origin)
13
+ $("#confirmation_dialog .modal-footer .cancel").html(element.data("confirm-cancel") || "Cancel")
14
+ $("#confirmation_dialog .modal-footer .proceed").html(element.data("confirm-proceed") || "Ok").attr("class", "btn proceed btn-primary").addClass(element.data("confirm-proceed-class"))
15
+ $("#confirmation_dialog").modal "show"
16
+
17
+ $("#confirmation_dialog .proceed").click ->
18
+ $("#confirmation_dialog").modal("hide").remove()
19
+ callback()
20
+ true
21
+
22
+ $("#confirmation_dialog .cancel").click ->
23
+ $("#confirmation_dialog").modal("hide").remove()
24
+ false
25
+
26
+ $.rails.allowAction = (element) ->
27
+ message = element.data("confirm")
28
+ answer = false
29
+ return true unless message
30
+
31
+ if $.rails.fire(element, "confirm")
32
+ TwitterBootstrapConfirmBox message, element, ->
33
+ #callback = $.rails.fire(element, "confirm:complete", [answer])
34
+ if $.rails.fire(element, "confirm:complete", [answer])
35
+ allowAction = $.rails.allowAction
36
+
37
+ $.rails.allowAction = ->
38
+ true
39
+ element.trigger "click"
40
+
41
+ $.rails.allowAction = allowAction
42
+
43
+ false
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitter-bootstrap-rails-confirm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rene van Lieshout
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-22 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Confirm dialogs using Twitter Bootstrap
15
+ email:
16
+ - rene@bluerail.nl
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/twitter-bootstrap-rails-confirm.rb
27
+ - lib/twitter-bootstrap-rails-confirm/engine.rb
28
+ - lib/twitter-bootstrap-rails-confirm/version.rb
29
+ - twitter-bootstrap-rails-confirm.gemspec
30
+ - vendor/assets/javascripts/bla.js
31
+ - vendor/assets/javascripts/twitter/bootstrap/rails/confirm.coffee
32
+ homepage: http://www.bluerail.nl
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ - vendor
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ segments:
46
+ - 0
47
+ hash: 1020449423471022572
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ segments:
55
+ - 0
56
+ hash: 1020449423471022572
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.21
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: Applies a custom confirm dialog for elements with a data-confirm attribute.
63
+ test_files: []