rails_db 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -2
  3. data/Gemfile.lock +51 -58
  4. data/app/assets/javascripts/rails_db/application.js +5 -21
  5. data/app/assets/javascripts/rails_db/{vendor/jquery.js → jquery.js} +0 -0
  6. data/app/assets/javascripts/rails_db/rails-ujs.js +685 -0
  7. data/app/assets/stylesheets/rails_db/{app.scss → app.css} +2 -2
  8. data/lib/rails_db.rb +0 -1
  9. data/lib/rails_db/engine.rb +2 -3
  10. data/lib/rails_db/version.rb +1 -1
  11. data/rails_db.gemspec +0 -2
  12. data/test/dummy/db/rails_db.sqlite3 +0 -0
  13. data/test/dummy/db/schema.rb +52 -47
  14. data/test/standalone/Gemfile +0 -1
  15. data/test/standalone/Gemfile.lock +0 -5
  16. metadata +113 -167
  17. data/app/assets/images/rails_db/down_arrow.gif +0 -0
  18. data/app/assets/images/rails_db/up_arrow.gif +0 -0
  19. data/app/assets/javascripts/rails_db/foundation/foundation.abide.js +0 -426
  20. data/app/assets/javascripts/rails_db/foundation/foundation.accordion.js +0 -125
  21. data/app/assets/javascripts/rails_db/foundation/foundation.alert.js +0 -43
  22. data/app/assets/javascripts/rails_db/foundation/foundation.clearing.js +0 -586
  23. data/app/assets/javascripts/rails_db/foundation/foundation.dropdown.js +0 -468
  24. data/app/assets/javascripts/rails_db/foundation/foundation.equalizer.js +0 -104
  25. data/app/assets/javascripts/rails_db/foundation/foundation.interchange.js +0 -360
  26. data/app/assets/javascripts/rails_db/foundation/foundation.joyride.js +0 -935
  27. data/app/assets/javascripts/rails_db/foundation/foundation.js +0 -732
  28. data/app/assets/javascripts/rails_db/foundation/foundation.magellan.js +0 -214
  29. data/app/assets/javascripts/rails_db/foundation/foundation.offcanvas.js +0 -225
  30. data/app/assets/javascripts/rails_db/foundation/foundation.orbit.js +0 -476
  31. data/app/assets/javascripts/rails_db/foundation/foundation.reveal.js +0 -522
  32. data/app/assets/javascripts/rails_db/foundation/foundation.slider.js +0 -296
  33. data/app/assets/javascripts/rails_db/foundation/foundation.tab.js +0 -247
  34. data/app/assets/javascripts/rails_db/foundation/foundation.tooltip.js +0 -348
  35. data/app/assets/javascripts/rails_db/foundation/foundation.topbar.js +0 -458
  36. data/app/assets/javascripts/rails_db/vendor/fastclick.js +0 -8
  37. data/app/assets/javascripts/rails_db/vendor/jquery.cookie.js +0 -8
  38. data/app/assets/javascripts/rails_db/vendor/modernizr.js +0 -8
  39. data/app/assets/javascripts/rails_db/vendor/placeholder.js +0 -2
  40. data/test/dummy/db/development.sqlite3 +0 -0
  41. data/test/dummy/db/rails_db_dev.sqlite3 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87353b44c67c392f75cda69ed969c15f3e2ea4dd
4
- data.tar.gz: 529f95a838ea1eeb648a7276f85750ad32ec6175
3
+ metadata.gz: 38ee5e7a2a449a75b5dee2890bfacb34e3600a73
4
+ data.tar.gz: 8cc216088bd7d1cf9b7ebff56a32fd46cebb3854
5
5
  SHA512:
6
- metadata.gz: dcc5f291b54eb0316b3f102be24da718ea79956e4bd0a9bf6dce48ef485bfe8b721b9f638673b6e1a881df1a9f9c96f2cf9e29ea6924a5c01d896182a9676bb5
7
- data.tar.gz: a5d5d9bc1fa56c0341b22eab3ae91167518da3e4aeca7ab6ca9702892a0a05ce717823847b23fcc5b5594d3c27b29a7501bd8dcf1ef3b18fb4c8442b9ccc854b
6
+ metadata.gz: fe5053a606b1f0924b48a82514eb6a21d98d69012056e3b40fe446b4ce1918dc08a4929ba63519bf6b40300da3923236e80bc445b8a4016b4efeb05e5226dfcd
7
+ data.tar.gz: ad341d49365dec5f75ee722b7420784278a2262971a68aed655c202d73f6d12d7715c3a2663388cf7f80e875d5e913f524ed4088bd101ee2ac771d9e51f5cb37
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'rails'
6
- gem 'jquery-rails'
7
6
  gem 'codemirror-rails'
8
7
  gem 'terminal-table'
9
8
  gem 'simple_form'
@@ -16,7 +15,6 @@ end
16
15
 
17
16
  group :test do
18
17
  gem "sqlite3"
19
- gem "jquery-rails"
20
18
  end
21
19
 
22
20
  gem 'will_paginate', '~> 3.0.6'
