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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71f242c9fa89f7ab7099f36a7c85fba048b261d2
4
- data.tar.gz: 0eecd3dd80aa5d2becd5269871efe2b6a4acbbcc
3
+ metadata.gz: e5a65c45169a29498afb0d1fa3152be24a82fc07
4
+ data.tar.gz: 2d0ddb08cfe971e85e0231e1c0c1584ad6857b50
5
5
  SHA512:
6
- metadata.gz: 61bd4f0bc8c0addeb21d76cf01b62d8d9d361b414a847d277429bf42fb8493b53e9046e5e4d7223d9a24ee8023eceaed13a72fb6cc0f26af93757ae807d4606d
7
- data.tar.gz: 9ce23184dfd20b0bbfad2791f2acf0a9cb16828b1eac4f458d5a29b3f94f34f5431769fe0475e7d935117c4c05d32e96c7a9a7b8c9a9d0b73075cebf04b4c0f2
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
- ## Parameters
71
- ### Access
72
- Parameters are accessed from `this.params` or as the first parameter:
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
- The request state (controller_path, action_name, jcontroller, etc.) are also given in `this.state` or the second parameter.
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](#access) to stop execution of functions:
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(state, params) {
13
+ dup: function(params, state) {
14
14
  var dup = $.extend({}, this, state.jaction);
15
- dup.state = state;
16
15
  dup.params = params;
17
- if (Jcontroller.present(dup.parent())) { dup.parent_cache = dup.parent().dup(state, params); }
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.html)) {
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(state, params) {
44
+ execute_jaction: function(params, state) {
45
45
  var controller = this.find(state.jaction.controller_path);
46
- if (this.present(controller)) { controller.dup(state, params).execute_action(); }
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; },
@@ -42,7 +42,7 @@ module Jcontroller
42
42
  end
43
43
 
44
44
  def to_params
45
- [state.to_json, string_params].join(",")
45
+ [string_params, state.to_json].join(",")
46
46
  end
47
47
 
48
48
  def state
@@ -1,3 +1,3 @@
1
1
  module Jcontroller
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcontroller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Chung