jcontroller 1.0.2 → 1.0.3
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.
- checksums.yaml +4 -4
- data/README.md +16 -6
- data/app/assets/javascripts/jcontroller.js +6 -6
- data/lib/jcontroller/jaction.rb +1 -1
- data/lib/jcontroller/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5a65c45169a29498afb0d1fa3152be24a82fc07
|
4
|
+
data.tar.gz: 2d0ddb08cfe971e85e0231e1c0c1584ad6857b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e398e233d3536d856247931d313df6deacca0f1e2782121c591aeebb86391b2e0e0c36c7cf581fb2a45622989a1c3ba9fe1e0a03f5674587954f563d32b27211
|
7
|
+
data.tar.gz: be60e2c9a7d95c1b37b8240ed2d37d12326ed960936cfed019bb8f5d173d17dae88d422d3d79ad79cf6f26a6c3e907a88972b5b3a8a59f0a7d528b8f76e93a62
|
data/README.md
CHANGED
@@ -67,9 +67,10 @@ Jcontroller.create('users', {
|
|
67
67
|
...
|
68
68
|
});
|
69
69
|
```
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
### API
|
71
|
+
- Parameters are accessed from `this.params` or as the first parameter
|
72
|
+
- The request state (controller_path, action_name, jcontroller, etc.) are also given in `this.state` or the second parameter
|
73
|
+
- And other methods to work with jcontrollers
|
73
74
|
```javascript
|
74
75
|
Jcontroller.create('users', {
|
75
76
|
html: {
|
@@ -78,12 +79,21 @@ Jcontroller.create('users', {
|
|
78
79
|
console.log(this.params);
|
79
80
|
//this.state === state
|
80
81
|
console.log(this.state);
|
82
|
+
|
83
|
+
var jcontroller = JController.find('application');
|
84
|
+
self.parent(); // === jcontroller
|
85
|
+
|
86
|
+
//excute application_jcontroller for this state and params again
|
87
|
+
jcontroller.execute_jaction(this.params, this.state);
|
88
|
+
//execute application_jcontroller html.index function
|
89
|
+
jcontroller.html.index();
|
81
90
|
}
|
82
91
|
}
|
83
92
|
});
|
84
93
|
```
|
85
|
-
|
86
|
-
|
94
|
+
### Organization
|
95
|
+
I like having a jcontrollers directory and calling my files as jcontroller files (ex. users_jcontroller.js).
|
96
|
+
## Parameters
|
87
97
|
### Manual
|
88
98
|
Use the `js` method with the `params` option.
|
89
99
|
```ruby
|
@@ -130,7 +140,7 @@ Execute all filters and actions related to a action:
|
|
130
140
|
```
|
131
141
|
|
132
142
|
### Manually filter in Javascript
|
133
|
-
You can use the given [state](#
|
143
|
+
You can use the given [state](#api) to stop execution of functions:
|
134
144
|
```javascript
|
135
145
|
Jcontroller.create('application', {
|
136
146
|
html: {
|
@@ -10,16 +10,16 @@ var Jcontroller = {
|
|
10
10
|
return this.parent_cache;
|
11
11
|
},
|
12
12
|
|
13
|
-
dup: function(
|
13
|
+
dup: function(params, state) {
|
14
14
|
var dup = $.extend({}, this, state.jaction);
|
15
|
-
dup.state = state;
|
16
15
|
dup.params = params;
|
17
|
-
|
16
|
+
dup.state = state;
|
17
|
+
if (Jcontroller.present(dup.parent())) { dup.parent_cache = dup.parent().dup(params, state); }
|
18
18
|
return dup;
|
19
19
|
},
|
20
20
|
|
21
21
|
execute_action: function() {
|
22
|
-
if ($.isPlainObject(this.
|
22
|
+
if ($.isPlainObject(this[this.format])) {
|
23
23
|
this.execute_post_order_filter('before');
|
24
24
|
this.execute_post_order_filter(this.action_name);
|
25
25
|
this.execute_pre_order_filter('after');
|
@@ -41,9 +41,9 @@ var Jcontroller = {
|
|
41
41
|
)
|
42
42
|
);
|
43
43
|
},
|
44
|
-
execute_jaction: function(
|
44
|
+
execute_jaction: function(params, state) {
|
45
45
|
var controller = this.find(state.jaction.controller_path);
|
46
|
-
if (this.present(controller)) { controller.dup(
|
46
|
+
if (this.present(controller)) { controller.dup(params, state).execute_action(); }
|
47
47
|
},
|
48
48
|
|
49
49
|
blank: function(o) { return typeof o === "undefined" || o === null; },
|
data/lib/jcontroller/jaction.rb
CHANGED
data/lib/jcontroller/version.rb
CHANGED