index_for 0.3.1 → 0.3.2

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: 925b8036067c5c22249a884e6159c2c9921c1c2d
4
- data.tar.gz: 3e65dec6318633705463a0b9a5de2029d29d8195
3
+ metadata.gz: 181813155c5638c7fd110640f99c9d36bb75de90
4
+ data.tar.gz: 75092c0750b6d76c5738209bac2afced08432e46
5
5
  SHA512:
6
- metadata.gz: 82fd862e2f45217f5fffc8dc086d9966c026f1229c49ac00b8f0a8cd62669c4e3461c36c5393388a53b855f494d113232b1be37b173320085b64d165089b4af2
7
- data.tar.gz: 978fc9786afe8f83da7567686fd2896756a6101d2b494902328f6a84a8d2e14d1797a86566ad51663cc95df112effe4d4335f23a2832439572cebe291851e226
6
+ metadata.gz: f880f014e3db919294bb2b5b6112f6fe4f14348e75a96948512d38c1de146180e240048b9522ff251e6bcaa0c13c29fb17e1d10ae79a6e5748ae2ab6cc0e789a
7
+ data.tar.gz: 0a7a161772673a5647ef3d3317262a148f3b112ca654f77b185eb4df1ebf34ce052f5ce439174c56a66097ab18facceeda6b0f4ba5c3b68ab505da8e2db48525
@@ -12,7 +12,7 @@
12
12
 
13
13
  <div class="col-sm-6 text-right index_for_filter">
14
14
  Search:
15
- <input type="search" class="form-control input" placeholder="<%= params[:search] %>" data-href="<%= url_for(params.merge(search: nil)) %>">
15
+ <input type="search" class="form-control input" placeholder="<%= params[:search] %>" data-href="<%= url_for(params.merge(search: nil, page: 1)) %>">
16
16
  </div>
17
17
  </div>
18
18
 
@@ -32,34 +32,32 @@
32
32
  </div>
33
33
 
34
34
  <script type="text/javascript">
