Merge branch 'jquery-1.10'

This commit is contained in:
r888888888
2013-06-18 18:38:28 -07:00
14 changed files with 469 additions and 311 deletions

View File

@@ -1,10 +1,8 @@
//= require jquery-1.7.1.min.js //= require jquery-1.10.1.min.js
//= require jquery-ui-1.8.12.custom.min.js //= require jquery-ui-1.10.3.min.js
//= require jquery.hotkeys.js //= require jquery.hotkeys.js
//= require jquery.timeout.js //= require jquery.timeout.js
//= require typeahead.min.js
//= require rails.js //= require rails.js
//= require common.js //= require common.js
//= require_self //= require_self
//= require_tree . //= require_tree .

View File

@@ -6,19 +6,30 @@
Danbooru.Artist.initialize_check_name_link(); Danbooru.Artist.initialize_check_name_link();
if (Danbooru.meta("enable-auto-complete") === "true") { if (Danbooru.meta("enable-auto-complete") === "true") {
Danbooru.Artist.initialize_typeahead(); Danbooru.Artist.initialize_auto_complete();
} }
} }
} }
Danbooru.Artist.initialize_typeahead = function() { Danbooru.Artist.initialize_auto_complete = function() {
$("#quick_search_name").typeahead({ $("#quick_search_name").autocomplete({
name: "artists", source: function(req, resp) {
remote: "/artists.json?search[name]=*%QUERY*", $.ajax({
limit: 10, url: "/artists.json",
valueKey: "name", data: {
template: function(context) { "search[name]": "*" + req.term + "*"
return "<p>" + context.name.replace(/_/g, " ") + "</p>"; },
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.name,
value: tag.name
};
}));
}
});
} }
}); });
} }

View File

@@ -14,13 +14,25 @@
Danbooru.Pool.initialize_add_to_pool_link = function() { Danbooru.Pool.initialize_add_to_pool_link = function() {
$("#add-to-pool-dialog").dialog({autoOpen: false}); $("#add-to-pool-dialog").dialog({autoOpen: false});
$("#c-pool-elements #a-new input[type=text]").typeahead({ $("#c-pool-elements #a-new input[type=text]").autocomplete({
name: "pools", source: function(req, resp) {
remote: "/pools.json?search[is_active]=true&search[name_matches]=%QUERY", $.ajax({
limit: 10, url: "/pools.json",
valueKey: "name", data: {
template: function(context) { "search[is_active]": "true"
return "<p>" + context.name.replace(/_/g, " ") + "</p>"; "search[name_matches]": req.term
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.name.replace(/_/g, " "),
value: tag.name
};
}));
}
});
} }
}); });

View File

@@ -6,7 +6,7 @@
Danbooru.Post.initialize_all = function() { Danbooru.Post.initialize_all = function() {
this.initialize_post_previews(); this.initialize_post_previews();
if (Danbooru.meta("enable-tag-autocomplete") === "true") { if (Danbooru.meta("enable-auto-complete") === "true") {
this.initialize_tag_autocomplete(); this.initialize_tag_autocomplete();
} }
@@ -36,13 +36,36 @@
} }
Danbooru.Post.initialize_tag_autocomplete = function() { Danbooru.Post.initialize_tag_autocomplete = function() {
$("#tags").typeahead({ $("#tags,#post_tag_string,#upload_tag_string").autocomplete({
name: "tags", focus: function() {
remote: "/tags.json?search[order]=count&search[name_matches]=%QUERY*", return false;
limit: 10, },
valueKey: "name", select: function(event, ui) {
template: function(context) { var terms = this.value.match(/\S+/g);
return "<p class=\"category-" + context.category + "\"><a>" + context.name + "</a></p>"; terms.pop();
terms.push(ui.item.value);
this.value = terms.join(" ") + " ";
return false;
},
source: function(req, resp) {
var term = req.term.match(/\S+/g).pop();
$.ajax({
url: "/tags.json",
data: {
"search[order]": "count",
"search[name_matches]": term + "*"
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.name,
value: tag.name
};
}));
}
});
} }
}); });
} }

View File

@@ -3,17 +3,32 @@
Danbooru.WikiPage.initialize_all = function() { Danbooru.WikiPage.initialize_all = function() {
if ($("#c-wiki-pages").length) { if ($("#c-wiki-pages").length) {
if (Danbooru.meta("enable-tag-autocomplete") === "true") { this.initialize_typeahead();
$("#quick_search_title,#wiki_page_title").typeahead({ }
name: "wiki_pages", }
remote: "/wiki_pages.json?search[title]=*%QUERY*",
limit: 10, Danbooru.WikiPage.initialize_typeahead = function() {
valueKey: "title", if (Danbooru.meta("enable-auto-complete") === "true") {
template: function(context) { $("#quick_search_title,#wiki_page_title").autocomplete({
return "<p>" + context.title.replace(/_/g, " ") + "</p>"; source: function(req, resp) {
$.ajax({
url: "/wiki_pages.json",
data: {
"search[title]": "*" + req.term + "*"
},
method: "get",
minLength: 2,
success: function(data) {
resp($.map(data, function(tag) {
return {
label: tag.title.replace(/_/g, " "),
value: tag.title
};
}));
} }
}); });
} }
});
} }
} }
})(); })();

View File

@@ -1,5 +1,5 @@
/* /*
*= require "smoothness/jquery-ui-1.8.5.custom.css" *= require "smoothness/jquery-ui-1.10.3.min.css"
*= require_self *= require_self
*= require_tree "./common" *= require_tree "./common"
*= require_tree "./specific" *= require_tree "./specific"

View File

@@ -50,27 +50,6 @@ a.blacklisted-active {
background-color: rgba(0,0,0,0.1); background-color: rgba(0,0,0,0.1);
} }
.tt-suggestions {
background: white;
display: block;
border: 1px solid black;
margin: 0;
padding: 0;
}
.tt-suggestion {
background: white;
padding: 0.25em 0.5em;
}
.tt-is-under-cursor {
background: $highlight_color;
}
.tt-suggestion p {
margin: 0;
}
#has-parent-relationship-preview, #has-children-relationship-preview { #has-parent-relationship-preview, #has-children-relationship-preview {
overflow-x: auto; overflow-x: auto;
white-space: nowrap; white-space: nowrap;
@@ -84,6 +63,14 @@ a.blacklisted-active {
} }
} }
.category-0 a, a.tag-type-0 {
color: $link_color;
&:hover {
color: $link_hover_color;
}
}
.category-1 a, a.tag-type-1 { .category-1 a, a.tag-type-1 {
color: #A00; color: #A00;

View File

@@ -1,4 +1,4 @@
<%= simple_form_for(comment) do |f| %> <%= simple_form_for(comment, :html => {:class => "edit_comment"}) do |f| %>
<%= dtext_field "comment", "body", :value => comment.body, :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %> <%= dtext_field "comment", "body", :value => comment.body, :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %>
<%= f.button :submit, "Submit" %> <%= f.button :submit, "Submit" %>
<%= dtext_preview_button "comment", "body", :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %> <%= dtext_preview_button "comment", "body", :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 208 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,57 +1,33 @@
(function($, undefined) {
/** /**
* Unobtrusive scripting adapter for jQuery * Unobtrusive scripting adapter for jQuery
*
* Requires jQuery 1.4.3 or later.
* https://github.com/rails/jquery-ujs * https://github.com/rails/jquery-ujs
* Uploading file using rails.js
* =============================
* *
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields * Requires jQuery 1.7.0 or later.
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
* *
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish. * Released under the MIT license
* *
* Ex:
* $('form').live('ajax:aborted:file', function(event, elements){
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
* // Returning false in this handler tells rails.js to disallow standard form submission
* return false;
* });
*
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
*
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
* techniques like the iframe method to upload the file instead.
*
* Required fields in rails.js
* ===========================
*
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
*
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
*
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
*
* Ex:
* $('form').live('ajax:aborted:required', function(event, elements){
* // Returning false in this handler tells rails.js to submit the form anyway.
* // The blank required inputs are passed to this function in `elements`.
* return ! confirm("Would you like to submit the form with missing info?");
* });
*/ */
(function($) { // Cut down on the number of issues from people inadvertently including jquery_ujs twice
// by detecting and raising an error when it happens.
if ( $.rails !== undefined ) {
$.error('jquery-ujs has already been loaded!');
}
// Shorthand to make it a little easier to call public rails functions from within rails.js // Shorthand to make it a little easier to call public rails functions from within rails.js
var rails; var rails;
$.rails = rails = { $.rails = rails = {
// Link elements bound by jquery-ujs // Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]', linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
// Button elements boud jquery-ujs
buttonClickSelector: 'button[data-remote]',
// Select elements bound by jquery-ujs
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
// Form elements bound by jquery-ujs // Form elements bound by jquery-ujs
formSubmitSelector: 'form', formSubmitSelector: 'form',
@@ -66,10 +42,13 @@
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled', enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
// Form required input elements // Form required input elements
requiredInputSelector: 'input[name][required],textarea[name][required]', requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
// Form file input elements // Form file input elements
fileInputSelector: 'input:file', fileInputSelector: 'input[type=file]',
// Link onClick disable selector with possible reenable after remote submission
linkDisableSelector: 'a[data-disable-with]',
// Make sure that every Ajax request sends the CSRF token // Make sure that every Ajax request sends the CSRF token
CSRFProtection: function(xhr) { CSRFProtection: function(xhr) {
@@ -84,12 +63,30 @@
return event.result !== false; return event.result !== false;
}, },
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
confirm: function(message) {
return confirm(message);
},
// Default ajax function, may be overridden with custom function in $.rails.ajax
ajax: function(options) {
return $.ajax(options);
},
// Default way to get an element's href. May be overridden at $.rails.href.
href: function(element) {
return element.attr('href');
},
// Submits "remote" forms and links with ajax // Submits "remote" forms and links with ajax
handleRemote: function(element) { handleRemote: function(element) {
var method, url, data, var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options;
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
if (rails.fire(element, 'ajax:before')) { if (rails.fire(element, 'ajax:before')) {
elCrossDomain = element.data('cross-domain');
crossDomain = elCrossDomain === undefined ? null : elCrossDomain;
withCredentials = element.data('with-credentials') || null;
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
if (element.is('form')) { if (element.is('form')) {
method = element.attr('method'); method = element.attr('method');
@@ -101,14 +98,24 @@
data.push(button); data.push(button);
element.data('ujs:submit-button', null); element.data('ujs:submit-button', null);
} }
} else if (element.is(rails.inputChangeSelector)) {
method = element.data('method');
url = element.data('url');
data = element.serialize();
if (element.data('params')) data = data + "&" + element.data('params');
} else if (element.is(rails.buttonClickSelector)) {
method = element.data('method') || 'get';
url = element.data('url');
data = element.serialize();
if (element.data('params')) data = data + "&" + element.data('params');
} else { } else {
method = element.data('method'); method = element.data('method');
url = element.attr('href'); url = rails.href(element);
data = null; data = element.data('params') || null;
} }
$.ajax({ options = {
url: url, type: method || 'GET', data: data, dataType: dataType, type: method || 'GET', data: data, dataType: dataType,
// stopping the "ajax:beforeSend" event will cancel the ajax request // stopping the "ajax:beforeSend" event will cancel the ajax request
beforeSend: function(xhr, settings) { beforeSend: function(xhr, settings) {
if (settings.dataType === undefined) { if (settings.dataType === undefined) {
@@ -124,16 +131,35 @@
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
element.trigger('ajax:error', [xhr, status, error]); element.trigger('ajax:error', [xhr, status, error]);
},
crossDomain: crossDomain
};
// There is no withCredentials for IE6-8 when
// "Enable native XMLHTTP support" is disabled
if (withCredentials) {
options.xhrFields = {
withCredentials: withCredentials
};
} }
});
// Only pass url to `ajax` options if not blank
if (url) { options.url = url; }
var jqxhr = rails.ajax(options);
element.trigger('ajax:send', jqxhr);
return jqxhr;
} else {
return false;
} }
}, },
// Handles "data-method" on links such as: // Handles "data-method" on links such as:
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a> // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
handleMethod: function(link) { handleMethod: function(link) {
var href = link.attr('href'), var href = rails.href(link),
method = link.data('method'), method = link.data('method'),
target = link.attr('target'),
csrf_token = $('meta[name=csrf-token]').attr('content'), csrf_token = $('meta[name=csrf-token]').attr('content'),
csrf_param = $('meta[name=csrf-param]').attr('content'), csrf_param = $('meta[name=csrf-param]').attr('content'),
form = $('<form method="post" action="' + href + '"></form>'), form = $('<form method="post" action="' + href + '"></form>'),
@@ -143,6 +169,8 @@
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />'; metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
} }
if (target) { form.attr('target', target); }
form.hide().append(metadata_input).appendTo('body'); form.hide().append(metadata_input).appendTo('body');
form.submit(); form.submit();
}, },
@@ -150,44 +178,68 @@
/* Disables form elements: /* Disables form elements:
- Caches element value in 'ujs:enable-with' data store - Caches element value in 'ujs:enable-with' data store
- Replaces element text with value of 'data-disable-with' attribute - Replaces element text with value of 'data-disable-with' attribute
- Adds disabled=disabled attribute - Sets disabled property to true
*/ */
disableFormElements: function(form) { disableFormElements: function(form) {
form.find(rails.disableSelector).each(function() { form.find(rails.disableSelector).each(function() {
var element = $(this), method = element.is('button') ? 'html' : 'val'; var element = $(this), method = element.is('button') ? 'html' : 'val';
element.data('ujs:enable-with', element[method]()); element.data('ujs:enable-with', element[method]());
element[method](element.data('disable-with')); element[method](element.data('disable-with'));
element.attr('disabled', 'disabled'); element.prop('disabled', true);
}); });
}, },
/* Re-enables disabled form elements: /* Re-enables disabled form elements:
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`) - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
- Removes disabled attribute - Sets disabled property to false
*/ */
enableFormElements: function(form) { enableFormElements: function(form) {
form.find(rails.enableSelector).each(function() { form.find(rails.enableSelector).each(function() {
var element = $(this), method = element.is('button') ? 'html' : 'val'; var element = $(this), method = element.is('button') ? 'html' : 'val';
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with')); if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
element.removeAttr('disabled'); element.prop('disabled', false);
}); });
}, },
// If message provided in 'data-confirm' attribute, fires `confirm` event and returns result of confirm dialog. /* For 'data-confirm' attribute:
// Attaching a handler to the element's `confirm` event that returns false cancels the confirm dialog. - Fires `confirm` event
- Shows the confirmation dialog
- Fires the `confirm:complete` event
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
*/
allowAction: function(element) { allowAction: function(element) {
var message = element.data('confirm'); var message = element.data('confirm'),
return !message || (rails.fire(element, 'confirm') && confirm(message)); answer = false, callback;
if (!message) { return true; }
if (rails.fire(element, 'confirm')) {
answer = rails.confirm(message);
callback = rails.fire(element, 'confirm:complete', [answer]);
}
return answer && callback;
}, },
// Helper function which checks for blank inputs in a form that match the specified CSS selector // Helper function which checks for blank inputs in a form that match the specified CSS selector
blankInputs: function(form, specifiedSelector, nonBlank) { blankInputs: function(form, specifiedSelector, nonBlank) {
var inputs = $(), input, var inputs = $(), input, valueToCheck,
selector = specifiedSelector || 'input,textarea'; selector = specifiedSelector || 'input,textarea',
form.find(selector).each(function() { allInputs = form.find(selector);
allInputs.each(function() {
input = $(this); input = $(this);
// Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : input.val();
if (nonBlank ? input.val() : !input.val()) { // If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
if (!valueToCheck === !nonBlank) {
// Don't count unchecked required radio if other radio with same name is checked
if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
return true; // Skip to next input
}
inputs = inputs.add(input); inputs = inputs.add(input);
} }
}); });
@@ -201,44 +253,81 @@
// Helper function, needed to provide consistent behavior in IE // Helper function, needed to provide consistent behavior in IE
stopEverything: function(e) { stopEverything: function(e) {
$(e.target).trigger('ujs:everythingStopped');
e.stopImmediatePropagation(); e.stopImmediatePropagation();
return false; return false;
}, },
// find all the submit events directly bound to the form and // replace element's html with the 'data-disable-with' after storing original html
// manually invoke them. If anyone returns false then stop the loop // and prevent clicking on it
callFormSubmitBindings: function(form) { disableElement: function(element) {
var events = form.data('events'), continuePropagation = true; element.data('ujs:enable-with', element.html()); // store enabled state
if (events !== undefined && events['submit'] !== undefined) { element.html(element.data('disable-with')); // set to disabled state
$.each(events['submit'], function(i, obj){ element.bind('click.railsDisable', function(e) { // prevent further clicking
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data); return rails.stopEverything(e);
}); });
},
// restore element to its original state which was disabled by 'disableElement' above
enableElement: function(element) {
if (element.data('ujs:enable-with') !== undefined) {
element.html(element.data('ujs:enable-with')); // set to old enabled state
element.removeData('ujs:enable-with'); // clean up cache
} }
return continuePropagation; element.unbind('click.railsDisable'); // enable element
} }
}; };
// ajaxPrefilter is a jQuery 1.5 feature if (rails.fire($(document), 'rails:attachBindings')) {
if ('ajaxPrefilter' in $) {
$.ajaxPrefilter(function(options, originalOptions, xhr){ rails.CSRFProtection(xhr); });
} else {
$(document).ajaxSend(function(e, xhr){ rails.CSRFProtection(xhr); });
}
$(rails.linkClickSelector).live('click.rails', function(e) { $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
var link = $(this);
$(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
rails.enableElement($(this));
});
$(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
var link = $(this), method = link.data('method'), data = link.data('params');
if (!rails.allowAction(link)) return rails.stopEverything(e); if (!rails.allowAction(link)) return rails.stopEverything(e);
if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
if (link.data('remote') !== undefined) { if (link.data('remote') !== undefined) {
rails.handleRemote(link); if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
var handleRemote = rails.handleRemote(link);
// response from rails.handleRemote() will either be false or a deferred object promise.
if (handleRemote === false) {
rails.enableElement(link);
} else {
handleRemote.error( function() { rails.enableElement(link); } );
}
return false; return false;
} else if (link.data('method')) { } else if (link.data('method')) {
rails.handleMethod(link); rails.handleMethod(link);
return false; return false;
} }
}); });
$(rails.formSubmitSelector).live('submit.rails', function(e) { $(document).delegate(rails.buttonClickSelector, 'click.rails', function(e) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(e);
rails.handleRemote(button);
return false;
});
$(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
var link = $(this);
if (!rails.allowAction(link)) return rails.stopEverything(e);
rails.handleRemote(link);
return false;
});
$(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
var form = $(this), var form = $(this),
remote = form.data('remote') !== undefined, remote = form.data('remote') !== undefined,
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector), blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
@@ -247,28 +336,33 @@
if (!rails.allowAction(form)) return rails.stopEverything(e); if (!rails.allowAction(form)) return rails.stopEverything(e);
// skip other logic when required values are missing or file upload is present // skip other logic when required values are missing or file upload is present
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) { if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
return !remote; return rails.stopEverything(e);
} }
if (remote) { if (remote) {
if (nonBlankFileInputs) { if (nonBlankFileInputs) {
return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]); // slight timeout so that the submit button gets properly serialized
} // (make it easy for event handler to serialize form without disabled values)
setTimeout(function(){ rails.disableFormElements(form); }, 13);
var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
// If browser does not support submit bubbling, then this live-binding will be called before direct // re-enable form elements if event bindings return false (canceling normal form submission)
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form. if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
return aborted;
}
rails.handleRemote(form); rails.handleRemote(form);
return false; return false;
} else { } else {
// slight timeout so that the submit button gets properly serialized // slight timeout so that the submit button gets properly serialized
setTimeout(function(){ rails.disableFormElements(form); }, 13); setTimeout(function(){ rails.disableFormElements(form); }, 13);
} }
}); });
$(rails.formInputClickSelector).live('click.rails', function(event) { $(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
var button = $(this); var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(event); if (!rails.allowAction(button)) return rails.stopEverything(event);
@@ -280,12 +374,20 @@
button.closest('form').data('ujs:submit-button', data); button.closest('form').data('ujs:submit-button', data);
}); });
$(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) { $(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
if (this == event.target) rails.disableFormElements($(this)); if (this == event.target) rails.disableFormElements($(this));
}); });
$(rails.formSubmitSelector).live('ajax:complete.rails', function(event) { $(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
if (this == event.target) rails.enableFormElements($(this)); if (this == event.target) rails.enableFormElements($(this));
}); });
$(function(){
// making sure that all forms have actual up-to-date token(cached forms contain old one)
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
$('form input[name="' + csrf_param + '"]').val(csrf_token);
});
}
})( jQuery ); })( jQuery );

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long