Skip to content
Snippets Groups Projects
Commit da7fef94 authored by Denys Rul's avatar Denys Rul
Browse files

MAGETWO-32484: Stabilization of changes and bug fixing

- Change components initialization
parent bb21de7a
Branches
No related merge requests found
...@@ -25,24 +25,34 @@ $_paymentBlock = $this->getLayout()->getBlock('checkout.onepage.payment'); ...@@ -25,24 +25,34 @@ $_paymentBlock = $this->getLayout()->getBlock('checkout.onepage.payment');
</ol> </ol>
<script> <script>
require([ require([
"jquery", "underscore",
"mage/mage" "accordion",
], function($){ "opcOrderReview",
], function(_, accordion, opcOrderReview){
'use strict'; 'use strict';
$(document).ready(function() { /**
$('#checkoutSteps').mage('accordion',{ * @todo refactor opcCheckoutMethod
'collapsibleElement' : ' > li', *
'openedState' : 'active' * Initializiation of this components can't be moved to a data-mage-init attribute
}).mage('opcOrderReview', $.extend({ * due to dependencies between instances of opcCheckoutMethod and mage.accordion.
'checkoutAgreements': '#checkout-agreements', * Thus initializiation has to be synchronyous.
'checkoutProgressContainer': '#checkout-progress-wrapper', */
'methodDescription': '.items' var elem = document.getElementById('checkoutSteps'),
}, opcConfig;
<?php echo $this->helper('Magento\Core\Helper\Data')->jsonEncode($_paymentBlock->getOptions()); ?>
));
});
opcConfig = _.extend({
'checkoutAgreements': '#checkout-agreements',
'checkoutProgressContainer': '#checkout-progress-wrapper',
'methodDescription': '.items'
},<?php echo $this->helper('Magento\Core\Helper\Data')->jsonEncode($_paymentBlock->getOptions()); ?>);
accordion({
'collapsibleElement': ' > li',
'openedState': 'active'
}, elem);
opcOrderReview(opcConfig, elem);
}); });
</script> </script>
</div> </div>
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/*jshint jquery:true browser:true*/
define([
"jquery",
"jquery/ui"
], function($){
'use strict';
// mage.accordion base functionality
$.widget('mage.accordion', $.ui.accordion, {
options: {
heightStyle: 'content',
animate: false,
beforeActivate: function(e, ui) {
// Make sure sections below current are not clickable and sections above are clickable
var newPanelParent = $(ui.newPanel).parent();
if (!newPanelParent.hasClass('allow')) {
return false;
}
newPanelParent.addClass('active allow').prevAll().addClass('allow');
newPanelParent.nextAll().removeClass('allow');
$(ui.oldPanel).parent().removeClass('active');
}
},
/**
* Accordion creation
* @protected
*/
_create: function() {
// Custom to enable section
this.element.on('enableSection', function(event, data) {
$(data.selector).addClass('allow').find('h2').trigger('click');
});
this._super();
$(this.options.activeSelector).addClass('allow active').find('h2').trigger('click');
}
});
});
\ No newline at end of file
...@@ -10,7 +10,6 @@ define([ ...@@ -10,7 +10,6 @@ define([
"jquery", "jquery",
"jquery/ui", "jquery/ui",
"mage/validation/validation", "mage/validation/validation",
"Magento_Checkout/js/accordion",
"mage/translate" "mage/translate"
], function($){ ], function($){
'use strict'; 'use strict';
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment