wickes-css2 2.98.0-develop.13 → 2.98.0-develop.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wickes-css2",
3
- "version": "2.98.0-develop.13",
3
+ "version": "2.98.0-develop.14",
4
4
  "description": "CSS and JS and page templates in use by Wickes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -108,7 +108,7 @@
108
108
  "branches": [
109
109
  "alt-master",
110
110
  {
111
- "name": "develop",
111
+ "name": "custom-tag/0.5.0-icons",
112
112
  "prerelease": "${name.replace(/^custom-tag\\//g, '')}"
113
113
  }
114
114
  ],
@@ -1,16 +1,67 @@
1
1
  $(document).ready(function () {
2
2
  Wick.OfferBanner = (function () {
3
3
  var offerBanner = $('.offer-banner')[0],
4
- offer;
4
+ offer;
5
5
 
6
- var init = function(){
6
+ var selectors = [
7
+ 'main > div > div > div:nth-child(1) > div > h1',
8
+ 'main > div.hybris-class > div > h1:nth-child(1)',
9
+ 'main > div.cartMessages',
10
+ 'main div.checkout-header',
11
+ 'main.my-account',
12
+ 'div.new-usp-container',
13
+ 'div.breadcrumbs'
14
+ ];
15
+
16
+ var targetContainers = ['main', 'div.new-usp-container', 'div.breadcrumbs'];
17
+
18
+ Wick.applyTopMarginIfBanner = function () {
19
+ if (!Wick.isTradePro) {
20
+ return;
21
+ }
22
+
23
+ if (!offerBanner) {
24
+ return;
25
+ }
26
+
27
+ let bannerHeight = $(offerBanner).outerHeight();
28
+
29
+ var containers = new Set();
30
+ var containersSelector = targetContainers.join(', ');
31
+
32
+ selectors.forEach(function (sel) {
33
+ var elements = $(sel);
34
+ if (!elements.length) return;
35
+
36
+ elements.each(function () {
37
+ var container = $(this).closest(containersSelector);
38
+ if (container.length) {
39
+ containers.add(container[0]);
40
+ }
41
+ });
42
+ });
43
+
44
+ var hasBreadcrumbs = Array.from(containers).some(el => $(el).is('div.breadcrumbs'));
45
+
46
+ if (hasBreadcrumbs) {
47
+ containers = new Set(
48
+ Array.from(containers).filter(el => $(el).is('div.breadcrumbs'))
49
+ );
50
+ }
51
+
52
+ containers.forEach(function (el) {
53
+ $(el).css('margin-top', bannerHeight + 'px');
54
+ });
55
+ }
56
+
57
+ var init = function () {
7
58
  offer = new Waypoint.Sticky({
8
59
  element: offerBanner
9
60
  });
10
61
  };
11
62
 
12
- var toggle = function(){
13
- if (offer){
63
+ var toggle = function () {
64
+ if (offer) {
14
65
  offer.destroy();
15
66
  offer = null;
16
67
  } else {
@@ -18,21 +69,19 @@ $(document).ready(function () {
18
69
  }
19
70
  };
20
71
 
21
- function handleResize(){o
22
- if (!offer){
72
+ function handleResize() {
73
+ if (!offer) {
23
74
  return;
24
75
  }
25
-
26
76
  var elHeight = offer.$element.outerHeight(true);
27
- if (elHeight !== offer.$wrapper.outerHeight(true)){
77
+ if (elHeight !== offer.$wrapper.outerHeight(true)) {
28
78
  offer.$wrapper.height(elHeight);
29
79
  }
30
- };
80
+ }
31
81
 
32
- var bindEvents = function(){
82
+ var bindEvents = function () {
33
83
  $(window).on('resize', handleResize);
34
84
  $(window).on('orientationchange', handleResize);
35
-
36
85
  $(document).on('mobileNav.toggle', toggle);
37
86
  };
38
87
 
@@ -40,13 +89,11 @@ $(document).ready(function () {
40
89
  return;
41
90
  }
42
91
 
43
- //Workaround for sticky banner functionality in IE
92
+ // Workaround for sticky banner functionality in IE
44
93
  function isIE() {
45
- ua = navigator.userAgent;
94
+ var ua = navigator.userAgent;
46
95
  /* MSIE used to detect old browsers and Trident used to newer ones*/
47
- var is_ie = ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
48
-
49
- return is_ie;
96
+ return ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
50
97
  }
51
98
 
52
99
  if (isIE()) {
@@ -54,6 +101,8 @@ $(document).ready(function () {
54
101
  bindEvents();
55
102
  }
56
103
 
104
+ Wick.applyTopMarginIfBanner();
105
+
57
106
  return offer;
58
107
  })();
59
108
  });