Skip to content

Commit 02d786b

Browse files
committed
Merge pull request #284 from magento-vanilla/PR2
[Vanilla] Bug fixes & tasks
2 parents 43e3fd7 + c44de40 commit 02d786b

File tree

13 files changed

+492
-10
lines changed

13 files changed

+492
-10
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<?php $_divId = 'tree-div_' . time() ?>
1212
<div id="<?php /* @escapeNotVerified */ echo $_divId ?>" class="tree"></div>
13-
<script id="ie-deferred-loader" defer="defer" src=""></script>
13+
<script id="ie-deferred-loader" defer="defer" src="//:"></script>
1414
<script>
1515
require([
1616
'jquery',

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<?php $_divId = 'tree' . $block->getId() ?>
1212
<div id="<?php /* @escapeNotVerified */ echo $_divId ?>" class="tree"></div>
1313
<!--[if IE]>
14-
<script id="ie-deferred-loader" defer="defer" src=""></script>
14+
<script id="ie-deferred-loader" defer="defer" src="//:"></script>
1515
<![endif]-->
1616
<script>
1717
require(['jquery', "prototype", "extjs/ext-tree-checkbox"], function(jQuery){

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<span class="title"><?php /* @escapeNotVerified */ echo __('Unassigned Attributes') ?></span>
3939
</div>
4040
<div id="tree-div2" class="attribute-set-tree"></div>
41-
<script id="ie-deferred-loader" defer="defer" src=""></script>
41+
<script id="ie-deferred-loader" defer="defer" src="//:"></script>
4242
<script>
4343
define("tree-panel",
4444
[
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'uiElement',
8+
'uiRegistry',
9+
'uiLayout',
10+
'mageUtils'
11+
], function (Element, registry, layout, utils) {
12+
'use strict';
13+
14+
return Element.extend({
15+
defaults: {
16+
additionalClasses: {},
17+
displayArea: 'outsideGroup',
18+
displayAsLink: false,
19+
elementTmpl: 'ui/form/element/button',
20+
template: 'ui/form/components/button/simple'
21+
},
22+
23+
/**
24+
* Initializes component.
25+
*
26+
* @returns {Object} Chainable.
27+
*/
28+
initialize: function () {
29+
return this._super()
30+
._setClasses();
31+
},
32+
33+
/**
34+
* Performs configured actions
35+
*/
36+
action: function () {
37+
this.actions.forEach(this.applyAction, this);
38+
},
39+
40+
/**
41+
* Apply action on target component,
42+
* but previously create this component from template if it is not existed
43+
*
44+
* @param {Object} action - action configuration
45+
*/
46+
applyAction: function (action) {
47+
var targetName = action.targetName,
48+
params = action.params,
49+
actionName = action.actionName,
50+
target;
51+
52+
if (!registry.has(targetName)) {
53+
this.getFromTemplate(targetName);
54+
}
55+
target = registry.async(targetName);
56+
57+
if (target && typeof target === 'function' && actionName) {
58+
target(actionName, params);
59+
}
60+
},
61+
62+
/**
63+
* Create target component from template
64+
*
65+
* @param {Object} targetName - name of component,
66+
* that supposed to be a template and need to be initialized
67+
*/
68+
getFromTemplate: function (targetName) {
69+
var parentName = targetName.split('.'),
70+
index = parentName.pop(),
71+
child;
72+
73+
parentName = parentName.join('.');
74+
child = utils.template({
75+
parent: parentName,
76+
name: index,
77+
nodeTemplate: targetName
78+
});
79+
layout([child]);
80+
},
81+
82+
/**
83+
* Extends 'additionalClasses' object.
84+
*
85+
* @returns {Object} Chainable.
86+
*/
87+
_setClasses: function () {
88+
if (typeof this.additionalClasses === 'string') {
89+
this.additionalClasses = this.additionalClasses
90+
.trim()
91+
.split(' ')
92+
.reduce(function (classes, name) {
93+
classes[name] = true;
94+
95+
return classes;
96+
}, {}
97+
);
98+
}
99+
100+
return this;
101+
}
102+
});
103+
});

app/code/Magento/Ui/view/base/web/js/lib/core/element/links.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ define([
5151
}
5252

5353
if (owner.component !== target.component) {
54-
value = utils.copy(value);
54+
value = data.inversionValue ? !utils.copy(value) : utils.copy(value);
5555
}
5656

5757
component.set(property, value);
@@ -149,6 +149,11 @@ define([
149149
function transfer(owner, data) {
150150
var args = _.toArray(arguments);
151151

152+
if (data.target.substr(0,1) === '!') {
153+
data.target = data.target.substr(1);
154+
data.inversionValue = true;
155+
}
156+
152157
if (owner.name === data.target) {
153158
args.unshift(owner);
154159

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/outer_click.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@ define([
1515
onlyIfVisible: true
1616
};
1717

18+
/**
19+
* Checks if element sis visible.
20+
*
21+
* @param {Element} el
22+
* @returns {Boolean}
23+
*/
24+
function isVisible(el) {
25+
var style = window.getComputedStyle(el),
26+
visibility = {
27+
display: 'none',
28+
visibility: 'hidden',
29+
opacity: '0'
30+
},
31+
visible = true;
32+
33+
_.each(visibility, function (val, key) {
34+
if (style[key] === val) {
35+
visible = false;
36+
}
37+
});
38+
39+
return visible;
40+
}
41+
1842
/**
1943
* Document click handler which in case if event target is not
2044
* a descendant of provided container element,
@@ -33,7 +57,7 @@ define([
3357
}
3458

3559
if (config.onlyIfVisible) {
36-
if (!_.isNull(container.offsetParent)) {
60+
if (!_.isNull(container.offsetParent) && isVisible(container)) {
3761
callback();
3862
}
3963
} else {

0 commit comments

Comments
 (0)