magic_grid 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,7 @@ $(function () {
32
32
  // Micro-plugin for collecting all the listener and search inputs
33
33
  $.fn.getGridParams = $.fn.getGridParams || function (extras) {
34
34
  var listeners = this.data("listeners"),
35
- params = $.extend({}, {'magic_grid_id' : this.attr('id')}, extras || {}),
35
+ params = $.extend({}, this.find("thead").data("params"), {'magic_grid_id' : this.attr('id')}, extras || {}),
36
36
  $input, param_key, listened_id;
37
37
  for (listened_id in listeners) {
38
38
  param_key = listeners[listened_id];
@@ -95,14 +95,11 @@ $(function () {
95
95
  current = $input.data("current"),
96
96
  value = $input.val(),
97
97
  length = value.length,
98
- url = base_url,
98
+ base_url = base_url.split("?", 2)[0],
99
99
  relevant = is_manual || (value != current && (length >= minLength || length == 0)),
100
- pos = $input.getCursor();
100
+ pos = $input.getCursor(),
101
+ url = base_url + '?' + $.param($grid.getGridParams());
101
102
  clearTimeout(timer);
102
- if (! /\?/.test(url)) {
103
- url += '?';
104
- }
105
- url += $.param($grid.getGridParams());
106
103
  if (relevant) {
107
104
  $grid.trigger("magic_grid:loading");
108
105
  if ($grid.data("remote")) {
@@ -129,10 +126,13 @@ $(function () {
129
126
  $(".magic_grid[data-listeners]").each( function () {
130
127
  var $grid = $(this),
131
128
  listeners = $grid.data("listeners"),
132
- grid_id = this.id
133
- base_url = $grid.data("current"),
129
+ grid_id = this.id,
134
130
  handler = function (change) {
135
- var url = base_url + "?" + $.param($grid.getGridParams());
131
+ if (! $("#"+change.data.field).hasClass("ready")) {
132
+ return;
133
+ }
134
+ var base_url = $grid.data("current").split("?", 2)[0];
135
+ var url = base_url + '?' + $.param($grid.getGridParams());
136
136
  $grid.trigger("magic_grid:loading");
137
137
  if ($grid.data("remote")) {
138
138
  $grid.load(url + ' #' + grid_id + " > *", function () {
@@ -143,13 +143,10 @@ $(function () {
143
143
  }
144
144
  };
145
145
  for (var k in listeners) {
146
- if ($("#" + k).hasClass("ready")) {
147
- $("#" + k).on("change", {"field": listeners[k]}, handler);
148
- } else {
149
- $("#" + k).on("ready", {"field": listeners[k]}, function (ready) {
150
- $(this).on("change", ready.data, handler);
151
- });
152
- }
146
+ $("#" + k).on("change", {"field": listeners[k]}, handler);
147
+ $("#" + k).on("ready", function (ready) {
148
+ $(this).addClass("ready");
149
+ });
153
150
  }
154
151
  });
155
152
 
@@ -1,3 +1,3 @@
1
1
  module MagicGrid
2
- VERSION = "0.10.3"
2
+ VERSION = "0.10.4"
3
3
  end
data/spec/helpers_spec.rb CHANGED
@@ -20,6 +20,7 @@ describe MagicGrid::Helpers do
20
20
  v.stub(:request) { request }
21
21
  }
22
22
  }
23
+ let(:view_renderer) { controller }
23
24
 
24
25
  describe "#normalize_magic" do
25
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.10.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-09 00:00:00.000000000 Z
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  segments:
210
210
  - 0
211
- hash: -3603937317512539474
211
+ hash: 591195015863992118
212
212
  required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  none: false
214
214
  requirements:
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  version: '0'
218
218
  segments:
219
219
  - 0
220
- hash: -3603937317512539474
220
+ hash: 591195015863992118
221
221
  requirements: []
222
222
  rubyforge_project:
223
223
  rubygems_version: 1.8.23