Responsive mixins usage
For grouping style rules in certain media queries .media-width() mixin used.
.media-width(<@extremum>, <@break>);
-
@extremum: max|min
- sets whether to use min-width or max-width in media query condition
- @break: value
- sets the value of breakpoint to compare with in media query condition.
+
@extremum: max|min
- sets whether to use min-width or max-width in media query condition
+ @break: value
- sets the value of breakpoint to compare with in media query condition.
For example
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
your styles
diff --git a/lib/web/css/docs/source/_layout.less b/lib/web/css/docs/source/_layout.less
index 09fd183e30ba..8c1c707ff358 100644
--- a/lib/web/css/docs/source/_layout.less
+++ b/lib/web/css/docs/source/_layout.less
@@ -57,25 +57,25 @@ footer.footer {
//
// @layout-class-1column
// page-layout-1column
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for one column layout
//
//
// @layout-class-2columns__left
// page-layout-2columns-left
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for two columns layout with left sidebar
//
//
// @layout-class-2columns__right
// page-layout-2columns-right
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for two columns layout with right sidebar
//
//
// @layout-class-3columns
// page-layout-3columns
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for three columns layout with left sidebar
//
//
diff --git a/lib/web/css/docs/source/_responsive.less b/lib/web/css/docs/source/_responsive.less
index 8e7397d6ad6f..dca60791bfac 100644
--- a/lib/web/css/docs/source/_responsive.less
+++ b/lib/web/css/docs/source/_responsive.less
@@ -4,7 +4,7 @@
// */
// # Responsive
-// Magento UI library provides a strong approach for working with media queries. It`s based on recursive call of .media-width()
mixin defined anywhere in project but invoked in one place in lib/web/css/source/lib/_responsive.less
. That's why in the resulting styles.css
we have every media query only once with all the rules there, not a multiple calls for the same query.
+// Magento UI library provides a strong approach for working with media queries. It`s based on recursive call of .media-width()
mixin defined anywhere in project but invoked in one place in lib/web/css/source/lib/_responsive.less
. That's why in the resulting styles.css
we have every media query only once with all the rules there, not a multiple calls for the same query.
//
// To see the media queries work resize window to understand which breakpoint is applied.
// ```
@@ -43,8 +43,8 @@
// ```css
// .media-width(<@extremum>, <@break>);
// ```
-// @extremum: max|min
- sets whether to use **min-width** or **max-width** in media query condition
-// @break: value
- sets the value of breakpoint to compare with in media query condition.
+// @extremum: max|min
- sets whether to use **min-width** or **max-width** in media query condition
+// @break: value
- sets the value of breakpoint to compare with in media query condition.
// For example
// ```css
// .media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
diff --git a/lib/web/css/docs/source/_variables.less b/lib/web/css/docs/source/_variables.less
index e1845786067c..74cbabdd0737 100644
--- a/lib/web/css/docs/source/_variables.less
+++ b/lib/web/css/docs/source/_variables.less
@@ -4169,25 +4169,25 @@
//
// @layout-class-1column
// page-layout-1column
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for one column layout
//
//
// @layout-class-2columns__left
// page-layout-2columns-left
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for two columns layout with left sidebar
//
//
// @layout-class-2columns__right
// page-layout-2columns-right
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for two columns layout with right sidebar
//
//
// @layout-class-3columns
// page-layout-3columns
-// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+// '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
// Class name for three columns layout with left sidebar
//
//
diff --git a/lib/web/css/docs/variables.html b/lib/web/css/docs/variables.html
index ebbf2122ab20..3c5a583e5101 100644
--- a/lib/web/css/docs/variables.html
+++ b/lib/web/css/docs/variables.html
@@ -4168,25 +4168,25 @@ Layout variables
@layout-class-1column
page-layout-1column
- '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+ '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
Class name for one column layout
@layout-class-2columns__left
page-layout-2columns-left
- '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+ '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
Class name for two columns layout with left sidebar
@layout-class-2columns__right
page-layout-2columns-right
- '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+ '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
Class name for two columns layout with right sidebar
@layout-class-3columns
page-layout-3columns
- '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
+ '' | false | page-layout-1column | page-layout-2columns-left | page-layout-2columns-right | page-layout-3columns
Class name for three columns layout with left sidebar
diff --git a/lib/web/mage/backend/button.js b/lib/web/mage/backend/button.js
index c06d2dedab05..453fc7443a7c 100644
--- a/lib/web/mage/backend/button.js
+++ b/lib/web/mage/backend/button.js
@@ -3,18 +3,10 @@
* See COPYING.txt for license details.
*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'jquery/ui'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'jquery/ui'
+], function ($) {
'use strict';
$.widget('ui.button', $.ui.button, {
@@ -58,4 +50,4 @@
});
return $.ui.button;
-}));
+});
diff --git a/lib/web/mage/backend/form.js b/lib/web/mage/backend/form.js
index 36b33d0a59d5..de270c8ccd20 100644
--- a/lib/web/mage/backend/form.js
+++ b/lib/web/mage/backend/form.js
@@ -2,18 +2,10 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'jquery/ui'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'jquery/ui'
+], function ($) {
'use strict';
$.widget('mage.form', {
@@ -209,4 +201,4 @@
});
return $.mage.form;
-}));
+});
diff --git a/lib/web/mage/backend/menu.js b/lib/web/mage/backend/menu.js
index b56d49086c4f..35a851fa0de4 100644
--- a/lib/web/mage/backend/menu.js
+++ b/lib/web/mage/backend/menu.js
@@ -3,18 +3,10 @@
* See COPYING.txt for license details.
*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'jquery/ui'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'jquery/ui'
+], function ($) {
'use strict';
$.widget('mage.menu', {
@@ -784,4 +776,4 @@
});
return $.mage.menu;
-}));
+});
diff --git a/lib/web/mage/backend/suggest.js b/lib/web/mage/backend/suggest.js
index d34be1042091..ffd615a62a22 100644
--- a/lib/web/mage/backend/suggest.js
+++ b/lib/web/mage/backend/suggest.js
@@ -3,22 +3,14 @@
* See COPYING.txt for license details.
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/template',
- 'mage/mage',
- 'jquery/ui',
- 'mage/backend/menu',
- 'mage/translate'
- ], factory);
- } else {
- factory(root.jQuery, root.mageTemplate);
- }
-}(this, function ($, mageTemplate) {
+define([
+ 'jquery',
+ 'mage/template',
+ 'mage/mage',
+ 'jquery/ui',
+ 'mage/backend/menu',
+ 'mage/translate'
+], function ($, mageTemplate) {
'use strict';
/**
@@ -1196,4 +1188,4 @@
});
return $.mage.suggest;
-}));
+});
diff --git a/lib/web/mage/backend/tabs.js b/lib/web/mage/backend/tabs.js
index 849b73c20b5b..5b602fda580e 100644
--- a/lib/web/mage/backend/tabs.js
+++ b/lib/web/mage/backend/tabs.js
@@ -4,18 +4,10 @@
*/
/* global FORM_KEY */
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'jquery/ui'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'jquery/ui'
+], function ($) {
'use strict';
var rhash, isLocal;
@@ -423,4 +415,4 @@
});
return $.mage.tabs;
-}));
+});
diff --git a/lib/web/mage/backend/tree-suggest.js b/lib/web/mage/backend/tree-suggest.js
index 47f034b0b243..8d09ce4dc119 100644
--- a/lib/web/mage/backend/tree-suggest.js
+++ b/lib/web/mage/backend/tree-suggest.js
@@ -3,20 +3,12 @@
* See COPYING.txt for license details.
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'jquery/ui',
- 'jquery/jstree/jquery.jstree',
- 'mage/backend/suggest'
- ], factory);
- } else {
- factory(root.jQuery);
- }
-}(this, function ($) {
+define([
+ 'jquery',
+ 'jquery/ui',
+ 'jquery/jstree/jquery.jstree',
+ 'mage/backend/suggest'
+], function ($) {
'use strict';
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
@@ -274,4 +266,4 @@
});
return $.mage.treeSuggest;
-}));
+});
diff --git a/lib/web/mage/backend/validation.js b/lib/web/mage/backend/validation.js
index 1043f45a7402..c07fcd154207 100644
--- a/lib/web/mage/backend/validation.js
+++ b/lib/web/mage/backend/validation.js
@@ -4,23 +4,15 @@
*/
/* global BASE_URL, alertAlreadyDisplayed */
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'underscore',
- 'Magento_Ui/js/modal/alert',
- 'jquery/ui',
- 'jquery/validate',
- 'mage/translate',
- 'mage/validation'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($, _, alert) {
+define([
+ 'jquery',
+ 'underscore',
+ 'Magento_Ui/js/modal/alert',
+ 'jquery/ui',
+ 'jquery/validate',
+ 'mage/translate',
+ 'mage/validation'
+], function ($, _, alert) {
'use strict';
$.extend(true, $.validator.prototype, {
@@ -307,4 +299,4 @@
});
return $.mage.validation;
-}));
+});
diff --git a/lib/web/mage/calendar.css b/lib/web/mage/calendar.css
index 071270feeeb3..da19f389d308 100644
--- a/lib/web/mage/calendar.css
+++ b/lib/web/mage/calendar.css
@@ -141,7 +141,6 @@
padding: 0;
}
.ui-datepicker {
- background: #ffffff;
padding: 15px;
border: #ffffff 4px solid;
-webkit-box-sizing: border-box;
diff --git a/lib/web/mage/calendar.js b/lib/web/mage/calendar.js
index 85f1904c0e19..d3eb055d29d8 100644
--- a/lib/web/mage/calendar.js
+++ b/lib/web/mage/calendar.js
@@ -4,20 +4,12 @@
*/
/*eslint max-depth: 0*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'jquery-ui-modules/widget',
- 'jquery-ui-modules/datepicker',
- 'jquery-ui-modules/timepicker'
- ], factory);
- } else {
- factory(window.jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'jquery-ui-modules/widget',
+ 'jquery-ui-modules/datepicker',
+ 'jquery-ui-modules/timepicker'
+], function ($) {
'use strict';
var calendarBasePrototype,
@@ -566,4 +558,4 @@
dateRange: $.mage.dateRange,
calendar: $.mage.calendar
};
-}));
+});
diff --git a/lib/web/mage/cookies.js b/lib/web/mage/cookies.js
index ee47d69949ea..627e22ade323 100644
--- a/lib/web/mage/cookies.js
+++ b/lib/web/mage/cookies.js
@@ -3,19 +3,11 @@
* See COPYING.txt for license details.
*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/mage',
- 'jquery/jquery.cookie'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'mage/mage',
+ 'jquery/jquery.cookie'
+], function ($) {
'use strict';
/**
@@ -154,4 +146,4 @@
$.extend($.mage.cookies.defaults, pageOptions);
$.extend($.cookie.defaults, $.mage.cookies.defaults);
};
-}));
+});
diff --git a/lib/web/mage/decorate.js b/lib/web/mage/decorate.js
index 238735ac455b..437dee1be288 100644
--- a/lib/web/mage/decorate.js
+++ b/lib/web/mage/decorate.js
@@ -4,16 +4,10 @@
*/
/* eslint-disable strict */
-(function (factory) {
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/translate'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'mage/translate'
+], function ($) {
var methods = {
/**
* Decorate a list (e.g. a containing ) recursively if specified.
@@ -25,7 +19,7 @@
items;
if (list.length > 0) {
- items = typeof isRecursive === undefined || isRecursive ?
+ items = typeof isRecursive === 'undefined' || isRecursive ?
list.find('li') :
list.children();
items.decorate('generic', ['odd', 'even', 'last']);
@@ -129,4 +123,4 @@
message = $.mage.__('Method %s does not exist on jQuery.decorate');
$.error(message.replace('%s', method));
};
-}));
+});
diff --git a/lib/web/mage/edit-trigger.js b/lib/web/mage/edit-trigger.js
index e28a826ec87e..30d26d8626df 100644
--- a/lib/web/mage/edit-trigger.js
+++ b/lib/web/mage/edit-trigger.js
@@ -6,19 +6,11 @@
/**
* @deprecated since version 2.2.0
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/template',
- 'jquery-ui-modules/widget'
- ], factory);
- } else {
- factory(root.jQuery, root.mageTemplate);
- }
-}(this, function ($, mageTemplate) {
+define([
+ 'jquery',
+ 'mage/template',
+ 'jquery-ui-modules/widget'
+], function ($, mageTemplate) {
'use strict';
var editTriggerPrototype;
@@ -220,4 +212,4 @@
}));
return $.mage.editTrigger;
-}));
+});
diff --git a/lib/web/mage/loader_old.js b/lib/web/mage/loader_old.js
index f759758acd12..f72191f5b634 100644
--- a/lib/web/mage/loader_old.js
+++ b/lib/web/mage/loader_old.js
@@ -3,20 +3,12 @@
* See COPYING.txt for license details.
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/template',
- 'jquery-ui-modules/widget',
- 'mage/translate'
- ], factory);
- } else {
- factory(root.jQuery, root.mageTemplate);
- }
-}(this, function ($, mageTemplate) {
+define([
+ 'jquery',
+ 'mage/template',
+ 'jquery-ui-modules/widget',
+ 'mage/translate'
+], function ($, mageTemplate) {
'use strict';
$.widget('mage.loader', {
@@ -232,4 +224,4 @@
loader: $.mage.loader,
loaderAjax: $.mage.loaderAjax
};
-}));
+});
diff --git a/lib/web/mage/mage.js b/lib/web/mage/mage.js
index ba9aa678aaef..9e479016fecc 100644
--- a/lib/web/mage/mage.js
+++ b/lib/web/mage/mage.js
@@ -3,18 +3,10 @@
* See COPYING.txt for license details.
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/apply/main'
- ], factory);
- } else {
- factory(root.jQuery);
- }
-}(this, function ($, mage) {
+define([
+ 'jquery',
+ 'mage/apply/main'
+], function ($, mage) {
'use strict';
/**
@@ -100,4 +92,4 @@
});
return $.mage;
-}));
+});
diff --git a/lib/web/mage/template.js b/lib/web/mage/template.js
index 3da9693eb534..db34bd4c4a1a 100644
--- a/lib/web/mage/template.js
+++ b/lib/web/mage/template.js
@@ -3,17 +3,9 @@
* See COPYING.txt for license details.
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'underscore'
- ], factory);
- } else {
- root.mageTemplate = factory(root._);
- }
-}(this, function (_) {
+define([
+ 'underscore'
+], function (_) {
'use strict';
/**
@@ -84,4 +76,4 @@
render(data) :
render;
};
-}));
+});
diff --git a/lib/web/mage/translate-inline-vde.css b/lib/web/mage/translate-inline-vde.css
index 369c1fb9a2f0..f898bb01c43d 100644
--- a/lib/web/mage/translate-inline-vde.css
+++ b/lib/web/mage/translate-inline-vde.css
@@ -52,7 +52,6 @@
}
.translate-dialog .ui-dialog-buttonset {
- padding-right: 0;
margin-right: 0;
float: right;
background: rgba(223, 243, 250, 1.0);
diff --git a/lib/web/mage/translate-inline-vde.js b/lib/web/mage/translate-inline-vde.js
index 485413e3c928..e39a86934b03 100644
--- a/lib/web/mage/translate-inline-vde.js
+++ b/lib/web/mage/translate-inline-vde.js
@@ -6,22 +6,14 @@
/**
* @deprecated since version 2.2.0
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/template',
- 'jquery-ui-modules/widget',
- 'jquery-ui-modules/core',
- 'mage/translate-inline',
- 'mage/translate'
- ], factory);
- } else {
- factory(root.jQuery, root.mageTemplate);
- }
-}(this, function ($, mageTemplate) {
+define([
+ 'jquery',
+ 'mage/template',
+ 'jquery-ui-modules/widget',
+ 'jquery-ui-modules/core',
+ 'mage/translate-inline',
+ 'mage/translate'
+], function ($, mageTemplate) {
'use strict';
/**
@@ -598,4 +590,4 @@
}
}
});
-}));
+});
diff --git a/lib/web/mage/translate-inline.js b/lib/web/mage/translate-inline.js
index cdd2b8ad322f..56acef5a49a4 100644
--- a/lib/web/mage/translate-inline.js
+++ b/lib/web/mage/translate-inline.js
@@ -3,20 +3,12 @@
* See COPYING.txt for license details.
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/template',
- 'jquery-ui-modules/dialog',
- 'mage/translate'
- ], factory);
- } else {
- factory(root.jQuery, root.mageTemplate);
- }
-}(this, function ($, mageTemplate) {
+define([
+ 'jquery',
+ 'mage/template',
+ 'jquery-ui-modules/dialog',
+ 'mage/translate'
+], function ($, mageTemplate) {
'use strict';
$.widget('mage.translateInline', $.ui.dialog, {
@@ -201,4 +193,4 @@
});
return $.mage.translateInline;
-}));
+});
diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js
index 2ec39efcc283..51c23a9b28c6 100644
--- a/lib/web/mage/validation.js
+++ b/lib/web/mage/validation.js
@@ -3,21 +3,13 @@
* See COPYING.txt for license details.
*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'moment',
- 'jquery-ui-modules/widget',
- 'jquery/validate',
- 'mage/translate'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($, moment) {
+define([
+ 'jquery',
+ 'moment',
+ 'jquery-ui-modules/widget',
+ 'jquery/validate',
+ 'mage/translate'
+], function ($, moment) {
'use strict';
var creditCartTypes, rules, showLabel, originValidateDelegate;
@@ -1987,4 +1979,4 @@
});
return $.mage.validation;
-}));
+});
diff --git a/lib/web/mage/validation/validation.js b/lib/web/mage/validation/validation.js
index 0f2c4c06b119..c8478ac84edd 100644
--- a/lib/web/mage/validation/validation.js
+++ b/lib/web/mage/validation/validation.js
@@ -3,19 +3,11 @@
* See COPYING.txt for license details.
*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/validation',
- 'mage/translate'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'mage/validation',
+ 'mage/translate'
+], function ($) {
'use strict';
$.each({
@@ -175,4 +167,4 @@
rule.unshift(i);
$.validator.addMethod.apply($.validator, rule);
});
-}));
+});
diff --git a/lib/web/mage/webapi.js b/lib/web/mage/webapi.js
index 3aa61b6f9775..ccb5efb85f64 100644
--- a/lib/web/mage/webapi.js
+++ b/lib/web/mage/webapi.js
@@ -6,18 +6,10 @@
/**
* @deprecated since version 2.2.0
*/
-(function (factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/mage'
- ], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) {
+define([
+ 'jquery',
+ 'mage/mage'
+], function ($) {
'use strict';
/**
@@ -208,4 +200,4 @@
}
};
};
-}));
+});
diff --git a/lib/web/mage/zoom.js b/lib/web/mage/zoom.js
index a7ad19fb560a..cd7dd738158d 100644
--- a/lib/web/mage/zoom.js
+++ b/lib/web/mage/zoom.js
@@ -6,19 +6,11 @@
/**
* @deprecated since version 2.2.0
*/
-(function (root, factory) {
- 'use strict';
-
- if (typeof define === 'function' && define.amd) {
- define([
- 'jquery',
- 'mage/template',
- 'jquery-ui-modules/widget'
- ], factory);
- } else {
- factory(root.jQuery, root.mageTemplate);
- }
-}(this, function ($, mageTemplate) {
+define([
+ 'jquery',
+ 'mage/template',
+ 'jquery-ui-modules/widget'
+], function ($, mageTemplate) {
'use strict';
$.widget('mage.zoom', {
@@ -538,4 +530,4 @@
});
return $.mage.zoom;
-}));
+});
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 7a097e49c628..23f8a13c8bfe 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -429,7 +429,7 @@ private function createModulesConfig($request, $dryRun = false)
$disable = $this->readListOfModules($all, $request, InstallCommand::INPUT_KEY_DISABLE_MODULES);
$result = [];
foreach ($all as $module) {
- if ((isset($currentModules[$module]) && !$currentModules[$module])) {
+ if (isset($currentModules[$module]) && !$currentModules[$module]) {
$result[$module] = 0;
} else {
$result[$module] = 1;
@@ -925,7 +925,7 @@ private function throwExceptionForNotWritablePaths(array $paths)
*/
private function handleDBSchemaData($setup, $type, array $request)
{
- if (!(($type === 'schema') || ($type === 'data'))) {
+ if (!($type === 'schema' || $type === 'data')) {
throw new \Magento\Setup\Exception("Unsupported operation type $type is requested");
}
$resource = new \Magento\Framework\Module\ModuleResource($this->context);
diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php
index d78e259ec06e..b3a2f14aa922 100644
--- a/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php
+++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php
@@ -10,6 +10,11 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\FileSystemException;
+/**
+ * Class ClassesScanner
+ *
+ * @package Magento\Setup\Module\Di\Code\Reader
+ */
class ClassesScanner implements ClassesScannerInterface
{
/**
@@ -29,7 +34,8 @@ class ClassesScanner implements ClassesScannerInterface
/**
* @param array $excludePatterns
- * @param string $generationDirectory
+ * @param DirectoryList|null $directoryList
+ * @throws FileSystemException
*/
public function __construct(array $excludePatterns = [], DirectoryList $directoryList = null)
{
@@ -61,7 +67,7 @@ public function addExcludePatterns(array $excludePatterns)
*/
public function getList($path)
{
-
+ // phpcs:ignore
$realPath = realpath($path);
$isGeneration = strpos($realPath, $this->generationDirectory) === 0;
@@ -94,7 +100,7 @@ public function getList($path)
*/
private function extract(\RecursiveIteratorIterator $recursiveIterator)
{
- $classes = [];
+ $classes = [[]];
foreach ($recursiveIterator as $fileItem) {
/** @var $fileItem \SplFileInfo */
if ($fileItem->isDir() || $fileItem->getExtension() !== 'php' || $fileItem->getBasename()[0] == '.') {
@@ -109,12 +115,14 @@ private function extract(\RecursiveIteratorIterator $recursiveIterator)
$fileScanner = new FileClassScanner($fileItemPath);
$classNames = $fileScanner->getClassNames();
$this->includeClasses($classNames, $fileItemPath);
- $classes = array_merge($classes, $classNames);
+ $classes [] = $classNames;
}
- return $classes;
+ return array_merge(...$classes);
}
/**
+ * Include classes from file path
+ *
* @param array $classNames
* @param string $fileItemPath
* @return bool Whether the class is included or not
@@ -123,6 +131,7 @@ private function includeClasses(array $classNames, $fileItemPath)
{
foreach ($classNames as $className) {
if (!class_exists($className)) {
+ // phpcs:ignore
require_once $fileItemPath;
return true;
}
diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php
index e34fcbd041c7..9a91006564d7 100644
--- a/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php
+++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php
@@ -6,8 +6,24 @@
namespace Magento\Setup\Module\Di\Code\Reader;
+/**
+ * Class FileClassScanner
+ *
+ * @package Magento\Setup\Module\Di\Code\Reader
+ */
class FileClassScanner
{
+ private const NAMESPACE_TOKENS = [
+ T_WHITESPACE => true,
+ T_STRING => true,
+ T_NS_SEPARATOR => true
+ ];
+
+ private const ALLOWED_OPEN_BRACES_TOKENS = [
+ T_CURLY_OPEN => true,
+ T_DOLLAR_OPEN_CURLY_BRACES => true,
+ T_STRING_VARNAME => true];
+
/**
* The filename of the file to introspect
*
@@ -34,7 +50,9 @@ class FileClassScanner
*/
public function __construct($filename)
{
+ // phpcs:ignore
$filename = realpath($filename);
+ // phpcs:ignore
if (!file_exists($filename) || !\is_file($filename)) {
throw new InvalidFileException(
sprintf(
@@ -53,12 +71,14 @@ public function __construct($filename)
*/
public function getFileContents()
{
+ // phpcs:ignore
return file_get_contents($this->filename);
}
/**
- * Extracts the fully qualified class name from a file. It only searches for the first match and stops looking
- * as soon as it enters the class definition itself.
+ * Extracts the fully qualified class name from a file.
+ *
+ * It only searches for the first match and stops looking as soon as it enters the class definition itself.
*
* Warnings are suppressed for this method due to a micro-optimization that only really shows up when this logic
* is called several millions of times, which can happen quite easily with even moderately sized codebases.
@@ -69,35 +89,36 @@ public function getFileContents()
*/
private function extract()
{
- $allowedOpenBraces = [T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES, T_STRING_VARNAME];
$classes = [];
- $namespace = '';
+ $namespaceParts = [];
$class = '';
$triggerClass = false;
$triggerNamespace = false;
$braceLevel = 0;
$bracedNamespace = false;
+ // phpcs:ignore
$this->tokens = token_get_all($this->getFileContents());
foreach ($this->tokens as $index => $token) {
+ $tokenIsArray = is_array($token);
// Is either a literal brace or an interpolated brace with a variable
- if ($token == '{' || (is_array($token) && in_array($token[0], $allowedOpenBraces))) {
+ if ($token === '{' || ($tokenIsArray && isset(self::ALLOWED_OPEN_BRACES_TOKENS[$token[0]]))) {
$braceLevel++;
- } else if ($token == '}') {
+ } elseif ($token === '}') {
$braceLevel--;
}
// The namespace keyword was found in the last loop
if ($triggerNamespace) {
// A string ; or a discovered namespace that looks like "namespace name { }"
- if (!is_array($token) || ($namespace && $token[0] == T_WHITESPACE)) {
+ if (!$tokenIsArray || ($namespaceParts && $token[0] === T_WHITESPACE)) {
$triggerNamespace = false;
- $namespace .= '\\';
+ $namespaceParts[] = '\\';
continue;
}
- $namespace .= $token[1];
+ $namespaceParts[] = $token[1];
- // The class keyword was found in the last loop
- } else if ($triggerClass && $token[0] == T_STRING) {
+ // The class keyword was found in the last loop
+ } elseif ($triggerClass && $token[0] === T_STRING) {
$triggerClass = false;
$class = $token[1];
}
@@ -106,7 +127,7 @@ private function extract()
case T_NAMESPACE:
// Current loop contains the namespace keyword. Between this and the semicolon is the namespace
$triggerNamespace = true;
- $namespace = '';
+ $namespaceParts = [];
$bracedNamespace = $this->isBracedNamespace($index);
break;
case T_CLASS:
@@ -118,9 +139,8 @@ private function extract()
}
// We have a class name, let's concatenate and store it!
- if ($class != '') {
- $namespace = trim($namespace);
- $fqClassName = $namespace . trim($class);
+ if ($class !== '') {
+ $fqClassName = trim(join('', $namespaceParts)) . trim($class);
$classes[] = $fqClassName;
$class = '';
}
@@ -139,15 +159,15 @@ private function isBracedNamespace($index)
$len = count($this->tokens);
while ($index++ < $len) {
if (!is_array($this->tokens[$index])) {
- if ($this->tokens[$index] == ';') {
+ if ($this->tokens[$index] === ';') {
return false;
- } else if ($this->tokens[$index] == '{') {
+ } elseif ($this->tokens[$index] === '{') {
return true;
}
continue;
}
- if (!in_array($this->tokens[$index][0], [T_WHITESPACE, T_STRING, T_NS_SEPARATOR])) {
+ if (!isset(self::NAMESPACE_TOKENS[$this->tokens[$index][0]])) {
throw new InvalidFileException('Namespace not defined properly');
}
}
@@ -155,8 +175,9 @@ private function isBracedNamespace($index)
}
/**
- * Retrieves the first class found in a class file. The return value is in an array format so it retains the
- * same usage as the FileScanner.
+ * Retrieves the first class found in a class file.
+ *
+ * The return value is in an array format so it retains the same usage as the FileScanner.
*
* @return array
*/
diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php
index ab66a63e2449..1cd242acbe50 100644
--- a/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php
+++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php
@@ -11,6 +11,11 @@
use Magento\Setup\Module\Di\Compiler\Log\Log;
use \Magento\Framework\Reflection\TypeProcessor;
+/**
+ * Class PhpScanner
+ *
+ * @package Magento\Setup\Module\Di\Code\Scanner
+ */
class PhpScanner implements ScannerInterface
{
/**
@@ -167,48 +172,51 @@ protected function _fetchMissingExtensionAttributesClasses($reflectionClass, $fi
*
* @param array $files
* @return array
+ * @throws \ReflectionException
*/
public function collectEntities(array $files)
{
- $output = [];
+ $output = [[]];
foreach ($files as $file) {
$classes = $this->_getDeclaredClasses($file);
foreach ($classes as $className) {
$reflectionClass = new \ReflectionClass($className);
- $output = array_merge(
- $output,
- $this->_fetchFactories($reflectionClass, $file),
- $this->_fetchMissingExtensionAttributesClasses($reflectionClass, $file)
- );
+ $output [] = $this->_fetchFactories($reflectionClass, $file);
+ $output [] = $this->_fetchMissingExtensionAttributesClasses($reflectionClass, $file);
}
}
- return array_unique($output);
+ return array_unique(array_merge(...$output));
}
/**
- * @param $tokenIterator int
- * @param $count int
- * @param $tokens array
+ * Fetch namespaces from tokenized PHP file
+ *
+ * @param int $tokenIterator
+ * @param int $count
+ * @param array $tokens
* @return string
*/
protected function _fetchNamespace($tokenIterator, $count, $tokens)
{
- $namespace = '';
+ $namespaceParts = [];
for ($tokenOffset = $tokenIterator + 1; $tokenOffset < $count; ++$tokenOffset) {
if ($tokens[$tokenOffset][0] === T_STRING) {
- $namespace .= "\\" . $tokens[$tokenOffset][1];
+ $namespaceParts[] = "\\";
+ $namespaceParts[] = $tokens[$tokenOffset][1];
} elseif ($tokens[$tokenOffset] === '{' || $tokens[$tokenOffset] === ';') {
break;
}
}
- return $namespace;
+ return join('', $namespaceParts);
}
/**
- * @param $namespace string
- * @param $tokenIterator int
- * @param $count int
- * @param $tokens array
+ * Fetch class names from tokenized PHP file
+ *
+ * @param string $namespace
+ * @param int $tokenIterator
+ * @param int $count
+ * @param array $tokens
* @return array
*/
protected function _fetchClasses($namespace, $tokenIterator, $count, $tokens)
@@ -230,23 +238,24 @@ protected function _fetchClasses($namespace, $tokenIterator, $count, $tokens)
*/
protected function _getDeclaredClasses($file)
{
- $classes = [];
- $namespace = '';
+ $classes = [[]];
+ $namespaceParts = [];
+ // phpcs:ignore
$tokens = token_get_all(file_get_contents($file));
$count = count($tokens);
for ($tokenIterator = 0; $tokenIterator < $count; $tokenIterator++) {
if ($tokens[$tokenIterator][0] == T_NAMESPACE) {
- $namespace .= $this->_fetchNamespace($tokenIterator, $count, $tokens);
+ $namespaceParts[] = $this->_fetchNamespace($tokenIterator, $count, $tokens);
}
if (($tokens[$tokenIterator][0] == T_CLASS || $tokens[$tokenIterator][0] == T_INTERFACE)
&& $tokens[$tokenIterator - 1][0] != T_DOUBLE_COLON
) {
- $classes = array_merge($classes, $this->_fetchClasses($namespace, $tokenIterator, $count, $tokens));
+ $classes[] = $this->_fetchClasses(join('', $namespaceParts), $tokenIterator, $count, $tokens);
}
}
- return array_unique($classes);
+ return array_unique(array_merge(...$classes));
}
/**
@@ -263,7 +272,7 @@ private function shouldGenerateClass($missingClassName, $entityType, $file)
if (class_exists($missingClassName)) {
return false;
}
- } catch (\RuntimeException $e) {
+ } catch (\RuntimeException $e) { //phpcs:ignore
}
$sourceClassName = $this->getSourceClassName($missingClassName, $entityType);
if (!class_exists($sourceClassName) && !interface_exists($sourceClassName)) {
diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/BackslashTrim.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/BackslashTrim.php
index 10b6b941df8e..ce0fa5dbac12 100644
--- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/BackslashTrim.php
+++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/BackslashTrim.php
@@ -8,8 +8,21 @@
use Magento\Setup\Module\Di\Compiler\Config\ModificationInterface;
+/**
+ * Class BackslashTrim
+ *
+ * @package Magento\Setup\Module\Di\Compiler\Config\Chain
+ */
class BackslashTrim implements ModificationInterface
{
+ /**
+ * Argument keys which require recursive resolving
+ */
+ private const RECURSIVE_ARGUMENT_KEYS = [
+ '_i_' => true, // shared instance of a class or interface
+ '_ins_' => true // non-shared instance of a class or interface
+ ];
+
/**
* Modifies input config
*
@@ -48,7 +61,6 @@ private function resolveInstancesNames(array $arguments)
* Resolves instances arguments
*
* @param array $argument
- * @return array
*/
private function resolveArguments(&$argument)
{
@@ -57,15 +69,12 @@ private function resolveArguments(&$argument)
}
foreach ($argument as $key => &$value) {
- if (in_array($key, ['_i_', '_ins_'], true)) {
+ if (isset(self::RECURSIVE_ARGUMENT_KEYS[$key])) {
$value = ltrim($value, '\\');
continue;
}
- if (is_array($value)) {
- $this->resolveArguments($value);
- }
+ $this->resolveArguments($value);
}
- return;
}
}
diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/PreferencesResolving.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/PreferencesResolving.php
index 8624ce39df09..d902c0c0eb62 100644
--- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/PreferencesResolving.php
+++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/PreferencesResolving.php
@@ -8,8 +8,21 @@
use Magento\Setup\Module\Di\Compiler\Config\ModificationInterface;
+/**
+ * Class PreferencesResolving
+ *
+ * @package Magento\Setup\Module\Di\Compiler\Config\Chain
+ */
class PreferencesResolving implements ModificationInterface
{
+ /**
+ * Argument keys which require recursive resolving
+ */
+ private const RECURSIVE_ARGUMENT_KEYS = [
+ '_i_' => true, // shared instance of a class or interface
+ '_ins_' => true // non-shared instance of a class or interface
+ ];
+
/**
* Modifies input config
*
@@ -32,7 +45,6 @@ public function modify(array $config)
*
* @param array $argument
* @param array $preferences
- * @return array
*/
private function resolvePreferences(&$argument, &$preferences)
{
@@ -41,14 +53,12 @@ private function resolvePreferences(&$argument, &$preferences)
}
foreach ($argument as $key => &$value) {
- if (in_array($key, ['_i_', '_ins_'], true)) {
+ if (isset(self::RECURSIVE_ARGUMENT_KEYS[$key])) {
$value = $this->resolvePreferenceRecursive($value, $preferences);
continue;
}
- if (is_array($value)) {
- $this->resolvePreferences($value, $preferences);
- }
+ $this->resolvePreferences($value, $preferences);
}
}
diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php
index 353e15d2da5d..9d431c30f001 100644
--- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php
+++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php
@@ -15,6 +15,7 @@
/**
* Class Reader
+ *
* @package Magento\Setup\Module\Di\Compiler\Config
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
@@ -84,7 +85,7 @@ public function generateCachePerScope(
}
$config = [];
-
+
$this->fillThirdPartyInterfaces($areaConfig, $definitionsCollection);
$config['arguments'] = $this->getConfigForScope($definitionsCollection, $areaConfig);
@@ -113,11 +114,10 @@ private function getConfigForScope(DefinitionsCollection $definitionsCollection,
{
$constructors = [];
$argumentsResolver = $this->argumentsResolverFactory->create($config);
- foreach ($definitionsCollection->getInstancesNamesList() as $instanceType) {
+ foreach ($definitionsCollection->getCollection() as $instanceType => $constructor) {
if (!$this->typeReader->isConcrete($instanceType)) {
continue;
}
- $constructor = $definitionsCollection->getInstanceArguments($instanceType);
$constructors[$instanceType] = $argumentsResolver->getResolvedConstructorArguments(
$instanceType,
$constructor
@@ -151,14 +151,9 @@ private function getConfigForScope(DefinitionsCollection $definitionsCollection,
*/
private function fillThirdPartyInterfaces(ConfigInterface $config, DefinitionsCollection $definitionsCollection)
{
- $definedInstances = $definitionsCollection->getInstancesNamesList();
-
- foreach (array_keys($config->getPreferences()) as $interface) {
- if (in_array($interface, $definedInstances)) {
- continue;
- }
-
- $definitionsCollection->addDefinition($interface, []);
- }
+ $definedInstances = $definitionsCollection->getCollection();
+ $newInstances = array_fill_keys(array_keys($config->getPreferences()), []);
+ $newCollection = array_merge($newInstances, $definedInstances);
+ $definitionsCollection->initialize($newCollection);
}
}