PageSourceSearch

https://www.thechilicool.com/wp-content/plugins/shopbop-widget/js/…?where=blog&modified=20190802&ver=6.0.16

js thechilicool.com collected 2026-10-02 10:31:00 UTC 7,780 bytes, 231 lines download raw bytes

1var SWJquery = jQuery;
2SWJquery(function($) {
3   
4	initShopbop();
5
6	function initShopbop(){
7		moveForcedLocation();
8		checkParentWidth(); 
9		reInitCarousel();
10		loadExternal();
11	}
12
13	function moveForcedLocation() {
14		$('.shopbop-core-widget--temp-location').each(function() {
15			$widget = $(this);
16			var target = $widget.data('forcelocation');
17			if(target && target.indexOf(':') > 1) {
18				target = target.split(':');
19				var $target = $(target[0]);
20				if($target && $target.length > 0) {
21					if(target[1] == 'after') {
22						$widget.detach().appendTo($target)
23					}
24					else {
25						$widget.detach().prependTo($target)
26					}
27				}
28				$widget.removeClass('shopbop-core-widget--temp-location');
29			}
30		});
31	}
32
33	function loadExternal()
34	{
35		var removeLoader = function()
36		{
37			SWJquery(".shopbop-widget-loading-bg").fadeOut(300, function() { $(this).remove(); });
38		};
39
40		SWJquery(".shopbop-widget-wrapper").css({visibility:"visible"});
41
42		var lang = SWJquery(".shopbop-core-widget:eq(0)").data("lang");
43		SWJquery.get(location.protocol+"//widgetcontent-shopbop.stickyhosting.co.uk/3.1/promotion-"+lang+".json?_=" + new Date().getTime(), function(data){
44			if(data && data.text) {
45				SWJquery(".shopbop-widget-feature").html(data.text);
46			}
47			SWJquery.get(location.protocol+"//widgetcontent-shopbop.stickyhosting.co.uk/3.1/marketing-"+lang+".json?_=" + new Date().getTime(), function(data){
48				if(data && data.text) {
49					SWJquery(".shopbop-widget-marketing-message").html(data.text);
50				}
51			}).always(removeLoader);
52		}).always(removeLoader);
53	}
54
55	function reInitCarousel(){
56		checkParentWidth();
57
58		var widget_index = 1;
59
60		SWJquery('.shopbop-core-widget .shopbop-widget-carousel').each(function(){
61			var root = SWJquery(this);
62
63			var totalLinks   = root.find('ul>li').length;
64			var visibleLinks = root.find('ul').carouFredSel().triggerHandler("configuration", "items.visible");
65
66			if (root.parent().parent().parent().parent().has('shopbop-mobile')) {
67				var widgetWidth  = root.width();
68			} else {
69				var widgetWidth  = root.parent().width() - 300;
70			}
71
72			root.attr('id', 'shopbop-widget-' + widget_index);
73			root.find('ul').carouFredSel({
74			
75				prev : '#shopbop-widget-' + widget_index + ' .shopbop-widget-carousel-prev',
76				next : '#shopbop-widget-' + widget_index + ' .shopbop-widget-carousel-next',
77				pagination : '#shopbop-widget-' + widget_index + ' .shopbop-widget-carousel-pager',
78				
79				circular : false,
80				infinite: true,
81				auto: false,
82				height : 250,
83				width: widgetWidth,
84				align: "center",
85				scroll:
86				{
87					easing: 'swing'
88				},
89
90				debug: false
91			});
92
93			widget_index++;
94		});
95
96		// add close button to content panes for mobile sized widgets
97		SWJquery('.shopbop-core-widget').not('.shopbob-bp--small').each(function(i, v) {
98			$panes = SWJquery(v).find('.shopbop-content-pane');
99			if ($panes.find('.close-pane').length == 0) {
100				$panes.each(function (index, value) {
101					// create the close button
102					var value = SWJquery(value);
103					var closeButton = document.createElement("div");
104					closeButton.setAttribute("class", "close-pane");
105					value.append(closeButton);
106
107					SWJquery(closeButton).on('click', function(evt) {
108						SWJquery(v).find('.shopbop-widget-header__nav a').removeClass('selected');
109						SWJquery(evt.srcElement).closest('.shopbop-content-pane').removeClass('shopbop-active-pane');
110						value.closest('.shopbop-widget-body').removeClass('shopbob--showing-slider');
111					});
112				});
113			}
114		});
115
116		// remove close button from content panes for non mobile sized widgets
117		SWJquery('.shopbop-core-widget.shopbob-bp--small').each(function(i, v){
118			$panes = SWJquery(v).find('.shopbop-content-pane .close-pane');
119			if ($panes.length > 0) {
120				$panes.remove();
121			}
122
123			// if no category is selected, select the first pane by default
124			// this occurs when the pane is closed and then resized to
125			// horizontal mode
126			if (SWJquery(v).find('.shopbop-widget-header__nav a.selected').length == 0) {
127				selectFirstPane(  SWJquery(v).closest('.shopbop-core-widget') );
128			}
129		});
130	}
131
132	//Element query
133	function checkParentWidth(){
134		SWJquery('.shopbop-core-widget').each(function(i, v) {
135			var widget = SWJquery(v);
136			var parentWidth = Math.floor(widget.outerWidth());
137			var sizeClass = 'large';
138			var size = [{'NAME':'shopbop-large', 'SIZE':99999},
139						{'NAME':'shopbop-medium','SIZE':1024},
140						{'NAME':'shopbop-small', 'SIZE':550},
141						{'NAME':'shopbop-mobile','SIZE':500},
142						{'NAME':'shopbop-mini','SIZE':201}
143					];
144
145			SWJquery.each(size, function( index, value ) {
146				widget.removeClass(value.NAME);
147				if(parentWidth < value.SIZE){
148					sizeClass = value.NAME;
149				}
150			});
151
152			var breakpoints = {
153				'shopbob-bp--small': 600,
154				'shopbob-bp--medium': 850,
155				'shopbob-bp--large': 960,
156			};
157			$.each(breakpoints, function( index, value ) {
158				widget.toggleClass(index, parentWidth >= value);
159			});
160
161			widget.addClass(sizeClass);
162
163			if( sizeClass != 'shopbop-mobile' ) {
164				if (!widget.hasClass('shopbop-auto')) {
165					selectFirstPane(widget);
166				}
167			}
168		});
169	}
170
171	SWJquery( window ).resize(function() {
172		reInitCarousel();
173	});
174
175	//Hides the
176	SWJquery('.shopbop-core-widget').mouseleave(function(){
177		//SWJquery('.shopbop-core-widget .shopbop-widget-carousel-next').hide();
178		//SWJquery('.shopbop-core-widget .shopbop-widget-carousel-prev').hide();
179	});
180
181	SWJquery('.shopbop-core-widget').mouseenter(function(){
182		//SWJquery('.shopbop-core-widget .shopbop-widget-carousel-next').fadeIn("slow").show();
183		//SWJquery('.shopbop-core-widget .shopbop-widget-carousel-prev').fadeIn("slow").show();
184	});
185
186	//Navigation button
187	SWJquery('.shopbop-core-widget a.shopbop-pane-button').click(function(event){
188		event.preventDefault();
189		toggleWidgetPanels( this );
190	});
191
192	function toggleWidgetPanels( el ){
193		var panel = SWJquery(el).data('shopbop-panel');
194		var $widget = SWJquery(el).closest('.shopbop-core-widget');
195
196		SWJquery(el).closest( '.shopbop-widget-header__nav' ).find('a').removeClass('selected');
197		SWJquery(el).addClass('selected');
198
199		$widget.find('.shopbop-content-pane').removeClass('shopbop-active-pane');
200		$widget.find('.shopbop-widget-'+panel).addClass('shopbop-active-pane');
201		$widget.find('.shopbop-widget-body').addClass('shopbob--showing-slider');
202
203		reInitCarousel();
204	}
205
206	function selectFirstPane( el ){
207	
208		SWJquery(el).addClass('shopbop-auto');
209		SWJquery('.shopbop-auto a.shopbop-pane-button1').addClass('selected');
210		SWJquery('.shopbop-auto .shopbop-widget-panel1').addClass('shopbop-active-pane');
211		SWJquery(el).closest('.shopbop-core-widget').find('.shopbop-widget-body').addClass('shopbob--showing-slider');
212	}
213
214	// SHOW DESCRIPTION FOR ITEMS
215	SWJquery('.shopbop-core-widget .shopbop-widget-carousel li').mouseenter(function() {
216		var self = $(this);
217
218		self.closest('.shopbop-widget-carousel').find('li').removeClass('hovered').removeClass('not-hovered');
219		self.closest('li').addClass('hovered').siblings().addClass('not-hovered');
220	});
221
222	var box_keep_open = '.shopbop-core-widget .shopbop-widget-carousel li, .shopbop-core-widget .shopbop-widget-carousel-info';
223	SWJquery(box_keep_open).mouseleave(function(e) {
224		if(!SWJquery(e.relatedTarget).is(box_keep_open) && SWJquery(e.relatedTarget).closest(box_keep_open).length == 0) {          
225			$(this).closest('.shopbop-widget-carousel').find('.hovered').removeClass('hovered');
226			$(this).closest('.shopbop-widget-carousel').find('.not-hovered').removeClass('not-hovered');
227		}
228	});
229
230	SWJquery('.shopbop-widget-carousel-info').hide();
231});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.