letter_opener_web 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/README.md +1 -1
- data/app/assets/javascripts/letter_opener_web/application.js +1 -0
- data/app/views/layouts/letter_opener_web/application.html.erb +0 -1
- data/letter_opener_web.gemspec +1 -1
- data/lib/letter_opener_web/version.rb +1 -1
- data/vendor/assets/javascripts/jquery_ujs.js +429 -0
- metadata +31 -47
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 099bd83dd3b54f69e8f544499a0d1d7664ed2efc
|
4
|
+
data.tar.gz: 757297b82f1f83e457d9ff12c4eea2fec206f87b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f7076fdf39cd462c02fbf422aebfae61efbfe3f296162303255c0631a4ce808e4afcebab87f7d443ebe0bcf5f1038681ba5407fe5eadc19d66001785ebe45d57
|
7
|
+
data.tar.gz: adf435eb9f1f68e2d85f54b79cde3d98f3818c9c7753ce6e3683c3b306e18b933874356ac0d461bbc5c9a4e64b2982be989d4663196709efe0e11382a3313a7a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
## [1.0.3](https://github.com/fgrehm/letter_opener_web/compare/v1.0.2...v1.0.3) (May 29, 2013)
|
2
|
+
|
3
|
+
- Fix clear button [#12](https://github.com/fgrehm/letter_opener_web/issues/12), tks to [@grumpit](https://github.com/grumpit)
|
4
|
+
|
5
|
+
## Previous
|
6
|
+
|
7
|
+
The changelog began with version 1.0.3 so any changes prior to that
|
8
|
+
can be seen by checking the tagged releases and reading git commit
|
9
|
+
messages.
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ browsing sent emails.
|
|
9
9
|
|
10
10
|
First add the gem to your development environment and run the `bundle` command to install it.
|
11
11
|
|
12
|
-
gem 'letter_opener_web', '~> 1.0', :group => :development
|
12
|
+
gem 'letter_opener_web', '~> 1.0.3', :group => :development
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
@@ -4,7 +4,6 @@
|
|
4
4
|
<title>LetterOpenerWeb</title>
|
5
5
|
<%= stylesheet_link_tag "letter_opener_web/application", :media => "all" %>
|
6
6
|
<%= javascript_include_tag "letter_opener_web/application" %>
|
7
|
-
<%= javascript_include_tag 'https://raw.github.com/indirect/jquery-rails/master/vendor/assets/javascripts/jquery_ujs.js' %>
|
8
7
|
<%= csrf_meta_tags %>
|
9
8
|
</head>
|
10
9
|
<body>
|
data/letter_opener_web.gemspec
CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_dependency 'letter_opener', '~> 1.0'
|
22
22
|
|
23
23
|
gem.add_development_dependency 'rspec-rails', '~> 2.0'
|
24
|
-
gem.add_development_dependency 'shoulda-matchers'
|
24
|
+
gem.add_development_dependency 'shoulda-matchers', '1.5.6'
|
25
25
|
gem.add_development_dependency 'combustion', '~> 0.3.1'
|
26
26
|
end
|
@@ -0,0 +1,429 @@
|
|
1
|
+
(function($, undefined) {
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Unobtrusive scripting adapter for jQuery
|
5
|
+
*
|
6
|
+
* Requires jQuery 1.6.0 or later.
|
7
|
+
* https://github.com/rails/jquery-ujs
|
8
|
+
|
9
|
+
* Uploading file using rails.js
|
10
|
+
* =============================
|
11
|
+
*
|
12
|
+
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
|
13
|
+
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
|
14
|
+
*
|
15
|
+
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
|
16
|
+
*
|
17
|
+
* Ex:
|
18
|
+
* $('form').live('ajax:aborted:file', function(event, elements){
|
19
|
+
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
|
20
|
+
* // Returning false in this handler tells rails.js to disallow standard form submission
|
21
|
+
* return false;
|
22
|
+
* });
|
23
|
+
*
|
24
|
+
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
|
25
|
+
*
|
26
|
+
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
|
27
|
+
* techniques like the iframe method to upload the file instead.
|
28
|
+
*
|
29
|
+
* Required fields in rails.js
|
30
|
+
* ===========================
|
31
|
+
*
|
32
|
+
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
|
33
|
+
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
|
34
|
+
*
|
35
|
+
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
|
36
|
+
*
|
37
|
+
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
|
38
|
+
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
|
39
|
+
*
|
40
|
+
* Ex:
|
41
|
+
* $('form').live('ajax:aborted:required', function(event, elements){
|
42
|
+
* // Returning false in this handler tells rails.js to submit the form anyway.
|
43
|
+
* // The blank required inputs are passed to this function in `elements`.
|
44
|
+
* return ! confirm("Would you like to submit the form with missing info?");
|
45
|
+
* });
|
46
|
+
*/
|
47
|
+
|
48
|
+
// Cut down on the number if issues from people inadvertently including jquery_ujs twice
|
49
|
+
// by detecting and raising an error when it happens.
|
50
|
+
var alreadyInitialized = function() {
|
51
|
+
var events = $._data(document, 'events');
|
52
|
+
return events && events.click && $.grep(events.click, function(e) { return e.namespace === 'rails'; }).length;
|
53
|
+
}
|
54
|
+
|
55
|
+
if ( alreadyInitialized() ) {
|
56
|
+
$.error('jquery-ujs has already been loaded!');
|
57
|
+
}
|
58
|
+
|
59
|
+
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
60
|
+
var rails;
|
61
|
+
|
62
|
+
$.rails = rails = {
|
63
|
+
// Link elements bound by jquery-ujs
|
64
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
|
65
|
+
|
66
|
+
// Select elements bound by jquery-ujs
|
67
|
+
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
|
68
|
+
|
69
|
+
// Form elements bound by jquery-ujs
|
70
|
+
formSubmitSelector: 'form',
|
71
|
+
|
72
|
+
// Form input elements bound by jquery-ujs
|
73
|
+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
|
74
|
+
|
75
|
+
// Form input elements disabled during form submission
|
76
|
+
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
|
77
|
+
|
78
|
+
// Form input elements re-enabled after form submission
|
79
|
+
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
|
80
|
+
|
81
|
+
// Form required input elements
|
82
|
+
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
83
|
+
|
84
|
+
// Form file input elements
|
85
|
+
fileInputSelector: 'input:file',
|
86
|
+
|
87
|
+
// Link onClick disable selector with possible reenable after remote submission
|
88
|
+
linkDisableSelector: 'a[data-disable-with]',
|
89
|
+
|
90
|
+
// Make sure that every Ajax request sends the CSRF token
|
91
|
+
CSRFProtection: function(xhr) {
|
92
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
93
|
+
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
94
|
+
},
|
95
|
+
|
96
|
+
// Triggers an event on an element and returns false if the event result is false
|
97
|
+
fire: function(obj, name, data) {
|
98
|
+
var event = $.Event(name);
|
99
|
+
obj.trigger(event, data);
|
100
|
+
return event.result !== false;
|
101
|
+
},
|
102
|
+
|
103
|
+
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
104
|
+
confirm: function(message) {
|
105
|
+
return confirm(message);
|
106
|
+
},
|
107
|
+
|
108
|
+
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
109
|
+
ajax: function(options) {
|
110
|
+
return $.ajax(options);
|
111
|
+
},
|
112
|
+
|
113
|
+
// Default way to get an element's href. May be overridden at $.rails.href.
|
114
|
+
href: function(element) {
|
115
|
+
return element.attr('href');
|
116
|
+
},
|
117
|
+
|
118
|
+
// Submits "remote" forms and links with ajax
|
119
|
+
handleRemote: function(element) {
|
120
|
+
var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options;
|
121
|
+
|
122
|
+
if (rails.fire(element, 'ajax:before')) {
|
123
|
+
elCrossDomain = element.data('cross-domain');
|
124
|
+
crossDomain = elCrossDomain === undefined ? null : elCrossDomain;
|
125
|
+
withCredentials = element.data('with-credentials') || null;
|
126
|
+
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
127
|
+
|
128
|
+
if (element.is('form')) {
|
129
|
+
method = element.attr('method');
|
130
|
+
url = element.attr('action');
|
131
|
+
data = element.serializeArray();
|
132
|
+
// memoized value from clicked submit button
|
133
|
+
var button = element.data('ujs:submit-button');
|
134
|
+
if (button) {
|
135
|
+
data.push(button);
|
136
|
+
element.data('ujs:submit-button', null);
|
137
|
+
}
|
138
|
+
} else if (element.is(rails.inputChangeSelector)) {
|
139
|
+
method = element.data('method');
|
140
|
+
url = element.data('url');
|
141
|
+
data = element.serialize();
|
142
|
+
if (element.data('params')) data = data + "&" + element.data('params');
|
143
|
+
} else {
|
144
|
+
method = element.data('method');
|
145
|
+
url = rails.href(element);
|
146
|
+
data = element.data('params') || null;
|
147
|
+
}
|
148
|
+
|
149
|
+
options = {
|
150
|
+
type: method || 'GET', data: data, dataType: dataType,
|
151
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
152
|
+
beforeSend: function(xhr, settings) {
|
153
|
+
if (settings.dataType === undefined) {
|
154
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
155
|
+
}
|
156
|
+
return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
|
157
|
+
},
|
158
|
+
success: function(data, status, xhr) {
|
159
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
160
|
+
},
|
161
|
+
complete: function(xhr, status) {
|
162
|
+
element.trigger('ajax:complete', [xhr, status]);
|
163
|
+
},
|
164
|
+
error: function(xhr, status, error) {
|
165
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
166
|
+
},
|
167
|
+
xhrFields: {
|
168
|
+
withCredentials: withCredentials
|
169
|
+
},
|
170
|
+
crossDomain: crossDomain
|
171
|
+
};
|
172
|
+
// Only pass url to `ajax` options if not blank
|
173
|
+
if (url) { options.url = url; }
|
174
|
+
|
175
|
+
var jqxhr = rails.ajax(options);
|
176
|
+
element.trigger('ajax:send', jqxhr);
|
177
|
+
return jqxhr;
|
178
|
+
} else {
|
179
|
+
return false;
|
180
|
+
}
|
181
|
+
},
|
182
|
+
|
183
|
+
// Handles "data-method" on links such as:
|
184
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
185
|
+
handleMethod: function(link) {
|
186
|
+
var href = rails.href(link),
|
187
|
+
method = link.data('method'),
|
188
|
+
target = link.attr('target'),
|
189
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
190
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
191
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
192
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
193
|
+
|
194
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
195
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
196
|
+
}
|
197
|
+
|
198
|
+
if (target) { form.attr('target', target); }
|
199
|
+
|
200
|
+
form.hide().append(metadata_input).appendTo('body');
|
201
|
+
form.submit();
|
202
|
+
},
|
203
|
+
|
204
|
+
/* Disables form elements:
|
205
|
+
- Caches element value in 'ujs:enable-with' data store
|
206
|
+
- Replaces element text with value of 'data-disable-with' attribute
|
207
|
+
- Sets disabled property to true
|
208
|
+
*/
|
209
|
+
disableFormElements: function(form) {
|
210
|
+
form.find(rails.disableSelector).each(function() {
|
211
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
212
|
+
element.data('ujs:enable-with', element[method]());
|
213
|
+
element[method](element.data('disable-with'));
|
214
|
+
element.prop('disabled', true);
|
215
|
+
});
|
216
|
+
},
|
217
|
+
|
218
|
+
/* Re-enables disabled form elements:
|
219
|
+
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
220
|
+
- Sets disabled property to false
|
221
|
+
*/
|
222
|
+
enableFormElements: function(form) {
|
223
|
+
form.find(rails.enableSelector).each(function() {
|
224
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
225
|
+
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
226
|
+
element.prop('disabled', false);
|
227
|
+
});
|
228
|
+
},
|
229
|
+
|
230
|
+
/* For 'data-confirm' attribute:
|
231
|
+
- Fires `confirm` event
|
232
|
+
- Shows the confirmation dialog
|
233
|
+
- Fires the `confirm:complete` event
|
234
|
+
|
235
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
236
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
237
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
238
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
239
|
+
*/
|
240
|
+
allowAction: function(element) {
|
241
|
+
var message = element.data('confirm'),
|
242
|
+
answer = false, callback;
|
243
|
+
if (!message) { return true; }
|
244
|
+
|
245
|
+
if (rails.fire(element, 'confirm')) {
|
246
|
+
answer = rails.confirm(message);
|
247
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
248
|
+
}
|
249
|
+
return answer && callback;
|
250
|
+
},
|
251
|
+
|
252
|
+
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
253
|
+
blankInputs: function(form, specifiedSelector, nonBlank) {
|
254
|
+
var inputs = $(), input, valueToCheck,
|
255
|
+
selector = specifiedSelector || 'input,textarea',
|
256
|
+
allInputs = form.find(selector);
|
257
|
+
|
258
|
+
allInputs.each(function() {
|
259
|
+
input = $(this);
|
260
|
+
valueToCheck = input.is(':checkbox,:radio') ? input.is(':checked') : input.val();
|
261
|
+
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
|
262
|
+
if (!valueToCheck === !nonBlank) {
|
263
|
+
|
264
|
+
// Don't count unchecked required radio if other radio with same name is checked
|
265
|
+
if (input.is(':radio') && allInputs.filter('input:radio:checked[name="' + input.attr('name') + '"]').length) {
|
266
|
+
return true; // Skip to next input
|
267
|
+
}
|
268
|
+
|
269
|
+
inputs = inputs.add(input);
|
270
|
+
}
|
271
|
+
});
|
272
|
+
return inputs.length ? inputs : false;
|
273
|
+
},
|
274
|
+
|
275
|
+
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
276
|
+
nonBlankInputs: function(form, specifiedSelector) {
|
277
|
+
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
278
|
+
},
|
279
|
+
|
280
|
+
// Helper function, needed to provide consistent behavior in IE
|
281
|
+
stopEverything: function(e) {
|
282
|
+
$(e.target).trigger('ujs:everythingStopped');
|
283
|
+
e.stopImmediatePropagation();
|
284
|
+
return false;
|
285
|
+
},
|
286
|
+
|
287
|
+
// find all the submit events directly bound to the form and
|
288
|
+
// manually invoke them. If anyone returns false then stop the loop
|
289
|
+
callFormSubmitBindings: function(form, event) {
|
290
|
+
var events = form.data('events'), continuePropagation = true;
|
291
|
+
if (events !== undefined && events['submit'] !== undefined) {
|
292
|
+
$.each(events['submit'], function(i, obj){
|
293
|
+
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
|
294
|
+
});
|
295
|
+
}
|
296
|
+
return continuePropagation;
|
297
|
+
},
|
298
|
+
|
299
|
+
// replace element's html with the 'data-disable-with' after storing original html
|
300
|
+
// and prevent clicking on it
|
301
|
+
disableElement: function(element) {
|
302
|
+
element.data('ujs:enable-with', element.html()); // store enabled state
|
303
|
+
element.html(element.data('disable-with')); // set to disabled state
|
304
|
+
element.bind('click.railsDisable', function(e) { // prevent further clicking
|
305
|
+
return rails.stopEverything(e);
|
306
|
+
});
|
307
|
+
},
|
308
|
+
|
309
|
+
// restore element to its original state which was disabled by 'disableElement' above
|
310
|
+
enableElement: function(element) {
|
311
|
+
if (element.data('ujs:enable-with') !== undefined) {
|
312
|
+
element.html(element.data('ujs:enable-with')); // set to old enabled state
|
313
|
+
// this should be element.removeData('ujs:enable-with')
|
314
|
+
// but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
|
315
|
+
element.data('ujs:enable-with', false); // clean up cache
|
316
|
+
}
|
317
|
+
element.unbind('click.railsDisable'); // enable element
|
318
|
+
}
|
319
|
+
|
320
|
+
};
|
321
|
+
|
322
|
+
if (rails.fire($(document), 'rails:attachBindings')) {
|
323
|
+
|
324
|
+
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
325
|
+
|
326
|
+
$(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
|
327
|
+
rails.enableElement($(this));
|
328
|
+
});
|
329
|
+
|
330
|
+
$(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
|
331
|
+
var link = $(this), method = link.data('method'), data = link.data('params');
|
332
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
333
|
+
|
334
|
+
if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
|
335
|
+
|
336
|
+
if (link.data('remote') !== undefined) {
|
337
|
+
if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
|
338
|
+
|
339
|
+
var handleRemote = rails.handleRemote(link);
|
340
|
+
// response from rails.handleRemote() will either be false or a deferred object promise.
|
341
|
+
if (handleRemote === false) {
|
342
|
+
rails.enableElement(link);
|
343
|
+
} else {
|
344
|
+
handleRemote.error( function() { rails.enableElement(link); } );
|
345
|
+
}
|
346
|
+
return false;
|
347
|
+
|
348
|
+
} else if (link.data('method')) {
|
349
|
+
rails.handleMethod(link);
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
});
|
353
|
+
|
354
|
+
$(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
|
355
|
+
var link = $(this);
|
356
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
357
|
+
|
358
|
+
rails.handleRemote(link);
|
359
|
+
return false;
|
360
|
+
});
|
361
|
+
|
362
|
+
$(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
|
363
|
+
var form = $(this),
|
364
|
+
remote = form.data('remote') !== undefined,
|
365
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
|
366
|
+
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
367
|
+
|
368
|
+
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
369
|
+
|
370
|
+
// skip other logic when required values are missing or file upload is present
|
371
|
+
if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
372
|
+
return rails.stopEverything(e);
|
373
|
+
}
|
374
|
+
|
375
|
+
if (remote) {
|
376
|
+
if (nonBlankFileInputs) {
|
377
|
+
// slight timeout so that the submit button gets properly serialized
|
378
|
+
// (make it easy for event handler to serialize form without disabled values)
|
379
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
380
|
+
var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
381
|
+
|
382
|
+
// re-enable form elements if event bindings return false (canceling normal form submission)
|
383
|
+
if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
|
384
|
+
|
385
|
+
return aborted;
|
386
|
+
}
|
387
|
+
|
388
|
+
// If browser does not support submit bubbling, then this live-binding will be called before direct
|
389
|
+
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
|
390
|
+
if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
|
391
|
+
|
392
|
+
rails.handleRemote(form);
|
393
|
+
return false;
|
394
|
+
|
395
|
+
} else {
|
396
|
+
// slight timeout so that the submit button gets properly serialized
|
397
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
398
|
+
}
|
399
|
+
});
|
400
|
+
|
401
|
+
$(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
|
402
|
+
var button = $(this);
|
403
|
+
|
404
|
+
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
405
|
+
|
406
|
+
// register the pressed submit button
|
407
|
+
var name = button.attr('name'),
|
408
|
+
data = name ? {name:name, value:button.val()} : null;
|
409
|
+
|
410
|
+
button.closest('form').data('ujs:submit-button', data);
|
411
|
+
});
|
412
|
+
|
413
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
|
414
|
+
if (this == event.target) rails.disableFormElements($(this));
|
415
|
+
});
|
416
|
+
|
417
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
|
418
|
+
if (this == event.target) rails.enableFormElements($(this));
|
419
|
+
});
|
420
|
+
|
421
|
+
$(function(){
|
422
|
+
// making sure that all forms have actual up-to-date token(cached forms contain old one)
|
423
|
+
csrf_token = $('meta[name=csrf-token]').attr('content');
|
424
|
+
csrf_param = $('meta[name=csrf-param]').attr('content');
|
425
|
+
$('form input[name="' + csrf_param + '"]').val(csrf_token);
|
426
|
+
});
|
427
|
+
}
|
428
|
+
|
429
|
+
})( jQuery );
|
metadata
CHANGED
@@ -1,96 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: letter_opener_web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Fabio Rehm
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
prerelease: false
|
16
14
|
name: rails
|
17
|
-
version_requirements: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '3.2'
|
22
|
-
none: false
|
23
15
|
requirement: !ruby/object:Gem::Requirement
|
24
16
|
requirements:
|
25
17
|
- - ~>
|
26
18
|
- !ruby/object:Gem::Version
|
27
19
|
version: '3.2'
|
28
|
-
none: false
|
29
20
|
type: :runtime
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
21
|
prerelease: false
|
32
|
-
name: letter_opener
|
33
22
|
version_requirements: !ruby/object:Gem::Requirement
|
34
23
|
requirements:
|
35
24
|
- - ~>
|
36
25
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
38
|
-
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: letter_opener
|
39
29
|
requirement: !ruby/object:Gem::Requirement
|
40
30
|
requirements:
|
41
31
|
- - ~>
|
42
32
|
- !ruby/object:Gem::Version
|
43
33
|
version: '1.0'
|
44
|
-
none: false
|
45
34
|
type: :runtime
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
35
|
prerelease: false
|
48
|
-
name: rspec-rails
|
49
36
|
version_requirements: !ruby/object:Gem::Requirement
|
50
37
|
requirements:
|
51
38
|
- - ~>
|
52
39
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
54
|
-
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
56
44
|
requirements:
|
57
45
|
- - ~>
|
58
46
|
- !ruby/object:Gem::Version
|
59
47
|
version: '2.0'
|
60
|
-
none: false
|
61
48
|
type: :development
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
49
|
prerelease: false
|
64
|
-
name: shoulda-matchers
|
65
50
|
version_requirements: !ruby/object:Gem::Requirement
|
66
51
|
requirements:
|
67
|
-
- -
|
52
|
+
- - ~>
|
68
53
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: shoulda-matchers
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- -
|
59
|
+
- - '='
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
-
none: false
|
61
|
+
version: 1.5.6
|
77
62
|
type: :development
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
63
|
prerelease: false
|
80
|
-
name: combustion
|
81
64
|
version_requirements: !ruby/object:Gem::Requirement
|
82
65
|
requirements:
|
83
|
-
- -
|
66
|
+
- - '='
|
84
67
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
86
|
-
|
68
|
+
version: 1.5.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: combustion
|
87
71
|
requirement: !ruby/object:Gem::Requirement
|
88
72
|
requirements:
|
89
73
|
- - ~>
|
90
74
|
- !ruby/object:Gem::Version
|
91
75
|
version: 0.3.1
|
92
|
-
none: false
|
93
76
|
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.3.1
|
94
83
|
description: Gives letter_opener an interface for browsing sent emails
|
95
84
|
email:
|
96
85
|
- fgrehm@gmail.com
|
@@ -101,6 +90,7 @@ files:
|
|
101
90
|
- .gitignore
|
102
91
|
- .rspec
|
103
92
|
- .travis.yml
|
93
|
+
- CHANGELOG.md
|
104
94
|
- Gemfile
|
105
95
|
- Guardfile
|
106
96
|
- LICENSE.txt
|
@@ -141,36 +131,30 @@ files:
|
|
141
131
|
- vendor/assets/images/glyphicons-halflings.png
|
142
132
|
- vendor/assets/javascripts/bootstrap.min.js
|
143
133
|
- vendor/assets/javascripts/jquery-1.8.3.min.js
|
134
|
+
- vendor/assets/javascripts/jquery_ujs.js
|
144
135
|
- vendor/assets/stylesheets/bootstrap.min.css
|
145
136
|
homepage: https://github.com/fgrehm/letter_opener_web
|
146
137
|
licenses: []
|
138
|
+
metadata: {}
|
147
139
|
post_install_message:
|
148
140
|
rdoc_options: []
|
149
141
|
require_paths:
|
150
142
|
- lib
|
151
143
|
required_ruby_version: !ruby/object:Gem::Requirement
|
152
144
|
requirements:
|
153
|
-
- -
|
145
|
+
- - '>='
|
154
146
|
- !ruby/object:Gem::Version
|
155
147
|
version: '0'
|
156
|
-
segments:
|
157
|
-
- 0
|
158
|
-
hash: -2596290624536593694
|
159
|
-
none: false
|
160
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
149
|
requirements:
|
162
|
-
- -
|
150
|
+
- - '>='
|
163
151
|
- !ruby/object:Gem::Version
|
164
152
|
version: '0'
|
165
|
-
segments:
|
166
|
-
- 0
|
167
|
-
hash: -2596290624536593694
|
168
|
-
none: false
|
169
153
|
requirements: []
|
170
154
|
rubyforge_project:
|
171
|
-
rubygems_version:
|
155
|
+
rubygems_version: 2.0.0
|
172
156
|
signing_key:
|
173
|
-
specification_version:
|
157
|
+
specification_version: 4
|
174
158
|
summary: Gives letter_opener an interface for browsing sent emails
|
175
159
|
test_files:
|
176
160
|
- spec/controllers/letter_opener_web/letters_controller_spec.rb
|