@@ -1,51 +1,48 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_db (1.4.1)
4
+ rails_db (1.5.0)
5
5
  codemirror-rails
6
- jquery-rails
7
6
  kaminari
8
7
  rails (>= 3.1.0)
9
8
  ransack
10
- sass
11
9
  simple_form
12
10
  terminal-table
13
11
 
14
12
  GEM
15
13
  remote: https://rubygems.org/
16
14
  specs:
17
- actionmailer (4.2.4)
18
- actionpack (= 4.2.4)
19
- actionview (= 4.2.4)
20
- activejob (= 4.2.4)
15
+ actionmailer (4.2.8)
16
+ actionpack (= 4.2.8)
17
+ actionview (= 4.2.8)
18
+ activejob (= 4.2.8)
21
19
  mail (~> 2.5, >= 2.5.4)
22
20
  rails-dom-testing (~> 1.0, >= 1.0.5)
23
- actionpack (4.2.4)
24
- actionview (= 4.2.4)
25
- activesupport (= 4.2.4)
21
+ actionpack (4.2.8)
22
+ actionview (= 4.2.8)
23
+ activesupport (= 4.2.8)
26
24
  rack (~> 1.6)
27
25
  rack-test (~> 0.6.2)
28
26
  rails-dom-testing (~> 1.0, >= 1.0.5)
29
27
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
30
- actionview (4.2.4)
31
- activesupport (= 4.2.4)
28
+ actionview (4.2.8)
29
+ activesupport (= 4.2.8)
32
30
  builder (~> 3.1)
33
31
  erubis (~> 2.7.0)
34
32
  rails-dom-testing (~> 1.0, >= 1.0.5)
35
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
36
- activejob (4.2.4)
37
- activesupport (= 4.2.4)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (4.2.8)
35
+ activesupport (= 4.2.8)
38
36
  globalid (>= 0.3.0)
39
- activemodel (4.2.4)
40
- activesupport (= 4.2.4)
37
+ activemodel (4.2.8)
38
+ activesupport (= 4.2.8)
41
39
  builder (~> 3.1)
42
- activerecord (4.2.4)
43
- activemodel (= 4.2.4)
44
- activesupport (= 4.2.4)
40
+ activerecord (4.2.8)
41
+ activemodel (= 4.2.8)
42
+ activesupport (= 4.2.8)
45
43
  arel (~> 6.0)
46
- activesupport (4.2.4)
44
+ activesupport (4.2.8)
47
45
  i18n (~> 0.7)
48
- json (~> 1.7, >= 1.7.7)
49
46
  minitest (~> 5.1)
50
47
  thread_safe (~> 0.3, >= 0.3.4)
51
48
  tzinfo (~> 1.1)
@@ -61,17 +58,14 @@ GEM
61
58
  builder (3.2.3)
62
59
  codemirror-rails (5.6)
63
60
  railties (>= 3.0, < 5)
61
+ concurrent-ruby (1.0.5)
64
62
  erubis (2.7.0)
65
63
  execjs (2.6.0)
66
- globalid (0.3.6)
67
- activesupport (>= 4.1.0)
64
+ globalid (0.4.0)
65
+ activesupport (>= 4.2.0)
68
66
  htmlentities (4.3.4)
69
- i18n (0.7.0)
70
- jquery-rails (4.0.5)
71
- rails-dom-testing (~> 1.0)
72
- railties (>= 4.2.0)
73
- thor (>= 0.14, < 2.0)
74
- json (1.8.6)
67
+ i18n (0.8.1)
68
+ json (2.1.0)
75
69
  kaminari (0.17.0)
76
70
  actionpack (>= 3.0.0)
77
71
  activesupport (>= 3.0.0)
@@ -79,13 +73,13 @@ GEM
79
73
  addressable (~> 2.3)
80
74
  loofah (2.0.3)
81
75
  nokogiri (>= 1.5.9)
82
- mail (2.6.3)
83
- mime-types (>= 1.16, < 3)
84
- mime-types (2.6.2)
76
+ mail (2.6.5)
77
+ mime-types (>= 1.16, < 4)
78
+ mime-types (2.99.3)
85
79
  mini_portile2 (2.1.0)
86
80
  minitest (5.10.1)
87
81
  mysql2 (0.3.20)
88
- nokogiri (1.7.0.1)
82
+ nokogiri (1.7.1)
89
83
  mini_portile2 (~> 2.1.0)
90
84
  pg (0.18.3)
91
85
  polyamorous (1.3.1)
@@ -93,16 +87,16 @@ GEM
93
87
  rack (1.6.5)
94
88
  rack-test (0.6.3)
95
89
  rack (>= 1.0)
96
- rails (4.2.4)
97
- actionmailer (= 4.2.4)
98
- actionpack (= 4.2.4)
99
- actionview (= 4.2.4)
100
- activejob (= 4.2.4)
101
- activemodel (= 4.2.4)
102
- activerecord (= 4.2.4)
103
- activesupport (= 4.2.4)
90
+ rails (4.2.8)
91
+ actionmailer (= 4.2.8)
92
+ actionpack (= 4.2.8)
93
+ actionview (= 4.2.8)
94
+ activejob (= 4.2.8)
95
+ activemodel (= 4.2.8)
96
+ activerecord (= 4.2.8)
97
+ activesupport (= 4.2.8)
104
98
  bundler (>= 1.3.0, < 2.0)
