Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove messages in console #7

Merged
merged 1 commit into from
Oct 16, 2023
Merged
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
2 changes: 1 addition & 1 deletion dist/powerbuttons.compress.js

Large diffs are not rendered by default.

66 changes: 40 additions & 26 deletions dist/powerbuttons.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
}
return els
};
window.powerButtons.version = "2.0.0";
window.powerButtons.version = "2.0.1";
window.powerButtons.plugins = function () {
return Object.keys(PowerButtons.actionsRegistered)
};
if (window.$ !== undefined) {
window.$.fn.powerButtons = function (pluginName, options = {}) {
window.powerButtons(pluginName, this, options);
return this
};
window.$.fn.powerButtons.version = window.powerButtons.version
window.$.fn.powerButtons.version = window.powerButtons.version;
window.$.fn.powerButtons.plugins = window.powerButtons.plugins
}

function pascalToSnake(str) {
Expand Down Expand Up @@ -516,7 +520,6 @@
class PowerButtons {
static actionsRegistered = {};
static registerAction(action) {
console.debug(`Registering action ${action.NAME.toLowerCase()}`);
this.actionsRegistered[action.NAME.toLowerCase()] = action;
if (window.powerButtons === undefined) {
window.powerButtons = {}
Expand Down Expand Up @@ -600,7 +603,7 @@
if (action === undefined) {
throw `The action ${currentActionSettings.type} is not registered`
}
action.execute(currentActionSettings, onNextAction, () => this.reset())
action.execute(this.el, currentActionSettings, onNextAction, () => this.reset())
}
reset() {
this.current_action = 0
Expand Down Expand Up @@ -665,7 +668,7 @@
this.initialize(el, options)
}
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
throw new Error("The execute method must be implemented by the derived class")
}
}
Expand All @@ -686,7 +689,7 @@
header: true,
footer: true
};
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let result = null;
let bindObject = searchForm(settings.form);
Expand Down Expand Up @@ -775,7 +778,7 @@
}
return options
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let dialog = Dialog.create({
title: settings.title,
Expand Down Expand Up @@ -816,7 +819,7 @@
task: "asynctask"
})
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
if (settings.task === null) {
console.error("The task to execute cannot be null");
Expand Down Expand Up @@ -884,7 +887,7 @@
header: true,
footer: true
};
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let dialog = Dialog.create({
title: settings.title,
Expand Down Expand Up @@ -934,27 +937,39 @@
Object.assign(options.fields, fields);
return options
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let formToSet = searchForm(settings.form);
if (formToSet === null) {
console.error(`Form not found ${settings.form}`);
return
let formToSet = null;
let inputFields = [];
let elements = [];
if (settings.form == "") {
if (el.form !== null) {
formToSet = el.form
} else {
elements = Array.from(document.querySelectorAll("input")).filter(input => input.form === null)
}
} else {
formToSet = searchForm(settings.form);
if (formToSet === null) {
console.error(`Form not found ${settings.form}`);
return
}
}
if (formToSet !== null) {
elements = Array.from(formToSet.elements)
}
let nameMap = {};
for (var i = 0; i < formToSet.elements.length; i++) {
let element = formToSet.elements[i];
elements.forEach(element => {
if (element.name !== "") {
nameMap[element.name.toLocaleLowerCase()] = element.name
inputFields[element.name.toLocaleLowerCase()] = element
}
if (element.id !== "") {
nameMap[element.id.toLocaleLowerCase()] = element.id
inputFields[element.id.toLocaleLowerCase()] = element
}
}
for (var field in settings.fields) {
if (nameMap[field] !== undefined) {
});
for (let field in settings.fields) {
if (inputFields[field] !== undefined) {
let value = settings.fields[field];
let result = getValueWithJavascriptSupport(value, formToSet);
let result = getValueWithJavascriptSupport(value, formToSet !== null ? formToSet : inputFields);
if (typeof result === "function") {
try {
result = result()
Expand All @@ -963,7 +978,7 @@
continue
}
}
formToSet[nameMap[field]].value = result
inputFields[field].value = result
}
}
onNextAction()
Expand Down Expand Up @@ -1001,7 +1016,6 @@
fieldname = pascalToSnake(fieldname);
break;
case "camel":
console.log(fieldname, pascalToCamel(fieldname));
fieldname = pascalToCamel(fieldname);
break;
case "pascal":
Expand Down Expand Up @@ -1058,7 +1072,7 @@
super.initialize(el, settings)
}
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let error = false;
for (let fieldName in settings.fields) {
Expand Down
64 changes: 39 additions & 25 deletions dist/powerbuttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
}
return els;
};
window.powerButtons.version = "2.0.0";
window.powerButtons.version = "2.0.1";
window.powerButtons.plugins = function () {
return Object.keys(PowerButtons.actionsRegistered);
};
if (window.$ !== undefined) {
window.$.fn.powerButtons = function (pluginName, options = {}) {
window.powerButtons(pluginName, this, options);
return this;
};
window.$.fn.powerButtons.version = window.powerButtons.version;
window.$.fn.powerButtons.plugins = window.powerButtons.plugins;
}

function pascalToSnake(str) {
Expand Down Expand Up @@ -516,7 +520,6 @@
class PowerButtons {
static actionsRegistered = {};
static registerAction(action) {
console.debug(`Registering action ${action.NAME.toLowerCase()}`);
this.actionsRegistered[action.NAME.toLowerCase()] = action;
if (window.powerButtons === undefined) {
window.powerButtons = {};
Expand Down Expand Up @@ -600,7 +603,7 @@
if (action === undefined) {
throw `The action ${currentActionSettings.type} is not registered`;
}
action.execute(currentActionSettings, onNextAction, () => this.reset());
action.execute(this.el, currentActionSettings, onNextAction, () => this.reset());
}
reset() {
this.current_action = 0;
Expand Down Expand Up @@ -665,7 +668,7 @@
this.initialize(el, options);
}
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
throw new Error("The execute method must be implemented by the derived class");
}
}
Expand All @@ -686,7 +689,7 @@
header: true,
footer: true
};
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let result = null;
let bindObject = searchForm(settings.form);
Expand Down Expand Up @@ -775,7 +778,7 @@
}
return options;
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let dialog = Dialog.create({
title: settings.title,
Expand Down Expand Up @@ -816,7 +819,7 @@
task: "asynctask"
});
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
if (settings.task === null) {
console.error("The task to execute cannot be null");
Expand Down Expand Up @@ -884,7 +887,7 @@
header: true,
footer: true
};
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let dialog = Dialog.create({
title: settings.title,
Expand Down Expand Up @@ -934,27 +937,39 @@
Object.assign(options.fields, fields);
return options;
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let formToSet = searchForm(settings.form);
if (formToSet === null) {
console.error(`Form not found ${settings.form}`);
return;
let formToSet = null;
let inputFields = [];
let elements = [];
if (settings.form == "") {
if (el.form !== null) {
formToSet = el.form;
} else {
elements = Array.from(document.querySelectorAll("input")).filter(input => input.form === null);
}
} else {
formToSet = searchForm(settings.form);
if (formToSet === null) {
console.error(`Form not found ${settings.form}`);
return;
}
}
if (formToSet !== null) {
elements = Array.from(formToSet.elements);
}
let nameMap = {};
for (var i = 0; i < formToSet.elements.length; i++) {
let element = formToSet.elements[i];
elements.forEach(element => {
if (element.name !== "") {
nameMap[element.name.toLocaleLowerCase()] = element.name;
inputFields[element.name.toLocaleLowerCase()] = element;
}
if (element.id !== "") {
nameMap[element.id.toLocaleLowerCase()] = element.id;
inputFields[element.id.toLocaleLowerCase()] = element;
}
}
for (var field in settings.fields) {
if (nameMap[field] !== undefined) {
});
for (let field in settings.fields) {
if (inputFields[field] !== undefined) {
let value = settings.fields[field];
let result = getValueWithJavascriptSupport(value, formToSet);
let result = getValueWithJavascriptSupport(value, formToSet !== null ? formToSet : inputFields);
if (typeof result === "function") {
try {
result = result();
Expand All @@ -963,7 +978,7 @@
continue;
}
}
formToSet[nameMap[field]].value = result;
inputFields[field].value = result;
}
}
onNextAction();
Expand Down Expand Up @@ -1001,7 +1016,6 @@
fieldname = pascalToSnake(fieldname);
break;
case "camel":
console.log(fieldname, pascalToCamel(fieldname));
fieldname = pascalToCamel(fieldname);
break;
case "pascal":
Expand Down Expand Up @@ -1058,7 +1072,7 @@
super.initialize(el, settings);
}
}
static execute(options, onNextAction, onCancelActions) {
static execute(el, options, onNextAction, onCancelActions) {
let settings = PowerButtons.getActionSettings(this, options);
let error = false;
for (let fieldName in settings.fields) {
Expand Down
2 changes: 1 addition & 1 deletion dist/powerbuttons.min.js

Large diffs are not rendered by default.

Loading