@htmlguyllc/jpack
Advanced tools
Comparing version 0.5.12 to 0.5.13
{ | ||
"name": "@htmlguyllc/jpack", | ||
"version": "0.5.12", | ||
"version": "0.5.13", | ||
"description": "Core Javascript Library of Everyday Objects, Events, and Utilities", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -152,46 +152,2 @@ import axios from 'axios'; | ||
/** | ||
* Allows you to insert the form wherever you want on the page | ||
* Override this method to customize where the form is inserted | ||
* (maybe you want to open a modal first and place it there?) | ||
* | ||
* parsed_content.html will always be the HTML | ||
* | ||
* parsed_content may contain other data like route and title if the form was pulled out of | ||
* a full HTML page which contains those items | ||
* | ||
* response is the full server response (html string or object from JSON - not provided if the response is only the form's HTML) | ||
* | ||
* form is provided if this is after the form was submitted and HTML was returned form the server | ||
* | ||
* @param parsed_content | ||
* @param response | ||
* @param form | ||
* @returns {*|Element|HTMLDocument} | ||
*/ | ||
this.insertForm = function(parsed_content, response, form) { | ||
//selector for where the form will go | ||
let el = this.getInsertIntoElement(); | ||
//if not provided | ||
if( el === null ) throw 'Cannot determine where to insert form. Overwrite insertForm() or provide insertIntoElement'; | ||
//get the container element - error if not found | ||
el = dom.getElement(el, true); | ||
//put the form in the container element | ||
el.innerHTML = parsed_content.html; | ||
//find the newly added form | ||
form = el.querySelector('form'); | ||
//attach an on-submit listener to send the form's values via XHR | ||
this.attachSubmitHandler(form); | ||
//run the onload callback now that the form is there | ||
this.triggerOnload()(); | ||
return el; | ||
}; | ||
/** | ||
* Use this method to modify the form immediately after it's displayed | ||
@@ -462,2 +418,47 @@ * | ||
} | ||
}; | ||
/** | ||
* Allows you to insert the form wherever you want on the page | ||
* Override this method to customize where the form is inserted | ||
* (maybe you want to open a modal first and place it there?) | ||
* | ||
* parsed_content.html will always be the HTML | ||
* | ||
* parsed_content may contain other data like route and title if the form was pulled out of | ||
* a full HTML page which contains those items | ||
* | ||
* response is the full server response (html string or object from JSON - not provided if the response is only the form's HTML) | ||
* | ||
* form is provided if this is after the form was submitted and HTML was returned form the server | ||
* | ||
* @param parsed_content | ||
* @param response | ||
* @param form | ||
* @returns {*|Element|HTMLDocument} | ||
*/ | ||
form.fromURL.prototype.insertForm = function(parsed_content, response, form) { | ||
//selector for where the form will go | ||
let el = this.getInsertIntoElement(); | ||
//if not provided | ||
if( el === null ) throw 'Cannot determine where to insert form. Overwrite insertForm() or provide insertIntoElement'; | ||
//get the container element - error if not found | ||
el = dom.getElement(el, true); | ||
//put the form in the container element | ||
el.innerHTML = parsed_content.html; | ||
//find the newly added form | ||
form = el.querySelector('form'); | ||
//attach an on-submit listener to send the form's values via XHR | ||
this.attachSubmitHandler(form); | ||
//run the onload callback now that the form is there | ||
this.triggerOnload()(); | ||
return el; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
413953