diff --git a/package-lock.json b/package-lock.json index 9f11b8f..37a78f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hellojs", - "version": "1.19.5", + "version": "1.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hellojs", - "version": "1.19.5", + "version": "1.20.0", "license": "MIT", "devDependencies": { "@semantic-release/changelog": "^6.0.2", @@ -9583,8 +9583,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz", "integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==", - "dev": true, - "requires": {} + "dev": true }, "@octokit/plugin-rest-endpoint-methods": { "version": "7.0.1", @@ -9949,8 +9948,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} + "dev": true }, "agent-base": { "version": "6.0.2", @@ -16073,8 +16071,7 @@ "version": "8.5.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", - "dev": true, - "requires": {} + "dev": true }, "xtend": { "version": "4.0.2", diff --git a/src/hello.js b/src/hello.js index a310208..800ba14 100644 --- a/src/hello.js +++ b/src/hello.js @@ -2405,9 +2405,6 @@ hello.utils.extend(hello.utils, { } } else { - // Its not a form element, - // Therefore it must be a JSON object of Key=>Value or Key=>Element - // If anyone of those values are a input type=file we shall shall insert its siblings into the form for which it belongs. for (x in data) if (data.hasOwnProperty(x)) { // Is this an input Element? if (_this.domInstance('input', data[x]) && data[x].type === 'file') { @@ -2416,7 +2413,6 @@ hello.utils.extend(hello.utils, { } } - // Do If there is no defined form element, lets create one. if (!form) { // Build form form = doc.createElement('form'); @@ -2426,16 +2422,13 @@ hello.utils.extend(hello.utils, { var input; - // Add elements to the form if they dont exist for (x in data) if (data.hasOwnProperty(x)) { // Is this an element? var el = (_this.domInstance('input', data[x]) || _this.domInstance('textArea', data[x]) || _this.domInstance('select', data[x])); - // Is this not an input element, or one that exists outside the form. if (!el || data[x].form !== form) { - // Does an element have the same name? var inputs = form.elements[x]; if (input) { // Remove it. @@ -2449,12 +2442,10 @@ hello.utils.extend(hello.utils, { } - // Create an input element input = doc.createElement('input'); input.setAttribute('type', 'hidden'); input.setAttribute('name', x); - // Does it have a value attribute? if (el) { input.value = data[x].value; } @@ -2468,47 +2459,37 @@ hello.utils.extend(hello.utils, { form.appendChild(input); } - // It is an element, which exists within the form, but the name is wrong else if (el && data[x].name !== x) { data[x].setAttribute('name', x); data[x].name = x; } } - // Disable elements from within the form if they weren't specified for (i = 0; i < form.elements.length; i++) { input = form.elements[i]; - // Does the same name and value exist in the parent if (!(input.name in data) && input.getAttribute('disabled') !== true) { // Disable input.setAttribute('disabled', true); - // Add re-enable to callback reenableAfterSubmit.push(input); } } } - // Set the target of the form form.setAttribute('method', 'POST'); form.setAttribute('target', callbackID); form.target = callbackID; - // Update the form URL form.setAttribute('action', url); - // Submit the form - // Some reason this needs to be offset from the current window execution setTimeout(function() { form.submit(); setTimeout(function() { try { - // Remove the iframe from the page. - //win.parentNode.removeChild(win); - // Remove the form + if (newform) { newform.parentNode.removeChild(newform); } @@ -2520,7 +2501,6 @@ hello.utils.extend(hello.utils, { catch (ee) {} } - // Reenable the disabled form for (var i = 0; i < reenableAfterSubmit.length; i++) { if (reenableAfterSubmit[i]) { reenableAfterSubmit[i].setAttribute('disabled', false); @@ -2531,8 +2511,6 @@ hello.utils.extend(hello.utils, { }, 100); }, - // Some of the providers require that only multipart is used with non-binary forms. - // This function checks whether the form contains binary data hasBinary: function(data) { for (var x in data) if (data.hasOwnProperty(x)) { if (this.isBinary(data[x])) { @@ -2543,7 +2521,6 @@ hello.utils.extend(hello.utils, { return false; }, - // Determines if a variable Either Is or like a FormInput has the value of a Blob isBinary: function(data) { @@ -2555,7 +2532,6 @@ hello.utils.extend(hello.utils, { }, - // Convert Data-URI to Blob string toBlob: function(dataURI) { var reg = /^data\:([^;,]+(\;charset=[^;,]+)?)(\;base64)?,/i; var m = dataURI.match(reg); @@ -2574,8 +2550,6 @@ hello.utils.extend(hello.utils, { }); -// EXTRA: Convert FormElement to JSON for POSTing -// Wrappers to add additional functionality to existing functions (function(hello) { // Copy original function @@ -2584,8 +2558,6 @@ hello.utils.extend(hello.utils, { utils.extend(utils, { - // DataToJSON - // This takes a FormElement|NodeList|InputElement|MixedObjects and convers the data object to JSON. dataToJSON: function(p) { var _this = this; @@ -2610,7 +2582,6 @@ hello.utils.extend(hello.utils, { data = {file: data}; } - // Loop through data if it's not form data it must now be a JSON object if (!('FormData' in w && data instanceof w.FormData)) { for (var x in data) if (data.hasOwnProperty(x)) { @@ -2638,8 +2609,6 @@ hello.utils.extend(hello.utils, { return data; }, - // NodeListToJSON - // Given a list of elements extrapolate their values and return as a json object nodeListToJSON: function(nodelist) { var json = {}; @@ -2683,11 +2652,6 @@ hello.utils.extend(hello.utils, { })(hello); -///////////////////////////////////// -// -// Save any access token that is in the current page URL -// Handle any response solicited through iframe hash tag following an API request -// -///////////////////////////////////// + hello.utils.responseHandler(window, window.opener || window.parent);