riot_js-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ ;(function($) {
2
+
3
+ var riotRails = {
4
+ componentSelector: '.riot-rails-component',
5
+ mounted: [],
6
+ mount: function(selector) {
7
+ var component = $(selector);
8
+ var opts = component.data('opts');
9
+ component.removeAttr('data-opts');
10
+ var mounted = riot.mount(selector, opts);
11
+ this.mounted.push(mounted[0]);
12
+ },
13
+ unmountAll: function () {
14
+ $.each(this.mounted, function(index, component) {
15
+ component.unmount();
16
+ });
17
+ this.mounted = [];
18
+ },
19
+ mountAll: function() {
20
+ var self = this;
21
+ $(self.componentSelector).each(function(){
22
+ self.mount('#' + $(this).attr('id'));
23
+ });
24
+ }
25
+ };
26
+
27
+ var handleNativePageLoad = function () {
28
+ $(function() {
29
+ riotRails.mountAll();
30
+ });
31
+ };
32
+
33
+ var handleTurbolinksPageLoad = function () {
34
+ var unmountEvent;
35
+
36
+ if (Turbolinks.EVENTS) {
37
+ unmountEvent = Turbolinks.EVENTS.BEFORE_UNLOAD;
38
+ } else {
39
+ unmountEvent = 'page:receive';
40
+ Turbolinks.pagesCached(0);
41
+
42
+ if (window.ReactRailsUJS.RAILS_ENV_DEVELOPMENT) {
43
+ console.warn('The Turbolinks cache has been disabled (Turbolinks >= 2.4.0 is recommended).');
44
+ }
45
+ }
46
+
47
+ $(document).on('page:change', function(){
48
+ riotRails.mountAll();
49
+ });
50
+
51
+ $(document).on(unmountEvent, function(){
52
+ riotRails.unmountAll();
53
+ });
54
+ };
55
+
56
+ if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
57
+ handleTurbolinksPageLoad();
58
+ } else {
59
+ handleNativePageLoad();
60
+ }
61
+
62
+ })(jQuery);
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riot_js-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bartosz Jaroszewski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: execjs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ description: This gem provides integration of Muut Riot with Rails
98
+ email:
99
+ - b.jarosze@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - README.md
107
+ - Rakefile
108
+ - lib/riot_js/rails.rb
109
+ - lib/riot_js/rails/engine.rb
110
+ - lib/riot_js/rails/helper.rb
111
+ - lib/riot_js/rails/processors/compiler.rb
112
+ - lib/riot_js/rails/processors/processor.rb
113
+ - lib/riot_js/rails/railtie.rb
114
+ - lib/riot_js/rails/version.rb
115
+ - riot_js-rails.gemspec
116
+ - vendor/assets/javascripts/compiler/compiler.js
117
+ - vendor/assets/javascripts/compiler/compiler_core.js
118
+ - vendor/assets/javascripts/compiler/node_runner.js
119
+ - vendor/assets/javascripts/compiler/parsers.js
120
+ - vendor/assets/javascripts/riot.js
121
+ - vendor/assets/javascripts/riot_rails.js
122
+ homepage: https://github.com/bjarosze/riot_js-rails
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.4.6
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Muut Riot integration with Rails.
146
+ test_files: []