Skip to content

Commit 82b7dba

Browse files
authored
Merge pull request #7336 from magento-trigger/AC-1963
[trigger][combined] AC-1963: Fix deprecated jquery code in magento2 CE
2 parents d553cf9 + 91a4dbe commit 82b7dba

File tree

40 files changed

+1626
-348
lines changed

40 files changed

+1626
-348
lines changed

app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ define([
6969
}
7070
});
7171

72-
$(document).ready(function () {
72+
$(function () {
7373
$('#system_messages .message-system-short .error').on('click', function () {
7474
$('#message-system-all').systemMessageDialog('openModal', 1);
7575
});

app/code/Magento/AdvancedSearch/view/adminhtml/web/js/testconnection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ define([
4444
fieldToCheck = this.options.fieldToCheck || 'success';
4545

4646
element.removeClass('success').addClass('fail');
47-
$.each($.parseJSON(this.options.fieldMapping), function (key, el) {
47+
$.each(JSON.parse(this.options.fieldMapping), function (key, el) {
4848
params[key] = $('#' + el).val();
4949
});
5050
$.ajax({

app/code/Magento/Backend/view/adminhtml/templates/widget/form/renderer/fieldset.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if ($isField) {
4040
data-role="<?= $block->escapeHtmlAttr($id) ?>-wrapper">
4141
<div class="fieldset-wrapper-title admin__fieldset-wrapper-title">
4242
<strong <?= /* @noEscape */ $isCollapsable ?
43-
'class="admin__collapsible-title" data-toggle="collapse" data-target="#' . $id . '-content"' :
43+
'class="admin__collapsible-title" data-bs-toggle="collapse" data-bs-target="#' . $id . '-content"' :
4444
'class="title"'; ?>>
4545
<span><?= $block->escapeHtml($element->getLegend()) ?></span>
4646
</strong>

app/code/Magento/Bundle/view/adminhtml/templates/product/edit/bundle/option.phtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<div class="fieldset-wrapper admin__collapsible-block-wrapper opened"
1414
id="<?= $block->escapeHtmlAttr($block->getFieldId()) ?>_<%- data.index %>-wrapper">
1515
<div class="fieldset-wrapper-title">
16-
<strong class="admin__collapsible-title" data-toggle="collapse"
17-
data-target="#<?= $block->escapeHtmlAttr($block->getFieldId()) ?>_<%- data.index %>-content">
16+
<strong class="admin__collapsible-title" data-bs-toggle="collapse"
17+
data-bs-target="#<?= $block->escapeHtmlAttr($block->getFieldId()) ?>_<%- data.index %>-content">
1818
<span><%- data.default_title %></span>
1919
</strong>
2020
<div class="actions">

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/labels.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<div class="fieldset-wrapper admin__collapsible-block-wrapper opened" id="manage-titles-wrapper">
1111
<div class="fieldset-wrapper-title">
12-
<strong class="admin__collapsible-title" data-toggle="collapse" data-target="#manage-titles-content">
12+
<strong class="admin__collapsible-title" data-bs-toggle="collapse" data-bs-target="#manage-titles-content">
1313
<span><?= $block->escapeHtml(__('Manage Titles (Size, Color, etc.)')) ?></span>
1414
</strong>
1515
</div>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<div class="fieldset-wrapper-title">
1717
<strong
1818
class="admin__collapsible-title"
19-
data-toggle="collapse"
20-
data-target="#<%- data.id %>-content">
19+
data-bs-toggle="collapse"
20+
data-bs-target="#<%- data.id %>-content">
2121
<span id="option_<%- data.id %>_header_title"><%- data.title %></span>
2222
</strong>
2323
<div class="actions">

app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ define([
177177
'products[]': request,
178178
'form_key': widget.options.formKey
179179
}, function ($data) {
180-
$.parseJSON($data).each(function (el) {
180+
$.each(JSON.parse($data), function (el) {
181181
var i;
182182

183183
el.id = widget.getFreeOptionId(el.id);

app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/variations/steps/summary-grid.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<div class="fieldset-wrapper admin__collapsible-block-wrapper opened" data-bind="mageInit: {'collapsible':{'active':true,'openedState':'opened'}}">
99
<div class="fieldset-wrapper-title toggle" data-role="title">
10-
<strong class="admin__collapsible-title" data-toggle="collapse" data-bind="attr:{'data-target': '#'+id}">
10+
<strong class="admin__collapsible-title" data-bs-toggle="collapse" data-bind="attr:{'data-bs-target': '#'+id}">
1111
<span data-bind="text: title"></span>
1212
</strong>
1313
</div>

app/code/Magento/Email/view/adminhtml/web/js/variables.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ define([
133133
}
134134
textareaElm.focus();
135135
textareaElm.scrollTop = scrollPos;
136-
jQuery(textareaElm).change();
136+
jQuery(textareaElm).trigger('change');
137137
textareaElm = null;
138138
}
139139
}

app/code/Magento/MediaStorage/App/Media.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Media application
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -45,8 +43,6 @@ class Media implements AppInterface
4543
private $isAllowed;
4644

4745
/**
48-
* Media directory path
49-
*
5046
* @var string
5147
*/
5248
private $mediaDirectoryPath;
@@ -238,7 +234,10 @@ private function createLocalCopy(): void
238234
*/
239235
private function checkMediaDirectoryChanged(): bool
240236
{
241-
return rtrim($this->mediaDirectoryPath, '/') !== rtrim($this->directoryMedia->getAbsolutePath(), '/');
237+
$mediaDirectoryPath = $this->mediaDirectoryPath ? rtrim($this->mediaDirectoryPath, '/') : '';
238+
$directoryMediaAbsolutePath = $this->directoryMedia->getAbsolutePath();
239+
$directoryMediaAbsolutePath = $directoryMediaAbsolutePath ? rtrim($directoryMediaAbsolutePath, '/') : '';
240+
return $mediaDirectoryPath !== $directoryMediaAbsolutePath;
242241
}
243242

244243
/**

app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function getForm()
215215
public function getJsTemplateName()
216216
{
217217
$templateCode = $this->getModel()->getTemplateCode();
218-
//phpcs:ignore Magento2.Functions.DiscouragedFunction
218+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
219219
return $templateCode ? addcslashes($templateCode, "\"\r\n\\") : '';
220220
}
221221

app/code/Magento/Paypal/view/frontend/web/js/order-review.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ define([
143143
success: function (response) {
144144
var msg;
145145

146-
if ($.type(response) === 'object' && !$.isEmptyObject(response)) {
146+
if (typeof response === 'object' && !$.isEmptyObject(response)) {
147147
if (response['error_messages']) {
148148
this._ajaxComplete();
149149
msg = response['error_messages'];
150150

151151
/* eslint-disable max-depth */
152152
if (msg) {
153-
if ($.type(msg) === 'array') {
153+
if (Array.isArray(msg)) {
154154
msg = msg.join('\n');
155155
}
156156
}
@@ -216,7 +216,7 @@ define([
216216
_updateOrderSubmit: function (shouldDisable, fn) {
217217
this._toggleButton(this.options.orderReviewSubmitSelector, shouldDisable);
218218

219-
if ($.type(fn) === 'function') {
219+
if (typeof fn === 'function') {
220220
fn.call(this);
221221
}
222222
},

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ define([
269269
i;
270270

271271
if (isJSON) {
272-
inputData = $.parseJSON(inputData);
272+
inputData = JSON.parse(inputData);
273273
}
274274

275275
for (i = 0; i < inputData.length; i++) {

app/code/Magento/Sales/view/adminhtml/web/order/create/giftmessage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ define([
248248
return false;
249249
}
250250

251-
if (jQuery.isFunction(giftOptionsForm[0].reset)) {
251+
if (typeof (giftOptionsForm[0].reset) === 'function') {
252252
giftOptionsForm[0].reset();
253253
}
254254
this.closeWindow();

app/code/Magento/Swatches/view/adminhtml/web/js/text.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ define([
214214
});
215215
}
216216

217-
jQuery(document).ready(function () {
217+
jQuery(function () {
218218
if (jQuery('#frontend_input').val() !== 'swatch_text') {
219219
jQuery('.swatch-text-field-0').removeClass('required-option');
220220
}

app/code/Magento/Variable/view/adminhtml/web/variables.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ define([
301301
updateElementAtCursor(textareaElm, value);
302302
textareaElm.focus();
303303
textareaElm.scrollTop = scrollPos;
304-
jQuery(textareaElm).change();
304+
jQuery(textareaElm).trigger('change');
305305
textareaElm = null;
306306
}
307307

app/design/adminhtml/Magento/backend/web/js/theme.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -594,13 +594,13 @@ define('collapsable', [
594594
var self = this;
595595

596596
this.element
597-
.on('show', function (e) {
597+
.on('show.bs.collapse', function (e) {
598598
var fieldsetWrapper = $(this).closest(self.options.wrapper);
599599

600600
fieldsetWrapper.addClass(self.options.openedClass);
601601
e.stopPropagation();
602602
})
603-
.on('hide', function (e) {
603+
.on('hide.bs.collapse', function (e) {
604604
var fieldsetWrapper = $(this).closest(self.options.wrapper);
605605

606606
fieldsetWrapper.removeClass(self.options.openedClass);

lib/internal/Magento/Framework/View/Page/Config.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,11 @@ public function __construct(
193193
$this->title = $title;
194194
$this->localeResolver = $localeResolver;
195195
$this->isIncludesAvailable = $isIncludesAvailable;
196+
$locale = $this->localeResolver->getLocale();
196197
$this->setElementAttribute(
197198
self::ELEMENT_TYPE_HTML,
198199
self::HTML_ATTRIBUTE_LANG,
199-
strstr($this->localeResolver->getLocale(), '_', true)
200+
$locale !== null ? strstr($locale, '_', true) : false
200201
);
201202
$this->escaper = $escaper ?? ObjectManager::getInstance()->get(
202203
Escaper::class

lib/web/css/docs/source/js/dropdown.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
});
6464
};
6565

66-
$(document).ready(function () {
66+
$(function () {
6767
$('[data-toggle=dropdown]').dropdown();
6868
});
6969

0 commit comments

Comments
 (0)