select_all-rails 0.2.0 → 0.3.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 +4 -4
- data/README.md +31 -15
- data/lib/select_all/rails/version.rb +1 -1
- data/select_all-rails.gemspec +1 -1
- data/vendor/assets/javascripts/select_all.js +1 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc71dc258533923cf02685cbc699b403f25519ac
|
4
|
+
data.tar.gz: 1969748f45c73664c875552d7559db4b90c3c2d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d525bb3296ba9ed9b7ab629e9966870614e25ae498f4d40d71e01bc7f86c2c4c9d064a38449e013fd8b4b2d60f57e793ded821ffc84b607e2686a8720c079af
|
7
|
+
data.tar.gz: 86bd01b18e7ec54605f8a92294badcc45bc8d8316eb5236e9b139fc9c9a381b8c07fb7ce5ee885ef13af0fe02f2eb07438e400cb00f01f379d230eade17427cf
|
data/README.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
# select_all-rails
|
2
|
+
***Simple to check and uncheck checkboxes***
|
3
|
+
***
|
4
|
+
[](https://badge.fury.io/rb/select_all-rails) [](https://codeclimate.com/github/JigneshSatam/select_all-rails) [](https://codeclimate.com/github/JigneshSatam/select_all-rails)
|
5
|
+
|
6
|
+
Select_all-rails is gem for implementing '**select-all**' functionality in more simple and effective way in your ruby-on-rails application.
|
7
|
+
## Functionalities
|
8
|
+
* [***Basic Usage***](http://jigneshsatam.github.io/checkbox_select_all/index_demo.html#basic_usage) - Selecting/Unselecting multiple checkboxes.
|
9
|
+
* [***Multiple Seletions***](http://jigneshsatam.github.io/checkbox_select_all/index_demo.html#multiple_selections) - Implementing more than one select-all functionalities in a page.
|
10
|
+
* [***Ajax Added Checkboxes***](http://jigneshsatam.github.io/checkbox_select_all/index_demo.html#ajax_added_checkboxes) - Implementing select-all functionality to new checkboxes added by an Ajax call.
|
11
|
+
* [***Show Selection/Count***](http://jigneshsatam.github.io/checkbox_select_all/index_demo.html#show_selected_count) - Display selected checkboxes count or checkboxes remaining to select count or selected checkboxes count out of total checkboxes.
|
7
12
|
## Installation
|
8
13
|
|
9
|
-
Add this line to your application's Gemfile
|
14
|
+
Add this line to your application's **Gemfile**:
|
10
15
|
|
11
16
|
```ruby
|
12
17
|
gem 'select_all-rails'
|
@@ -19,26 +24,37 @@ And then execute:
|
|
19
24
|
Or install it yourself as:
|
20
25
|
|
21
26
|
$ gem install select_all-rails
|
22
|
-
|
23
|
-
And add the following line to your application.js file:
|
27
|
+
|
28
|
+
And add the following line to your **application.js** file after jquery:
|
24
29
|
|
25
30
|
//= require select_all.js
|
26
31
|
|
27
32
|
## Usage
|
33
|
+
Call the function **select_all()** on main checkbox and add class **'selectable'** to sub-checkboxes.
|
28
34
|
|
29
|
-
|
35
|
+
HTML example:
|
36
|
+
```html
|
37
|
+
<input type="checkbox" id="selectAll">All Items</input>
|
30
38
|
|
31
|
-
<
|
39
|
+
<input type="checkbox" class="selectable">Item 1</input>
|
40
|
+
<input type="checkbox" class="selectable">Item 2</input>
|
41
|
+
<input type="checkbox" class="selectable">Item 3</input>
|
42
|
+
|
43
|
+
<script type="text/javascript">
|
44
|
+
$("#selectAll").select_all();
|
45
|
+
</script>
|
46
|
+
```
|
47
|
+
***For more usage checkout*** [**Demo**](http://jigneshsatam.github.io/checkbox_select_all/index_demo.html)
|
32
48
|
|
33
49
|
|
34
50
|
Rails haml example:
|
35
|
-
```
|
51
|
+
```haml
|
36
52
|
= check_box_tag 'checkAll'
|
37
53
|
= check_box_tag 'selected_ids[]', "1", false, class: 'selectable'
|
38
54
|
= check_box_tag 'selected_ids[]', "2", false, class: 'selectable'
|
39
55
|
= check_box_tag 'selected_ids[]', "3", false, class: 'selectable'
|
40
|
-
|
41
|
-
|
56
|
+
|
57
|
+
:javascript
|
42
58
|
$("#checkAll").select_all();
|
43
59
|
```
|
44
60
|
|
@@ -55,4 +71,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
55
71
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
72
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
73
|
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
-
5. Create a new Pull Request
|
74
|
+
5. Create a new Pull Request
|
data/select_all-rails.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["jigneshsatam@gmail.com"]
|
11
11
|
|
12
12
|
if spec.respond_to?(:metadata)
|
13
|
-
# spec.metadata['allowed_push_host'] = "
|
13
|
+
# spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
14
14
|
end
|
15
15
|
|
16
16
|
spec.summary = %q{Simple to select all checkboxes.}
|
@@ -1,39 +1 @@
|
|
1
|
-
|
2
|
-
if (typeof jQuery === "undefined") {
|
3
|
-
throw new Error("select_all requires jQuery");
|
4
|
-
}
|
5
|
-
|
6
|
-
(function ( $ ) {
|
7
|
-
$.fn.select_all = function(options) {
|
8
|
-
var settings = $.extend({
|
9
|
-
class: "no_class"
|
10
|
-
}, options );
|
11
|
-
|
12
|
-
var select_all = $(this);
|
13
|
-
var find_in = select_all;
|
14
|
-
|
15
|
-
select_all.addClass("select_all "+settings.class);
|
16
|
-
|
17
|
-
while( !find_in.is("body") ){
|
18
|
-
var selectables = find_in.find(":checkbox.selectable");
|
19
|
-
if (selectables.length > 0){
|
20
|
-
selectables.addClass(settings.class);
|
21
|
-
find_in = $("body");
|
22
|
-
}
|
23
|
-
else{
|
24
|
-
find_in = find_in.parent();
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
$(".select_all."+settings.class).change(function(){
|
29
|
-
$(".selectable."+settings.class).prop('checked', $(this).prop("checked"));
|
30
|
-
});
|
31
|
-
$(".selectable."+settings.class).change(function(){
|
32
|
-
if ($(".selectable."+settings.class+":checked").length == $(".selectable."+settings.class).length)
|
33
|
-
$(".select_all."+settings.class).prop('checked', "checked");
|
34
|
-
else
|
35
|
-
$(".select_all."+settings.class).prop('checked', false);
|
36
|
-
});
|
37
|
-
}
|
38
|
-
return $(this);
|
39
|
-
}( jQuery ));
|
1
|
+
if("undefined"==typeof jQuery)throw new Error("select_all requires jQuery");!function(t){t.fn.select_all=function(e){function a(e){for(var a,c;!e.is("body");)c=e.find(":checkbox.selectable"),c.length>0?(a=c,e=t("body")):e=e.parent();return a}function c(e,a,c){switch(e.data("show_count")){case"checked":count_result="(Selected "+a+")";break;case"checked_with_total":count_result="("+a+"/"+c+")";break;case"unchecked":var l=c-a;count_result="(Unselected "+l+")";break;default:count_result="(Selected "+a+")"}var n=t(e.data("attach_count_to"));0==n.length&&(n=e.parent()),t("span#select_all_count_id[data-select_all_uid='"+e.data("select_all_uid")+"']").length>0?t("span#select_all_count_id[data-select_all_uid='"+e.data("select_all_uid")+"']").text(count_result):t("<span id='select_all_count_id' data-select_all_uid="+e.data("select_all_uid")+">"+count_result+"</span>").appendTo(n)}function l(e){t(e).change(function(){var e=t(".select_all[data-select_all_class='"+d["class"]+"']"),a=t(".selectable."+d["class"]+":checked").length,l=t(".selectable."+d["class"]).length;a==l?e.prop("checked","checked"):e.prop("checked",!1),e.data("show_count").length>0&&c(e,a,l)})}function n(e){e.change(function(){var a=t(".selectable."+d["class"]),l=t(this).prop("checked");if(a.prop("checked",l),e.data("show_count").length>0){var n=l?a.length:0;c(e,n,a.length)}})}var s,d=t.extend({"class":"no_class",infinite_scroll_select:!1,show_count:!1,attach_count_to:!1,uniq_id:Math.random()},e),o=t(this),_=o;return o.addClass("select_all").attr("data-select_all_class",d["class"]).attr("data-select_all_uid",d.uniq_id),o.data("show_count",d.show_count),o.data("attach_count_to",d.attach_count_to),s=a(_),s.length>0&&s.addClass(d["class"]),t(".select_all[data-select_all_class='"+d["class"]+"']").change(function(){t(".selectable."+d["class"]).prop("checked",t(this).prop("checked"))}),d.infinite_scroll_select&&(t(o).attr("data-total_child_count",s.length),t(document).ajaxComplete(function(e,n,s){t("[data-total_child_count]").each(function(){var e=t(this),n=a(e);n.length>e.data("total_child_count")&&(n.addClass(e.data("select_all_class")),e.attr("data-total_child_count",n.length),l(n),e.prop("checked")&&n.prop("checked",!0),e.data("show_count")&&c(e,n.parent().find(":checked").length,n.length))})})),d.show_count!==!1&&c(o,s.parent().find(":checked").length,s.length),n(o),l(s),t(this)}}(jQuery);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: select_all-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jignesh Satam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|