hobo_jquery 1.4.0.pre8 → 2.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/hobo_jquery_helper.rb +8 -2
- data/hobo_jquery.gemspec +1 -1
- data/vendor/assets/javascripts/hobo-jquery/hjq-before-unload.js +15 -0
- data/vendor/assets/javascripts/hobo-jquery/hjq-input-many.js +2 -0
- data/vendor/assets/javascripts/hobo-jquery/hjq-sortable-input-many.js +33 -0
- data/vendor/assets/javascripts/hobo-jquery/hjq-spinner.js +7 -23
- data/vendor/assets/javascripts/hobo-jquery/hjq.js +12 -7
- metadata +8 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0.pre1
|
@@ -1,5 +1,11 @@
|
|
1
1
|
module HoboJqueryHelper
|
2
|
-
def data_rapid(tag, options = {})
|
3
|
-
|
2
|
+
def data_rapid(tag, options = {}, attributes = {})
|
3
|
+
if attributes['data_rapid']
|
4
|
+
hash = ActiveSupport::JSON.decode(attributes['data_rapid'])
|
5
|
+
else
|
6
|
+
hash = {}
|
7
|
+
end
|
8
|
+
hash[tag] = options
|
9
|
+
hash.to_json
|
4
10
|
end
|
5
11
|
end
|
data/hobo_jquery.gemspec
CHANGED
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
|
|
17
17
|
s.rdoc_options = ["--charset=UTF-8"]
|
18
18
|
s.require_paths = ["lib", "vendor", "taglibs"]
|
19
19
|
|
20
|
-
s.add_runtime_dependency('jquery-rails', ["~>
|
20
|
+
s.add_runtime_dependency('jquery-rails', ["~> 2.0"])
|
21
21
|
s.add_runtime_dependency('hobo', ["= #{version}"])
|
22
22
|
|
23
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* search_results */
|
2
|
+
(function($) {
|
3
|
+
$.fn.hjq_before_unload = function(annotations) {
|
4
|
+
var that = this;
|
5
|
+
that.find(":input").bind('change', function() {
|
6
|
+
window.onbeforeunload = function() {
|
7
|
+
return that.find(typeof(annotations.message == 'string') ? annotations.message : "You have unsaved changes. If you exit this page, your changes will not be saved.");
|
8
|
+
}
|
9
|
+
});
|
10
|
+
that.submit(function() {
|
11
|
+
window.onbeforeunload = null;
|
12
|
+
});
|
13
|
+
return that;
|
14
|
+
}
|
15
|
+
}( jQuery ));
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/* hjq-input-many */
|
2
|
+
(function($) {
|
3
|
+
var methods = {
|
4
|
+
init: function(annotations) {
|
5
|
+
var options = $.extend({update: methods.update}, this.hjq('getOptions', annotations));
|
6
|
+
this.sortable(options);
|
7
|
+
this.on('rapid:change', methods.update);
|
8
|
+
},
|
9
|
+
|
10
|
+
update: function() {
|
11
|
+
var that=$(this);
|
12
|
+
var annotations=that.data('rapid')['sortable-input-many'];
|
13
|
+
that.find("li:visible input.sortable-position").each(function(index) {
|
14
|
+
$(this).val(index+1);
|
15
|
+
});
|
16
|
+
return that;
|
17
|
+
}
|
18
|
+
|
19
|
+
};
|
20
|
+
|
21
|
+
|
22
|
+
$.fn.hjq_sortable_input_many = function( method ) {
|
23
|
+
|
24
|
+
if ( methods[method] ) {
|
25
|
+
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
26
|
+
} else if ( typeof method === 'object' || ! method ) {
|
27
|
+
return methods.init.apply( this, arguments );
|
28
|
+
} else {
|
29
|
+
$.error( 'Method ' + method + ' does not exist on hjq_sortable_collection' );
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
})( jQuery );
|
@@ -6,9 +6,9 @@
|
|
6
6
|
// removal ensures it stays on screen long enough to be visible.
|
7
7
|
|
8
8
|
var methods = {
|
9
|
-
/* without any options, $(foo).hjq_spinner() places a spinner
|
9
|
+
/* without any options, spinner = $(foo).hjq_spinner() places a spinner
|
10
10
|
to the left of foo until you remove it via
|
11
|
-
|
11
|
+
spinner.hjq_spinner('remove');
|
12
12
|
|
13
13
|
options:
|
14
14
|
- spinner-next-to: DOM id of the element to place the spinner next to.
|
@@ -18,20 +18,17 @@
|
|
18
18
|
- message: the message to display inside the spinner
|
19
19
|
|
20
20
|
If options.message is false-ish, default_message is displayed.
|
21
|
+
|
22
|
+
The spinner is returned.
|
21
23
|
*/
|
22
24
|
init: function(options, default_message) {
|
23
25
|
var original=$("#ajax-progress");
|
24
26
|
if (original.length==0) return this;
|
25
27
|
|
26
28
|
options = $.extend({}, defaultOptions.call(this), options);
|
27
|
-
if(options['no-spinner']) return
|
29
|
+
if(options['no-spinner']) return $();
|
28
30
|
|
29
31
|
var clone=original.clone();
|
30
|
-
var spinner_list = this.data('hjq-spinner') || [];
|
31
|
-
spinner_list.push(clone);
|
32
|
-
|
33
|
-
this.data('hjq-spinner', spinner_list);
|
34
|
-
clone.data('source', this);
|
35
32
|
|
36
33
|
clone.find("span").text(options.message || default_message || "");
|
37
34
|
|
@@ -42,24 +39,11 @@
|
|
42
39
|
else if(options['spinner-next-to']) pos_options.of=$("#"+options['spinner-next-to']);
|
43
40
|
|
44
41
|
clone.insertBefore(original).show().position(pos_options);
|
45
|
-
return
|
42
|
+
return clone;
|
46
43
|
},
|
47
44
|
|
48
45
|
remove: function() {
|
49
|
-
|
50
|
-
var clone = spinner_list.pop();
|
51
|
-
var that=this;
|
52
|
-
if(!clone) {
|
53
|
-
$(".ajax-progress").each(function() {
|
54
|
-
if($(this).data('source')[0]==that[0]) {
|
55
|
-
clone=$(this);
|
56
|
-
return false;
|
57
|
-
}
|
58
|
-
});
|
59
|
-
}
|
60
|
-
if(!clone) return this;
|
61
|
-
clone.remove();
|
62
|
-
return this;
|
46
|
+
return this.remove();
|
63
47
|
}
|
64
48
|
};
|
65
49
|
|
@@ -238,12 +238,16 @@
|
|
238
238
|
|
239
239
|
result.context = this;
|
240
240
|
result.type = o.type || 'GET';
|
241
|
-
result.data = {
|
242
|
-
|
243
|
-
|
241
|
+
result.data = {};
|
242
|
+
/* These are now the defaults, so we don't need to send
|
243
|
+
them over the wire.
|
244
|
+
result.data = {"render_options[preamble]": o.preamble || '',
|
245
|
+
"render_options[contexts_function]": 'hjq.ajax.updatePartContexts'
|
246
|
+
}; */
|
247
|
+
if(o.preamble) result.data["render_options[preamble]"] = o.postamble;
|
244
248
|
if(o.postamble) result.data["render_options[postamble]"] = o.postamble;
|
245
249
|
if(o.content_type) result.data["render_options[content_type]"] = o.content_type;
|
246
|
-
if(o.attrs
|
250
|
+
if(o.attrs['errors-ok']) result.data["render_options[errors_ok]"] = 1;
|
247
251
|
result.dataType = 'script';
|
248
252
|
o.spec = jQuery.extend({'function': 'hjq.ajax.update', preamble: ''}, o.spec);
|
249
253
|
|
@@ -258,7 +262,8 @@
|
|
258
262
|
if(part_data) $("#"+ids[i]).data('hjq-ajax', part_data);
|
259
263
|
result.data["render["+i+"][part_context]"] = page_data.hobo_parts[ids[i]];
|
260
264
|
result.data["render["+i+"][id]"] = ids[i];
|
261
|
-
|
265
|
+
// default for render[i][function] is hjq.ajax.update
|
266
|
+
if(o.function) result.data["render["+i+"][function]"] = o['function'];
|
262
267
|
}
|
263
268
|
|
264
269
|
return result;
|
@@ -269,7 +274,7 @@
|
|
269
274
|
if (!o.attrs) o.attrs = {};
|
270
275
|
if (!o.extra_callbacks) o.extra_callbacks = {};
|
271
276
|
|
272
|
-
this.hjq_spinner(o.attrs, "Saving...");
|
277
|
+
var spinner = this.hjq_spinner(o.attrs, "Saving...");
|
273
278
|
|
274
279
|
var success_dfd = jQuery.Deferred();
|
275
280
|
if(o.attrs.success) success_dfd.done(methods.createFunction.call(that, o.attrs.success));
|
@@ -299,7 +304,7 @@
|
|
299
304
|
complete_dfd.done(function() {
|
300
305
|
if(that.parents("body").length==0) $(document).trigger('rapid:ajax:complete', [that]);
|
301
306
|
else that.trigger('rapid:ajax:complete', [that]);
|
302
|
-
|
307
|
+
spinner.hjq_spinner('remove');
|
303
308
|
if(o.attrs.refocus_form) that.find(":input[type!=hidden]:first").focus();
|
304
309
|
});
|
305
310
|
result.complete = complete_dfd.resolve;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobo_jquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre1
|
5
5
|
prerelease: 6
|
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-
|
12
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-rails
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '2.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: hobo
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 2.0.0.pre1
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 2.0.0.pre1
|
46
46
|
description: JQuery support for Hobo
|
47
47
|
email: bryan@larsen.st
|
48
48
|
executables: []
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/hobo_jquery/railtie.rb
|
60
60
|
- taglibs/hobo_jquery.dryml
|
61
61
|
- vendor/assets/javascripts/hobo-jquery/hjq-a.js
|
62
|
+
- vendor/assets/javascripts/hobo-jquery/hjq-before-unload.js
|
62
63
|
- vendor/assets/javascripts/hobo-jquery/hjq-click-editor.js
|
63
64
|
- vendor/assets/javascripts/hobo-jquery/hjq-delete-button.js
|
64
65
|
- vendor/assets/javascripts/hobo-jquery/hjq-filter-menu.js
|
@@ -71,6 +72,7 @@ files:
|
|
71
72
|
- vendor/assets/javascripts/hobo-jquery/hjq-search-results.js
|
72
73
|
- vendor/assets/javascripts/hobo-jquery/hjq-select-many.js
|
73
74
|
- vendor/assets/javascripts/hobo-jquery/hjq-sortable-collection.js
|
75
|
+
- vendor/assets/javascripts/hobo-jquery/hjq-sortable-input-many.js
|
74
76
|
- vendor/assets/javascripts/hobo-jquery/hjq-spinner.js
|
75
77
|
- vendor/assets/javascripts/hobo-jquery/hjq.js
|
76
78
|
- vendor/assets/javascripts/hobo_jquery.js
|