Skip to content

Commit

Permalink
Refactor JS code and added JS component file
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshsuhagiya authored and chirag-wagento committed Jun 5, 2018
1 parent 110ee75 commit 3994790
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
18 changes: 8 additions & 10 deletions app/code/Magento/Ui/view/base/templates/control/button/split.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</button>
<?php if ($block->hasSplit()): ?>
<button <?= $block->getToggleAttributesHtml() ?>>
<span>Select</span>
<span><?= /* @escapeNotVerified */ __('Select'); ?></span>
</button>

<?php if (!$block->getDisabled()): ?>
Expand All @@ -40,12 +40,10 @@
<?php endif; ?>
<?php endif; ?>
</div>

<script>
require(['jquery'], function ($) {
$('.actions-split')
.on('click.splitDefault', '.action-default', function () {
$(this).siblings('.dropdown-menu').find('.item-default').trigger('click');
});
});
</script>
<script type="text/x-magento-init">
{
".actions-split": {
"Magento_Ui/js/grid/controls/button/split": {}
}
}
</script>
17 changes: 17 additions & 0 deletions app/code/Magento/Ui/view/base/web/js/grid/controls/button/split.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'jquery'
], function ($) {
'use strict';

return function (data, element) {

$(element).on('click.splitDefault', '.action-default', function () {
$(this).siblings('.dropdown-menu').find('.item-default').trigger('click');
});
};
});

0 comments on commit 3994790

Please sign in to comment.