jqr-helpers 1.0.24 → 1.0.25
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +13 -0
- data/app/assets/javascripts/jqr-helpers.js +30 -1
- data/jqr-helpers.gemspec +2 -2
- data/lib/jqr-helpers/helpers.rb +2 -0
- data/lib/jqr-helpers/version.rb +1 -1
- metadata +2 -2
data/Readme.md
CHANGED
@@ -120,6 +120,19 @@ an ancestor of the button tag with the class of `my-parent`.
|
|
120
120
|
|
121
121
|
Other Ajax options:
|
122
122
|
|
123
|
+
* `:empty` (String) - the ID of an element which should be shown when the
|
124
|
+
element you are appending/deleting from is empty. If you delete the last child
|
125
|
+
from an element, that element will be hidden and the "empty" element will
|
126
|
+
be shown. Conversely, when you add a child to a target with no children, the
|
127
|
+
"empty" element will be hidden. Using `empty` without `container` implies that
|
128
|
+
the target element's parent should be hidden when the last child is deleted.
|
129
|
+
* `container` (String) - the selector (ID or class name for a parent) of the
|
130
|
+
element which contains the target. For example, if you are appending to a
|
131
|
+
`tbody` element, you may pass the `table` element's ID into this. This can be
|
132
|
+
used in conjunction with `empty` to hide the entire table, including the header,
|
133
|
+
when it is empty and instead show the `empty` element, and vice versa.
|
134
|
+
You can skip using this option to indicate that the show/hide
|
135
|
+
behavior should still happen but it should use the target element itself.
|
123
136
|
* `:callback` (String) - the name of a JS function to call on completion.
|
124
137
|
The function will be in the scope of the original element, and
|
125
138
|
will be passed the result data of the Ajax request.
|
@@ -233,21 +233,50 @@
|
|
233
233
|
callback.call(targetElement, data);
|
234
234
|
}
|
235
235
|
var selector = element.data('selector');
|
236
|
+
var empty = element.data('empty');
|
237
|
+
var container = element.data('container');
|
236
238
|
var target = null;
|
237
239
|
if (selector) {
|
238
240
|
if (selector[0] == '#') target = $(selector);
|
239
241
|
else target = $(targetElement).parents(selector);
|
242
|
+
|
243
|
+
if (container) {
|
244
|
+
if (container[0] == '#') container = $(container);
|
245
|
+
else container = targetElement.parents(container);
|
246
|
+
}
|
247
|
+
|
240
248
|
switch (element.data('result-method')) {
|
241
249
|
case 'update':
|
242
250
|
target = $(data).replaceAll(target);
|
243
251
|
target.trigger('jqr.load');
|
244
252
|
break;
|
245
253
|
case 'append':
|
254
|
+
if (empty && target.children().length == 0) {
|
255
|
+
$('#' + empty).hide();
|
256
|
+
if (container) {
|
257
|
+
container.show();
|
258
|
+
}
|
259
|
+
else {
|
260
|
+
target.show();
|
261
|
+
}
|
262
|
+
}
|
246
263
|
target.append(data);
|
247
264
|
target.trigger('jqr.load');
|
248
265
|
break;
|
249
266
|
case 'delete':
|
250
|
-
|
267
|
+
if (empty && target.parent().children().length == 1) {
|
268
|
+
if (container) {
|
269
|
+
container.hide();
|
270
|
+
}
|
271
|
+
else {
|
272
|
+
target.parent().hide();
|
273
|
+
}
|
274
|
+
$('#' + empty).show();
|
275
|
+
$(target).remove();
|
276
|
+
}
|
277
|
+
else {
|
278
|
+
target.fadeOut(500, function() {$(this).remove()});
|
279
|
+
}
|
251
280
|
break;
|
252
281
|
}
|
253
282
|
target.effect('highlight');
|
data/jqr-helpers.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'jqr-helpers'
|
3
3
|
s.require_paths = %w(. lib lib/jqr-helpers)
|
4
|
-
s.version = '1.0.
|
5
|
-
s.date = '2014-01-
|
4
|
+
s.version = '1.0.25'
|
5
|
+
s.date = '2014-01-17'
|
6
6
|
s.summary = 'Helpers to print unobtrusive jQuery-UI tags.'
|
7
7
|
s.description = <<-EOF
|
8
8
|
This gem adds helper methods to create unobtrusive jQuery code. It outputs
|
data/lib/jqr-helpers/helpers.rb
CHANGED
@@ -462,6 +462,8 @@ module JqrHelpers
|
|
462
462
|
new_options[:'data-redirect'] = true if options.delete(:redirect)
|
463
463
|
new_options[:'data-scroll-to'] = true if options.delete(:scroll_to)
|
464
464
|
new_options[:'data-throbber'] = options.delete(:throbber) || 'small'
|
465
|
+
new_options[:'data-empty'] = options.delete(:empty)
|
466
|
+
new_options[:'data-container'] = options.delete(:container)
|
465
467
|
|
466
468
|
[:update, :append, :delete].each do |result_method|
|
467
469
|
selector = options.delete(result_method)
|
data/lib/jqr-helpers/version.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: jqr-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.25
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel Orner
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|