Skip to content

Commit

Permalink
Merge pull request #284 from magento-vanilla/PR2
Browse files Browse the repository at this point in the history
[Vanilla] Bug fixes & tasks
  • Loading branch information
guz-anton committed Jan 24, 2016
2 parents 43e3fd7 + c44de40 commit 02d786b
Show file tree
Hide file tree
Showing 13 changed files with 492 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<?php $_divId = 'tree-div_' . time() ?>
<div id="<?php /* @escapeNotVerified */ echo $_divId ?>" class="tree"></div>
<script id="ie-deferred-loader" defer="defer" src=""></script>
<script id="ie-deferred-loader" defer="defer" src="//:"></script>
<script>
require([
'jquery',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<?php $_divId = 'tree' . $block->getId() ?>
<div id="<?php /* @escapeNotVerified */ echo $_divId ?>" class="tree"></div>
<!--[if IE]>
<script id="ie-deferred-loader" defer="defer" src=""></script>
<script id="ie-deferred-loader" defer="defer" src="//:"></script>
<![endif]-->
<script>
require(['jquery', "prototype", "extjs/ext-tree-checkbox"], function(jQuery){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<span class="title"><?php /* @escapeNotVerified */ echo __('Unassigned Attributes') ?></span>
</div>
<div id="tree-div2" class="attribute-set-tree"></div>
<script id="ie-deferred-loader" defer="defer" src=""></script>
<script id="ie-deferred-loader" defer="defer" src="//:"></script>
<script>
define("tree-panel",
[
Expand Down
103 changes: 103 additions & 0 deletions app/code/Magento/Ui/view/base/web/js/form/components/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'uiElement',
'uiRegistry',
'uiLayout',
'mageUtils'
], function (Element, registry, layout, utils) {
'use strict';

return Element.extend({
defaults: {
additionalClasses: {},
displayArea: 'outsideGroup',
displayAsLink: false,
elementTmpl: 'ui/form/element/button',
template: 'ui/form/components/button/simple'
},

/**
* Initializes component.
*
* @returns {Object} Chainable.
*/
initialize: function () {
return this._super()
._setClasses();
},

/**
* Performs configured actions
*/
action: function () {
this.actions.forEach(this.applyAction, this);
},

/**
* Apply action on target component,
* but previously create this component from template if it is not existed
*
* @param {Object} action - action configuration
*/
applyAction: function (action) {
var targetName = action.targetName,
params = action.params,
actionName = action.actionName,
target;

if (!registry.has(targetName)) {
this.getFromTemplate(targetName);
}
target = registry.async(targetName);

if (target && typeof target === 'function' && actionName) {
target(actionName, params);
}
},

/**
* Create target component from template
*
* @param {Object} targetName - name of component,
* that supposed to be a template and need to be initialized
*/
getFromTemplate: function (targetName) {
var parentName = targetName.split('.'),
index = parentName.pop(),
child;

parentName = parentName.join('.');
child = utils.template({
parent: parentName,
name: index,
nodeTemplate: targetName
});
layout([child]);
},

/**
* Extends 'additionalClasses' object.
*
* @returns {Object} Chainable.
*/
_setClasses: function () {
if (typeof this.additionalClasses === 'string') {
this.additionalClasses = this.additionalClasses
.trim()
.split(' ')
.reduce(function (classes, name) {
classes[name] = true;

return classes;
}, {}
);
}

return this;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ define([
}

if (owner.component !== target.component) {
value = utils.copy(value);
value = data.inversionValue ? !utils.copy(value) : utils.copy(value);
}

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

if (data.target.substr(0,1) === '!') {
data.target = data.target.substr(1);
data.inversionValue = true;
}

if (owner.name === data.target) {
args.unshift(owner);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ define([
onlyIfVisible: true
};

/**
* Checks if element sis visible.
*
* @param {Element} el
* @returns {Boolean}
*/
function isVisible(el) {
var style = window.getComputedStyle(el),
visibility = {
display: 'none',
visibility: 'hidden',
opacity: '0'
},
visible = true;

_.each(visibility, function (val, key) {
if (style[key] === val) {
visible = false;
}
});

return visible;
}

/**
* Document click handler which in case if event target is not
* a descendant of provided container element,
Expand All @@ -33,7 +57,7 @@ define([
}

if (config.onlyIfVisible) {
if (!_.isNull(container.offsetParent)) {
if (!_.isNull(container.offsetParent) && isVisible(container)) {
callback();
}
} else {
Expand Down
Loading

0 comments on commit 02d786b

Please sign in to comment.