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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c676120ffbea7c9505e35ba59a44b82cfb40d94d
4
- data.tar.gz: bea92d1211ae55ec61be5564ffb1e135ecde36dd
3
+ metadata.gz: 4626d9c6f6040d05ecbbbcf5d8d3e80121af6f36
4
+ data.tar.gz: cae3f9d0f9021c893c98e6a34d1ef015edaf2af4
5
5
  SHA512:
6
- metadata.gz: 4b54f7137441741b94fd26967dd515380cf21ab3b8ee6a28eb669d0613f667bc8b46b6e246c39e2720d7b7f0c54da9dd9a7c383bc513f9c33e0087d90b5508ca
7
- data.tar.gz: 2a02580cfb9feb603c919a82c7ecfcbcf36a2bbfe9231a47a4b4443ce0e0b2062fdf01a678666853ae50a3149df92f7318b558470850b69f5885b4547fc25015
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 assets application.js include appropriate libs:
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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Styxie
4
- VERSION = '0.0.8'.freeze
4
+ VERSION = '0.0.9'.freeze
5
5
  end
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.8
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: 2018-08-01 00:00:00.000000000 Z
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