button_link_to 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +25 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/button_link_to.js +31 -0
- data/button_link_to.gemspec +23 -0
- data/lib/button_link_to.rb +8 -0
- data/lib/button_link_to/engine.rb +11 -0
- data/lib/button_link_to/helper.rb +16 -0
- data/lib/button_link_to/version.rb +3 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b0ab80e421367cd685e605c95646314a3f28432
|
4
|
+
data.tar.gz: 25248e9d98500f8126b8eda393635245e06ee643
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9912b76898e8eb8332c6ebd439fc96e5cfdb244ef806f0566baeea34a2adaefbdc2037dbb3397e0ed5cad6daa8fb689c1f7c6078059486417024be4c6def905f
|
7
|
+
data.tar.gz: d987859782ce6e7af1a7ebbb26a41a1cf28fda1affafbf68c4ff6036b13a38ef07fcbde97e37e6fc01187f71a43af7f2f1624ccf88c4458f109490adb5ce1aac
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 tonilin
|
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,25 @@
|
|
1
|
+
# ButtonLinkTo
|
2
|
+
|
3
|
+
A button version of Rails link_to helper
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'button_link_to'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
1. Fork it
|
22
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
23
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
24
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
25
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
// jquery ujs hack for remote ajax button
|
3
|
+
$(document).on("mouseup", "button[data-remote]", function(e) {
|
4
|
+
// middle button click
|
5
|
+
if(e.which == 2) {
|
6
|
+
$(e.currentTarget).trigger("click.rails")
|
7
|
+
}
|
8
|
+
});
|
9
|
+
|
10
|
+
// jquery ujs hack for form restful button
|
11
|
+
$(document).on("click.rails", "button[data-method]", function(e) {
|
12
|
+
button = $(e.currentTarget)
|
13
|
+
|
14
|
+
var url = button.data("url"),
|
15
|
+
method = button.data('method'),
|
16
|
+
target = button.data('target'),
|
17
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
18
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
19
|
+
form = $('<form method="post" action="' + url + '"></form>'),
|
20
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
21
|
+
|
22
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
23
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
24
|
+
}
|
25
|
+
|
26
|
+
if (target) { form.attr('target', target); }
|
27
|
+
|
28
|
+
form.hide().append(metadata_input).appendTo('body');
|
29
|
+
form.submit();
|
30
|
+
|
31
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'button_link_to/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "button_link_to"
|
8
|
+
spec.version = ButtonLinkTo::VERSION
|
9
|
+
spec.authors = ["tonilin"]
|
10
|
+
spec.email = ["tonilin@gmail.com"]
|
11
|
+
spec.description = "a button version of Rails link_to helper"
|
12
|
+
spec.summary = "a button version of Rails link_to helper"
|
13
|
+
spec.homepage = "https://github.com/tonilin/button_link_to"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ButtonLinkTo
|
2
|
+
module Helper
|
3
|
+
|
4
|
+
def button_link_to(name = nil, options = nil, html_options = nil, &block)
|
5
|
+
html_options, options = options, name if block_given?
|
6
|
+
options ||= {}
|
7
|
+
html_options = convert_options_to_data_attributes(options, html_options)
|
8
|
+
url = url_for(options)
|
9
|
+
|
10
|
+
html_options.merge!({"data-url" => url, :type => "button"})
|
11
|
+
|
12
|
+
content_tag(:button, name || url, html_options, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: button_link_to
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tonilin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: a button version of Rails link_to helper
|
42
|
+
email:
|
43
|
+
- tonilin@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- app/assets/javascripts/button_link_to.js
|
54
|
+
- button_link_to.gemspec
|
55
|
+
- lib/button_link_to.rb
|
56
|
+
- lib/button_link_to/engine.rb
|
57
|
+
- lib/button_link_to/helper.rb
|
58
|
+
- lib/button_link_to/version.rb
|
59
|
+
homepage: https://github.com/tonilin/button_link_to
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.0.6
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: a button version of Rails link_to helper
|
83
|
+
test_files: []
|