styxie 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -1
- data/lib/styxie/helpers.rb +36 -0
- data/lib/styxie/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: 4626d9c6f6040d05ecbbbcf5d8d3e80121af6f36
|
4
|
+
data.tar.gz: cae3f9d0f9021c893c98e6a34d1ef015edaf2af4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74599580e1b30690cacc6540c8b6fd23417068c8d56e311c696a23c0968d625fe896fb2f4b18fe7088ce54731e1e24faffc1165926d4ad821e2175fd25b1f235
|
7
|
+
data.tar.gz: efa637de588df0ddc1ec2b4555650642e0cd5c993e231531633916113ed7ed957845ad3370e77ed14519035e3f12e1f75d99a33ef02d364b507d74f54519ab9f
|
data/README.md
CHANGED
@@ -11,9 +11,26 @@ In your Gemfile, add this line:
|
|
11
11
|
|
12
12
|
gem 'styxie'
|
13
13
|
|
14
|
-
In your
|
14
|
+
In your Assets Pipeline javascript manifest (e.g. application.js) include appropriate libs:
|
15
15
|
|
16
16
|
//= require styxie <- Helpers and Initializers
|
17
|
+
|
18
|
+
|
19
|
+
**If you don't use sprockets:**
|
20
|
+
|
21
|
+
Add these lines to controller, in actions of wich you want use Styxie:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
include Styxie::Helpers
|
25
|
+
helper_method :styxie_include # in case of Rails
|
26
|
+
```
|
27
|
+
|
28
|
+
And add this helper in those actions:
|
29
|
+
|
30
|
+
```erb
|
31
|
+
<%= styxie_include %>
|
32
|
+
```
|
33
|
+
|
17
34
|
|
18
35
|
## Basic Usage
|
19
36
|
|
data/lib/styxie/helpers.rb
CHANGED
@@ -12,5 +12,41 @@ module Styxie
|
|
12
12
|
# TODO: support nested namespaces?
|
13
13
|
namespace == controller_path.split('/').first
|
14
14
|
end
|
15
|
+
|
16
|
+
def styxie_include
|
17
|
+
result = <<~CODE
|
18
|
+
<script type="text/javascript">
|
19
|
+
if (window.Styxie == null) { window.Styxie = {}; }
|
20
|
+
|
21
|
+
window.Styxie.Initializers = {};
|
22
|
+
if (window.Styxie.initQueue == null) { window.Styxie.initQueue = []; }
|
23
|
+
|
24
|
+
window.Styxie.applyInitializer = function(klass, method, json) {
|
25
|
+
const initializer = this.Initializers[klass];
|
26
|
+
if (!initializer) { return; }
|
27
|
+
|
28
|
+
if (initializer.initialize) {
|
29
|
+
initializer.initialize(json);
|
30
|
+
}
|
31
|
+
|
32
|
+
if (initializer[method]) {
|
33
|
+
return initializer[method](json);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
window.Styxie.deferredInit = function() {
|
38
|
+
for (let args of Array.from(this.initQueue)) { this.applyInitializer.apply(this, args); }
|
39
|
+
return this.initQueue = [];
|
40
|
+
};
|
41
|
+
|
42
|
+
window.initStyxie = () => {
|
43
|
+
return this.Styxie.deferredInit();
|
44
|
+
};
|
45
|
+
</script>
|
46
|
+
CODE
|
47
|
+
|
48
|
+
result.html_safe
|
49
|
+
end
|
50
|
+
|
15
51
|
end
|
16
52
|
end
|
data/lib/styxie/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: styxie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Kotov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Set of helpers to maintain bridge between Server side and Client (JS)
|
15
15
|
side
|