105
- railties (= 4.2.4)
99
+ railties (= 4.2.8)
106
100
  sprockets-rails
107
101
  rails-deprecated_sanitizer (1.0.3)
108
102
  activesupport (>= 4.2.0.alpha)
@@ -112,12 +106,12 @@ GEM
112
106
  rails-deprecated_sanitizer (>= 1.0.1)
113
107
  rails-html-sanitizer (1.0.3)
114
108
  loofah (~> 2.0)
115
- railties (4.2.4)
116
- actionpack (= 4.2.4)
117
- activesupport (= 4.2.4)
109
+ railties (4.2.8)
110
+ actionpack (= 4.2.8)
111
+ activesupport (= 4.2.8)
118
112
  rake (>= 0.8.7)
119
113
  thor (>= 0.18.1, < 2.0)
120
- rake (10.4.2)
114
+ rake (12.0.0)
121
115
  ransack (1.8.2)
122
116
  actionpack (>= 3.0)
123
117
  activerecord (>= 3.0)
@@ -125,21 +119,21 @@ GEM
125
119
  i18n
126
120
  polyamorous (~> 1.3)
127
121
  rubyzip (1.0.0)
128
- sass (3.4.23)
129
122
  simple_form (3.2.0)
130
123
  actionpack (~> 4.0)
131
124
  activemodel (~> 4.0)
132
- sprockets (3.4.0)
125
+ sprockets (3.7.1)
126
+ concurrent-ruby (~> 1.0)
133
127
  rack (> 1, < 3)
134
- sprockets-rails (2.3.3)
135
- actionpack (>= 3.0)
136
- activesupport (>= 3.0)
137
- sprockets (>= 2.8, < 4.0)
128
+ sprockets-rails (3.2.0)
129
+ actionpack (>= 4.0)
130
+ activesupport (>= 4.0)
131
+ sprockets (>= 3.0.0)
138
132
  sqlite3 (1.3.11)
139
133
  terminal-table (1.5.2)
140
- thor (0.19.1)
141
- thread_safe (0.3.5)
142
- tzinfo (1.2.2)
134
+ thor (0.19.4)
135
+ thread_safe (0.3.6)
136
+ tzinfo (1.2.3)
143
137
  thread_safe (~> 0.1)
144
138
  uglifier (2.7.2)
145
139
  execjs (>= 0.3.0)
@@ -152,7 +146,6 @@ PLATFORMS
152
146
  DEPENDENCIES
153
147
  axlsx_rails
154
148
  codemirror-rails
155
- jquery-rails
156
149
  kaminari (>= 0.17.0)
157
150
  launchy
158
151
  mime-types (< 3.0)
@@ -168,4 +161,4 @@ DEPENDENCIES
168
161
  will_paginate (~> 3.0.6)
169
162
 
170
163
  BUNDLED WITH
171
- 1.13.6
164
+ 1.14.3
@@ -1,30 +1,14 @@
1
- //= require jquery
2
- //= require jquery_ujs
1
+ //= require rails_db/jquery
2
+ //= require rails_db/jquery.cookie
3
+ //= require rails_db/rails-ujs
3
4
  //= require rails_db/foundation.min
4
- //= require rails_db/foundation/foundation.abide
5
- //= require rails_db/foundation/foundation.accordion
6
- //= require rails_db/foundation/foundation.alert
7
- //= require rails_db/foundation/foundation.clearing
8
- //= require rails_db/foundation/foundation.dropdown
9
- //= require rails_db/foundation/foundation.equalizer
10
- //= require rails_db/foundation/foundation.interchange
11
- //= require rails_db/foundation/foundation.joyride
12
- //= require rails_db/foundation/foundation.magellan
13
- //= require rails_db/foundation/foundation.offcanvas
14
- //= require rails_db/foundation/foundation.orbit
15
- //= require rails_db/foundation/foundation.reveal
16
- //= require rails_db/foundation/foundation.slider
17
- //= require rails_db/foundation/foundation.tab
18
- //= require rails_db/foundation/foundation.tooltip
19
- //= require rails_db/foundation/foundation.topbar
20
5
  //= require rails_db/sticky
21
- //= require rails_db/jquery.cookie
6
+ //= require rails_db/show_hide_columns.js
7
+ //= require rails_db/search.js
22
8
  //= require codemirror
23
9
  //= require codemirror/modes/sql
24
10
  //= require codemirror/addons/hint/show-hint.js
25
11
  //= require codemirror/addons/hint/sql-hint.js
26
- //= require rails_db/show_hide_columns.js
27
- //= require rails_db/search.js
28
12
 