35
- $(document).on("ready page:load page:restore", function() {
36
- $(".wice_index_for").each(function() {
37
- var $this = $(this);
38
- if ($this.data("wice-index-for")) return;
39
- $this.data("wice-index-for", true);
40
- $this.find(".index_for_length select").change(function(event) {
41
- var location = $(event.target).find("option:selected").data("href");
42
- if (location) window.location = location;
43
- });
35
+ $(".wice_index_for").each(function() {
36
+ var $this = $(this);
37
+ if ($this.data("wice-index-for")) return;
38
+ $this.data("wice-index-for", true);
39
+ $this.find(".index_for_length select").change(function(event) {
40
+ var location = $(event.target).find("option:selected").data("href");
41
+ if (location) window.location = location;
42
+ });
44
43
 
45
- $this.find(".index_for thead th").click(function(event) {
46
- var location = $(event.target).data("href");
47
- if (location) window.location = location;
48
- });
44
+ $this.find(".index_for thead th").click(function(event) {
45
+ var location = $(event.target).data("href");
46
+ if (location) window.location = location;
47
+ });
49
48
 
50
- $this.find(".index_for_filter input").keypress(function(event) {
51
- if (event.which === 13 || event.keyCode === 13) {
52
- var location = $(event.target).data("href"),
53
- search = $(event.target).val();
54
- if (location) {
55
- if (location.indexOf("?") >= 0) {
56
- window.location = location + "&search=" + search;
57
- } else {
58
- window.location = location + "?search=" + search;
59
- }
49
+ $this.find(".index_for_filter input").keypress(function(event) {
50
+ if (event.which === 13 || event.keyCode === 13) {
51
+ var location = $(event.target).data("href"),
52
+ search = $(event.target).val();
53
+ if (location) {
54
+ if (location.indexOf("?") >= 0) {
55
+ window.location = location + "&search=" + search;
56
+ } else {
57
+ window.location = location + "?search=" + search;
60
58
  }
61
59
  }
62
- })
60
+ }
63
61
  })
64
62
  });
65
63
  </script>
@@ -4,12 +4,15 @@
4
4
  Show
5
5
  %select.form-control.input
6
6
  - builder.per_pages do |per_page, url, active|
7
- %option{ "data-href" => url, "selected" => active }
8
- = per_page
7
+ %option{"data-href" => ""}
8
+ = url
9
+ " #{selected if active}&gt;#{per_page}
9
10
  entries
10
11
  .col-sm-6.text-right.index_for_filter
11
12
  Search:
12
- %input.form-control.input{ "type" => "search", "placeholder" => params[:search], "data-href" => url_for(params.merge(search: nil)) }
13
+ %input.form-control.input{:placeholder => "", :type => "search"}/
14
+ = params[:search]
15
+ " data-href="#{url_for(params.merge(search: nil, page: 1))}"&gt;
13
16
  .row
14
17
  .col-sm-12
15
18
  - html_options[:head_builder] ||= IndexFor::WiceHeadColumnBuilder
@@ -18,3 +21,33 @@
18
21
  .col-sm-5.index_for_info= page_entries_info objects
19
22
  .col-sm-7.text-right.index_for_pagination
20
23
  = paginate objects, window: 2
24
+
25
+ :javascript
26
+ $(".wice_index_for").each(function() {
27
+ var $this = $(this);
28
+ if ($this.data("wice-index-for")) return;
29
+ $this.data("wice-index-for", true);
30
+ $this.find(".index_for_length select").change(function(event) {
31
+ var location = $(event.target).find("option:selected").data("href");
32
+ if (location) window.location = location;
33
+ });
34
+
35
+ $this.find(".index_for thead th").click(function(event) {
36
+ var location = $(event.target).data("href");
37
+ if (location) window.location = location;
38
+ });
39
+
40
+ $this.find(".index_for_filter input").keypress(function(event) {
41
+ if (event.which === 13 || event.keyCode === 13) {
42
+ var location = $(event.target).data("href"),
43
+ search = $(event.target).val();
44
+ if (location) {
45
+ if (location.indexOf("?") >= 0) {
46
+ window.location = location + "&search=" + search;
47
+ } else {
48
+ window.location = location + "?search=" + search;
49
+ }
50
+ }
51
+ }
52
+ })
53
+ });
@@ -4,12 +4,15 @@
4
4
  | Show
5
5
  select.form-control.input
6
6
  - builder.per_pages do |per_page, url, active|
7
- option data-href=url selected=(active )
8
- = per_page
7
+ option data-href=""
8
+ = url
9
+ | " #{selected if active}&gt;#{per_page}
9
10
  | entries
10
11
  .col-sm-6.text-right.index_for_filter
11
12
  | Search:
12
- input.form-control.input type="search" placeholder=params[:search] data-href=(url_for(params.merge(search: nil)) )
13
+ input.form-control.input placeholder="" type="search" /
14
+ = params[:search]
15
+ | " data-href="#{url_for(params.merge(search: nil, page: 1))}"&gt;
13
16
  .row
14
17
  .col-sm-12
15
18
  - html_options[:head_builder] ||= IndexFor::WiceHeadColumnBuilder
@@ -18,3 +21,33 @@
18
21
  .col-sm-5.index_for_info= page_entries_info objects
19
22
  .col-sm-7.text-right.index_for_pagination
20
23
  = paginate objects, window: 2
24
+
25
+ javascript:
26
+ $(".wice_index_for").each(function() {
27
+ var $this = $(this);
28
+ if ($this.data("wice-index-for")) return;
29
+ $this.data("wice-index-for", true);
30
+ $this.find(".index_for_length select").change(function(event) {
31
+ var location = $(event.target).find("option:selected").data("href");
32
+ if (location) window.location = location;
33
+ });
34
+
35
+ $this.find(".index_for thead th").click(function(event) {
36
+ var location = $(event.target).data("href");
37
+ if (location) window.location = location;
38
+ });
39
+
40
+ $this.find(".index_for_filter input").keypress(function(event) {
41
+ if (event.which === 13 || event.keyCode === 13) {
42
+ var location = $(event.target).data("href"),
43
+ search = $(event.target).val();
44
+ if (location) {
45
+ if (location.indexOf("?") >= 0) {
46
+ window.location = location + "&search=" + search;
47
+ } else {
48
+ window.location = location + "?search=" + search;
49
+ }
50
+ }
51
+ }
52
+ })
53
+ });
@@ -1,3 +1,3 @@
1
1
  module IndexFor
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: index_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo