Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. <referenceBlock name="authentication-popup">
  2. <action method="setTemplate">
  3. <argument name="template" xsi:type="string">Company_Sso::account/ssologin-popup.phtml</argument>
  4. </action>
  5. <arguments>
  6. <argument name="jsLayout" xsi:type="array">
  7. <item name="components" xsi:type="array">
  8. <item name="ssoLogin" xsi:type="array">
  9. <item name="component" xsi:type="string">Company_Sso/js/view/ssologin-popup</item>
  10. <item name="children" xsi:type="array">
  11. <item name="messages" xsi:type="array">
  12. <item name="component" xsi:type="string">Magento_Ui/js/view/messages</item>
  13. <item name="displayArea" xsi:type="string">messages</item>
  14. </item>
  15. </item>
  16. </item>
  17. </item>
  18. </argument>
  19. </arguments>
  20.  
  21. <div id="ssologin-popup" data-bind="scope:'ssoLogin'" style="display: none;">
  22. <script>
  23. window.ssoLogin = <?= /* @noEscape */ $block->getSerializedConfig() ?>;
  24. </script>
  25. <!-- ko template: getTemplate() --><!-- /ko -->
  26. <script type="text/x-magento-init">
  27. {
  28. "#ssologin-popup": {
  29. "Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
  30. }
  31. }
  32. </script>
  33. </div>
  34.  
  35. define([
  36. 'jquery',
  37. 'ko',
  38. 'Magento_Ui/js/form/form',
  39. 'Magento_Customer/js/action/login',
  40. 'Magento_Customer/js/customer-data',
  41. 'Magento_Customer/js/model/authentication-popup',
  42. 'mage/translate',
  43. 'mage/url',
  44. 'mage/validation'
  45. ], function ($, ko, Component, loginAction, customerData, ssoLogin, $t, url) {
  46. 'use strict';
  47.  
  48. return Component.extend({
  49. registerUrl: window.ssoLogin.customerRegisterUrl,
  50. forgotPasswordUrl: window.ssoLogin.customerForgotPasswordUrl,
  51. autocomplete: window.ssoLogin.autocomplete,
  52. modalWindow: null,
  53. isLoading: ko.observable(false),
  54.  
  55. defaults: {
  56. template: 'Company_Sso/ssologin-popup'
  57. },
  58.  
  59. /**
  60. * Init
  61. */
  62. initialize: function () {
  63. var self = this;
  64.  
  65. this._super();
  66.  
  67. url.setBaseUrl(window.ssoLogin.baseUrl);
  68. loginAction.registerLoginCallback(function () {
  69. self.isLoading(false);
  70. });
  71. },
  72.  
  73. /** Init popup login window */
  74. setAjaxModelElement: function (element) {
  75. if (ssoLogin.modalWindow == null) {
  76. ssoLogin.createPopUp(element);
  77. }
  78. },
  79.  
  80. /** Is login form enabled for current customer */
  81. isActive: function () {
  82. var customer = customerData.get('customer');
  83.  
  84. return customer() == false; //eslint-disable-line eqeqeq
  85. },
  86.  
  87. /** Show login popup window */
  88. showModal: function () {
  89. if (this.modalWindow) {
  90. $(this.modalWindow).modal('openModal');
  91. }
  92. },
  93.  
  94. /**
  95. * Provide login action
  96. *
  97. * @return {Boolean}
  98. */
  99. login: function (formUiElement, event) {
  100. var loginData = {},
  101. formElement = $(event.currentTarget),
  102. formDataArray = formElement.serializeArray();
  103.  
  104. event.stopPropagation();
  105. event.preventDefault();
  106.  
  107. formDataArray.forEach(function (entry) {
  108. loginData[entry.name] = entry.value;
  109. });
  110.  
  111. if (formElement.validation() &&
  112. formElement.validation('isValid')
  113. ) {
  114. this.isLoading(true);
  115. loginAction(loginData);
  116. }
  117.  
  118. return false;
  119. }
  120. });
  121. });
  122.  
  123. <div class="block-authentication"
  124. data-bind="afterRender: setModalElement, blockLoader: isLoading"
  125. style="display: none">
  126. hi hello
  127. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement