jcontroller 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -7
- data/app/assets/javascripts/jcontroller.js +3 -3
- data/lib/jcontroller/version.rb +1 -1
- data/spec/fake_app/app/assets/javascripts/application.js +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71f242c9fa89f7ab7099f36a7c85fba048b261d2
|
4
|
+
data.tar.gz: 0eecd3dd80aa5d2becd5269871efe2b6a4acbbcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61bd4f0bc8c0addeb21d76cf01b62d8d9d361b414a847d277429bf42fb8493b53e9046e5e4d7223d9a24ee8023eceaed13a72fb6cc0f26af93757ae807d4606d
|
7
|
+
data.tar.gz: 9ce23184dfd20b0bbfad2791f2acf0a9cb16828b1eac4f458d5a29b3f94f34f5431769fe0475e7d935117c4c05d32e96c7a9a7b8c9a9d0b73075cebf04b4c0f2
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Rails controller based javascript to keep your javascript outside of your views.
|
3
3
|
|
4
4
|
Based off [Paul Irish's DOM-based Routing](http://www.paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/)
|
5
|
-
(or Garber-Irish Implementation). __Works with turbolinks__
|
5
|
+
(or Garber-Irish Implementation). __Works with turbolinks__.
|
6
6
|
|
7
7
|
## How it works
|
8
8
|
```javascript
|
@@ -16,9 +16,9 @@ Jcontroller.create('users', {
|
|
16
16
|
No other code is needed.
|
17
17
|
|
18
18
|
## Installation
|
19
|
-
Add `gem '
|
19
|
+
Add `gem 'jcontroller'` to your application's `Gemfile` and run the `bundle` command, then add this to your `app/assets/javascripts/application.js`
|
20
20
|
|
21
|
-
//= require
|
21
|
+
//= require jcontroller
|
22
22
|
|
23
23
|
## Controllers
|
24
24
|
### Namespaces
|
@@ -69,17 +69,20 @@ Jcontroller.create('users', {
|
|
69
69
|
```
|
70
70
|
## Parameters
|
71
71
|
### Access
|
72
|
-
Parameters are accessed from `this.params
|
72
|
+
Parameters are accessed from `this.params` or as the first parameter:
|
73
73
|
```javascript
|
74
74
|
Jcontroller.create('users', {
|
75
75
|
html: {
|
76
|
-
index: function() {
|
76
|
+
index: function(params, state) {
|
77
|
+
//this.params === params
|
77
78
|
console.log(this.params);
|
79
|
+
//this.state === state
|
80
|
+
console.log(this.state);
|
78
81
|
}
|
79
82
|
}
|
80
83
|
});
|
81
84
|
```
|
82
|
-
The request state (controller_path, action_name, jcontroller, etc.) are also given in `this.state
|
85
|
+
The request state (controller_path, action_name, jcontroller, etc.) are also given in `this.state` or the second parameter.
|
83
86
|
|
84
87
|
### Manual
|
85
88
|
Use the `js` method with the `params` option.
|
@@ -127,7 +130,7 @@ Execute all filters and actions related to a action:
|
|
127
130
|
```
|
128
131
|
|
129
132
|
### Manually filter in Javascript
|
130
|
-
You can use the given state to stop execution of functions:
|
133
|
+
You can use the given [state](#access) to stop execution of functions:
|
131
134
|
```javascript
|
132
135
|
Jcontroller.create('application', {
|
133
136
|
html: {
|
@@ -26,15 +26,15 @@ var Jcontroller = {
|
|
26
26
|
}
|
27
27
|
},
|
28
28
|
execute_post_order_filter: function(filter) {
|
29
|
-
if (Jcontroller.present(this.parent())) this.parent().execute_post_order_filter(filter);
|
29
|
+
if (Jcontroller.present(this.parent())) { this.parent().execute_post_order_filter(filter); }
|
30
30
|
this.execute_filter(this[this.format][filter]);
|
31
31
|
},
|
32
32
|
execute_pre_order_filter: function(filter) {
|
33
33
|
this.execute_filter(this[this.format][filter]);
|
34
|
-
if (Jcontroller.present(this.parent())) this.parent().execute_pre_order_filter(filter);
|
34
|
+
if (Jcontroller.present(this.parent())) { this.parent().execute_pre_order_filter(filter); }
|
35
35
|
},
|
36
36
|
execute_filter: function(filter) {
|
37
|
-
if ($.isFunction(filter)) { $.proxy(filter, this)(); }
|
37
|
+
if ($.isFunction(filter)) { $.proxy(filter, this)(this.params, this.state); }
|
38
38
|
}
|
39
39
|
},
|
40
40
|
definition
|
data/lib/jcontroller/version.rb
CHANGED
@@ -14,8 +14,10 @@ test_append = function(controller_namespace, filter, params) {
|
|
14
14
|
create_routes = function(controller_path, extend) {
|
15
15
|
var set_basic_filters = function(format, filters) {
|
16
16
|
$.each(filters, function(index, filter) {
|
17
|
-
hash[format][filter] = function() {
|
18
|
-
|
17
|
+
hash[format][filter] = function(params, state) {
|
18
|
+
if (this.params.s === params.s && this.state.action_name === state.action_name) {
|
19
|
+
test_append(controller_path, filter, this.params);
|
20
|
+
}
|
19
21
|
}
|
20
22
|
});
|
21
23
|
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jcontroller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Chung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|