Skip to content

Commit c88ba31

Browse files
author
Denys Rul
committed
MAGETWO-32484: Stabilization of changes and bug fixing
- Rebuild legacy-build.min file using yui compressor
1 parent 46d72da commit c88ba31

File tree

7 files changed

+118
-57
lines changed

7 files changed

+118
-57
lines changed

Gruntfile.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module.exports = function (grunt) {
1111
// Require
1212
// --------------------------------------
1313

14+
require('./dev/tools/grunt/tasks/mage-minify')(grunt);
15+
1416
// Time how long tasks take. Can help when optimizing build times
1517
require('time-grunt')(grunt);
1618

@@ -136,13 +138,15 @@ module.exports = function (grunt) {
136138
}
137139
},
138140

139-
uglify: {
141+
'mage-minify': {
140142
legacy: {
141143
options: {
142-
mangle: false
144+
type: 'yui-js',
145+
tempPath: 'var/cache/'
143146
},
144147
files: {
145148
'<%= config.path.uglify.legacy %>': [
149+
'lib/web/prototype/prototype.js',
146150
'lib/web/prototype/window.js',
147151
'lib/web/scriptaculous/builder.js',
148152
'lib/web/scriptaculous/effects.js',
@@ -162,7 +166,7 @@ module.exports = function (grunt) {
162166
* Mostly prototype dependant libraries.
163167
*/
164168
grunt.registerTask('legacy-build', [
165-
'uglify:legacy'
169+
'mage-minify:legacy'
166170
]);
167171

168172
// Default task

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
99
<head>
1010
<title>Magento Admin</title>
11-
<link src="prototype/prototype.js"/>
1211
<link src="legacy-build.min.js"/>
1312
<link src="requirejs/require.js"/>
14-
<link src="mage/requirejs/resolver.js"/>
1513
<link src="jquery.js"/>
1614
<css src="mage/calendar.css"/>
1715
<css src="extjs/resources/css/ext-all.css"/>

app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
/* @var $this \Magento\ConfigurableProduct\Block\Product\Configurable\AttributeSelector */
77
?>
88
<script>
9-
(function($){
9+
(function(){
10+
'use strict';
11+
1012
var $form;
1113

1214
require([
1315
"jquery",
1416
"jquery/ui",
1517
"Magento_ConfigurableProduct/catalog/product-variation"
1618
], function($){
17-
'use strict';
18-
1919
$form = $('#affected-attribute-set-form');
2020

2121
var resetValidation = function() {
@@ -98,37 +98,43 @@
9898
}
9999
});
100100
});
101+
102+
require([
103+
'jquery'
104+
], function ($) {
101105

102-
/**
103-
* This fix was made in order to properly handle 'stopImmediatePropagation'.
104-
*/
105-
$('#save-split-button .item').on('click', function(event) {
106-
if ($('#new-variations-attribute-set-id').val() != '') {
107-
return; // affected attribute set was already chosen
108-
}
106+
/**
107+
* This fix was made in order to properly handle 'stopImmediatePropagation'.
108+
*/
109+
$('#save-split-button .item').on('click', function(event) {
110+
if ($('#new-variations-attribute-set-id').val() != '') {
111+
return; // affected attribute set was already chosen
112+
}
109113

110-
var extendingAttributes = [];
114+
var extendingAttributes = [];
111115

112-
$.each($('#configurable-attributes-container').variationsAttributes('getAttributes'), function () {
113-
if (!$('#attribute-' + this.code + '-container').length) {
114-
extendingAttributes.push(this.id);
116+
$.each($('#configurable-attributes-container').variationsAttributes('getAttributes'), function () {
117+
if (!$('#attribute-' + this.code + '-container').length) {
118+
extendingAttributes.push(this.id);
119+
}
120+
});
121+
if (!extendingAttributes.length) {
122+
$('#new-variations-attribute-set-id').val($('#attribute_set_id').val());
123+
return; // all selected configurable attributes belong to current attribute set
124+
}
125+
if (!$('[data-role=product-variations-matrix] [data-column=entity_id]:checked')
126+
.closest('tr').has('input[name$="[name]"]').length
127+
) {
128+
return; // no new simple products to save from matrix: uniting attribute set is not needed
115129
}
116-
});
117-
if (!extendingAttributes.length) {
118-
$('#new-variations-attribute-set-id').val($('#attribute_set_id').val());
119-
return; // all selected configurable attributes belong to current attribute set
120-
}
121-
if (!$('[data-role=product-variations-matrix] [data-column=entity_id]:checked')
122-
.closest('tr').has('input[name$="[name]"]').length
123-
) {
124-
return; // no new simple products to save from matrix: uniting attribute set is not needed
125-
}
126130

127-
event.stopImmediatePropagation();
131+
event.stopImmediatePropagation();
132+
133+
$form.data('target', event.target)
134+
.dialog('open');
135+
});
128136

129-
$form.data('target', event.target)
130-
.dialog('open');
131137
});
132138

133-
})(jQuery);
139+
})();
134140
</script>

dev/tools/grunt/tasks/mage-minify.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
module.exports = function (grunt) {
6+
'use strict';
7+
8+
var compressor = require('node-minify'),
9+
_ = require('underscore');
10+
11+
/**
12+
* Helper function used to create config object for compressor.
13+
*
14+
* @param {Object} options - Options object for a current task.
15+
* @param {Object} file - File object with 'sorce' and 'destination' properties.
16+
* @return {Object} Config object for compressor.
17+
*/
18+
function getConfig(options, file) {
19+
return _.extend({
20+
fileIn: file.src,
21+
fileOut: file.dest
22+
}, options);
23+
}
24+
25+
grunt.registerMultiTask('mage-minify', 'Minify files with a various compressor engines', function () {
26+
var done = this.async(),
27+
files = this.files,
28+
total = files.length,
29+
options = this.options();
30+
31+
this.files.forEach(function (file, i) {
32+
var config = getConfig(options, file);
33+
34+
/**
35+
* Callback function.
36+
*/
37+
config.callback = function (err) {
38+
if (err) {
39+
done(false);
40+
} else if (i === total - 1) {
41+
done();
42+
}
43+
};
44+
45+
new compressor.minify(config);
46+
});
47+
});
48+
};

lib/web/legacy-build.min.js

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/web/mage/backend/button.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
*/
55
/*global require:true*/
66
(function (factory) {
7+
'use strict';
8+
79
if (typeof define === 'function' && define.amd) {
810
define([
9-
"jquery",
10-
"jquery/ui"
11+
'jquery',
12+
'jquery/ui',
13+
'mage/requirejs/resolver'
1114
], factory);
1215
} else {
1316
factory(jQuery);
1417
}
1518
}(function ($) {
1619
'use strict';
17-
20+
1821
var resolver = require && require.resolver;
1922

2023
$.widget('ui.button', $.ui.button, {
@@ -27,7 +30,7 @@
2730
* Button creation.
2831
* @protected
2932
*/
30-
_create: function() {
33+
_create: function () {
3134
if (this.options.event) {
3235
this.options.target = this.options.target || this.element;
3336
this._bind();
@@ -39,53 +42,50 @@
3942
* Bind handler on button click.
4043
* @protected
4144
*/
42-
_bind: function() {
45+
_bind: function () {
4346
var waitTillResolved = this.options.waitTillResolved,
4447
handler = !waitTillResolved || !resolver ? this._click : this._proxyClick;
4548

4649
this.element
47-
.off( 'click.button' )
48-
.on( 'click.button', $.proxy(handler, this) );
50+
.off('click.button')
51+
.on('click.button', $.proxy(handler, this));
4952
},
5053

5154
/**
5255
* Button click handler.
5356
* @protected
5457
*/
55-
_click: function(){
58+
_click: function () {
5659
var options = this.options;
5760

5861
$(options.target).trigger(options.event, [options.eventData]);
5962
},
6063

6164
/**
6265
* Proxy button click handler that might postpone the event
63-
* untill all of the rjs dependencies will be resolved.
66+
* untill all of the rjs dependencies will be resolved.
6467
* @protected
6568
*/
66-
_proxyClick: function(){
67-
var options = this.options;
68-
69-
if( resolver.resolved ){
69+
_proxyClick: function () {
70+
if (resolver.resolved) {
7071
this._click();
71-
}
72-
else if( !resolver.hasListeners('spinnerCover') ){
72+
} else if (!resolver.hasListeners('spinnerCover')) {
7373
$('body').trigger('processStart');
7474

75-
resolver.on('spinnerCover', $.proxy(this._onResolve, this) );
75+
resolver.on('spinnerCover', $.proxy(this._onResolve, this));
7676
}
7777
},
7878

7979
/**
8080
* Callback of the rjs resolver 'onAllResolved' event.
8181
* @protected
8282
*/
83-
_onResolve: function(){
83+
_onResolve: function () {
8484
$('body').trigger('processStop');
8585

8686
this._click();
8787
}
8888
});
89-
89+
9090
return $.ui.button;
9191
}));

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
"grunt-contrib-clean": "^0.6.0",
77
"grunt-contrib-less": "^0.12.0",
88
"grunt-contrib-watch": "^0.6.1",
9-
"grunt-contrib-uglify": "^0.7.0",
109
"grunt-styledocco": "^0.1.4",
1110
"load-grunt-tasks": "^1.0.0",
12-
"time-grunt": "^1.0.0"
11+
"time-grunt": "^1.0.0",
12+
"underscore": "^1.7.0",
13+
"node-minify": "^1.0.1"
1314
},
1415
"engines": {
1516
"node": ">=0.10.0"

0 commit comments

Comments
 (0)