From 9d85baee37c2d2eb7e8eda5eb64bb967b9d70a37 Mon Sep 17 00:00:00 2001 From: Felix Wiedenbach Date: Sat, 13 Feb 2021 08:29:13 +0100 Subject: [PATCH] move error callback into options and rename it --- js/main.js | 12 +++++------- js/module.js | 5 +---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/js/main.js b/js/main.js index 082f2114..f836e78b 100644 --- a/js/main.js +++ b/js/main.js @@ -279,9 +279,8 @@ var MM = (function () { * @param {number} speed The speed of the show animation. * @param {Function} callback Called when the animation is done. * @param {object} [options] Optional settings for the show method. - * @param {Function} errorCallback Called when the module failed to show. */ - var showModule = function (module, speed, callback, errorCallback, options) { + var showModule = function (module, speed, callback, options) { options = options || {}; // remove lockString if set in options. @@ -296,8 +295,8 @@ var MM = (function () { // Otherwise cancel show action. if (module.lockStrings.length !== 0 && options.force !== true) { Log.log("Will not show " + module.name + ". LockStrings active: " + module.lockStrings.join(",")); - if (typeof errorCallback === "function") { - errorCallback(new Error("ERR_ACTIVE_LOCK_STRINGS")); + if (typeof options.onError === "function") { + options.onError(new Error("ERR_ACTIVE_LOCK_STRINGS")); } return; } @@ -590,11 +589,10 @@ var MM = (function () { * @param {number} speed The speed of the show animation. * @param {Function} callback Called when the animation is done. * @param {object} [options] Optional settings for the show method. - * @param {Function} errorCallback Called when the module failed to show. */ - showModule: function (module, speed, callback, errorCallback, options) { + showModule: function (module, speed, callback, options) { // do not change module.hidden yet, only if we really show it later - showModule(module, speed, callback, errorCallback, options); + showModule(module, speed, callback, options); } }; })(); diff --git a/js/module.js b/js/module.js index 976a7cab..2e2c94a9 100644 --- a/js/module.js +++ b/js/module.js @@ -416,9 +416,8 @@ var Module = Class.extend({ * @param {number} speed The speed of the show animation. * @param {Function} callback Called when the animation is done. * @param {object} [options] Optional settings for the show method. - * @param {Function} errorCallback Called when the module failed to show. */ - show: function (speed, callback, options, errorCallback) { + show: function (speed, callback, options) { if (typeof callback === "object") { options = callback; callback = function () {}; @@ -426,7 +425,6 @@ var Module = Class.extend({ callback = callback || function () {}; options = options || {}; - errorCallback = errorCallback || function () {}; MM.showModule( this, @@ -435,7 +433,6 @@ var Module = Class.extend({ this.resume(); callback(); }, - errorCallback, options ); }