Skip to content

Commit

Permalink
bugfix:
Browse files Browse the repository at this point in the history
Lightbox init in global search
failed to update multiple modules at once
  • Loading branch information
stefan committed May 6, 2024
1 parent 1be7f9e commit 333b138
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 23 deletions.
28 changes: 21 additions & 7 deletions core/js/gsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,30 @@ if (fpcm === undefined) {

fpcm.gsearch = {

_lightbox: null,

init: function ()
{

fpcm.dom.bindEvent('#fpcm-id-search-global-btn', 'hidden.bs.dropdown', function (_e, _ui) {
fpcm.dom.fromClass('fpcm.ui-search-global-results').remove();
fpcm.dom.fromId('fpcm-id-search-global-text').val('');
});

fpcm.dom.bindEvent('#fpcm-id-search-global-btn', 'shown.bs.dropdown', function (_e, _ui) {
fpcm.dom.fromId('fpcm-id-search-global-text').focus();
});

fpcm.dom.bindEvent('#fpcm-id-search-global-text', 'keydown', function (_e,_ui) {

var _sterm = fpcm.dom.fromId('fpcm-id-search-global-text').val();
if (!_sterm || _sterm.length < 3) {
if (!_ui.value || _ui.value.length < 3) {
return true;
}

fpcm.gsearch.results(_sterm);
fpcm.gsearch.results(_ui.value);
}, false, true);

fpcm.dom.bindClick('#btnSearchGlobalStart', function () {
fpcm.dom.bindClick('#fpcm-id-search-global-start', function () {

var _sterm = fpcm.dom.fromId('fpcm-id-search-global-text').val();
if (!_sterm || _sterm.length < 3) {
Expand All @@ -43,7 +48,7 @@ fpcm.gsearch = {

results: function (_sterm) {

fpcm.ui.replaceIcon('btnSearchGlobalStart', 'magnifying-glass-arrow-right', 'circle-notch fa-spin-pulse');
fpcm.ui.replaceIcon('fpcm-id-search-global-start', 'magnifying-glass-arrow-right', 'circle-notch fa-spin-pulse');

fpcm.ajax.post('searchall', {
quiet: true,
Expand Down Expand Up @@ -80,7 +85,16 @@ fpcm.gsearch = {
let text = _result.items[i].text;
let icon = _result.items[i].icon;
let linkCss = _result.items[i].lightbox ? 'fpcm ui-link-fancybox' : '';
let linkData = _result.items[i].lightbox ? 'data-fancybox="group"' : '';

let linkData = '';
if (_result.items[i].lightbox) {

_img = new Image();
_img.src = link;

linkData = `data-pswp-width="${_img.naturalWidth}" data-pswp-height="${_img.naturalHeight}"`;
}


_list += `<div class="${_resCss}"><a href="${link}" target="_blank" class="text-truncate ${linkCss}" ${linkData}>${icon}${text}</a></div>`;
}
Expand All @@ -92,7 +106,7 @@ fpcm.gsearch = {
fpcm.ui.initLightbox();
}

fpcm.ui.replaceIcon('btnSearchGlobalStart', 'circle-notch fa-spin-pulse', 'magnifying-glass-arrow-right');
fpcm.ui.replaceIcon('fpcm-id-search-global-start', 'circle-notch fa-spin-pulse', 'magnifying-glass-arrow-right');
}
});

Expand Down
2 changes: 1 addition & 1 deletion core/views/common/menutop.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="dropdown-item-text">
<div class="input-group input-group-sm w-auto">
<input type="text" class="form-control" id="fpcm-id-search-global-text" placeholder="<?php $theView->write('ARTICLE_SEARCH_TEXT'); ?>" aria-label="<?php $theView->write('ARTICLE_SEARCH_TEXT'); ?>">
<?php $theView->button('searchGlobalStart')
<?php $theView->button('fpcm-id-search-global-start')
->overrideButtonType('outline-secondary')
->setText('ARTICLE_SEARCH_START')
->setIcon('magnifying-glass-arrow-right')
Expand Down
24 changes: 12 additions & 12 deletions inc/controller/action/packagemgr/moduleBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* AJAX module installer controller
* @author Stefan Seehafer <sea75300@yahoo.de>
* @copyright (c) 2011-2022, Stefan Seehafer
* @copyright (c) 2011-2024, Stefan Seehafer
* @license http://www.gnu.org/licenses/gpl.txt GPLv3
*/

Expand All @@ -27,7 +27,7 @@ class moduleBase extends \fpcm\controller\abstracts\controller
protected $updateMultiple = false;

/**
*
*
* @var array
*/
protected $jsVars = [];
Expand All @@ -54,7 +54,7 @@ class moduleBase extends \fpcm\controller\abstracts\controller
];

/**
*
*
* @return bool
*/
public function isAccessible(): bool
Expand All @@ -63,7 +63,7 @@ public function isAccessible(): bool
}

/**
*
*
* @return string
*/
protected function getViewPath(): string
Expand All @@ -84,7 +84,7 @@ public function request()
$this->key = $this->request->fromGET('key', [
\fpcm\model\http\request::FILTER_URLDECODE
]);

if (!\fpcm\module\module::validateKey($this->key)) {
$this->view = new \fpcm\view\error('MODULES_KEY_INVALID');
return false;
Expand Down Expand Up @@ -114,17 +114,17 @@ public function process()
(new \fpcm\view\helper\linkButton('backbtn'))->setText('MODULES_LIST_BACKTOLIST')->setUrl(\fpcm\classes\tools::getFullControllerLink('modules/list'))->setIcon('chevron-circle-left'),
(new \fpcm\view\helper\linkButton('protobtn'))->setText('HL_LOGS')->setUrl(\fpcm\classes\tools::getFullControllerLink('system/logs'))->setIcon('exclamation-triangle')->setTarget(\fpcm\view\helper\linkButton::TARGET_NEW),
]);

$tabText = $this->language->translate($this->steps['tabHeadline']).': '. $this->key;

$this->view->addTabs('updater', [
(new \fpcm\view\helper\tabItem('sysupdate'))->setText($tabText)->setFile($this->getViewPath())
]);

$this->assignMultipleUpdates();
$this->view->addJsFiles(['modules/installer.js']);
$this->view->render();

}

/**
Expand All @@ -146,7 +146,7 @@ private function assignMultipleUpdates() : bool
if ($updateKeys === null || !trim($updateKeys)) {
return false;
}

$updateKeys = explode(';', $updateKeys);
if (!count($updateKeys)) {
return false;
Expand All @@ -156,7 +156,7 @@ private function assignMultipleUpdates() : bool
(new \fpcm\view\helper\linkButton('runUpdateNext'))
->setUrl(\fpcm\classes\tools::getFullControllerLink('package/modupdate', [
'key' => array_shift($updateKeys),
'updateKeys' => base64_decode($this->crypt->encrypt(implode(';', $updateKeys)))
'updateKeys' => base64_encode($this->crypt->encrypt(implode(';', $updateKeys)))
])
)->setText('MODULES_LIST_UPDATE_NEXT')
->setIcon('sync')
Expand All @@ -166,5 +166,5 @@ private function assignMultipleUpdates() : bool

return true;
}

}
2 changes: 1 addition & 1 deletion inc/controller/action/packagemgr/moduleUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function process()
$this->steps['tabHeadline'] = 'MODULES_LIST_UPDATE';
$this->steps['successMsg'] = 'PACKAGEMANAGER_SUCCESS_UPDATE';
$this->steps['errorMsg'] = 'PACKAGEMANAGER_FAILED_UPDATE';

$this->jsVars = [
'pkgdata' => [
'action' => 'update',
Expand Down
15 changes: 14 additions & 1 deletion modules/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,18 @@ fpcm.lightbox.captionPlugin = new PhotoSwipeDynamicCaption(fpcm.lightbox, {
type: 'below',
});

fpcm.lightbox.init();

fpcm.lightbox.init();
if (fpcm.gsearch !== undefined) {
fpcm.gsearch._lightbox = new PhotoSwipeLightBox({
gallery: '#fpcm-id-search-global',
children: 'a.fpcm.ui-link-fancybox',
pswpModule: () => PhotoSwipeCore
});

fpcm.gsearch._lightbox .captionPlugin = new PhotoSwipeDynamicCaption(fpcm.lightbox, {
type: 'below',
});

fpcm.gsearch._lightbox .init();
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.0-rc1
5.2.0-rc2

0 comments on commit 333b138

Please sign in to comment.