Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <referenceBlock name="authentication-popup">
- <action method="setTemplate">
- <argument name="template" xsi:type="string">Company_Sso::account/ssologin-popup.phtml</argument>
- </action>
- <arguments>
- <argument name="jsLayout" xsi:type="array">
- <item name="components" xsi:type="array">
- <item name="ssoLogin" xsi:type="array">
- <item name="component" xsi:type="string">Company_Sso/js/view/ssologin-popup</item>
- <item name="children" xsi:type="array">
- <item name="messages" xsi:type="array">
- <item name="component" xsi:type="string">Magento_Ui/js/view/messages</item>
- <item name="displayArea" xsi:type="string">messages</item>
- </item>
- </item>
- </item>
- </item>
- </argument>
- </arguments>
- <div id="ssologin-popup" data-bind="scope:'ssoLogin'" style="display: none;">
- <script>
- window.ssoLogin = <?= /* @noEscape */ $block->getSerializedConfig() ?>;
- </script>
- <!-- ko template: getTemplate() --><!-- /ko -->
- <script type="text/x-magento-init">
- {
- "#ssologin-popup": {
- "Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
- }
- }
- </script>
- </div>
- define([
- 'jquery',
- 'ko',
- 'Magento_Ui/js/form/form',
- 'Magento_Customer/js/action/login',
- 'Magento_Customer/js/customer-data',
- 'Magento_Customer/js/model/authentication-popup',
- 'mage/translate',
- 'mage/url',
- 'mage/validation'
- ], function ($, ko, Component, loginAction, customerData, ssoLogin, $t, url) {
- 'use strict';
- return Component.extend({
- registerUrl: window.ssoLogin.customerRegisterUrl,
- forgotPasswordUrl: window.ssoLogin.customerForgotPasswordUrl,
- autocomplete: window.ssoLogin.autocomplete,
- modalWindow: null,
- isLoading: ko.observable(false),
- defaults: {
- template: 'Company_Sso/ssologin-popup'
- },
- /**
- * Init
- */
- initialize: function () {
- var self = this;
- this._super();
- url.setBaseUrl(window.ssoLogin.baseUrl);
- loginAction.registerLoginCallback(function () {
- self.isLoading(false);
- });
- },
- /** Init popup login window */
- setAjaxModelElement: function (element) {
- if (ssoLogin.modalWindow == null) {
- ssoLogin.createPopUp(element);
- }
- },
- /** Is login form enabled for current customer */
- isActive: function () {
- var customer = customerData.get('customer');
- return customer() == false; //eslint-disable-line eqeqeq
- },
- /** Show login popup window */
- showModal: function () {
- if (this.modalWindow) {
- $(this.modalWindow).modal('openModal');
- }
- },
- /**
- * Provide login action
- *
- * @return {Boolean}
- */
- login: function (formUiElement, event) {
- var loginData = {},
- formElement = $(event.currentTarget),
- formDataArray = formElement.serializeArray();
- event.stopPropagation();
- event.preventDefault();
- formDataArray.forEach(function (entry) {
- loginData[entry.name] = entry.value;
- });
- if (formElement.validation() &&
- formElement.validation('isValid')
- ) {
- this.isLoading(true);
- loginAction(loginData);
- }
- return false;
- }
- });
- });
- <div class="block-authentication"
- data-bind="afterRender: setModalElement, blockLoader: isLoading"
- style="display: none">
- hi hello
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement