Remove deprecated JS function setModalLoader() (#6389)

* Refactor deprecated `setModalLoader()` usage

* Remove deprecated JS function `setModalLoader()`

* Update MIGRATE-DEV.md

---------

Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
Yuriy Bakhtin 2023-06-15 14:18:28 +04:00 committed by GitHub
parent 836acf2c1d
commit 77d64b1d32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 35 deletions

View File

@ -51,3 +51,4 @@ HumHub Changelog
- Enh #6369: Don't pin draft and scheduled contents on dashboard
- Enh #6370: Remove FlatElements CSS
- Enh #6384: Added Serbian(sr) language
- Enh #6389: Remove deprecated JS function `setModalLoader()`

View File

@ -13,6 +13,7 @@ Version 1.15 (Unreleased)
want to match against the end of the names.
- `\humhub\libs\BaseSettingsManager::get()` now returns a pure int in case the (trimmed) value can be converted
- New `PolymorphicRelation::getObjectModel()`: should replace `get_class()`
- Removed deprecated javascript method `setModalLoader()`
### Type restrictions

View File

@ -2,7 +2,7 @@
/**
* This file is generated by the "yii asset" command.
* DO NOT MODIFY THIS FILE DIRECTLY.
* @version 2023-06-02 15:55:23
* @version 2023-06-14 17:22:59
*/
return [
'app' => [

View File

@ -4,7 +4,6 @@ use humhub\modules\space\models\Space;
use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\modules\user\models\User;
use humhub\widgets\AjaxButton;
use humhub\widgets\LoaderWidget;
/**
* @var $module \humhub\components\Module
@ -51,8 +50,8 @@ use humhub\widgets\LoaderWidget;
'label' => Yii::t('AdminModule.modules', 'Save'),
'ajaxOptions' => [
'type' => 'POST',
'beforeSend' => new yii\web\JsExpression('function(){ setModalLoader(); }'),
'success' => new yii\web\JsExpression('function(html){ $("#globalModal").html(html); }'),
'beforeSend' => new yii\web\JsExpression('humhub.require("ui.modal").footerLoader'),
'success' => new yii\web\JsExpression('humhub.require("ui.modal").setContent'),
'url' => \yii\helpers\Url::to(['/admin/module/set-as-default', 'moduleId' => $module->id]),
],
'htmlOptions' => ['class' => 'btn btn-primary']
@ -61,8 +60,6 @@ use humhub\widgets\LoaderWidget;
<button type="button" class="btn btn-primary" data-dismiss="modal">
<?= Yii::t('AdminModule.modules', 'Close'); ?>
</button>
<?= LoaderWidget::widget(['id' => 'default-loader', 'cssClass' => 'loader-modal hidden']); ?>
</div>
<?php $form::end(); ?>

View File

@ -5,7 +5,6 @@ use humhub\modules\space\models\forms\RequestMembershipForm;
use humhub\modules\space\models\Space;
use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\widgets\AjaxButton;
use humhub\widgets\LoaderWidget;
/**
* @var $space Space
@ -39,8 +38,8 @@ use humhub\widgets\LoaderWidget;
'label' => Yii::t('SpaceModule.base', 'Send'),
'ajaxOptions' => [
'type' => 'POST',
'beforeSend' => new yii\web\JsExpression('function(){ setModalLoader(evt); }'),
'success' => new yii\web\JsExpression('function(html){ $("#globalModal").html(html); }'),
'beforeSend' => new yii\web\JsExpression('humhub.require("ui.modal").footerLoader'),
'success' => new yii\web\JsExpression('humhub.require("ui.modal").setContent'),
'url' => $space->createUrl('/space/membership/request-membership-form'),
],
'htmlOptions' => [
@ -51,8 +50,6 @@ use humhub\widgets\LoaderWidget;
<button type="button" class="btn btn-default" data-dismiss="modal">
<?= Yii::t('SpaceModule.base', 'Close'); ?>
</button>
<?= LoaderWidget::widget(['id' => 'send-loader', 'cssClass' => 'loader-modal hidden']); ?>
</div>
<?php $form::end(); ?>
</div>

View File

@ -25,14 +25,14 @@ class AjaxLinkPager extends \humhub\widgets\LinkPager
*
* @var string
*/
public $jsBeforeSend = 'function(){ setModalLoader(); }';
public $jsBeforeSend = 'humhub.require("ui.modal").footerLoader';
/**
* Success Javascript Expression
*
* @var string
* @var string
*/
public $jsSuccess = 'function(html){ $("#globalModal").html(html); }';
public $jsSuccess = 'humhub.require("ui.modal").setContent';
/**
* @inheritdoc

View File

@ -415,15 +415,3 @@ humhub.module('ui.additions', function (module, require, $) {
};
})(jQuery, window);
/**
* @deprecated since v1.2
*/
function setModalLoader(evt) {
var modalFooter = $('.modal-footer');
if (typeof evt === 'object') {
modalFooter = $(evt.target).closest('.modal-footer');
}
modalFooter.find('.btn').hide();
modalFooter.find('.loader').removeClass('hidden');
}

View File

@ -128,6 +128,13 @@ humhub.module('ui.modal', function (module, require, $) {
this.show();
};
/**
* Sets the loader to footer in order to inactivate the action buttons
*/
Modal.prototype.footerLoader = function () {
loader.set(this.getFooter(), {css: {padding: '13px 0 14px'}});
}
/**
* Sets the default content (a loader animation)
* @returns {undefined}
@ -756,6 +763,14 @@ humhub.module('ui.modal', function (module, require, $) {
};
};
const footerLoader = function () {
module.global.footerLoader();
}
const setContent = function (html) {
module.global.setContent(html);
}
module.export({
init: init,
sortOrder: 100,
@ -767,6 +782,8 @@ humhub.module('ui.modal', function (module, require, $) {
load: load,
unload: unload,
show: show,
submit: submit
submit: submit,
footerLoader,
setContent
});
});

View File

@ -1,12 +1,4 @@
/**
* @deprecated since v1.2
*/
function setModalLoader() {
$(".modal-footer .btn").hide();
$(".modal-footer .loader").removeClass("hidden");
}
/**
* USED in fileuploader.js
*/