29
13
  $(function(){
30
14
  $(document).foundation();
@@ -0,0 +1,685 @@
1
+ /*
2
+ Unobtrusive JavaScript
3
+ https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts
4
+ Released under the MIT license
5
+ */
6
+
7
+ ;
8
+
9
+ (function() {
10
+ (function() {
11
+ (function() {
12
+ this.Rails = {
13
+ linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]',
14
+ buttonClickSelector: {
15
+ selector: 'button[data-remote]:not([form]), button[data-confirm]:not([form])',
16
+ exclude: 'form button'
17
+ },
18
+ inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
19
+ formSubmitSelector: 'form',
20
+ formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
21
+ formDisableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
22
+ formEnableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled',
23
+ fileInputSelector: 'input[name][type=file]:not([disabled])',
24
+ linkDisableSelector: 'a[data-disable-with], a[data-disable]',
25
+ buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]'
26
+ };
27
+
28
+ }).call(this);
29
+ }).call(this);
30
+
31
+ var Rails = this.Rails;
32
+
33
+ (function() {
34
+ (function() {
35
+ var expando, m;
36
+
37
+ m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;
38
+
39
+ Rails.matches = function(element, selector) {
40
+ if (selector.exclude != null) {
41
+ return m.call(element, selector.selector) && !m.call(element, selector.exclude);
42
+ } else {
43
+ return m.call(element, selector);
44
+ }
45
+ };
46
+
47
+ expando = '_ujsData';
48
+
49
+ Rails.getData = function(element, key) {
50
+ var ref;
51
+ return (ref = element[expando]) != null ? ref[key] : void 0;
52
+ };
53
+
54
+ Rails.setData = function(element, key, value) {
55
+ if (element[expando] == null) {
56
+ element[expando] = {};
57
+ }
58
+ return element[expando][key] = value;
59
+ };
60
+
61
+ Rails.$ = function(selector) {
62
+ return Array.prototype.slice.call(document.querySelectorAll(selector));
63
+ };
64
+
65
+ }).call(this);
66
+ (function() {
67
+ var $, csrfParam, csrfToken;
68
+
69
+ $ = Rails.$;
70
+
71
+ csrfToken = Rails.csrfToken = function() {
72
+ var meta;
73
+ meta = document.querySelector('meta[name=csrf-token]');
74
+ return meta && meta.content;
75
+ };
76
+
77
+ csrfParam = Rails.csrfParam = function() {
78
+ var meta;
79
+ meta = document.querySelector('meta[name=csrf-param]');
80
+ return meta && meta.content;
81
+ };
82
+
83
+ Rails.CSRFProtection = function(xhr) {
84
+ var token;
85
+ token = csrfToken();
86
+ if (token != null) {
87
+ return xhr.setRequestHeader('X-CSRF-Token', token);
88
+ }
89
+ };
90
+
91
+ Rails.refreshCSRFTokens = function() {
92
+ var param, token;
93
+ token = csrfToken();
94
+ param = csrfParam();
95
+ if ((token != null) && (param != null)) {
96
+ return $('form input[name="' + param + '"]').forEach(function(input) {
97
+ return input.value = token;
98
+ });
99
+ }
100
+ };
101
+
102
+ }).call(this);
103
+ (function() {
104
+ var CustomEvent, fire, matches;
105
+
106
+ matches = Rails.matches;
107
+
108
+ CustomEvent = window.CustomEvent;
109
+
110
+ if (typeof CustomEvent !== 'function') {
111
+ CustomEvent = function(event, params) {
112
+ var evt;
113
+ evt = document.createEvent('CustomEvent');
114
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
115
+ return evt;
116
+ };
117
+ CustomEvent.prototype = window.Event.prototype;
118
+ }
119
+
120
+ fire = Rails.fire = function(obj, name, data) {
121
+ var event;
122
+ event = new CustomEvent(name, {
123
+ bubbles: true,
124
+ cancelable: true,
125
+ detail: data
126
+ });
127
+ obj.dispatchEvent(event);
128
+ return !event.defaultPrevented;
129
+ };
130
+
131
+ Rails.stopEverything = function(e) {
132
+ fire(e.target, 'ujs:everythingStopped');
133
+ e.preventDefault();
134
+ e.stopPropagation();
135
+ return e.stopImmediatePropagation();
136
+ };
137
+
138
+ Rails.delegate = function(element, selector, eventType, handler) {
139
+ return element.addEventListener(eventType, function(e) {
140
+ var target;
141
+ target = e.target;
142
+ while (!(!(target instanceof Element) || matches(target, selector))) {
143
+ target = target.parentNode;
144
+ }
145
+ if (target instanceof Element && handler.call(target, e) === false) {
146
+ e.preventDefault();
147
+ return e.stopPropagation();
148
+ }
149
+ });
150
+ };
151
+
152
+ }).call(this);
153
+ (function() {
154
+ var AcceptHeaders, CSRFProtection, createXHR, fire, prepareOptions, processResponse;
155
+
156
+ CSRFProtection = Rails.CSRFProtection, fire = Rails.fire;
157
+
158
+ AcceptHeaders = {
159
+ '*': '*/*',
160
+ text: 'text/plain',
161
+ html: 'text/html',
162
+ xml: 'application/xml, text/xml',
163
+ json: 'application/json, text/javascript',
164
+ script: 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript'
165
+ };
166
+
167
+ Rails.ajax = function(options) {
168
+ var xhr;
169
+ options = prepareOptions(options);
170
+ xhr = createXHR(options, function() {
171
+ var response;
172
+ response = processResponse(xhr.response, xhr.getResponseHeader('Content-Type'));
173
+ if (Math.floor(xhr.status / 100) === 2) {
174
+ if (typeof options.success === "function") {
175
+ options.success(response, xhr.statusText, xhr);
176
+ }
177
+ } else {
178
+ if (typeof options.error === "function") {
179
+ options.error(response, xhr.statusText, xhr);
180
+ }
181
+ }
182
+ return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : void 0;
183
+ });
184
+ if (typeof options.beforeSend === "function") {
185
+ options.beforeSend(xhr, options);
186
+ }
187
+ if (xhr.readyState === XMLHttpRequest.OPENED) {
188
+ return xhr.send(options.data);
189
+ } else {
190
+ return fire(document, 'ajaxStop');
191
+ }
192
+ };
193
+
194
+ prepareOptions = function(options) {
195
+ options.url = options.url || location.href;
196
+ options.type = options.type.toUpperCase();
197
+ if (options.type === 'GET' && options.data) {
198
+ if (options.url.indexOf('?') < 0) {
199
+ options.url += '?' + options.data;
200
+ } else {
201
+ options.url += '&' + options.data;
202
+ }
203
+ }
204
+ if (AcceptHeaders[options.dataType] == null) {
205
+ options.dataType = '*';
206
+ }
207
+ options.accept = AcceptHeaders[options.dataType];
208
+ if (options.dataType !== '*') {
209
+ options.accept += ', */*; q=0.01';
210
+ }
211
+ return options;
212
+ };
213
+
214
+ createXHR = function(options, done) {
215
+ var xhr;
216
+ xhr = new XMLHttpRequest();
217
+ xhr.open(options.type, options.url, true);
218
+ xhr.setRequestHeader('Accept', options.accept);
219
+ if (typeof options.data === 'string') {
220
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
221
+ }
222
+ if (!options.crossDomain) {
223
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
224
+ }
225
+ CSRFProtection(xhr);
226
+ xhr.withCredentials = !!options.withCredentials;
227
+ xhr.onreadystatechange = function() {
228
+ if (xhr.readyState === XMLHttpRequest.DONE) {
229
+ return done(xhr);
230
+ }
231
+ };
232
+ return xhr;
233
+ };
234
+
235
+ processResponse = function(response, type) {
236
+ var parser, script;
237
+ if (typeof response === 'string' && typeof type === 'string') {
238
+ if (type.match(/\bjson\b/)) {
239
+ try {
240
+ response = JSON.parse(response);
241
+ } catch (error) { }
242
+ } else if (type.match(/\b(?:java|ecma)script\b/)) {
243
+ script = document.createElement('script');
244
+ script.text = response;
245
+ document.head.appendChild(script).parentNode.removeChild(script);
246
+ } else if (type.match(/\b(xml|html|svg)\b/)) {
247
+ parser = new DOMParser();
248
+ type = type.replace(/;.+/, '');
249
+ try {
250
+ response = parser.parseFromString(response, type);
251
+ } catch (error) { }
252
+ }
253
+ }
254
+ return response;
255
+ };
256
+
257
+ Rails.href = function(element) {
258
+ return element.href;
259
+ };
260
+
261
+ Rails.isCrossDomain = function(url) {
262
+ var e, originAnchor, urlAnchor;
263
+ originAnchor = document.createElement('a');
264
+ originAnchor.href = location.href;
265
+ urlAnchor = document.createElement('a');
266
+ try {
267
+ urlAnchor.href = url;
268
+ return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) || (originAnchor.protocol + '//' + originAnchor.host === urlAnchor.protocol + '//' + urlAnchor.host));
269
+ } catch (error) {
270
+ e = error;
271
+ return true;
272
+ }
273
+ };
274
+
275
+ }).call(this);
276
+ (function() {
277
+ var matches, toArray;
278
+
279
+ matches = Rails.matches;
280
+
281
+ toArray = function(e) {
282
+ return Array.prototype.slice.call(e);
283
+ };
284
+
285
+ Rails.serializeElement = function(element, additionalParam) {
286
+ var inputs, params;
287
+ inputs = [element];
288
+ if (matches(element, 'form')) {
289
+ inputs = toArray(element.elements);
290
+ }
291
+ params = [];
292
+ inputs.forEach(function(input) {
293
+ if (!input.name) {
294
+ return;
295
+ }
296
+ if (matches(input, 'select')) {
297
+ return toArray(input.options).forEach(function(option) {
298
+ if (option.selected) {
299
+ return params.push({
300
+ name: input.name,
301
+ value: option.value
302
+ });
303
+ }
304
+ });
305
+ } else if (input.checked || ['radio', 'checkbox', 'submit'].indexOf(input.type) === -1) {
306
+ return params.push({
307
+ name: input.name,
308
+ value: input.value
309
+ });
310
+ }
311
+ });
312
+ if (additionalParam) {
313
+ params.push(additionalParam);
314
+ }
315
+ return params.map(function(param) {
316
+ if (param.name != null) {
317
+ return (encodeURIComponent(param.name)) + "=" + (encodeURIComponent(param.value));
318
+ } else {
319
+ return param;
320
+ }
321
+ }).join('&');
322
+ };
323
+
324
+ Rails.formElements = function(form, selector) {
325
+ if (matches(form, 'form')) {
326
+ return toArray(form.elements).filter(function(el) {
327
+ return matches(el, selector);
328
+ });
329
+ } else {
330
+ return toArray(form.querySelectorAll(selector));
331
+ }
332
+ };
333
+
334
+ }).call(this);
335
+ (function() {
336
+ var allowAction, fire, stopEverything;
337
+
338
+ fire = Rails.fire, stopEverything = Rails.stopEverything;
339
+
340
+ Rails.handleConfirm = function(e) {
341
+ if (!allowAction(this)) {
342
+ return stopEverything(e);
343
+ }
344
+ };
345
+
346
+ allowAction = function(element) {
347
+ var answer, callback, message;
348
+ message = element.getAttribute('data-confirm');
349
+ if (!message) {
350
+ return true;
351
+ }
352
+ answer = false;
353
+ if (fire(element, 'confirm')) {
354
+ try {
355
+ answer = confirm(message);
356
+ } catch (error) { }
357
+ callback = fire(element, 'confirm:complete', [answer]);
358
+ }
359
+ return answer && callback;
360
+ };
361
+
362
+ }).call(this);
363
+ (function() {
364
+ var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, matches, setData, stopEverything;
365
+
366
+ matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, stopEverything = Rails.stopEverything, formElements = Rails.formElements;
367
+
368
+ Rails.handleDisabledElement = function(e) {
369
+ var element;
370
+ element = this;
371
+ if (element.disabled) {
372
+ return stopEverything(e);
373
+ }
374
+ };
375
+
376
+ Rails.enableElement = function(e) {
377
+ var element;
378
+ element = e instanceof Event ? e.target : e;
379
+ if (matches(element, Rails.linkDisableSelector)) {
380
+ return enableLinkElement(element);
381
+ } else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formEnableSelector)) {
382
+ return enableFormElement(element);
383
+ } else if (matches(element, Rails.formSubmitSelector)) {
384
+ return enableFormElements(element);
385
+ }
386
+ };
387
+
388
+ Rails.disableElement = function(e) {
389
+ var element;
390
+ element = e instanceof Event ? e.target : e;
391
+ if (matches(element, Rails.linkDisableSelector)) {
392
+ return disableLinkElement(element);
393
+ } else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formDisableSelector)) {
394
+ return disableFormElement(element);
395
+ } else if (matches(element, Rails.formSubmitSelector)) {
396
+ return disableFormElements(element);
397
+ }
398
+ };
399
+
400
+ disableLinkElement = function(element) {
401
+ var replacement;
402
+ replacement = element.getAttribute('data-disable-with');
403
+ if (replacement != null) {
404
+ setData(element, 'ujs:enable-with', element.innerHTML);
405
+ element.innerHTML = replacement;
406
+ }
407
+ element.addEventListener('click', stopEverything);
408
+ return setData(element, 'ujs:disabled', true);
409
+ };
410
+
411
+ enableLinkElement = function(element) {
412
+ var originalText;
413
+ originalText = getData(element, 'ujs:enable-with');
414
+ if (originalText != null) {
415
+ element.innerHTML = originalText;
416
+ setData(element, 'ujs:enable-with', null);
417
+ }
418
+ element.removeEventListener('click', stopEverything);
419
+ return setData(element, 'ujs:disabled', null);
420
+ };
421
+
422
+ disableFormElements = function(form) {
423
+ return formElements(form, Rails.formDisableSelector).forEach(disableFormElement);
424
+ };
425
+
426
+ disableFormElement = function(element) {
427
+ var replacement;
428
+ replacement = element.getAttribute('data-disable-with');
429
+ if (replacement != null) {
430
+ if (matches(element, 'button')) {
431
+ setData(element, 'ujs:enable-with', element.innerHTML);
432
+ element.innerHTML = replacement;
433
+ } else {
434
+ setData(element, 'ujs:enable-with', element.value);
435
+ element.value = replacement;
436
+ }
437
+ }
438
+ element.disabled = true;
439
+ return setData(element, 'ujs:disabled', true);
440
+ };
441
+
442
+ enableFormElements = function(form) {
443
+ return formElements(form, Rails.formEnableSelector).forEach(enableFormElement);
444
+ };
445
+
446
+ enableFormElement = function(element) {
447
+ var originalText;
448
+ originalText = getData(element, 'ujs:enable-with');
449
+ if (originalText != null) {
450
+ if (matches(element, 'button')) {
451
+ element.innerHTML = originalText;
452
+ } else {
453
+ element.value = originalText;
454
+ }
455
+ setData(element, 'ujs:enable-with', null);
456
+ }
457
+ element.disabled = false;
458
+ return setData(element, 'ujs:disabled', null);
459
+ };
460
+
461
+ }).call(this);
462
+ (function() {
463
+ var stopEverything;
464
+
465
+ stopEverything = Rails.stopEverything;
466
+
467
+ Rails.handleMethod = function(e) {
468
+ var csrfParam, csrfToken, form, formContent, href, link, method;
469
+ link = this;
470
+ method = link.getAttribute('data-method');
471
+ if (!method) {
472
+ return;
473
+ }
474
+ href = Rails.href(link);
475
+ csrfToken = Rails.csrfToken();
476
+ csrfParam = Rails.csrfParam();
477
+ form = document.createElement('form');
478
+ formContent = "<input name='_method' value='" + method + "' type='hidden' />";
479
+ if ((csrfParam != null) && (csrfToken != null) && !Rails.isCrossDomain(href)) {
480
+ formContent += "<input name='" + csrfParam + "' value='" + csrfToken + "' type='hidden' />";
481
+ }
482
+ formContent += '<input type="submit" />';
483
+ form.method = 'post';
484
+ form.action = href;
485
+ form.target = link.target;
486
+ form.innerHTML = formContent;
487
+ form.style.display = 'none';
488
+ document.body.appendChild(form);
489
+ form.querySelector('[type="submit"]').click();
490
+ return stopEverything(e);
491
+ };
492
+
493
+ }).call(this);
494
+ (function() {
495
+ var ajax, fire, getData, isCrossDomain, isRemote, matches, serializeElement, setData, stopEverything,
496
+ slice = [].slice;
497
+
498
+ matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, fire = Rails.fire, stopEverything = Rails.stopEverything, ajax = Rails.ajax, isCrossDomain = Rails.isCrossDomain, serializeElement = Rails.serializeElement;
499
+
500
+ isRemote = function(element) {
501
+ var value;
502
+ value = element.getAttribute('data-remote');
503
+ return (value != null) && value !== 'false';
504
+ };
505
+
506
+ Rails.handleRemote = function(e) {
507
+ var button, data, dataType, element, method, url, withCredentials;
508
+ element = this;
509
+ if (!isRemote(element)) {
510
+ return true;
511
+ }
512
+ if (!fire(element, 'ajax:before')) {
513
+ fire(element, 'ajax:stopped');
514
+ return false;
515
+ }
516
+ withCredentials = element.getAttribute('data-with-credentials');
517
+ dataType = element.getAttribute('data-type') || 'script';
518
+ if (matches(element, Rails.formSubmitSelector)) {
519
+ button = getData(element, 'ujs:submit-button');
520
+ method = getData(element, 'ujs:submit-button-formmethod') || element.method;
521
+ url = getData(element, 'ujs:submit-button-formaction') || element.getAttribute('action') || location.href;
522
+ if (method.toUpperCase() === 'GET') {
523
+ url = url.replace(/\?.*$/, '');
524
+ }
525
+ if (element.enctype === 'multipart/form-data') {
526
+ data = new FormData(element);
527
+ if (button != null) {
528
+ data.append(button.name, button.value);
529
+ }
530
+ } else {
531
+ data = serializeElement(element, button);
532
+ }
533
+ setData(element, 'ujs:submit-button', null);
534
+ setData(element, 'ujs:submit-button-formmethod', null);
535
+ setData(element, 'ujs:submit-button-formaction', null);
536
+ } else if (matches(element, Rails.buttonClickSelector) || matches(element, Rails.inputChangeSelector)) {
537
+ method = element.getAttribute('data-method');
538
+ url = element.getAttribute('data-url');
539
+ data = serializeElement(element, element.getAttribute('data-params'));
540
+ } else {
541
+ method = element.getAttribute('data-method');
542
+ url = Rails.href(element);
543
+ data = element.getAttribute('data-params');
544
+ }
545
+ ajax({
546
+ type: method || 'GET',
547
+ url: url,
548
+ data: data,
549
+ dataType: dataType,
550
+ beforeSend: function(xhr, options) {
551
+ if (fire(element, 'ajax:beforeSend', [xhr, options])) {
552
+ return fire(element, 'ajax:send', [xhr]);
553
+ } else {
554
+ fire(element, 'ajax:stopped');
555
+ return xhr.abort();
556
+ }
557
+ },
558
+ success: function() {
559
+ var args;
560
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
561
+ return fire(element, 'ajax:success', args);
562
+ },
563
+ error: function() {
564
+ var args;
565
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
566
+ return fire(element, 'ajax:error', args);
567
+ },
568
+ complete: function() {
569
+ var args;
570
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
571
+ return fire(element, 'ajax:complete', args);
572
+ },
573
+ crossDomain: isCrossDomain(url),
574
+ withCredentials: (withCredentials != null) && withCredentials !== 'false'
575
+ });
576
+ return stopEverything(e);
577
+ };
578
+
579
+ Rails.formSubmitButtonClick = function(e) {
580
+ var button, form;
581
+ button = this;
582
+ form = button.form;
583
+ if (!form) {
584
+ return;
585
+ }
586
+ if (button.name) {
587
+ setData(form, 'ujs:submit-button', {
588
+ name: button.name,
589
+ value: button.value
590
+ });
591
+ }
592
+ setData(form, 'ujs:formnovalidate-button', button.formNoValidate);
593
+ setData(form, 'ujs:submit-button-formaction', button.getAttribute('formaction'));
594
+ return setData(form, 'ujs:submit-button-formmethod', button.getAttribute('formmethod'));
595
+ };
596
+
597
+ Rails.handleMetaClick = function(e) {
598
+ var data, link, metaClick, method;
599
+ link = this;
600
+ method = (link.getAttribute('data-method') || 'GET').toUpperCase();
601
+ data = link.getAttribute('data-params');
602
+ metaClick = e.metaKey || e.ctrlKey;
603
+ if (metaClick && method === 'GET' && !data) {
604
+ return e.stopImmediatePropagation();
605
+ }
606
+ };
607
+
608
+ }).call(this);
609
+ (function() {
610
+ var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMetaClick, handleMethod, handleRemote, refreshCSRFTokens;
611
+
612
+ fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMetaClick = Rails.handleMetaClick, handleMethod = Rails.handleMethod;
613
+
614
+ if ((typeof jQuery !== "undefined" && jQuery !== null) && !jQuery.rails) {
615
+ jQuery.rails = Rails;
616
+ jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
617
+ if (!options.crossDomain) {
618
+ return CSRFProtection(xhr);
619
+ }
620
+ });
621
+ }
622
+
623
+ Rails.start = function() {
624
+ if (window._rails_loaded) {
625
+ throw new Error('rails-ujs has already been loaded!');
626
+ }
627
+ window.addEventListener('pageshow', function() {
628
+ $(Rails.formEnableSelector).forEach(function(el) {
629
+ if (getData(el, 'ujs:disabled')) {
630
+ return enableElement(el);
631
+ }
632
+ });
633
+ return $(Rails.linkDisableSelector).forEach(function(el) {
634
+ if (getData(el, 'ujs:disabled')) {
635
+ return enableElement(el);
636
+ }
637
+ });
638
+ });
639
+ delegate(document, Rails.linkDisableSelector, 'ajax:complete', enableElement);
640
+ delegate(document, Rails.linkDisableSelector, 'ajax:stopped', enableElement);
641
+ delegate(document, Rails.buttonDisableSelector, 'ajax:complete', enableElement);
642
+ delegate(document, Rails.buttonDisableSelector, 'ajax:stopped', enableElement);
643
+ delegate(document, Rails.linkClickSelector, 'click', handleDisabledElement);
644
+ delegate(document, Rails.linkClickSelector, 'click', handleConfirm);
645
+ delegate(document, Rails.linkClickSelector, 'click', handleMetaClick);
646
+ delegate(document, Rails.linkClickSelector, 'click', disableElement);
647
+ delegate(document, Rails.linkClickSelector, 'click', handleRemote);
648
+ delegate(document, Rails.linkClickSelector, 'click', handleMethod);
649
+ delegate(document, Rails.buttonClickSelector, 'click', handleDisabledElement);
650
+ delegate(document, Rails.buttonClickSelector, 'click', handleConfirm);
651
+ delegate(document, Rails.buttonClickSelector, 'click', disableElement);
652
+ delegate(document, Rails.buttonClickSelector, 'click', handleRemote);
653
+ delegate(document, Rails.inputChangeSelector, 'change', handleDisabledElement);
654
+ delegate(document, Rails.inputChangeSelector, 'change', handleConfirm);
655
+ delegate(document, Rails.inputChangeSelector, 'change', handleRemote);
656
+ delegate(document, Rails.formSubmitSelector, 'submit', handleDisabledElement);
657
+ delegate(document, Rails.formSubmitSelector, 'submit', handleConfirm);
658
+ delegate(document, Rails.formSubmitSelector, 'submit', handleRemote);
659
+ delegate(document, Rails.formSubmitSelector, 'submit', function(e) {
660
+ return setTimeout((function() {
661
+ return disableElement(e);
662
+ }), 13);
663
+ });
664
+ delegate(document, Rails.formSubmitSelector, 'ajax:send', disableElement);
665
+ delegate(document, Rails.formSubmitSelector, 'ajax:complete', enableElement);
666
+ delegate(document, Rails.formInputClickSelector, 'click', handleDisabledElement);
667
+ delegate(document, Rails.formInputClickSelector, 'click', handleConfirm);
668
+ delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick);
669
+ document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
670
+ return window._rails_loaded = true;
671
+ };
672
+
673
+ if (window.Rails === Rails && fire(document, 'rails:attachBindings')) {
674
+ Rails.start();
675
+ }
676
+
677
+ }).call(this);
678
+ }).call(this);
679
+
680
+ if (typeof module === "object" && module.exports) {
681
+ module.exports = Rails;
682
+ } else if (typeof define === "function" && define.amd) {
683
+ define(Rails);
684
+ }
685
+ }).call(this);