-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
53 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
document.querySelectorAll('[data-formsjs-onload]').forEach(function (element) { | ||
let _method = element.getAttribute('data-formsjs-onload'); | ||
window[_method](element); | ||
element.setAttribute('data-formsjs-rendered', true); | ||
}); | ||
|
||
document.querySelectorAll('[data-formsjs-onchange]').forEach(function (element) { | ||
let _method = element.getAttribute('data-formsjs-onchange'); | ||
_method = _method.replace('(event)', ''); | ||
|
||
element.addEventListener('change', function (event) { | ||
window[_method](event); | ||
}); | ||
}); | ||
|
||
document.querySelectorAll('[data-formsjs-onclick]').forEach(function (element) { | ||
let _method = element.getAttribute('data-formsjs-onclick'); | ||
_method = _method.replace('(event)', ''); | ||
element.addEventListener('click', function (event) { | ||
event.preventDefault(); | ||
_method = _method.replace('return ', ''); | ||
_method = _method.replace('window.', ''); | ||
|
||
if (_method.includes('Forms_validate_submission')) { | ||
window.Forms_validate_submission(event.target.form, '<i class=\"fas fa-circle-notch fa-spin mr-2\"></i> Save',event.target); | ||
} else if (_method.includes('FormsJS_disableOnSubmit')) { | ||
window.FormsJS_disableOnSubmit(event); | ||
} else if (_method.includes('.')) { | ||
let _path = _method.split('.'); | ||
if (_path.length == 2) { | ||
window[_path[0]][_path[1]](event); | ||
} | ||
|
||
if (_path.length == 3) { | ||
window[_path[0]][_path[1]][_path[2]](event); | ||
} | ||
|
||
if (_path.length == 4) { | ||
throw new Error('Method nesting is too deep. Max of 3!'); | ||
} | ||
} else if (typeof window[_method] === 'function') { | ||
window[_method](event); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters