pagehook-rails 0.0.1 → 0.0.2
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/app/assets/javascripts/pagehook_rails/pagehook.js +16 -18
- data/lib/pagehook-rails/version.rb +1 -1
- 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: cb52eecc763ca2f4c570e6e5c1c728dc71730bd4
|
4
|
+
data.tar.gz: 35708ed0d651329f25487a9d3e727fccc98b6ea6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3234581d1807f6f1d06127c0337b5fea2836243e524230384bbd2a19d9b2199b265b5a956c90593127ef4ccfbcedda731b664bc0ff175cea0df27689c550fb14
|
7
|
+
data.tar.gz: d0893e20e2b052e632aa9c5fa5ee3207b0d0fbd0d943f058960a334e89138e07a2025a12286a55880f035eca7434de46737767d7cde296ade726c7be7a32f6e7
|
@@ -20,7 +20,7 @@
|
|
20
20
|
};
|
21
21
|
|
22
22
|
function Pagehook() {
|
23
|
-
this.definitions =
|
23
|
+
this.definitions = {};
|
24
24
|
this.handler = (function(_this) {
|
25
25
|
return function() {
|
26
26
|
return _this.handlerUnbound();
|
@@ -29,44 +29,42 @@
|
|
29
29
|
}
|
30
30
|
|
31
31
|
Pagehook.prototype.register = function(name_or_map, func) {
|
32
|
-
var name, _results;
|
32
|
+
var name, _base, _results;
|
33
33
|
if (typeof name_or_map === "string") {
|
34
|
-
return this.definitions
|
34
|
+
return ((_base = this.definitions)[name_or_map] || (_base[name_or_map] = [])).push(func);
|
35
35
|
} else {
|
36
36
|
_results = [];
|
37
37
|
for (name in name_or_map) {
|
38
38
|
func = name_or_map[name];
|
39
|
-
_results.push(this.
|
39
|
+
_results.push(this.register(name, func));
|
40
40
|
}
|
41
41
|
return _results;
|
42
42
|
}
|
43
43
|
};
|
44
44
|
|
45
|
-
Pagehook.prototype.dispatch = function(name,
|
46
|
-
var func,
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
_results.push(func(
|
53
|
-
} else {
|
54
|
-
_results.push(void 0);
|
45
|
+
Pagehook.prototype.dispatch = function(name, arg) {
|
46
|
+
var func, _i, _len, _ref, _results;
|
47
|
+
if (this.definitions[name]) {
|
48
|
+
_ref = this.definitions[name];
|
49
|
+
_results = [];
|
50
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
51
|
+
func = _ref[_i];
|
52
|
+
_results.push(func(arg));
|
55
53
|
}
|
54
|
+
return _results;
|
56
55
|
}
|
57
|
-
return _results;
|
58
56
|
};
|
59
57
|
|
60
58
|
Pagehook.prototype.handlerUnbound = function() {
|
61
|
-
var
|
59
|
+
var arg, e, name, _i, _len, _ref, _results;
|
62
60
|
this.dispatch(Pagehook.GLOBAL_HOOK_NAME);
|
63
61
|
_ref = document.querySelectorAll("[" + Pagehook.ATTRIBUTE_NAME + "]");
|
64
62
|
_results = [];
|
65
63
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
66
64
|
e = _ref[_i];
|
67
65
|
name = e.getAttribute(Pagehook.ATTRIBUTE_NAME);
|
68
|
-
|
69
|
-
_results.push(this.dispatch(name,
|
66
|
+
arg = this.isBlank(e.textContent) ? void 0 : JSON.parse(e.textContent);
|
67
|
+
_results.push(this.dispatch(name, arg));
|
70
68
|
}
|
71
69
|
return _results;
|
72
70
|
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagehook-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- labocho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|