Fix linting errors
This commit is contained in:
committed by
BehindTheMath
parent
e586440964
commit
c0d64e41b8
@@ -5,16 +5,15 @@ var clone = require("../clone")
|
||||
|
||||
var attrClick = "data-pjax-click-state"
|
||||
|
||||
var formAction = function(el, event){
|
||||
|
||||
var formAction = function(el, event) {
|
||||
this.options.requestOptions = {
|
||||
requestUrl : el.getAttribute('action') || window.location.href,
|
||||
requestMethod : el.getAttribute('method') || 'GET',
|
||||
requestUrl: el.getAttribute("action") || window.location.href,
|
||||
requestMethod: el.getAttribute("method") || "GET",
|
||||
}
|
||||
|
||||
//create a testable virtual link of the form action
|
||||
var virtLinkElement = document.createElement('a');
|
||||
virtLinkElement.setAttribute('href', this.options.requestOptions.requestUrl);
|
||||
// create a testable virtual link of the form action
|
||||
var virtLinkElement = document.createElement("a");
|
||||
virtLinkElement.setAttribute("href", this.options.requestOptions.requestUrl);
|
||||
|
||||
// Ignore external links.
|
||||
if (virtLinkElement.protocol !== window.location.protocol || virtLinkElement.host !== window.location.host) {
|
||||
@@ -35,7 +34,7 @@ var formAction = function(el, event){
|
||||
}
|
||||
|
||||
// if declared as a full reload, just normally submit the form
|
||||
if ( this.options.currentUrlFullReload) {
|
||||
if (this.options.currentUrlFullReload) {
|
||||
el.setAttribute(attrClick, "reload");
|
||||
return;
|
||||
}
|
||||
@@ -43,17 +42,19 @@ var formAction = function(el, event){
|
||||
event.preventDefault()
|
||||
|
||||
var paramObject = [];
|
||||
for(var elementKey in el.elements) {
|
||||
for (var elementKey in el.elements) {
|
||||
var element = el.elements[elementKey];
|
||||
if (!!element.name && element.attributes !== undefined && element.tagName.toLowerCase() !== 'button'){
|
||||
if ((element.attributes.type !== 'checkbox' && element.attributes.type !== 'radio') || element.checked) {
|
||||
paramObject.push({ name: encodeURIComponent(element.name), value: encodeURIComponent(element.value)});
|
||||
// jscs:disable disallowImplicitTypeConversion
|
||||
if (!!element.name && element.attributes !== undefined && element.tagName.toLowerCase() !== "button") {
|
||||
// jscs:enable disallowImplicitTypeConversion
|
||||
if ((element.attributes.type !== "checkbox" && element.attributes.type !== "radio") || element.checked) {
|
||||
paramObject.push({name: encodeURIComponent(element.name), value: encodeURIComponent(element.value)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Creating a getString
|
||||
var paramsString = (paramObject.map(function(value){return value.name+"="+value.value;})).join('&');
|
||||
// Creating a getString
|
||||
var paramsString = (paramObject.map(function(value) {return value.name + "=" + value.value;})).join("&");
|
||||
|
||||
this.options.requestOptions.requestPayload = paramObject;
|
||||
this.options.requestOptions.requestPayloadString = paramsString;
|
||||
@@ -63,7 +64,6 @@ var formAction = function(el, event){
|
||||
const options = clone(this.options);
|
||||
options.triggerElement = el;
|
||||
this.loadUrl(virtLinkElement.href, options);
|
||||
|
||||
};
|
||||
|
||||
var isDefaultPrevented = function(event) {
|
||||
|
||||
Reference in New Issue
Block a user