Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.35 KB | None | 0 0
  1. var config = {
  2. config: {
  3. mixins: {
  4. 'Magento_Catalog/js/product-gallery': {
  5. 'Hs_Mageenhancement/js/product-gallery-mixin': true
  6. }
  7. }
  8. }
  9. };
  10.  
  11. define([
  12. 'jquery',
  13. 'underscore',
  14. 'mage/template',
  15. 'uiRegistry'
  16. ], function($, _, mageTemplate, registry){
  17. 'use strict';
  18. return function (widget) {
  19. $.widget('mage.productGallery', widget, {
  20. /**
  21. * Initializes dialog element.
  22. */
  23. _initDialog: function () {
  24. var $dialog = $(this.dialogContainerTmpl());
  25.  
  26. $dialog.modal({
  27. 'type': 'slide',
  28. title: $.mage.__('Image Detail'),
  29. buttons: [],
  30.  
  31. /** @inheritdoc */
  32. opened: function () {
  33. $dialog.trigger('open');
  34. },
  35.  
  36. /** @inheritdoc */
  37. closed: function () {
  38. $dialog.trigger('close');
  39. }
  40. });
  41.  
  42. $dialog.on('open', this.onDialogOpen.bind(this));
  43. $dialog.on('close', function () {
  44. var $imageContainer = $dialog.data('imageContainer');
  45.  
  46. $imageContainer.removeClass('active');
  47. $dialog.find('#hide-from-product-page').remove();
  48. });
  49.  
  50. $dialog.on('change', '[data-role=type-selector]', function () {
  51. var parent = $(this).closest('.item'),
  52. selectedClass = 'selected';
  53.  
  54. parent.toggleClass(selectedClass, $(this).prop('checked'));
  55. });
  56.  
  57. $dialog.on('change', '[data-role=type-selector]', $.proxy(this._notifyType, this));
  58.  
  59. $dialog.on('change', '[data-role=visibility-trigger]', $.proxy(function (e) {
  60. var imageData = $dialog.data('imageData');
  61.  
  62. this.element.trigger('updateVisibility', {
  63. disabled: $(e.currentTarget).is(':checked'),
  64. imageData: imageData
  65. });
  66. }, this));
  67.  
  68. $dialog.on('change', '[data-role="image-description"]', function (e) {
  69. var target = $(e.target),
  70. targetName = target.attr('name'),
  71. desc = target.val(),
  72. imageData = $dialog.data('imageData');
  73.  
  74. this.element.find('input[type="hidden"][name="' + targetName + '"]').val(desc);
  75.  
  76. imageData.label = desc;
  77. imageData['label_default'] = desc;
  78.  
  79. this.element.trigger('updateImageTitle', {
  80. imageData: imageData
  81. });
  82. }.bind(this));
  83.  
  84. $dialog.on('change', '[data-role=image-related-tire-price]', $.proxy(function (e) {
  85. var target = $(e.target),
  86. targetName = target.attr('name'),
  87. tirePriceQty = target.val(),
  88. imageData = $dialog.data('imageData');
  89.  
  90. this.element.find('input[type="hidden"][name="' + targetName + '"]').val(tirePriceQty);
  91. }, this));
  92.  
  93. this.$dialog = $dialog;
  94. }
  95. });
  96. return $.mage.productGallery;
  97. }
  98. });
  99.  
  100. <script>
  101. require(
  102. [
  103. 'jquery',
  104. 'Magento_Ui/js/modal/modal'
  105. ],
  106. function(
  107. $,
  108. modal
  109. ) {
  110. var contactOptions = {
  111. type: 'popup',
  112. title: $.mage.__('Contact Us'),
  113. responsive: true,
  114. innerScroll: false,
  115. buttons: [{
  116. text: $.mage.__('Close'),
  117. class: '',
  118. click: function () {
  119. this.closeModal();
  120. }
  121. }]
  122. };
  123.  
  124. var contactPopup = modal(contactOptions, $('#contact-popup-mpdal'));
  125. $("#ContactUsModal").on('click',function(){
  126. $("#contact-popup-mpdal").modal("openModal");
  127. });
  128.  
  129. var pricePromiseOptions = {
  130. type: 'popup',
  131. title: $.mage.__('Price Match Promise Terms and Conditions'),
  132. responsive: true,
  133. innerScroll: false,
  134. buttons: [{
  135. text: $.mage.__('Close'),
  136. class: '',
  137. click: function () {
  138. this.closeModal();
  139. }
  140. }]
  141. };
  142.  
  143. var pricePromisePopup = modal(pricePromiseOptions, $('#price-promise-popup-mpdal'));
  144. $("#price_promise").on('click',function(){
  145. $("#price-promise-popup-mpdal").modal("openModal");
  146. });
  147.  
  148. var privacyPolicyOptions = {
  149. type: 'popup',
  150. title: $.mage.__('Privacy Policy'),
  151. responsive: true,
  152. innerScroll: false,
  153. buttons: [{
  154. text: $.mage.__('Close'),
  155. class: '',
  156. click: function () {
  157. this.closeModal();
  158. }
  159. }]
  160. };
  161.  
  162. var privacyPolicyPopup = modal(privacyPolicyOptions, $('#privacy-policy-popup-mpdal'));
  163. $("#privacy_policy").on('click',function(){
  164. $("#privacy-policy-popup-mpdal").modal("openModal");
  165. });
  166.  
  167. var cookiesPolicyOptions = {
  168. type: 'popup',
  169. title: $.mage.__('Cookie Policy'),
  170. responsive: true,
  171. innerScroll: false,
  172. buttons: [{
  173. text: $.mage.__('Close'),
  174. class: '',
  175. click: function () {
  176. this.closeModal();
  177. }
  178. }]
  179. };
  180.  
  181. var cookiesPolicyPopup = modal(cookiesPolicyOptions, $('#cookie-policy-popup-mpdal'));
  182. $("#cookies_policy").on('click',function(){
  183. $("#cookie-policy-popup-mpdal").modal("openModal");
  184. });
  185.  
  186. var termsConditionOptions = {
  187. type: 'popup',
  188. title: $.mage.__('Terms and Conditions'),
  189. responsive: true,
  190. innerScroll: false,
  191. buttons: [{
  192. text: $.mage.__('Close'),
  193. class: '',
  194. click: function () {
  195. this.closeModal();
  196. }
  197. }]
  198. };
  199.  
  200. var termsConditionPopup = modal(termsConditionOptions, $('#terms-condition-popup-mpdal'));
  201. $("#TermsCondiModal").on('click',function(){
  202. $("#terms-condition-popup-mpdal").modal("openModal");
  203. });
  204.  
  205. }
  206. );
  207. </script>
  208.  
  209. <script>
  210. require(
  211. [
  212. 'jquery',
  213. 'Magento_Ui/js/modal/modal',
  214. 'mage/validation'
  215. ],
  216. function(
  217. $,
  218. modal
  219. ) {
  220. jQuery(document).ready(function(){
  221. var options = {
  222. type: 'popup',
  223. title: $.mage.__('All Reviews'),
  224. responsive: true,
  225. innerScroll: false,
  226. buttons: [{
  227. text: $.mage.__('Close'),
  228. class: '',
  229. click: function () {
  230. this.closeModal();
  231. }
  232. }]
  233. };
  234.  
  235. var popup = modal(options, $('#list-review-popup-mpdal'));
  236. jQuery("#ListReview").on('click',function(){
  237. jQuery("#list-review-popup-mpdal").modal("openModal");
  238. });
  239.  
  240. var reviewFormOptions = {
  241. type: 'popup',
  242. title: $.mage.__('Write a Review'),
  243. responsive: true,
  244. innerScroll: true,
  245. buttons: [{
  246. text: $.mage.__('Close'),
  247. class: '',
  248. click: function () {
  249. this.closeModal();
  250. }
  251. }]
  252. };
  253.  
  254. var reviewFormPopup = modal(reviewFormOptions, $('#submit-review-popup-mpdal'));
  255. jQuery("#SubmitReview").on('click',function(){
  256. jQuery("#submit-review-popup-mpdal").modal("openModal");
  257. });
  258.  
  259. var dataForm = $('#review-form');
  260. dataForm.mage('validation', {});
  261. jQuery('body').on('click', '#review-form .action.submit', function(e){
  262. e.preventDefault();
  263. e.stopImmediatePropagation();
  264. if(dataForm.validation('isValid')) {
  265. jQuery.ajax({
  266. type: 'post',
  267. url: jQuery('#review-form').attr('action'),
  268. data: jQuery('#review-form').serialize(),
  269. cache: false,
  270. showLoader: 'true',
  271. success: function(response) {
  272. var message = response.message;
  273. if(response.success) {
  274. jQuery('#feedback_review').removeClass('error-msg');
  275. jQuery('#feedback_review').addClass('Succ-msg');
  276. } else {
  277. jQuery('#feedback_review').removeClass('Succ-msg');
  278. jQuery('#feedback_review').addClass('error-msg');
  279. }
  280. jQuery('#feedback_review').html(message).show();
  281. }
  282. });
  283. }
  284. return false;
  285. });
  286.  
  287. });
  288. }
  289. );
  290. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement