Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 2 additions & 38 deletions src/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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');
Expand All @@ -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.
Expand All @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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])) {
Expand All @@ -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) {

Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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)) {
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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);