From 5522348c8aabd1194e5a056ead0953bf749f1272 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Wed, 11 Mar 2020 18:05:03 +0900 Subject: [PATCH] edit.js update This is jquery only update Add new overlay and action indicator for auto any overlay boxes. Stack with GS_OB_S and min zIndex layer 10 and raise +1 for each new show overlay call and lower for each hide call --- 4dev/database/log/.gitignore | 2 + www/layout/admin/css/edit.css | 2 +- www/layout/admin/javascript/edit.jq.js | 172 +++++++++++++++++++++- www/lib/CoreLibs/Output/Form/Generate.php | 2 +- 4 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 4dev/database/log/.gitignore diff --git a/4dev/database/log/.gitignore b/4dev/database/log/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/4dev/database/log/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/www/layout/admin/css/edit.css b/www/layout/admin/css/edit.css index 19371ba0..6711061c 100644 --- a/www/layout/admin/css/edit.css +++ b/www/layout/admin/css/edit.css @@ -382,7 +382,7 @@ input[type="text"]:focus, textarea:focus, select:focus { left: 0; top: 0; position: absolute; - z-index: 100; + z-index: 1000; } /* Animation for above progress */ @keyframes rotate { diff --git a/www/layout/admin/javascript/edit.jq.js b/www/layout/admin/javascript/edit.jq.js index 713ce455..51da3f08 100644 --- a/www/layout/admin/javascript/edit.jq.js +++ b/www/layout/admin/javascript/edit.jq.js @@ -12,6 +12,10 @@ if (!DEBUG) { }); }*/ +// open overlay boxes counter +var GL_OB_S = 10; +var GL_OB_BASE = 10; + /** * opens a popup window with winName and given features (string) * @param {String} theURL the url @@ -393,6 +397,20 @@ function errorCatch(err) } } +/************************************************************* + * OLD action indicator and overlay boxes calls + * DO NOT USE + * actionIndicator -> showActionIndicator + * actionIndicator -> hideActionIndicator + * actionIndicatorShow -> showActionIndicator + * actionIndicatorHide -> hideActionIndicator + * overlayBoxShow -> showOverlayBoxLayers + * overlayBoxHide -> hideOverlayBoxLayers + * setOverlayBox -> showOverlayBoxLayers + * hideOverlayBox -> hideOverlayBoxLayers + * ClearCall -> ClearCallActionBox + * ***********************************************************/ + /** * show or hide the "do" overlay * @param {String} loc location name for action indicator @@ -401,10 +419,10 @@ function errorCatch(err) */ function actionIndicator(loc, overlay = true) { - if ($('#overlayBox').is(':visible')) { + if ($('#indicator').is(':visible')) { actionIndicatorHide(loc, overlay); } else { - actionIndicatorShow(loc, overlay); + actionIndicatorShow(loc, overlay); } } @@ -455,6 +473,7 @@ function overlayBoxShow() $('#overlayBox').css('zIndex', '100'); } else { $('#overlayBox').show(); + $('#overlayBox').css('zIndex', '98'); } } @@ -464,7 +483,7 @@ function overlayBoxShow() function overlayBoxHide() { // if the overlay box z-index is 100, do no hide, but set to 98 - if ($('#overlayBox').css('zIndex') == 100) { + if ($('#overlayBox').css('zIndex') >= 100) { $('#overlayBox').css('zIndex', '98'); } else { $('#overlayBox').hide(); @@ -501,6 +520,153 @@ function ClearCall() $('#overlayBox').hide(); } +/************************************************************* + * NEW action indicator and overlay box calls + * USE THIS + * ***********************************************************/ + +/** + * show action indicator + * - checks if not existing and add + * - only shows if not visible (else ignore) + * - overlaybox check is called and shown on a fixzed + * zIndex of 1000 + * - indicator is page centered + * @param {String} loc ID string, only used for console log + */ +function showActionIndicator(loc) +{ + console.log('Indicator: SHOW [%s]', loc); + // check if indicator element exists + if ($('#indicator').length == 0) { + var el = document.createElement('div'); + el.className = 'progress hide'; + el.id = 'indicator'; + $('body').append(el); + } + // indicator not visible + if (!$('#indicator').is(':visible')) { + // check if overlay box element exits + checkOverlayExists(); + // if not visible show + if (!$('#overlayBox').is(':visible')) { + $('#overlayBox').show(); + } + // always set to 1000 zIndex to be top + $('#overlayBox').css('zIndex', 1000); + // show indicator + $('#indicator').show(); + // center it + setCenter('indicator', true, true); + } +} + +/** + * hide action indicator, if it is visiable + * If the global variable GL_OB_S is > 10 then + * the overlayBox is not hidden but the zIndex + * is set to this value + * @param {String} loc ID string, only used for console log + */ +function hideActionIndicator(loc) +{ + console.log('Indicator: HIDE [%s]', loc); + // check if indicator is visible + if ($('#indicator').is(':visible')) { + // hide indicator + $('#indicator').hide(); + // if global overlay box count is > 0 + // then set it to this level and keep + if (GL_OB_S > GL_OB_BASE) { + $('#overlayBox').css('zIndex', GL_OB_S); + } else { + // else hide overlay box and set zIndex to 0 + $('#overlayBox').hide(); + $('#overlayBox').css('zIndex', GL_OB_BASE); + } + } +} + +/** + * checks if overlayBox exists, if not it is + * added as hidden item at the body end + */ +function checkOverlayExists() +{ + // check if overlay box exists, if not create it + if ($('#overlayBox').length == 0) { + var el = document.createElement('div'); + el.className = 'overlayBoxElement hide'; + el.id = 'overlayBox'; + $('body').append(el); + } +} + +/** + * show overlay box + * if not visible show and set zIndex to 10 (GL_OB_BASE) + * if visible, add +1 to the GL_OB_S variable and + * up zIndex by this value + */ +function showOverlayBoxLayers(el_id) +{ + console.log('SHOW overlaybox: %s', GL_OB_S); + // if overlay box is not visible show and set zIndex to 0 + if (!$('#overlayBox').is(':visible')) { + $('#overlayBox').show(); + $('#overlayBox').css('zIndex', GL_OB_BASE); + // also set start variable to 0 + GL_OB_S = GL_OB_BASE; + } + // up the overlay box counter by 1 + GL_OB_S ++; + // set zIndex + $('#overlayBox').css('zIndex', GL_OB_S); + // if element given raise zIndex and show + if (el_id) { + if ($('#' + el_id).length > 0) { + $('#' + el_id).css('zIndex', GL_OB_S + 1); + $('#' + el_id).show(); + } + } + console.log('SHOW overlaybox NEW zIndex: %s', $('#overlayBox').css('zIndex')); +} + +/** + * hide overlay box + * lower GL_OB_S value by -1 + * if we are 10 (GL_OB_BASE) or below hide the overlayIndex + * and set zIndex and GL_OB_S to 0 + * else just set zIndex to the new GL_OB_S value + */ +function hideOverlayBoxLayers() +{ + console.log('HIDE overlaybox: %s', GL_OB_S); + // remove on layer + GL_OB_S --; + // if 0 or lower (overflow) hide it and + // set zIndex to 0 + if (GL_OB_S <= GL_OB_BASE) { + GL_OB_S = GL_OB_BASE; + $('#overlayBox').hide(); + $('#overlayBox').css('zIndex', GL_OB_BASE); + } else { + // if OB_S > 0 then set new zIndex + $('#overlayBox').css('zIndex', GL_OB_S); + } + console.log('HIDE overlaybox NEW zIndex: %s', $('#overlayBox').css('zIndex')); +} + +/** + * only for single action box + */ +function clearCallActionBox() +{ + $('#actionBox').html(''); + $('#actionBox').hide(); + hideOverlayBoxLayers(); +} + // *** DOM MANAGEMENT FUNCTIONS /** * reates object for DOM element creation flow diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php index e4101754..a43cebca 100644 --- a/www/lib/CoreLibs/Output/Form/Generate.php +++ b/www/lib/CoreLibs/Output/Form/Generate.php @@ -829,7 +829,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $data['checked'] = 0; for ($i = (count($this->table_array[$element_name]['element_list']) - 1); $i >= 0; $i --) { $data['value'][] = $i; - $data['output'][] = $this->table_array[$element_name]['element_list'][$i]; + $data['output'][] = $this->table_array[$element_name]['element_list'][$i] ?? null; $data['name'] = $element_name; if (isset($this->table_array[$element_name]['value']) && (($i && $this->table_array[$element_name]['value']) ||