hammock 0.5.4 → 0.5.5
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.
- data/History.txt +6 -0
- data/VERSION +1 -1
- data/hammock.gemspec +2 -2
- data/lib/hammock/ajaxinate.rb +8 -3
- data/public/javascripts/ajax.js +23 -7
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 0.5.5 2009-12-14
|
2
|
+
Attributes in #ajaxinate link_data render as hashes now, not strings of json hashes, so they're converted to json properly.
|
3
|
+
Send record/form/passed attributes in non-GET ajax requests.
|
4
|
+
Updated $() to jQuery() calls in ajax.js.
|
5
|
+
|
6
|
+
|
1
7
|
== 0.5.4 2009-11-18
|
2
8
|
Use self.attributes in AR::Base#adjust_attributes.
|
3
9
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.5
|
data/hammock.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hammock}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Hoskings"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-12-14}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{ben@hoskings.net}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/hammock/ajaxinate.rb
CHANGED
@@ -42,6 +42,11 @@ module Hammock
|
|
42
42
|
:path => route.path,
|
43
43
|
:http_method => route.http_method,
|
44
44
|
:fake_http_method => route.fake_http_method,
|
45
|
+
:resource => entity.base_model,
|
46
|
+
:attribute => link_params[:attribute],
|
47
|
+
:record_attributes => record_attributes.to_param_hash,
|
48
|
+
:passed_attributes => link_params.to_param_hash,
|
49
|
+
:forgery_key => forgery_key_json(route.http_method),
|
45
50
|
:format => (opts[:format].blank? ? 'html' : opts[:format].to_s)
|
46
51
|
}
|
47
52
|
|
@@ -85,7 +90,7 @@ module Hammock
|
|
85
90
|
jQuery.extend(
|
86
91
|
#{params},
|
87
92
|
{format: '#{opts[:format] || 'html'}', _method: '#{route.http_method}'},
|
88
|
-
#{forgery_key_json(route.http_method)}
|
93
|
+
#{forgery_key_json(route.http_method).to_flattened_json}
|
89
94
|
),
|
90
95
|
function(data, textStatus) {
|
91
96
|
#{response_action}
|
@@ -111,9 +116,9 @@ module Hammock
|
|
111
116
|
|
112
117
|
def forgery_key_json request_method = nil
|
113
118
|
if !protect_against_forgery? || (:get == (request_method || request.method))
|
114
|
-
|
119
|
+
{}
|
115
120
|
else
|
116
|
-
|
121
|
+
{request_forgery_protection_token => escape_javascript(form_authenticity_token)}
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
data/public/javascripts/ajax.js
CHANGED
@@ -7,8 +7,8 @@ var hamlink_log = function(link_key, message) {
|
|
7
7
|
};
|
8
8
|
|
9
9
|
var hammock_ajax = function() {
|
10
|
-
|
11
|
-
link_key =
|
10
|
+
jQuery('a.hammock').live('click', function() {
|
11
|
+
link_key = jQuery(this).attr('class').match(/hammock_link_(\w+)/)[1];
|
12
12
|
if (!hammock_link_map[link_key]) {
|
13
13
|
hamlink_log(link_key, 'no entry in link map');
|
14
14
|
} else {
|
@@ -28,12 +28,28 @@ var fire_hammock_ajax = function(data) {
|
|
28
28
|
if (data.before && false == data.before()) {
|
29
29
|
hamlink_log(data.klass, "before callback failed.");
|
30
30
|
} else {
|
31
|
+
if (data.http_method == 'get') {
|
32
|
+
form_attributes = {};
|
33
|
+
// } else if (data.attribute) {
|
34
|
+
// resource = data.resource;
|
35
|
+
// attribute = data.attribute;
|
36
|
+
// form_attributes = {resource: {attribute: jQuery('.' + data.klass).val() } };
|
37
|
+
} else {
|
38
|
+
form_attributes = jQuery('form').serializeHash();
|
39
|
+
}
|
40
|
+
|
31
41
|
jQuery[data.fake_http_method](
|
32
42
|
data.path,
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
43
|
+
jQuery.extend(
|
44
|
+
data.record_attributes,
|
45
|
+
form_attributes,
|
46
|
+
{
|
47
|
+
'_method': data.http_method,
|
48
|
+
'format': data.format
|
49
|
+
},
|
50
|
+
data.passed_attributes,
|
51
|
+
data.forgery_key
|
52
|
+
),
|
37
53
|
function(response, textStatus) {
|
38
54
|
if (data.format == 'js') {
|
39
55
|
eval(response);
|
@@ -48,6 +64,6 @@ var fire_hammock_ajax = function(data) {
|
|
48
64
|
}
|
49
65
|
};
|
50
66
|
|
51
|
-
|
67
|
+
jQuery(function() {
|
52
68
|
hammock_ajax();
|
53
69
|
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Hoskings
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-14 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|