From 4c01d16f1d8e9860c180466d8679b345872601db Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Wed, 29 Mar 2023 14:15:22 +0200 Subject: [PATCH] ENH: Use make_form_modal in ext_trigger_crawler_form --- src/core/js/ext_trigger_crawler_form.js | 32 +++---------------------- src/core/js/form_elements.js | 2 +- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/core/js/ext_trigger_crawler_form.js b/src/core/js/ext_trigger_crawler_form.js index 0796ef77..900cda98 100644 --- a/src/core/js/ext_trigger_crawler_form.js +++ b/src/core/js/ext_trigger_crawler_form.js @@ -41,7 +41,7 @@ * variable `BUILD_MODULE_EXT_TRIGGER_CRAWLER_FORM_TOOLBOX`. The default is * `Tools`. */ -var ext_trigger_crawler_form = function () { +var ext_trigger_crawler_form = function ($, form_elements) { var init = function (toolbox) { const _toolbox = toolbox || "${BUILD_MODULE_EXT_TRIGGER_CRAWLER_FORM_TOOLBOX}"; @@ -52,7 +52,7 @@ var ext_trigger_crawler_form = function () { const crawler_form = make_scripting_caller_form( script, button_name); - const modal = make_form_modal(crawler_form); + const modal = form_elements.make_form_modal(crawler_form, "Trigger the crawler", "Crawl the selected path"); navbar.add_tool(button_name, _toolbox, { @@ -63,32 +63,6 @@ var ext_trigger_crawler_form = function () { }); } - /** - * Wrap the form into a Bootstrap modal. - */ - var make_form_modal = function (form) { - const title = "Trigger the Crawler"; - const modal = $(` - <div class="modal fade" tabindex="-1" role="dialog"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" - class="btn-close" - data-bs-dismiss="modal" - aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - <h4 class="modal-title">${title}</h4> - </div> - <div class="modal-body"> - </div> - </div> - </div>`); - modal.find(".modal-body").append(form); - return modal[0]; - } - /** * Create the trigger crawler form. */ @@ -123,7 +97,7 @@ var ext_trigger_crawler_form = function () { init: init, }; -}(); +}($, form_elements); $(document).ready(function () { if ("${BUILD_MODULE_EXT_TRIGGER_CRAWLER_FORM}" === "ENABLED") { diff --git a/src/core/js/form_elements.js b/src/core/js/form_elements.js index 48e97848..5d2143b5 100644 --- a/src/core/js/form_elements.js +++ b/src/core/js/form_elements.js @@ -1571,7 +1571,7 @@ var form_elements = new function () { * @param {string} explanation_text - An optional paragraph shown between * modal title and form. */ - this.make_for_modal = function (form, title, explanation_text) { + this.make_form_modal = function (form, title, explanation_text) { const modal = $(` <div class="modal fade" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> -- GitLab