mr_video 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +60 -0
- data/Rakefile +29 -0
- data/app/assets/fonts/mr_video/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/mr_video/bootstrap/glyphicons-halflings-regular.svg +229 -0
- data/app/assets/fonts/mr_video/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/mr_video/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/javascripts/mr_video/application.js +14 -0
- data/app/assets/javascripts/mr_video/bootstrap/bootstrap.js +1951 -0
- data/app/assets/javascripts/mr_video/jquery/jquery.js +10308 -0
- data/app/assets/javascripts/mr_video/jquery/jquery_ujs.js +445 -0
- data/app/assets/stylesheets/mr_video/application.css +18 -0
- data/app/assets/stylesheets/mr_video/bootstrap/bootstrap-theme.css +347 -0
- data/app/assets/stylesheets/mr_video/bootstrap/bootstrap-theme.css.map +1 -0
- data/app/assets/stylesheets/mr_video/bootstrap/bootstrap.css +5785 -0
- data/app/assets/stylesheets/mr_video/bootstrap/bootstrap.css.map +1 -0
- data/app/controllers/mr_video/cassettes_controller.rb +20 -0
- data/app/controllers/mr_video/episodes_controller.rb +29 -0
- data/app/controllers/mr_video/mr_video_controller.rb +9 -0
- data/app/models/mr_video/cassette.rb +134 -0
- data/app/models/mr_video/episode.rb +72 -0
- data/app/views/layouts/mr_video.html.erb +55 -0
- data/app/views/mr_video/cassettes/destroy.js.erb +1 -0
- data/app/views/mr_video/cassettes/index.html.erb +34 -0
- data/app/views/mr_video/cassettes/show.html.erb +37 -0
- data/app/views/mr_video/episodes/destroy.js.erb +1 -0
- data/config/routes.rb +9 -0
- data/lib/mr_video.rb +13 -0
- data/lib/mr_video/configuration.rb +13 -0
- data/lib/mr_video/constants.rb +5 -0
- data/lib/mr_video/engine.rb +14 -0
- data/lib/tasks/mr_video_tasks.rake +4 -0
- data/spec/controllers/video_store/cassettes_controller_spec.rb +55 -0
- data/spec/controllers/video_store/episodes_controller_spec.rb +54 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +14 -0
- data/spec/dummy/app/assets/stylesheets/application.css +12 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +63 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +38 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +38 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/mr_video.rb +5 -0
- data/spec/dummy/config/initializers/mr_video.sublime-workspace +1395 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +16552 -0
- data/spec/dummy/log/test.log +5727 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/tmp/cache/assets/BC5/340/sprockets%2F011f96233377718645eef75033490731 +0 -0
- data/spec/dummy/tmp/cache/assets/BDC/290/sprockets%2F03520429830109b18adc104487330f65 +0 -0
- data/spec/dummy/tmp/cache/assets/C2D/510/sprockets%2F20b2ed248141350042180775bd7ca300 +0 -0
- data/spec/dummy/tmp/cache/assets/C33/7B0/sprockets%2F279f3425616908db21248ef7c0377697 +0 -0
- data/spec/dummy/tmp/cache/assets/C45/3B0/sprockets%2Fc56cb6a022490005d187389a831e2571 +0 -0
- data/spec/dummy/tmp/cache/assets/C57/F30/sprockets%2F51c3849868a70eb80c4d3855054c5930 +0 -0
- data/spec/dummy/tmp/cache/assets/C5C/230/sprockets%2F46ad27872159cec6e741991594d15124 +0 -0
- data/spec/dummy/tmp/cache/assets/C63/E70/sprockets%2Fa2f5ad8491396950056b8735f7a62938 +0 -0
- data/spec/dummy/tmp/cache/assets/C90/F00/sprockets%2F9642a8960af3f6345953b23606e93f9a +0 -0
- data/spec/dummy/tmp/cache/assets/C91/E80/sprockets%2F72be6d14725d786093b9e882ca816554 +0 -0
- data/spec/dummy/tmp/cache/assets/C97/920/sprockets%2F46f0b5fb097c2965c2848d4680f80958 +0 -0
- data/spec/dummy/tmp/cache/assets/C9D/350/sprockets%2F068bb04107b41c00343e11c7b98e883c +0 -0
- data/spec/dummy/tmp/cache/assets/CBC/A90/sprockets%2F88375d83a044a38a353166d47ce9e54f +0 -0
- data/spec/dummy/tmp/cache/assets/CC5/A40/sprockets%2F0886ca2691d8b490d337e3ee76854d85 +0 -0
- data/spec/dummy/tmp/cache/assets/CD6/140/sprockets%2F11c0952cbcae9bcd899a084245590122 +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/800/sprockets%2F02b42c31b4c63833bd5391cf9673ca85 +0 -0
- data/spec/dummy/tmp/cache/assets/CDA/2C0/sprockets%2F221516f58730c4380758cbae2fec6a71 +0 -0
- data/spec/dummy/tmp/cache/assets/CDA/480/sprockets%2F95e6eb142db561885f06505a5914abb1 +0 -0
- data/spec/dummy/tmp/cache/assets/CE1/E10/sprockets%2F5210ce2ae5da974288dd019797e20a48 +0 -0
- data/spec/dummy/tmp/cache/assets/CE2/6A0/sprockets%2Fe8f56390ce25f90d5d83417710a37d2a +0 -0
- data/spec/dummy/tmp/cache/assets/CE6/6B0/sprockets%2F6f59704f0eb8d426364a45ae84a72a84 +0 -0
- data/spec/dummy/tmp/cache/assets/CED/190/sprockets%2F4ead8ef219866589f2daa431e2766343 +0 -0
- data/spec/dummy/tmp/cache/assets/CF8/CB0/sprockets%2Fd34d984764979dd92d43410c8def138e +0 -0
- data/spec/dummy/tmp/cache/assets/CFC/880/sprockets%2Fb2dd1136875dcde12d761017ac03372e +0 -0
- data/spec/dummy/tmp/cache/assets/CFF/B30/sprockets%2F48e1115402264fa234aabcb489ee518b +0 -0
- data/spec/dummy/tmp/cache/assets/D14/700/sprockets%2Fce8e69a02c907e441390a9c86b13df90 +0 -0
- data/spec/dummy/tmp/cache/assets/D16/7D0/sprockets%2F475812a15ca9d81ff39dd6ab61482d75 +0 -0
- data/spec/dummy/tmp/cache/assets/D26/B40/sprockets%2F5bdcd40a041fa14d4469b4a190161f3e +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D38/F40/sprockets%2Fd48477e04ed5bf10a5fc7c10130a679e +0 -0
- data/spec/dummy/tmp/cache/assets/D38/FE0/sprockets%2Fbfa23201384b9d7dc4b502b8dc29e656 +0 -0
- data/spec/dummy/tmp/cache/assets/D3D/0B0/sprockets%2F79fb602c1c65f8724a3c80dfe3c3361c +0 -0
- data/spec/dummy/tmp/cache/assets/D3E/800/sprockets%2F85894a92c6d354c2aac841b14a7bd55e +0 -0
- data/spec/dummy/tmp/cache/assets/D47/9C0/sprockets%2F57478f21bedc6548e8eca1d0a25a4958 +0 -0
- data/spec/dummy/tmp/cache/assets/D49/A90/sprockets%2F4433dd9a2fe90f951c6f5f7b71b0e853 +0 -0
- data/spec/dummy/tmp/cache/assets/D4C/0A0/sprockets%2Fd1ec53c5f942e6b79641c45766a2d7fc +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/D5B/300/sprockets%2Fe62362bab720236b43e1a038fd9dbdd2 +0 -0
- data/spec/dummy/tmp/cache/assets/D68/5D0/sprockets%2F8ffa00e8e5f7803b6aaa18a23329f22f +0 -0
- data/spec/dummy/tmp/cache/assets/D6A/730/sprockets%2F9d1c16a25124c1fea9d3f5b37db76c19 +0 -0
- data/spec/dummy/tmp/cache/assets/D87/010/sprockets%2F2fd000d05c3caccd47a7b99f7b220d31 +0 -0
- data/spec/dummy/tmp/cache/assets/D88/840/sprockets%2Fbbb470f1d92872d9e96736ffee738ab8 +0 -0
- data/spec/dummy/tmp/cache/assets/D8B/D70/sprockets%2Fac6110ef0f1216d4e86c2ed603eac82c +0 -0
- data/spec/dummy/tmp/cache/assets/D96/5C0/sprockets%2Fbfe0beb29fcee39b99441a7be0138101 +0 -0
- data/spec/dummy/tmp/cache/assets/DAD/BA0/sprockets%2F6b7678daa66e961e3dbb796535af3bcd +0 -0
- data/spec/dummy/tmp/cache/assets/DBE/F30/sprockets%2Fe042264dbae9fca26108ce7b4dce350b +0 -0
- data/spec/dummy/tmp/cache/assets/DC4/330/sprockets%2Fdfbbbc7c7a2a52cfcb710542961ec664 +0 -0
- data/spec/dummy/tmp/cache/assets/DC8/C50/sprockets%2Fb5abe9d8e041580bfe17daf381a91dd2 +0 -0
- data/spec/dummy/tmp/cache/assets/DD5/5B0/sprockets%2Fe3162de85dd0ebaa5e479ef9d19aa582 +0 -0
- data/spec/dummy/tmp/cache/assets/DE7/290/sprockets%2Fa972abb5f2c3d2064a7c43a3d0bc5bee +0 -0
- data/spec/dummy/tmp/cache/assets/DFD/C30/sprockets%2F2e060bbba7e5d1f81562fbcca678f9bf +0 -0
- data/spec/dummy/tmp/cache/assets/E06/E60/sprockets%2Ff0eaaf5cea0945a49feab7878c8a44a8 +0 -0
- data/spec/dummy/tmp/cache/assets/E0E/BB0/sprockets%2Ff48af82fa284ceabac74ee8258d1f88d +0 -0
- data/spec/dummy/tmp/cache/assets/E27/6C0/sprockets%2F12ffc203c4789ac5acc3bdceade8395a +0 -0
- data/spec/dummy/tmp/cache/assets/E55/230/sprockets%2Fea4a67dddbbcb11bf04bf77af7b90f54 +0 -0
- data/spec/dummy/tmp/cache/assets/EE0/840/sprockets%2Fdcbdff354ddfdcdb2a5abd9f03ce620c +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/factories/factories.rb +3 -0
- data/spec/fixtures/vcr_cassettes/bell_house.yml +12100 -0
- data/spec/fixtures/vcr_cassettes/brooklyn_bridge_park.yml +25703 -0
- data/spec/fixtures/vcr_cassettes/date_time_service.yml +38 -0
- data/spec/fixtures/vcr_cassettes/dummy_cassette.yml +12100 -0
- data/spec/fixtures/vcr_cassettes/ticket_fly.yml +18813 -0
- data/spec/models/mr_video/cassette_spec.rb +64 -0
- data/spec/models/mr_video/episode_spec.rb +83 -0
- data/spec/rails_helper.rb +72 -0
- data/spec/spec_helper.rb +78 -0
- data/spec/support/coveralls.rb +2 -0
- metadata +289 -0
@@ -0,0 +1,445 @@
|
|
1
|
+
(function($, undefined) {
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Unobtrusive scripting adapter for jQuery
|
5
|
+
* https://github.com/rails/jquery-ujs
|
6
|
+
*
|
7
|
+
* Requires jQuery 1.8.0 or later.
|
8
|
+
*
|
9
|
+
* Released under the MIT license
|
10
|
+
*
|
11
|
+
*/
|
12
|
+
|
13
|
+
// Cut down on the number of issues from people inadvertently including jquery_ujs twice
|
14
|
+
// by detecting and raising an error when it happens.
|
15
|
+
if ( $.rails !== undefined ) {
|
16
|
+
$.error('jquery-ujs has already been loaded!');
|
17
|
+
}
|
18
|
+
|
19
|
+
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
20
|
+
var rails;
|
21
|
+
var $document = $(document);
|
22
|
+
|
23
|
+
$.rails = rails = {
|
24
|
+
// Link elements bound by jquery-ujs
|
25
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]',
|
26
|
+
|
27
|
+
// Button elements bound by jquery-ujs
|
28
|
+
buttonClickSelector: 'button[data-remote], button[data-confirm]',
|
29
|
+
|
30
|
+
// Select elements bound by jquery-ujs
|
31
|
+
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
|
32
|
+
|
33
|
+
// Form elements bound by jquery-ujs
|
34
|
+
formSubmitSelector: 'form',
|
35
|
+
|
36
|
+
// Form input elements bound by jquery-ujs
|
37
|
+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
|
38
|
+
|
39
|
+
// Form input elements disabled during form submission
|
40
|
+
disableSelector: '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',
|
41
|
+
|
42
|
+
// Form input elements re-enabled after form submission
|
43
|
+
enableSelector: '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',
|
44
|
+
|
45
|
+
// Form required input elements
|
46
|
+
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
47
|
+
|
48
|
+
// Form file input elements
|
49
|
+
fileInputSelector: 'input[type=file]',
|
50
|
+
|
51
|
+
// Link onClick disable selector with possible reenable after remote submission
|
52
|
+
linkDisableSelector: 'a[data-disable-with], a[data-disable]',
|
53
|
+
|
54
|
+
// Button onClick disable selector with possible reenable after remote submission
|
55
|
+
buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]',
|
56
|
+
|
57
|
+
// Make sure that every Ajax request sends the CSRF token
|
58
|
+
CSRFProtection: function(xhr) {
|
59
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
60
|
+
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
61
|
+
},
|
62
|
+
|
63
|
+
// making sure that all forms have actual up-to-date token(cached forms contain old one)
|
64
|
+
refreshCSRFTokens: function(){
|
65
|
+
var csrfToken = $('meta[name=csrf-token]').attr('content');
|
66
|
+
var csrfParam = $('meta[name=csrf-param]').attr('content');
|
67
|
+
$('form input[name="' + csrfParam + '"]').val(csrfToken);
|
68
|
+
},
|
69
|
+
|
70
|
+
// Triggers an event on an element and returns false if the event result is false
|
71
|
+
fire: function(obj, name, data) {
|
72
|
+
var event = $.Event(name);
|
73
|
+
obj.trigger(event, data);
|
74
|
+
return event.result !== false;
|
75
|
+
},
|
76
|
+
|
77
|
+
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
78
|
+
confirm: function(message) {
|
79
|
+
return confirm(message);
|
80
|
+
},
|
81
|
+
|
82
|
+
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
83
|
+
ajax: function(options) {
|
84
|
+
return $.ajax(options);
|
85
|
+
},
|
86
|
+
|
87
|
+
// Default way to get an element's href. May be overridden at $.rails.href.
|
88
|
+
href: function(element) {
|
89
|
+
return element.attr('href');
|
90
|
+
},
|
91
|
+
|
92
|
+
// Submits "remote" forms and links with ajax
|
93
|
+
handleRemote: function(element) {
|
94
|
+
var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options;
|
95
|
+
|
96
|
+
if (rails.fire(element, 'ajax:before')) {
|
97
|
+
elCrossDomain = element.data('cross-domain');
|
98
|
+
crossDomain = elCrossDomain === undefined ? null : elCrossDomain;
|
99
|
+
withCredentials = element.data('with-credentials') || null;
|
100
|
+
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
101
|
+
|
102
|
+
if (element.is('form')) {
|
103
|
+
method = element.attr('method');
|
104
|
+
url = element.attr('action');
|
105
|
+
data = element.serializeArray();
|
106
|
+
// memoized value from clicked submit button
|
107
|
+
var button = element.data('ujs:submit-button');
|
108
|
+
if (button) {
|
109
|
+
data.push(button);
|
110
|
+
element.data('ujs:submit-button', null);
|
111
|
+
}
|
112
|
+
} else if (element.is(rails.inputChangeSelector)) {
|
113
|
+
method = element.data('method');
|
114
|
+
url = element.data('url');
|
115
|
+
data = element.serialize();
|
116
|
+
if (element.data('params')) data = data + "&" + element.data('params');
|
117
|
+
} else if (element.is(rails.buttonClickSelector)) {
|
118
|
+
method = element.data('method') || 'get';
|
119
|
+
url = element.data('url');
|
120
|
+
data = element.serialize();
|
121
|
+
if (element.data('params')) data = data + "&" + element.data('params');
|
122
|
+
} else {
|
123
|
+
method = element.data('method');
|
124
|
+
url = rails.href(element);
|
125
|
+
data = element.data('params') || null;
|
126
|
+
}
|
127
|
+
|
128
|
+
options = {
|
129
|
+
type: method || 'GET', data: data, dataType: dataType,
|
130
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
131
|
+
beforeSend: function(xhr, settings) {
|
132
|
+
if (settings.dataType === undefined) {
|
133
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
134
|
+
}
|
135
|
+
if (rails.fire(element, 'ajax:beforeSend', [xhr, settings])) {
|
136
|
+
element.trigger('ajax:send', xhr);
|
137
|
+
} else {
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
},
|
141
|
+
success: function(data, status, xhr) {
|
142
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
143
|
+
},
|
144
|
+
complete: function(xhr, status) {
|
145
|
+
element.trigger('ajax:complete', [xhr, status]);
|
146
|
+
},
|
147
|
+
error: function(xhr, status, error) {
|
148
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
149
|
+
},
|
150
|
+
crossDomain: crossDomain
|
151
|
+
};
|
152
|
+
|
153
|
+
// There is no withCredentials for IE6-8 when
|
154
|
+
// "Enable native XMLHTTP support" is disabled
|
155
|
+
if (withCredentials) {
|
156
|
+
options.xhrFields = {
|
157
|
+
withCredentials: withCredentials
|
158
|
+
};
|
159
|
+
}
|
160
|
+
|
161
|
+
// Only pass url to `ajax` options if not blank
|
162
|
+
if (url) { options.url = url; }
|
163
|
+
|
164
|
+
return rails.ajax(options);
|
165
|
+
} else {
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
},
|
169
|
+
|
170
|
+
// Handles "data-method" on links such as:
|
171
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
172
|
+
handleMethod: function(link) {
|
173
|
+
var href = rails.href(link),
|
174
|
+
method = link.data('method'),
|
175
|
+
target = link.attr('target'),
|
176
|
+
csrfToken = $('meta[name=csrf-token]').attr('content'),
|
177
|
+
csrfParam = $('meta[name=csrf-param]').attr('content'),
|
178
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
179
|
+
metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
|
180
|
+
|
181
|
+
if (csrfParam !== undefined && csrfToken !== undefined) {
|
182
|
+
metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
|
183
|
+
}
|
184
|
+
|
185
|
+
if (target) { form.attr('target', target); }
|
186
|
+
|
187
|
+
form.hide().append(metadataInput).appendTo('body');
|
188
|
+
form.submit();
|
189
|
+
},
|
190
|
+
|
191
|
+
// Helper function that returns form elements that match the specified CSS selector
|
192
|
+
// If form is actually a "form" element this will return associated elements outside the from that have
|
193
|
+
// the html form attribute set
|
194
|
+
formElements: function(form, selector) {
|
195
|
+
return form.is('form') ? $(form[0].elements).filter(selector) : form.find(selector);
|
196
|
+
},
|
197
|
+
|
198
|
+
/* Disables form elements:
|
199
|
+
- Caches element value in 'ujs:enable-with' data store
|
200
|
+
- Replaces element text with value of 'data-disable-with' attribute
|
201
|
+
- Sets disabled property to true
|
202
|
+
*/
|
203
|
+
disableFormElements: function(form) {
|
204
|
+
rails.formElements(form, rails.disableSelector).each(function() {
|
205
|
+
rails.disableFormElement($(this));
|
206
|
+
});
|
207
|
+
},
|
208
|
+
|
209
|
+
disableFormElement: function(element) {
|
210
|
+
var method, replacement;
|
211
|
+
|
212
|
+
method = element.is('button') ? 'html' : 'val';
|
213
|
+
replacement = element.data('disable-with');
|
214
|
+
|
215
|
+
element.data('ujs:enable-with', element[method]());
|
216
|
+
if (replacement !== undefined) {
|
217
|
+
element[method](replacement);
|
218
|
+
}
|
219
|
+
|
220
|
+
element.prop('disabled', true);
|
221
|
+
},
|
222
|
+
|
223
|
+
/* Re-enables disabled form elements:
|
224
|
+
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
225
|
+
- Sets disabled property to false
|
226
|
+
*/
|
227
|
+
enableFormElements: function(form) {
|
228
|
+
rails.formElements(form, rails.enableSelector).each(function() {
|
229
|
+
rails.enableFormElement($(this));
|
230
|
+
});
|
231
|
+
},
|
232
|
+
|
233
|
+
enableFormElement: function(element) {
|
234
|
+
var method = element.is('button') ? 'html' : 'val';
|
235
|
+
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
236
|
+
element.prop('disabled', false);
|
237
|
+
},
|
238
|
+
|
239
|
+
/* For 'data-confirm' attribute:
|
240
|
+
- Fires `confirm` event
|
241
|
+
- Shows the confirmation dialog
|
242
|
+
- Fires the `confirm:complete` event
|
243
|
+
|
244
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
245
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
246
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
247
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
248
|
+
*/
|
249
|
+
allowAction: function(element) {
|
250
|
+
var message = element.data('confirm'),
|
251
|
+
answer = false, callback;
|
252
|
+
if (!message) { return true; }
|
253
|
+
|
254
|
+
if (rails.fire(element, 'confirm')) {
|
255
|
+
answer = rails.confirm(message);
|
256
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
257
|
+
}
|
258
|
+
return answer && callback;
|
259
|
+
},
|
260
|
+
|
261
|
+
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
262
|
+
blankInputs: function(form, specifiedSelector, nonBlank) {
|
263
|
+
var inputs = $(), input, valueToCheck,
|
264
|
+
selector = specifiedSelector || 'input,textarea',
|
265
|
+
allInputs = form.find(selector);
|
266
|
+
|
267
|
+
allInputs.each(function() {
|
268
|
+
input = $(this);
|
269
|
+
valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : input.val();
|
270
|
+
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
|
271
|
+
if (!valueToCheck === !nonBlank) {
|
272
|
+
|
273
|
+
// Don't count unchecked required radio if other radio with same name is checked
|
274
|
+
if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
|
275
|
+
return true; // Skip to next input
|
276
|
+
}
|
277
|
+
|
278
|
+
inputs = inputs.add(input);
|
279
|
+
}
|
280
|
+
});
|
281
|
+
return inputs.length ? inputs : false;
|
282
|
+
},
|
283
|
+
|
284
|
+
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
285
|
+
nonBlankInputs: function(form, specifiedSelector) {
|
286
|
+
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
287
|
+
},
|
288
|
+
|
289
|
+
// Helper function, needed to provide consistent behavior in IE
|
290
|
+
stopEverything: function(e) {
|
291
|
+
$(e.target).trigger('ujs:everythingStopped');
|
292
|
+
e.stopImmediatePropagation();
|
293
|
+
return false;
|
294
|
+
},
|
295
|
+
|
296
|
+
// replace element's html with the 'data-disable-with' after storing original html
|
297
|
+
// and prevent clicking on it
|
298
|
+
disableElement: function(element) {
|
299
|
+
var replacement = element.data('disable-with');
|
300
|
+
|
301
|
+
element.data('ujs:enable-with', element.html()); // store enabled state
|
302
|
+
if (replacement !== undefined) {
|
303
|
+
element.html(replacement);
|
304
|
+
}
|
305
|
+
|
306
|
+
element.bind('click.railsDisable', function(e) { // prevent further clicking
|
307
|
+
return rails.stopEverything(e);
|
308
|
+
});
|
309
|
+
},
|
310
|
+
|
311
|
+
// restore element to its original state which was disabled by 'disableElement' above
|
312
|
+
enableElement: function(element) {
|
313
|
+
if (element.data('ujs:enable-with') !== undefined) {
|
314
|
+
element.html(element.data('ujs:enable-with')); // set to old enabled state
|
315
|
+
element.removeData('ujs:enable-with'); // clean up cache
|
316
|
+
}
|
317
|
+
element.unbind('click.railsDisable'); // enable element
|
318
|
+
}
|
319
|
+
};
|
320
|
+
|
321
|
+
if (rails.fire($document, 'rails:attachBindings')) {
|
322
|
+
|
323
|
+
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
324
|
+
|
325
|
+
$document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {
|
326
|
+
rails.enableElement($(this));
|
327
|
+
});
|
328
|
+
|
329
|
+
$document.delegate(rails.buttonDisableSelector, 'ajax:complete', function() {
|
330
|
+
rails.enableFormElement($(this));
|
331
|
+
});
|
332
|
+
|
333
|
+
$document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
|
334
|
+
var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
|
335
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
336
|
+
|
337
|
+
if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link);
|
338
|
+
|
339
|
+
if (link.data('remote') !== undefined) {
|
340
|
+
if (metaClick && (!method || method === 'GET') && !data) { return true; }
|
341
|
+
|
342
|
+
var handleRemote = rails.handleRemote(link);
|
343
|
+
// response from rails.handleRemote() will either be false or a deferred object promise.
|
344
|
+
if (handleRemote === false) {
|
345
|
+
rails.enableElement(link);
|
346
|
+
} else {
|
347
|
+
handleRemote.error( function() { rails.enableElement(link); } );
|
348
|
+
}
|
349
|
+
return false;
|
350
|
+
|
351
|
+
} else if (link.data('method')) {
|
352
|
+
rails.handleMethod(link);
|
353
|
+
return false;
|
354
|
+
}
|
355
|
+
});
|
356
|
+
|
357
|
+
$document.delegate(rails.buttonClickSelector, 'click.rails', function(e) {
|
358
|
+
var button = $(this);
|
359
|
+
if (!rails.allowAction(button)) return rails.stopEverything(e);
|
360
|
+
|
361
|
+
if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button);
|
362
|
+
|
363
|
+
var handleRemote = rails.handleRemote(button);
|
364
|
+
// response from rails.handleRemote() will either be false or a deferred object promise.
|
365
|
+
if (handleRemote === false) {
|
366
|
+
rails.enableFormElement(button);
|
367
|
+
} else {
|
368
|
+
handleRemote.error( function() { rails.enableFormElement(button); } );
|
369
|
+
}
|
370
|
+
return false;
|
371
|
+
});
|
372
|
+
|
373
|
+
$document.delegate(rails.inputChangeSelector, 'change.rails', function(e) {
|
374
|
+
var link = $(this);
|
375
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
376
|
+
|
377
|
+
rails.handleRemote(link);
|
378
|
+
return false;
|
379
|
+
});
|
380
|
+
|
381
|
+
$document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
|
382
|
+
var form = $(this),
|
383
|
+
remote = form.data('remote') !== undefined,
|
384
|
+
blankRequiredInputs,
|
385
|
+
nonBlankFileInputs;
|
386
|
+
|
387
|
+
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
388
|
+
|
389
|
+
// skip other logic when required values are missing or file upload is present
|
390
|
+
if (form.attr('novalidate') == undefined) {
|
391
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector);
|
392
|
+
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
393
|
+
return rails.stopEverything(e);
|
394
|
+
}
|
395
|
+
}
|
396
|
+
|
397
|
+
if (remote) {
|
398
|
+
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
399
|
+
if (nonBlankFileInputs) {
|
400
|
+
// slight timeout so that the submit button gets properly serialized
|
401
|
+
// (make it easy for event handler to serialize form without disabled values)
|
402
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
403
|
+
var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
404
|
+
|
405
|
+
// re-enable form elements if event bindings return false (canceling normal form submission)
|
406
|
+
if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
|
407
|
+
|
408
|
+
return aborted;
|
409
|
+
}
|
410
|
+
|
411
|
+
rails.handleRemote(form);
|
412
|
+
return false;
|
413
|
+
|
414
|
+
} else {
|
415
|
+
// slight timeout so that the submit button gets properly serialized
|
416
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
417
|
+
}
|
418
|
+
});
|
419
|
+
|
420
|
+
$document.delegate(rails.formInputClickSelector, 'click.rails', function(event) {
|
421
|
+
var button = $(this);
|
422
|
+
|
423
|
+
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
424
|
+
|
425
|
+
// register the pressed submit button
|
426
|
+
var name = button.attr('name'),
|
427
|
+
data = name ? {name:name, value:button.val()} : null;
|
428
|
+
|
429
|
+
button.closest('form').data('ujs:submit-button', data);
|
430
|
+
});
|
431
|
+
|
432
|
+
$document.delegate(rails.formSubmitSelector, 'ajax:send.rails', function(event) {
|
433
|
+
if (this == event.target) rails.disableFormElements($(this));
|
434
|
+
});
|
435
|
+
|
436
|
+
$document.delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
|
437
|
+
if (this == event.target) rails.enableFormElements($(this));
|
438
|
+
});
|
439
|
+
|
440
|
+
$(function(){
|
441
|
+
rails.refreshCSRFTokens();
|
442
|
+
});
|
443
|
+
}
|
444
|
+
|
445
|
+
})( jQuery );
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_tree ./bootstrap
|
12
|
+
*= require_self
|
13
|
+
*/
|
14
|
+
|
15
|
+
body {
|
16
|
+
padding-top: 70px;
|
17
|
+
padding-bottom: 70px;
|
18
|
+
}
|