Skip to content

Commit

Permalink
because of JS modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Aug 19, 2024
1 parent 2503374 commit d34c3ec
Show file tree
Hide file tree
Showing 30 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Fields/Attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static function js($id, $options)
let file = attachment.files[j];
var sizes = ['B', 'KB', 'MB', 'GB'];
fileSize = file.size;
var fileSize = file.size;
var sizeIndex = 0;
while (fileSize > 1024) {
Expand Down
6 changes: 3 additions & 3 deletions src/Fields/AutoSuggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_autoSuggestField = function (element) {
window._formsjs_autoSuggestField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
let arr = _config.options;
Expand Down Expand Up @@ -104,7 +104,7 @@ function formCloseAllLists(elmnt) {
}
}
_formDisplaySelection = function (_field, val) {
window._formDisplaySelection = function (_field, val) {
currentFocus = -1;
let _formElementStyle = getComputedStyle(_field);
Expand All @@ -119,7 +119,7 @@ function formCloseAllLists(elmnt) {
/*append the DIV element as a child of the autocomplete container:*/
_field.parentNode.appendChild(a);
for (i = 0; i < arr.length; i++) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
let b = document.createElement("DIV");
let background = "background-color: " + _formElementStyle.backgroundColor + "; ";
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/AutoSuggestSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_autosuggestSelectField = function (inp) {
window._formsjs_autosuggestSelectField = function (inp) {
if (! inp.getAttribute('data-formsjs-rendered')) {
let arr = JSON.parse(inp.getAttribute('data-formsjs-onload-data'));
inp.type = "hidden";
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/AutosizeTextArea.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function onLoadJs($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_autosizeTextAreaField = function (element) {
window._formsjs_autosizeTextAreaField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
autosize(element);
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Bootstrap/DateTimePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_datetimePickerField = function (element) {
window._formsjs_datetimePickerField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
var _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
let _dateTimeConfig = {
Expand Down
6 changes: 3 additions & 3 deletions src/Fields/Bootstrap/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_bootstrapSelect_addInpKeyPress = function (t, ev, id) {
window._formsjs_bootstrapSelect_addInpKeyPress = function (t, ev, id) {
ev.stopPropagation();
// do not allow pipe character
Expand All @@ -169,7 +169,7 @@ public static function js($id, $options)
}
}
_formsjs_bootstrapSelect_addSelectItem = function (t, ev, id) {
window._formsjs_bootstrapSelect_addSelectItem = function (t, ev, id) {
ev.stopPropagation();
let bs = $(t).closest('.bootstrap-select')
Expand All @@ -191,7 +191,7 @@ public static function js($id, $options)
});
}
_formsjs_bootstrapSelectField = function (element) {
window._formsjs_bootstrapSelectField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _id = element.getAttribute('id');
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Bootstrap/Select2.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_bootstrapSelect2Field = function (element) {
window._formsjs_bootstrapSelect2Field = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
let _id = element.getAttribute('id');
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Bootstrap/SimpleDatalist.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_bootstrapSimpleDatalistField = function (element) {
window._formsjs_bootstrapSimpleDatalistField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _id = element.getAttribute('id');
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Bootstrap/SimpleSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_bootstrapCustomSelectField = function (element) {
window._formsjs_bootstrapCustomSelectField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _id = element.getAttribute('id');
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Bootstrap/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_toggleField = function (element) {
window._formsjs_toggleField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
$(element).bootstrapToggle({
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Choices.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_choicesField = function (element) {
window._formsjs_choicesField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _id = element.getAttribute('id');
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_codeField = function (element) {
window._formsjs_codeField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Datepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_DatepickerField = function (element) {
window._formsjs_DatepickerField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Dropzone.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_reload_page = function () {
window._formsjs_reload_page = function () {
window.location.reload();
}
_formsjs_dropzoneField = function (element) {
window._formsjs_dropzoneField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
let _fieldId = element.getAttribute('id');
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_editorField = function (element) {
window._formsjs_editorField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
let _Editor_value = element.value;
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/FileWithPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_fileWithPreviewField = function (element) {
window._formsjs_fileWithPreviewField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Filepond.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function js($id, $options)
$url = url('/');

return <<<JS
_formsjs_FilePondField = function (element) {
window._formsjs_FilePondField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_FlatpickrField = function (element) {
window._formsjs_FlatpickrField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/GrapesJs.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_grapesjsField = function (element) {
window._formsjs_grapesjsField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _id = element.getAttribute('id');
let _elementId = _id+'_Grapes';
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/PasswordWithReveal.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_passwordWithRevealField = function (element) {
window._formsjs_passwordWithRevealField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _selector = '.' + element.getAttribute('data-formsjs-onload-data');
PasswordRevealer(element, { trigger: { selector: _selector, eventListener: 'click' } }).init();
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Quill.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_quillField = function (element) {
window._formsjs_quillField = function (element) {
element.addEventListener('grafite-form-change', function (event) {
let _method = element.form.getAttribute('data-formsjs-onchange');
_method = _method.replace('(event)', '');
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Quill2.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_quillField = function (element) {
window._formsjs_quillField = function (element) {
element.addEventListener('grafite-form-change', function (event) {
let _method = element.form.getAttribute('data-formsjs-onchange');
_method = _method.replace('(event)', '');
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function onLoadJs($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_rating_field = function (element) {
window._formsjs_rating_field = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
$(element).barrating({
theme: element.getAttribute('data-formsjs-onload-data')
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function onLoadJs($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_slug_field = function (element) {
window._formsjs_slug_field = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
element.addEventListener("keyup", event => {
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Summernote.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_summernoteField = function (element) {
window._formsjs_summernoteField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _id = element.getAttribute('id');
$(document).ready(function() {
Expand Down
12 changes: 6 additions & 6 deletions src/Fields/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_tableActionBinding = function (element) {
window._formsjs_tableActionBinding = function (element) {
let _id = element.getAttribute('name');
document.querySelectorAll(`.\${_id}-add-item`).forEach(function (_item) {
Expand All @@ -64,7 +64,7 @@ public static function js($id, $options)
});
}
_formsjs_tableCreateRow = function (element, item, _template, _index, _makeClearRow) {
window._formsjs_tableCreateRow = function (element, item, _template, _index, _makeClearRow) {
let _id = element.getAttribute('name');
let _nextItem = _template.cloneNode(true);
_nextItem.setAttribute('data-item-number', _index);
Expand All @@ -90,7 +90,7 @@ public static function js($id, $options)
element.parentNode.appendChild(_nextItem);
}
_formsjs_tableRemoveRow = function (e) {
window._formsjs_tableRemoveRow = function (e) {
e.preventDefault();
let _row = e.target;
if (e.target.matches('.fa.fa-minus')) {
Expand Down Expand Up @@ -120,7 +120,7 @@ public static function js($id, $options)
_formsjs_tableActionBinding(_element);
}
_formsjs_tableAddItem = function (e) {
window._formsjs_tableAddItem = function (e) {
e.preventDefault();
let _row = e.target;
if (e.target.matches('.fa.fa-plus')) {
Expand All @@ -142,12 +142,12 @@ public static function js($id, $options)
let _max = Math.max.apply(this, _index);
_formsjs_tableCreateRow(_element, _row, _row.parentNode, _max + 1, true);
window._formsjs_tableCreateRow(_element, _row, _row.parentNode, _max + 1, true);
let event = new Event('change', { 'bubbles': true });
_element.dispatchEvent(event);
_formsjs_tableActionBinding(_element);
window._formsjs_tableActionBinding(_element);
}
_formsjs_getTableRowTemplate = function (element) {
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Toggled.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function onLoadJs($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_toggledField = function (element) {
window._formsjs_toggledField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _checkbox = element.parentNode;
_checkbox.classList.add('toggle-slider-wrapper')
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Trix.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_trixField = function (element) {
window._formsjs_trixField = function (element) {
element.addEventListener('grafite-form-change', function (event) {
let _method = element.form.getAttribute('data-formsjs-onchange');
_method = _method.replace('(event)', '');
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Typeahead.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function onLoadJsData($id, $options)
public static function js($id, $options)
{
return <<<JS
_formsjs_typeaheadField = function (element) {
window._formsjs_typeaheadField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
let _config = JSON.parse(element.getAttribute('data-formsjs-onload-data'));
Expand Down
4 changes: 2 additions & 2 deletions src/Services/FormAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function addStylesheets($stylesheets)
public function addScripts($scripts)
{
foreach ($scripts as $script) {
$this->scripts[] = '<script src="' . $script . '"></script>';
$this->scripts[] = '<script type="module" src="' . $script . '"></script>';
}

return $this;
Expand Down Expand Up @@ -130,7 +130,7 @@ protected function compileScripts($type, $nonce = false)

$function = "window.FormsJS = () => { {$js} }";

$output .= "<!-- Form Scripts --><script {$nonce}>\n{$function}\nwindow.FormsJS();\n</script>\n";
$output .= "<!-- Form Scripts --><script type=\"module\" {$nonce}>\n{$function}\nwindow.FormsJS();\n</script>\n";
}

return $output;
Expand Down

0 comments on commit d34c3ec

Please sign in to comment.