|
|
@ -33,12 +33,17 @@ Released under the MIT license
|
|
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
(function() {
|
|
|
|
(function() {
|
|
|
|
(function() {
|
|
|
|
var cspNonce;
|
|
|
|
var nonce;
|
|
|
|
|
|
|
|
|
|
|
|
cspNonce = Rails.cspNonce = function() {
|
|
|
|
nonce = null;
|
|
|
|
var meta;
|
|
|
|
|
|
|
|
meta = document.querySelector('meta[name=csp-nonce]');
|
|
|
|
Rails.loadCSPNonce = function() {
|
|
|
|
return meta && meta.content;
|
|
|
|
var ref;
|
|
|
|
|
|
|
|
return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rails.cspNonce = function() {
|
|
|
|
|
|
|
|
return nonce != null ? nonce : Rails.loadCSPNonce();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}).call(this);
|
|
|
|
}).call(this);
|
|
|
@ -617,24 +622,29 @@ Released under the MIT license
|
|
|
|
return setData(form, 'ujs:submit-button-formmethod', button.getAttribute('formmethod'));
|
|
|
|
return setData(form, 'ujs:submit-button-formmethod', button.getAttribute('formmethod'));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Rails.handleMetaClick = function(e) {
|
|
|
|
Rails.preventInsignificantClick = function(e) {
|
|
|
|
var data, link, metaClick, method;
|
|
|
|
var data, insignificantMetaClick, link, metaClick, method, primaryMouseKey;
|
|
|
|
link = this;
|
|
|
|
link = this;
|
|
|
|
method = (link.getAttribute('data-method') || 'GET').toUpperCase();
|
|
|
|
method = (link.getAttribute('data-method') || 'GET').toUpperCase();
|
|
|
|
data = link.getAttribute('data-params');
|
|
|
|
data = link.getAttribute('data-params');
|
|
|
|
metaClick = e.metaKey || e.ctrlKey;
|
|
|
|
metaClick = e.metaKey || e.ctrlKey;
|
|
|
|
if (metaClick && method === 'GET' && !data) {
|
|
|
|
insignificantMetaClick = metaClick && method === 'GET' && !data;
|
|
|
|
|
|
|
|
primaryMouseKey = e.button === 0;
|
|
|
|
|
|
|
|
if (!primaryMouseKey || insignificantMetaClick) {
|
|
|
|
return e.stopImmediatePropagation();
|
|
|
|
return e.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}).call(this);
|
|
|
|
}).call(this);
|
|
|
|
(function() {
|
|
|
|
(function() {
|
|
|
|
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMetaClick, handleMethod, handleRemote, refreshCSRFTokens;
|
|
|
|
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, loadCSPNonce = Rails.loadCSPNonce, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, preventInsignificantClick = Rails.preventInsignificantClick, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMethod = Rails.handleMethod;
|
|
|
|
|
|
|
|
|
|
|
|
if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null) && !jQuery.rails) {
|
|
|
|
if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null)) {
|
|
|
|
|
|
|
|
if (jQuery.rails) {
|
|
|
|
|
|
|
|
throw new Error('If you load both jquery_ujs and rails-ujs, use rails-ujs only.');
|
|
|
|
|
|
|
|
}
|
|
|
|
jQuery.rails = Rails;
|
|
|
|
jQuery.rails = Rails;
|
|
|
|
jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
|
|
|
|
jQuery.ajaxPrefilter(function(options, originalOptions, xhr) {
|
|
|
|
if (!options.crossDomain) {
|
|
|
|
if (!options.crossDomain) {
|
|
|
@ -663,12 +673,13 @@ Released under the MIT license
|
|
|
|
delegate(document, Rails.linkDisableSelector, 'ajax:stopped', enableElement);
|
|
|
|
delegate(document, Rails.linkDisableSelector, 'ajax:stopped', enableElement);
|
|
|
|
delegate(document, Rails.buttonDisableSelector, 'ajax:complete', enableElement);
|
|
|
|
delegate(document, Rails.buttonDisableSelector, 'ajax:complete', enableElement);
|
|
|
|
delegate(document, Rails.buttonDisableSelector, 'ajax:stopped', enableElement);
|
|
|
|
delegate(document, Rails.buttonDisableSelector, 'ajax:stopped', enableElement);
|
|
|
|
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', preventInsignificantClick);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleDisabledElement);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleDisabledElement);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleConfirm);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleConfirm);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleMetaClick);
|
|
|
|
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', disableElement);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', disableElement);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleRemote);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleRemote);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleMethod);
|
|
|
|
delegate(document, Rails.linkClickSelector, 'click', handleMethod);
|
|
|
|
|
|
|
|
delegate(document, Rails.buttonClickSelector, 'click', preventInsignificantClick);
|
|
|
|
delegate(document, Rails.buttonClickSelector, 'click', handleDisabledElement);
|
|
|
|
delegate(document, Rails.buttonClickSelector, 'click', handleDisabledElement);
|
|
|
|
delegate(document, Rails.buttonClickSelector, 'click', handleConfirm);
|
|
|
|
delegate(document, Rails.buttonClickSelector, 'click', handleConfirm);
|
|
|
|
delegate(document, Rails.buttonClickSelector, 'click', disableElement);
|
|
|
|
delegate(document, Rails.buttonClickSelector, 'click', disableElement);
|
|
|
@ -686,10 +697,12 @@ Released under the MIT license
|
|
|
|
});
|
|
|
|
});
|
|
|
|
delegate(document, Rails.formSubmitSelector, 'ajax:send', disableElement);
|
|
|
|
delegate(document, Rails.formSubmitSelector, 'ajax:send', disableElement);
|
|
|
|
delegate(document, Rails.formSubmitSelector, 'ajax:complete', enableElement);
|
|
|
|
delegate(document, Rails.formSubmitSelector, 'ajax:complete', enableElement);
|
|
|
|
|
|
|
|
delegate(document, Rails.formInputClickSelector, 'click', preventInsignificantClick);
|
|
|
|
delegate(document, Rails.formInputClickSelector, 'click', handleDisabledElement);
|
|
|
|
delegate(document, Rails.formInputClickSelector, 'click', handleDisabledElement);
|
|
|
|
delegate(document, Rails.formInputClickSelector, 'click', handleConfirm);
|
|
|
|
delegate(document, Rails.formInputClickSelector, 'click', handleConfirm);
|
|
|
|
delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick);
|
|
|
|
delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick);
|
|
|
|
document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
|
|
|
|
document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', loadCSPNonce);
|
|
|
|
return window._rails_loaded = true;
|
|
|
|
return window._rails_loaded = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|