PageSourceSearch

https://palomasala.com/wp-content/themes/Impreza/framework/js/us.widgets.js?ver=3.4

js palomasala.com collected 2026-10-06 13:16:43 UTC 51,915 bytes, 1,710 lines download raw bytes

1/**
2 * UpSolution Shortcode: us_message
3 */
4(function($){
5	"use strict";
6
7	$.fn.usMessage = function(){
8		return this.each(function(){
9			var $this = $(this),
10				$closer = $this.find('.w-message-close');
11			$closer.click(function(){
12				$this.wrap('<div></div>');
13				var $wrapper = $this.parent();
14				$wrapper.css({overflow: 'hidden', height: $this.outerHeight(true)});
15				$wrapper.performCSSTransition({
16					height: 0
17				}, 400, function(){
18					$wrapper.remove();
19					$us.$canvas.trigger('contentChange');
20				}, 'cubic-bezier(.4,0,.2,1)');
21			});
22		});
23	};
24
25	$(function(){
26		$('.w-message').usMessage();
27	});
28})(jQuery);
29
30
31/**
32 * Focus for different kind of forms
33 */
34jQuery(function($){
35	$(document).on('focus', '.w-form-row-field input, .w-form-row-field textarea', function(){
36		$(this).closest('.w-form-row').addClass('focused');
37	});
38	$(document).on('blur', '.w-form-row-field input, .w-form-row-field textarea', function(){
39		$(this).closest('.w-form-row').removeClass('focused');
40	});
41});
42
43
44/**
45 * UpSolution Widget: w-dropdown
46 */
47(function($){
48	"use strict";
49	$.fn.wDropdown = function(){
50		return this.each(function(){
51			var $this = $(this),
52				$list = $this.find('.w-dropdown-list'),
53				$current = $this.find('.w-dropdown-current');
54			var closeList = function(){
55				$list.slideUpCSS(250, function(){
56					$this.removeClass('active');
57				});
58				$us.$window.off('mouseup touchstart mousewheel DOMMouseScroll touchstart', closeListEvent);
59			};
60			var closeListEvent = function(e){
61				if ($this.has(e.target).length !== 0) return;
62				e.stopPropagation();
63				e.preventDefault();
64				closeList();
65			};
66			$list.hide();
67			$current.click(function(){
68				if ($this.hasClass('active')) {
69					closeList();
70					return;
71				}
72				$this.addClass('active');
73				$list.slideDownCSS();
74				$us.$window.on('mouseup touchstart mousewheel DOMMouseScroll touchstart', closeListEvent);
75			});
76		});
77	};
78	$(function(){
79		$('.w-dropdown').wDropdown();
80	});
81})(jQuery);
82
83
84/**
85 * UpSolution Widget: w-blog
86 */
87(function($){
88	"use strict";
89
90	$us.WBlog = function(container, options){
91		this.init(container, options);
92	};
93
94	$us.WBlog.prototype = {
95
96		init: function(container, options){
97			// Commonly used dom elements
98			this.$container = $(container);
99			this.$filters = this.$container.find('.g-filters-item');
100			this.$list = this.$container.find('.w-blog-list');
101			this.$items = this.$container.find('.w-blog-post');
102			this.$pagination = this.$container.find('.g-pagination');
103			this.$loadmore = this.$container.find('.g-loadmore');
104			this.$preloader = this.$container.find('.w-blog-preloader');
105			this.curCategory = '';
106			this.paginationType = this.$pagination.length ? 'regular' : (this.$loadmore.length ? 'ajax' : 'none');
107			this.items = [];
108			this.loading = false;
109
110			if (this.paginationType != 'none') {
111				var $jsonContainer = this.$container.find('.w-blog-json');
112				if ($jsonContainer.length == 0) return;
113				this.ajaxData = $jsonContainer[0].onclick() || {};
114				this.ajaxUrl = this.ajaxData.ajax_url || '';
115				this.permalinkUrl = this.ajaxData.permalink_url || '';
116				this.templateVars = this.ajaxData.template_vars || {};
117				this.category = this.templateVars.query_args.category_name || '';
118				this.curCategory = this.category;
119				this.curPage = this.ajaxData.current_page || 1;
120				this.perpage = this.ajaxData.perpage || this.$items.length;
121				this.infiniteScroll = this.ajaxData.infinite_scroll || 0;
122				$jsonContainer.remove();
123
124			}
125
126			if (this.paginationType == 'ajax') {
127				if (this.templateVars.query_args.orderby == 'rand') {
128					this.$items.each(function(index, item){
129						this.items.push(parseInt(item.getAttribute('data-id')));
130					}.bind(this));
131				}
132				this.$loadmore.on('click', function(){
133					if (this.curPage < this.ajaxData.max_num_pages) {
134						this.setState(this.curPage + 1);
135					}
136				}.bind(this));
137
138				if (this.infiniteScroll) {
139					$us.scroll.addWaypoint(this.$loadmore, '-70%', function(){
140						this.$loadmore.click();
141					}.bind(this));
142				}
143			}
144			else if (this.paginationType == 'regular' && this.$filters.length) {
145				this.paginationPcre = new RegExp('/page/([0-9]+)/$');
146				this.location = location.href.replace(this.paginationPcre, '/');
147				this.$navLinks = this.$container.find('.nav-links');
148				var self = this;
149				this.$navLinks.on('click', 'a', function(e){
150					e.preventDefault();
151					var arr,
152						pageNum = (arr = self.paginationPcre.exec(this.href)) ? parseInt(arr[1]) : 1;
153					self.setState(pageNum);
154				});
155			}
156
157			if (this.$container.hasClass('with_isotope') && $.fn.isotope) {
158				this.$list.imagesLoaded(function(){
159					this.$list.isotope({
160						itemSelector: '.w-blog-post',
161						layoutMode: (this.$container.hasClass('isotope_fit_rows')) ? 'fitRows' : 'masonry',
162						isOriginLeft: !$('.l-body').hasClass('rtl')
163					});
164					this.$list.isotope();
165				}.bind(this));
166
167				$us.$canvas.on('contentChange', function(){
168					this.$list.imagesLoaded(function(){
169						this.$list.isotope('layout');
170					}.bind(this));
171				}.bind(this));
172			}
173
174			this.$filters.each(function(index, filter){
175				var $filter = $(filter),
176					category = $filter.data('category');
177				$filter.on('click', function(){
178					if (category != this.curCategory) {
179						this.setState(1, category);
180						this.$filters.removeClass('active');
181						$filter.addClass('active');
182					}
183				}.bind(this))
184			}.bind(this));
185		},
186
187		setState: function(page, category){
188			if (this.paginationType == 'none') {
189				// Simple state changer
190				this.$list.isotope({filter: (category == '*') ? '*' : ('.' + category)});
191				this.curCategory = category;
192				return;
193			}
194
195			if (this.loading) return;
196
197			this.loading = true;
198
199			category = category || this.curCategory;
200			if (category == '*') {
201				category = this.category;
202			}
203
204			this.templateVars.query_args.paged = page;
205			this.templateVars.query_args.category_name = category;
206
207			if (this.paginationType == 'ajax') {
208				if (page == 1) {
209					this.items = [];
210					this.templateVars.query_args.post__not_in = this.items;
211					this.$loadmore.addClass('done');
212				} else {
213					if (this.templateVars.query_args.orderby == 'rand') {
214						this.templateVars.query_args.paged = 1;
215						this.templateVars.query_args.post__not_in = this.items;
216					}
217					this.$loadmore.addClass('loading');
218				}
219			}
220
221			if (this.paginationType != 'ajax' || page == 1) {
222				this.$preloader.addClass('active');
223				if (this.$list.data('isotope')) {
224					this.$list.isotope('remove', this.$container.find('.w-blog-post'));
225					this.$list.isotope('layout');
226				} else {
227					this.$container.find('.w-blog-post').remove();
228				}
229			}
230
231			this.ajaxData.template_vars = JSON.stringify(this.templateVars);
232
233			// In case we set paged to 1 for rand order - setting it back
234			this.templateVars.query_args.paged = page;
235
236			$.ajax({
237				type: 'post',
238				url: this.ajaxData.ajax_url,
239				data: this.ajaxData,
240				success: function(html){
241					var $result = $(html),
242						$container = $result.find('.w-blog-list'),
243						$items = $container.children(),
244						isotope = this.$list.data('isotope');
245					$container.imagesLoaded(function(){
246						this.beforeAppendItems($items);
247						$items.appendTo(this.$list);
248						$container.remove();
249						var $sliders = $items.find('.w-slider');
250						this.afterAppendItems($items);
251						if (isotope) {
252							isotope.appended($items);
253						}
254						$sliders.each(function(index, slider){
255							$(slider).wSlider().find('.royalSlider').data('royalSlider').ev.on('rsAfterInit', function(){
256								if (isotope) {
257									this.$list.isotope('layout');
258								}
259							});
260						}.bind(this));
261						if (isotope) {
262							this.$list.isotope('layout');
263						}
264						if (this.paginationType == 'regular') {
265							this.$pagination.remove();
266
267							var $pagination = $result.find('.g-pagination');
268
269							this.$container.append($pagination);
270							this.$pagination = this.$container.find('.g-pagination');
271
272							var self = this;
273							this.$pagination.find('.nav-links a').each(function(){
274								var $link = $(this),
275									linkURL = $link.attr('href');
276								linkURL = linkURL.replace(self.ajaxUrl, self.permalinkUrl);
277								$link.attr('href', linkURL);
278							});
279
280							this.paginationPcre = new RegExp('/page/([0-9]+)/$');
281							this.location = location.href.replace(this.paginationPcre, '/');
282							this.$navLinks = this.$container.find('.nav-links');
283
284							this.$navLinks.on('click', 'a', function(e){
285								e.preventDefault();
286								var arr,
287									pageNum = (arr = self.paginationPcre.exec(this.href)) ? parseInt(arr[1]) : 1;
288								self.setState(pageNum);
289							});
290
291						}
292						if (this.paginationType == 'ajax') {
293							if (page == 1) {
294								var $jsonContainer = $result.find('.w-blog-json');
295								if ($jsonContainer.length) {
296									var ajaxData = $jsonContainer[0].onclick() || {};
297									this.ajaxData.max_num_pages = ajaxData.max_num_pages || this.ajaxData.max_num_pages;
298								} else {
299									this.ajaxData.max_num_pages = 1;
300								}
301							}
302
303							if (this.templateVars.query_args.orderby == 'rand') {
304								$items.each(function(index, item){
305									this.items.push(parseInt(item.getAttribute('data-id')));
306								}.bind(this));
307							}
308
309							if (this.templateVars.query_args.paged >= this.ajaxData.max_num_pages) {
310								this.$loadmore.addClass('done');
311							} else {
312								this.$loadmore.removeClass('done');
313								this.$loadmore.removeClass('loading');
314							}
315
316							if (this.infiniteScroll) {
317								$us.scroll.addWaypoint(this.$loadmore, '-70%', function(){
318									this.$loadmore.click();
319								}.bind(this));
320							}
321						}
322						this.$preloader.removeClass('active');
323					}.bind(this));
324
325					this.loading = false;
326
327				}.bind(this),
328				error: function(){
329					this.$loadmore.removeClass('loading');
330				}.bind(this)
331			});
332
333
334			this.curPage = page;
335			this.curCategory = category;
336
337		},
338		/**
339		 * Overloadable function for themes
340		 * @param $items
341		 */
342		beforeAppendItems: function($items){
343		},
344
345		afterAppendItems: function($items){
346		}
347
348	};
349
350	$.fn.wBlog = function(options){
351		return this.each(function(){
352			$(this).data('wBlog', new $us.WBlog(this, options));
353		});
354	};
355
356})(jQuery);
357
358
359/**
360 * UpSolution Widget: w-tabs
361 *
362 * @requires $us.canvas
363 */
364!function($){
365	"use strict";
366
367	$us.WTabs = function(container, options){
368		this.init(container, options);
369	};
370
371	$us.WTabs.prototype = {
372
373		init: function(container, options){
374			// Setting options
375			var defaults = {
376				duration: 300,
377				easing: 'cubic-bezier(.78,.13,.15,.86)'
378			};
379			this.options = $.extend({}, defaults, options);
380			this.isRtl = $('.l-body').hasClass('rtl');
381
382			// Commonly used dom elements
383			this.$container = $(container);
384			this.$tabsList = this.$container.find('.w-tabs-list:first');
385			this.$tabs = this.$tabsList.find('.w-tabs-item');
386			this.$tabsH = this.$tabsList.find('.w-tabs-item-h');
387			this.$sectionsWrapper = this.$container.find('.w-tabs-sections:first');
388			this.$sectionsHelper = this.$sectionsWrapper.children();
389			this.$sections = this.$sectionsHelper.find('.w-tabs-section');
390			this.$headers = this.$sections.children('.w-tabs-section-header');
391			this.$contents = this.$sections.children('.w-tabs-section-content');
392
393			// Class variables
394			this.width = 0;
395			this.tabWidths = [];
396			this.isTogglable = (this.$container.usMod('type') == 'togglable');
397			// Basic layout
398			this.basicLayout = this.$container.hasClass('accordion') ? 'accordion' : (this.$container.usMod('layout') || 'default');
399			// Current active layout (may be switched to 'accordion')
400			this.curLayout = this.basicLayout;
401			this.responsive = $us.canvas.options.responsive;
402			// Array of active tabs indexes
403			this.active = [];
404			this.count = this.$tabs.length;
405			// Container width at which we should switch to accordion layout
406			this.minWidth = 0;
407
408			if (this.count == 0) return;
409
410			// Preparing arrays of jQuery objects for easier manipulating in future
411			this.tabs = $.map(this.$tabs.toArray(), $);
412			this.sections = $.map(this.$sections.toArray(), $);
413			this.headers = $.map(this.$headers.toArray(), $);
414			this.contents = $.map(this.$contents.toArray(), $);
415
416			$.each(this.tabs, function(index){
417				if (this.tabs[index].hasClass('active')) {
418					this.active.push(index);
419				}
420				this.tabs[index].add(this.headers[index]).on('click', function(e){
421					e.preventDefault();
422					// Toggling accordion sections
423					if (this.curLayout == 'accordion' && this.isTogglable) {
424						// Cannot toggle the only active item
425						this.toggleSection(index);
426					}
427					// Setting tabs active item
428					else if (index != this.active[0]) {
429						this.openSection(index);
430					}
431				}.bind(this));
432			}.bind(this));
433
434			this.$tabsH.on('click', function(e){
435				e.preventDefault();
436			});
437
438			// Boundable events
439			this._events = {
440				resize: this.resize.bind(this),
441				contentChanged: function(){
442					$us.$canvas.trigger('contentChange');
443				}
444			};
445
446			// Starting everything
447			this.switchLayout(this.curLayout);
448			if (this.curLayout != 'accordion' || !this.isTogglable) {
449				this.openSection(this.active[0]);
450			}
451
452			setTimeout(this._events.resize, 50);
453			$us.$window.on('resize load', this._events.resize);
454
455			// Open tab on page load by hash
456			if (window.location.hash) {
457				var hash = window.location.hash.substr(1),
458					$linkedSection = this.$container.find('.w-tabs-section[id="' + hash + '"]');
459				if ($linkedSection.length && ( !$linkedSection.hasClass('active'))) {
460					var $header = $linkedSection.find('.w-tabs-section-header');
461					$header.click();
462				}
463			}
464			// Support for external links to tabs
465			$.each(this.tabs, function(index){
466				if (this.headers[index].attr('href') != undefined) {
467					var tabHref = this.headers[index].attr('href'),
468						tabHeader = this.headers[index];
469					$('a[href=' + tabHref + ']').on('click', function(e){
470						e.preventDefault();
471						if ($(this).hasClass('w-tabs-section-header', 'w-tabs-item-h')) {
472							return;
473						}
474						tabHeader.click();
475					});
476				}
477			}.bind(this));
478		},
479
480		switchLayout: function(to){
481			this.cleanUpLayout(this.curLayout);
482			this.prepareLayout(to);
483			this.curLayout = to;
484		},
485
486		/**
487		 * Clean up layout's special inline styles and/or dom elements
488		 * @param from
489		 */
490		cleanUpLayout: function(from){
491			if (from == 'default' || from == 'timeline' || from == 'modern' || from == 'trendy') {
492				this.$sectionsWrapper.clearPreviousTransitions().resetInlineCSS('width', 'height');
493				this.$sectionsHelper.clearPreviousTransitions().resetInlineCSS('position', 'width', 'left');
494				this.$sections.resetInlineCSS('width');
495				this.$container.removeClass('autoresize');
496			}
497			else if (from == 'accordion') {
498				this.$container.removeClass('accordion');
499				this.$contents.resetInlineCSS('height', 'padding-top', 'padding-bottom', 'display', 'opacity');
500			}
501			else if (from == 'ver') {
502				this.$contents.resetInlineCSS('height', 'padding-top', 'padding-bottom', 'display', 'opacity');
503			}
504		},
505
506		/**
507		 * Apply layout's special inline styles and/or dom elements
508		 * @param to
509		 */
510		prepareLayout: function(to){
511			if (to == 'default' || to == 'timeline' || to == 'modern' || to == 'trendy') {
512				this.$container.addClass('autoresize');
513				this.$sectionsHelper.css('position', 'absolute');
514			}
515			else if (to == 'accordion') {
516				this.$container.addClass('accordion');
517				this.$contents.hide();
518				for (var i = 0; i < this.active.length; i++) {
519					if (this.contents[this.active[i]] !== undefined) {
520						this.contents[this.active[i]].show();
521					}
522				}
523			}
524			else if (to == 'ver') {
525				this.$contents.hide();
526				this.contents[this.active[0]].show();
527			}
528		},
529
530		/**
531		 * Measure needed sizes and store them to this.tabWidths variable
532		 *
533		 * TODO Count minWidth here as well
534		 */
535		measure: function(){
536			if (this.basicLayout == 'ver') {
537				// Measuring minimum tabs width
538				this.$tabsList.css('width', 0);
539				var minTabWidth = this.$tabsList.outerWidth(true);
540				this.$tabsList.css('width', '');
541				// Measuring the mininum content width
542				this.$container.addClass('measure');
543				var minContentWidth = this.$sectionsWrapper.outerWidth(true);
544				this.$container.removeClass('measure');
545				// Measuring minimum tabs width for percent-based sizes
546				var navWidth = this.$container.usMod('navwidth');
547				if (navWidth != 'auto') {
548					// Percent-based measure
549					minTabWidth = Math.max(minTabWidth, minContentWidth * parseInt(navWidth) / (100 - parseInt(navWidth)));
550				}
551				this.minWidth = Math.max(480, minContentWidth + minTabWidth + 1);
552			} else {
553				this.tabWidths = [];
554				// We hide active line temporarily to count tab sizes properly
555				this.$container.addClass('measure');
556				for (var index = 0; index < this.tabs.length; index++) {
557					this.tabWidths.push(this.tabs[index].outerWidth(true));
558				}
559				this.$container.removeClass('measure');
560				if (this.basicLayout == 'default' || this.basicLayout == 'timeline' || this.basicLayout == 'modern' || this.basicLayout == 'trendy') {
561					// Array sum
562					this.minWidth = this.tabWidths.reduce(function(pv, cv){
563						return pv + cv;
564					}, 0);
565				}
566			}
567		},
568
569		/**
570		 * Open tab section
571		 *
572		 * @param index int
573		 */
574		openSection: function(index){
575			if (this.sections[index] === undefined) return;
576			if (this.curLayout == 'default' || this.curLayout == 'timeline' || this.curLayout == 'modern' || this.curLayout == 'trendy') {
577				this.$container.removeClass('autoresize');
578				var height = this.sections[index].height();
579				this.$sectionsHelper.performCSSTransition({
580					left: -this.width * (this.isRtl ? (this.count - index - 1 ) : index)
581				}, this.options.duration, this._events.contentChanged, this.options.easing);
582				this.$sectionsWrapper.performCSSTransition({
583					height: height
584				}, this.options.duration, function(){
585					this.$container.addClass('autoresize');
586				}.bind(this), this.options.easing);
587			}
588			else if (this.curLayout == 'accordion' || this.curLayout == 'ver') {
589				if (this.contents[this.active[0]] !== undefined) {
590					this.contents[this.active[0]].css('display', 'block').slideUp(this.options.duration);
591				}
592				this.contents[index].css('display', 'none').slideDown(this.options.duration, this._events.contentChanged);
593				// Scrolling to the opened section at small window dimensions
594				if (this.curLayout == 'accordion' && $us.canvas.winWidth < 768) {
595					var newTop = this.headers[0].offset().top;
596					for (var i = 0; i < index; i++) {
597						newTop += this.headers[i].outerHeight();
598					}
599					$us.scroll.scrollTo(newTop, true);
600				}
601			}
602			this._events.contentChanged();
603			this.$tabs.removeClass('active');
604			this.tabs[index].addClass('active');
605			this.$sections.removeClass('active');
606			this.sections[index].addClass('active');
607			this.active[0] = index;
608		},
609
610		/**
611		 * Toggle some togglable accordion section
612		 *
613		 * @param index
614		 */
615		toggleSection: function(index){
616			// (!) Can only be used within accordion state
617			var indexPos = $.inArray(index, this.active);
618			if (indexPos != -1) {
619				this.contents[index].css('display', 'block').slideUp(this.options.duration, this._events.contentChanged);
620				this.tabs[index].removeClass('active');
621				this.sections[index].removeClass('active');
622				this.active.splice(indexPos, 1);
623			}
624			else {
625				this.contents[index].css('display', 'none').slideDown(this.options.duration, this._events.contentChanged);
626				this.tabs[index].addClass('active');
627				this.sections[index].addClass('active');
628				this.active.push(index);
629			}
630		},
631
632		/**
633		 * Resize-driven logics
634		 */
635		resize: function(){
636			this.width = this.$container.width();
637			this.$tabsList.removeClass('hidden');
638
639			// Basic layout may be overriden
640			if (this.responsive) {
641				if (this.basicLayout == 'ver' && this.curLayout != 'ver') this.switchLayout('ver');
642				if (this.curLayout != 'accordion') this.measure();
643				var nextLayout = (this.width < this.minWidth) ? 'accordion' : this.basicLayout;
644				if (nextLayout !== this.curLayout) this.switchLayout(nextLayout);
645			}
646
647			// Fixing tabs display
648			if (this.curLayout == 'default' || this.curLayout == 'timeline' || this.curLayout == 'modern' || this.curLayout == 'trendy') {
649				this.$container.addClass('autoresize');
650				this.$sectionsWrapper.css('width', this.width);
651				this.$sectionsHelper.css('width', this.count * this.width);
652				this.$sections.css('width', this.width);
653				if (this.contents[this.active[0]] !== undefined) {
654					this.$sectionsHelper.css('left', -this.width * (this.isRtl ? (this.count - this.active[0] - 1) : this.active[0])
654);
655					var height = this.sections[this.active[0]].height();
656					this.$sectionsWrapper.css('height', height);
657				}
658			} else if (this.curLayout == 'ver') {
659				var sectionsWrapperWidth = this.$sectionsWrapper.width();
660			}
661			this._events.contentChanged();
662		}
663
664	};
665
666	$.fn.wTabs = function(options){
667		return this.each(function(){
668			$(this).data('wTabs', new $us.WTabs(this, options));
669		});
670	};
671
672}(jQuery);
673
674
675/**
676 * UpSolution Shortcode: us_logos
677 */
678jQuery(function($){
679	$(".w-logos.type_carousel .w-logos-list").each(function(){
680		var $list = $(this),
681			items = parseInt($list.data('items'));
682		$list.owlCarousel({
683			items: items,
684			center: (items == 1),
685			loop: true,
686			rtl: $('.l-body').hasClass('rtl'),
687			nav: $list.data('nav'),
688			autoplay: $list.data('autoplay'),
689			autoplayTimeout: $list.data('timeout'),
690			autoplayHoverPause: true,
691			responsive: {
692				0: {items: 1, center: true},
693				480: {items: Math.min(items, 2)},
694				768: {items: Math.min(items, 3)},
695				900: {items: Math.min(items, 4)},
696				1200: {items: items}
697			}
698		});
699	});
700});
701
702
703/**
704 * UpSolution Shortcode: us_feedback
705 */
706jQuery(function($){
707
708	$('.w-form.for_cform').each(function(){
709		var $container = $(this),
710			$form = $container.find('form:first'),
711			$submitBtn = $form.find('.w-btn'),
712			$resultField = $form.find('.w-form-message'),
713			options = $container.find('.w-form-json')[0].onclick();
714
715		$form.submit(function(event){
716			event.preventDefault();
717
718			// Prevent double-sending
719			if ($submitBtn.hasClass('loading')) return;
720
721			$resultField.usMod('type', false).html('');
722			// Validation
723			var errors = 0;
724			$form.find('[data-required="true"]').each(function(){
725				var $input = $(this),
726					isEmpty = ($input.val() == ''),
727					$row = $input.closest('.w-form-row'),
728					errorText = options.errors[$input.attr('name')] || '';
729				$row.toggleClass('check_wrong', isEmpty);
730				$row.find('.w-form-row-state').html(isEmpty ? errorText : '');
731				if (isEmpty) {
732					errors++;
733				}
734			});
735
736			if (errors != 0) return;
737
738			$submitBtn.addClass('loading');
739			$.ajax({
740				type: 'POST',
741				url: options.ajaxurl,
742				dataType: 'json',
743				data: $form.serialize(),
744				success: function(result){
745					if (result.success) {
746						$resultField.usMod('type', 'success').html(result.data);
747						$form.find('.w-form-row.check_wrong').removeClass('check_wrong');
748						$form.find('.w-form-row.not-empty').removeClass('not-empty');
749						$form.find('.w-form-state').html('');
750						$form.find('input[type="text"], input[type="email"], textarea').val('');
751					} else {
752						$form.find('.w-form-row.check_wrong').removeClass('check_wrong');
753						$form.find('.w-form-state').html('');
754						if (result.data && typeof result.data == 'object') {
755							for (var fieldName in result.data) {
756								if (fieldName == 'empty_message') {
757									var errorText = result.data[fieldName];
758									$resultField.usMod('type', 'error').html(errorText);
759									continue;
760								}
761								if (!result.data.hasOwnProperty(fieldName)) continue;
762								var $input = $form.find('[name="' + fieldName + '"]'),
763									errorText = result.data[fieldName];
764								$input.closest('.w-form-row').addClass('check_wrong')
765									.find('.w-form-row-state').html(errorText);
766							}
767						} else {
768							$resultField.usMod('type', 'error').html(result.data);
769						}
770					}
771				},
772				complete: function(){
773					$submitBtn.removeClass('loading');
774				}
775			});
776		});
777
778	});
779});
780
781
782/**
783 * UpSolution Shortcode: us_counter
784 */
785jQuery(function($){
786	$('.w-counter').each(function(index, elm){
787		var $container = $(this),
788			$number = $container.find('.w-counter-number'),
789			initial = ($container.data('initial') || '0') + '',
790			target = ($container.data('target') || '10') + '',
791			prefix = $container.data('prefix') || '',
792			suffix = $container.data('suffix') || '',
793		// 0 for integers, 1+ for floats (number of digits after the decimal)
794			precision = 0;
795		if (target.indexOf('.') != -1) {
796			precision = target.length - 1 - target.indexOf('.');
797		}
798		initial = window[precision ? 'parseFloat' : 'parseInt'](initial, 10);
799		target = window[precision ? 'parseFloat' : 'parseInt'](target, 10);
800
801		$number.html(prefix + initial.toFixed(precision) + suffix);
802
803		$us.scroll.addWaypoint(this, '15%', function(){
804			var current = initial,
805				step = 25,
806				stepValue = (target - initial) / 25,
807				interval = setInterval(function(){
808					current += stepValue;
809					step--;
810					$number.html(prefix + current.toFixed(precision) + suffix);
811					if (step <= 0) {
812						$number.html(prefix + target.toFixed(precision) + suffix);
813						window.clearInterval(interval);
814					}
815				}, 40);
816		});
817	});
818});
819
820
821/**
822 * UpSolution Shortcode: us_progbar
823 */
824jQuery(function($){
825	$('.w-progbar').each(function(index, elm){
826		var $container = $(this),
827			$bar = $container.find('.w-progbar-bar-h'),
828			count = $container.data('count') + '',
829			$titleCount = $container.find('.w-progbar-title-count'),
830			$barCount = $container.find('.w-progbar-bar-count');
831
832		if (count === null) {
833			count = 50;
834		}
835
836		$titleCount.html('0%');
837		$barCount.html('0%');
838
839		$us.scroll.addWaypoint(this, '15%', function(){
840			var current = 0,
841				step = 40,
842				stepValue = count / 40,
843				interval = setInterval(function(){
844					current += stepValue;
845					step--;
846					$titleCount.html(current.toFixed(0) + '%');
847					$barCount.html(current.toFixed(0) + '%');
848					if (step <= 0) {
849						$titleCount.html(count + '%');
850						$barCount.html(count + '%');
851						window.clearInterval(interval);
852					}
853				}, 20);
854
855			$container.removeClass('initial');
856		});
857	});
858});
859
860
861/**
862 * UpSolution Shortcode: us_gallery
863 */
864jQuery(function($){
865	if ($.fn.magnificPopup) {
866		$('.w-gallery.link_media .w-gallery-list').each(function(){
867			$(this).magnificPopup({
868				type: 'image',
869				delegate: 'a.w-gallery-item',
870				gallery: {
871					enabled: true,
872					navigateByImgClick: true,
873					preload: [0, 1],
874					tPrev: $us.langOptions.magnificPopup.tPrev, // Alt text on left arrow
875					tNext: $us.langOptions.magnificPopup.tNext, // Alt text on right arrow
876					tCounter: $us.langOptions.magnificPopup.tCounter // Markup for "1 of 7" counter
877				},
878				removalDelay: 300,
879				mainClass: 'mfp-fade',
880				fixedContentPos: false
881			});
882		});
883	}
884	if ($.fn.isotope) {
885		// Applying isotope to gallery
886		$('.w-gallery.layout_masonry').each(function(index, gallery){
887			if ($(gallery).hasClass('cols_1')) return; // TODO: check if we can replace this condition with CSS :not(.cols_1) selector
888
889			var $container = $($(gallery).find('.w-gallery-list'));
890			$container.imagesLoaded(function(){
891				$container.isotope({
892					layoutMode: 'masonry',
893					isOriginLeft: !$('body').hasClass('rtl')
894				});
895				$container.isotope();
896			});
897		});
898	}
899});
900
901
902/**
903 * UpSolution Shortcode: us_slider
904 */
905(function($){
906	$.fn.wSlider = function(){
907		return this.each(function(){
908			var $this = $(this),
909				$slider = $this.find('.royalSlider'),
910				$options = $this.find('.w-slider-json'),
911				options = $options[0].onclick() || {};
912			$options.remove();
913			if (!$.fn.royalSlider) {
914				return;
915			}
916			// Always apply certain fit options for blog listing slider
917			if ($this.parent().hasClass('w-blog-post-preview')) {
918				options['imageScaleMode'] = 'fill';
919			}
920			$slider.royalSlider(options);
921			var slider = $slider.data('royalSlider');
922			if (options.fullscreen && options.fullscreen.enabled) {
923				// Moving royal slider to the very end of body element to allow a proper fullscreen
924				var rsEnterFullscreen = function(){
925					$slider.appendTo($('body'));
926					slider.ev.off('rsEnterFullscreen', rsEnterFullscreen);
927					slider.exitFullscreen();
928					slider.enterFullscreen();
929					slider.ev.on('rsEnterFullscreen', rsEnterFullscreen);
930					slider.ev.on('rsExitFullscreen', rsExitFullscreen);
931				};
932				slider.ev.on('rsEnterFullscreen', rsEnterFullscreen);
933				var rsExitFullscreen = function(){
934					$slider.prependTo($this);
935					slider.ev.off('rsExitFullscreen', rsExitFullscreen);
936					slider.exitFullscreen();
937				};
938			}
939			$us.$canvas.on('contentChange', function(){
940				$slider.parent().imagesLoaded(function(){
941					slider.updateSliderSize();
942				});
943			});
944		});
945	};
946	$(function(){
947		jQuery('.w-slider').wSlider();
948	});
949})(jQuery);
950
951
952/**
953 * UpSolution Widget: w-portfolio
954 */
955!function($){
956	"use strict";
957
958	$us.WPortfolio = function(container, options){
959		this.init(container, options);
960	};
961
962	$us.WPortfolio.prototype = {
963
964		init: function(container, options){
965			// Commonly used dom elements
966			this.$container = $(container);
967
968			if (this.$container.usMod('position') != 'isotope' || !$.fn.isotope) {
969				// No scripts needed
970				return;
971			}
972
973			this.$filters = this.$container.find('.g-filters-item');
974			this.$list = this.$container.find('.w-portfolio-list');
975			this.$items = this.$container.find('.w-portfolio-item');
976			this.$pagination = this.$container.find('.g-pagination');
977			this.$loadmore = this.$container.find('.g-loadmore');
978			this.paginationType = this.$pagination.length ? 'regular' : (this.$loadmore.length ? 'ajax' : 'none');
979			this.items = {};
980			this.curCategory = '*';
981			this.loading = false;
982
983			this.$items.each(function(index, item){
984				this.items[parseInt(item.getAttribute('data-id'))] = $(item);
985			}.bind(this));
986
987			this.isotopeOptions = {
988				itemSelector: '.w-portfolio-item',
989				layoutMode: 'masonry',
990				masonry: {},
991				isOriginLeft: !$('.l-body').hasClass('rtl')
992			};
993
994			if (this.$container.find('.w-portfolio-item.size_1x1').length) {
995				this.itemWidth = 1;
996				this.isotopeOptions.masonry.columnWidth = '.size_1x1';
997			} else if (this.$container.find('.w-portfolio-item.size_1x2').length) {
998				this.itemWidth = 1;
999				this.isotopeOptions.masonry.columnWidth = '.size_1x2';
1000			} else {
1001				this.itemWidth = 2;
1002				this.isotopeOptions.masonry.columnWidth = '.w-portfolio-item';
1003			}
1004
1005			if (this.paginationType != 'none') {
1006				var $jsonContainer = this.$container.find('.w-portfolio-json');
1007				if ($jsonContainer.length == 0) return;
1008				this.jsonData = $jsonContainer[0].onclick() || {};
1009				this.ajaxUrl = this.jsonData.ajax_url || '';
1010				this.templateVars = JSON.stringify(this.jsonData.template_vars || {});
1011				this.perpage = this.jsonData.perpage || this.$items.length;
1012				this.order = this.jsonData.order || {};
1013				this.sizes = this.jsonData.sizes || {};
1014				this.curPage = this.jsonData.page || 1;
1015				$jsonContainer.remove();
1016				this.isotopeOptions.sortBy = 'number';
1017				this.isotopeOptions.getSortData = {
1018					number: function(elm){
1019						return this.order['*'].indexOf(parseInt(elm.getAttribute('data-id')));
1020					}.bind(this)
1021				};
1022			}
1023
1024			if (this.paginationType == 'ajax') {
1025				this.$loadmore.on('click', function(){
1026					var maxPage = Math.ceil(this.order[this.curCategory].length / this.perpage);
1027					if (this.curPage < maxPage) {
1028						this.setState(this.curPage + 1);
1029					}
1030				}.bind(this));
1031			}
1032			else if (this.paginationType == 'regular') {
1033				this.paginationPcre = new RegExp('/page/([0-9]+)/$');
1034				this.location = location.href.replace(this.paginationPcre, '/');
1035				this.$navLinks = this.$container.find('.nav-links');
1036				var self = this;
1037				this.$navLinks.on('click', 'a', function(e){
1038					e.preventDefault();
1039					var arr,
1040						pageNum = (arr = self.paginationPcre.exec(this.href)) ? parseInt(arr[1]) : 1;
1041					self.setState(pageNum);
1042				});
1043				this.renderPagination(this.curPage);
1044			}
1045
1046			this.$filters.each(function(index, filter){
1047				var $filter = $(filter),
1048					category = $filter.data('category');
1049				$filter.on('click', function(){
1050					if (category != this.curCategory) {
1051						this.setState((this.paginationType == 'regular') ? 1 : this.curPage, category);
1052						this.$filters.removeClass('active');
1053						$filter.addClass('active');
1054					}
1055				}.bind(this))
1056			}.bind(this));
1057
1058			// Applying isotope
1059			this.loading = true;
1060			this.$list.imagesLoaded(function(){
1061				this.$list.isotope(this.isotopeOptions);
1062				this.$list.isotope();
1063				this.loading = false;
1064				$us.$canvas.on('contentChange', function(){
1065					this.$list.isotope('layout');
1066				}.bind(this));
1067				$(window).on('resize', function(){
1068					this.$list.isotope('layout');
1069				}.bind(this));
1070			}.bind(this));
1071		},
1072
1073		setState: function(page, category){
1074			if (this.paginationType == 'none') {
1075				// Simple state changer
1076				this.$list.isotope({filter: (category == '*') ? '*' : ('.' + category)});
1077				this.curCategory = category;
1078				return;
1079			}
1080
1081			if (this.loading) return;
1082			category = category || this.curCategory;
1083			var start = (this.paginationType == 'ajax') ? 0 : ((page - 1) * this.perpage),
1084				length = page * this.perpage,
1085				showIds = (this.order[category] || []).slice(start, length),
1086				loadIds = [],
1087				$newItems = [];
1088			$.each(showIds, function(i, id){
1089				// Determining which items we need to load via ajax and creating temporary stubs for them
1090				if (this.items[id] !== undefined) return;
1091				var itemSize = (this.sizes[id] || '1x1'),
1092					itemHtml = '<div class="w-portfolio-item size_' + itemSize + ' loading" data-id="' + id + '">' +
1093						'<div class="w-portfolio-item-anchor"><div class="g-preloader type_1"></div></div></div>';
1094				this.items[id] = $(itemHtml).appendTo(this.$list);
1095				$newItems.push(this.items[id][0]);
1096				loadIds.push(showIds[i]);
1097			}.bind(this));
1098			if (loadIds.length > 0) {
1099				// Loading new items
1100				var $insertedItems = $();
1101				$.ajax({
1102					type: 'post',
1103					url: this.ajaxUrl,
1104					data: {
1105						action: 'us_ajax_portfolio',
1106						ids: loadIds.join(','),
1107						template_vars: this.templateVars
1108					},
1109					success: function(html){
1110						var $container = $('<div>', {html: html}),
1111							$items = $container.children(),
1112							isotope = this.$list.data('isotope');
1113						$items.each(function(index, item){
1114							var $item = $(item),
1115								itemID = parseInt($item.data('id'));
1116							$item.imagesLoaded(function(){
1117								this.items[itemID].attr('class', $item.attr('class')).attr('style', $item.attr('style'));
1118								this.itemLoaded(itemID, $item);
1119								this.items[itemID].html($item.html());
1120								$insertedItems = $insertedItems.add(this.items[itemID]);
1121								if ($insertedItems.length >= loadIds.length) {
1122									$container.remove();
1123									this.itemsLoaded($insertedItems);
1124								}
1125								if (isotope) {
1126									if (this.itemWidth != 1) {
1127										if (this.$container.find('.w-portfolio-item.size_1x1').length) {
1128											this.itemWidth = 1;
1129											this.isotopeOptions.masonry.columnWidth = '.size_1x1';
1130										} else if (this.$container.find('.w-portfolio-item.size_1x2').length) {
1131											this.itemWidth = 1;
1132											this.isotopeOptions.masonry.columnWidth = '.size_1x2';
1133										} else {
1134											this.itemWidth = 2;
1135											this.isotopeOptions.masonry.columnWidth = '.w-portfolio-item';
1136										}
1137										if (this.itemWidth == 1) {
1138											this.$list.isotope(this.isotopeOptions);
1139										}
1140									}
1141
1142									this.$list.isotope('layout');
1143								}
1144							}.bind(this));
1145						}.bind(this));
1146					}.bind(this)
1147				});
1148			}
1149			this.$list.isotope({
1150				filter: function(){
1151					return (showIds.indexOf(parseInt(this.getAttribute('data-id'))) != -1);
1152				}
1153			});
1154			if (loadIds.length > 0) {
1155				this.$list.isotope('insert', $newItems);
1156			}
1157			this.curPage = page;
1158			this.curCategory = category;
1159			this.renderPagination();
1160		},
1161
1162		renderPagination: function(){
1163			if (this.paginationType == 'ajax') {
1164				var maxPage = Math.ceil(this.order[this.curCategory].length / this.perpage);
1165				this.$loadmore[(this.curPage < maxPage) ? 'removeClass' : 'addClass']('done');
1166			}
1167			else if (this.paginationType == 'regular') {
1168				var maxPage = Math.ceil(this.order[this.curCategory].length / this.perpage),
1169					html = '';
1170				if (maxPage > 1) {
1171					if (this.curPage > 1) {
1172						html += '<a href="' + this.pageUrl(this.curPage - 1) + '" class="prev page-numbers"><span>&lt;</span></a>';
1173					} else {
1174						html += '<span class="prev page-numbers">&lt;</span>';
1175					}
1176					for (var i = 1; i <= maxPage; i++) {
1177						if (i != this.curPage) {
1178							html += '<a href="' + this.pageUrl(i) + '" class="page-numbers"><span>' + i + '</span></a>';
1179						} else {
1180							html += '<span class="page-numbers current"><span>' + i + '</span></span>';
1181						}
1182					}
1183					if (this.curPage < maxPage) {
1184						html += '<a href="' + this.pageUrl(this.curPage + 1) + '" class="next page-numbers"><span>&gt;</span></a>';
1185					} else {
1186						html += '<span class="next page-numbers">&gt;</span>';
1187					}
1188				}
1189				this.$navLinks.html(html);
1190			}
1191		},
1192
1193		pageUrl: function(page){
1194			return (page == 1) ? this.location : (this.location + 'page/' + page + '/');
1195		},
1196
1197		/**
1198		 * Overloadable function for themes
1199		 * @param $item
1200		 */
1201		itemLoaded: function($item){
1202		},
1203
1204		/**
1205		 * Overloadable function for themes
1206		 * @param $item
1207		 */
1208		itemsLoaded: function($items){
1209		}
1210
1211	};
1212
1213	$.fn.wPortfolio = function(options){
1214		return this.each(function(){
1215			$(this).data('wPortfolio', new $us.WPortfolio(this, options));
1216		});
1217	};
1218
1219	if ($.fn.magnificPopup) {
1220		$('.w-portfolio-list').each(function(){
1221			$(this).magnificPopup({
1222				type: 'image',
1223				delegate: 'a[ref=magnificPopupPortfolio]:visible',
1224				gallery: {
1225					enabled: true,
1226					navigateByImgClick: true,
1227					preload: [0, 1],
1228					tPrev: $us.langOptions.magnificPopup.tPrev, // Alt text on left arrow
1229					tNext: $us.langOptions.magnificPopup.tNext, // Alt text on right arrow
1230					tCounter: $us.langOptions.magnificPopup.tCounter // Markup for "1 of 7" counter
1231				},
1232				removalDelay: 300,
1233				mainClass: 'mfp-fade',
1234				fixedContentPos: false
1235			});
1236		});
1237	}
1238
1239}(jQuery);
1240
1241/**
1242 * UpSolution Widget: w-cart
1243 *
1244 * @requires $us.canvas
1245 * @requires $us.nav
1246 */
1247jQuery(function($){
1248	var $cart = $('.w-cart');
1249	if ($cart.length == 0) return;
1250	var $quantity = $cart.find('.w-cart-quantity');
1251
1252	var updateCart = function(){
1253		var $mini_cart_amount = $cart.find('.us_mini_cart_amount'),
1254			mini_cart_amount = $mini_cart_amount.text();
1255
1256		if (mini_cart_amount !== undefined) {
1257			mini_cart_amount = mini_cart_amount + '';
1258			mini_cart_amount = mini_cart_amount.match(/\d+/g);
1259
1260			if (mini_cart_amount > 0) {
1261				$quantity.html(mini_cart_amount);
1262				$cart.removeClass('empty');
1263			} else {
1264				$quantity.html('0');
1265				$cart.addClass('empty');
1266			}
1267
1268		} else {
1269			// fallback in case our action wasn't fired somehow
1270			var $quantities = $cart.find('.quantity'),
1271				total = 0;
1272			$quantities.each(function(){
1273				var quantity,
1274					text = $(this).text() + '',
1275					matches = text.match(/\d+/g);
1276
1277				if (matches) {
1278					quantity = parseInt(matches[0], 10);
1279					total += quantity;
1280				}
1281
1282			});
1283
1284			if (total > 0) {
1285				$quantity.html(total);
1286				$cart.removeClass('empty');
1287			} else {
1288				$quantity.html('0');
1289				$cart.addClass('empty');
1290			}
1291
1292		}
1293
1294	};
1295
1296	updateCart();
1297
1298	$(document.body).bind('wc_fragments_loaded', function(){
1299		updateCart();
1300	});
1301
1302	$(document.body).bind('wc_fragments_refreshed', function(){
1303		updateCart();
1304	});
1305
1306	var $notification = $cart.find('.w-cart-notification'),
1307		$productName = $notification.find('.product-name'),
1308		$cartLink = $cart.find('.w-cart-link'),
1309		$dropdown = $cart.find('.w-cart-dropdown'),
1310		$quantity = $cart.find('.w-cart-quantity'),
1311		productName = $productName.text(),
1312		animationType = (window.$us !== undefined && window.$us.nav !== undefined) ? $us.nav.animationType : 'opacity',
1313		showFn = 'fadeInCSS',
1314		hideFn = 'fadeOutCSS',
1315		opened = false;
1316
1317	if (animationType == 'height') {
1318		showFn = 'slideDownCSS';
1319		hideFn = 'slideUpCSS';
1320	}
1321	else if (animationType == 'mdesign') {
1322		showFn = 'showMD';
1323		hideFn = 'hideMD';
1324	}
1325
1326	$notification.on('click', function(){
1327		$notification[hideFn]();
1328	});
1329
1330	jQuery('body').bind('added_to_cart', function(event, fragments, cart_hash, $button){
1331		if (event === undefined) return;
1332
1333		$quantity.html(parseInt($quantity.html(), 10) + 1);
1334
1335		$cart.removeClass('empty');
1336
1337		productName = $button.closest('.product').find('.product-meta h3:first').text();
1338		$productName.html(productName);
1339
1340		$notification[showFn](undefined, function(){
1341			var newTimerId = setTimeout(function(){
1342				$notification[hideFn]();
1343			}, 3000);
1344			$notification.data('animation-timers', $notification.data('animation-timers') + ',' + newTimerId);
1345		});
1346	});
1347
1348	if ($.isMobile) {
1349		var outsideClickEvent = function(e){
1350			if (jQuery.contains($cart[0], e.target)) return;
1351			$dropdown[hideFn]();
1352			$us.$body.off('touchstart', outsideClickEvent);
1353			opened = false;
1354		};
1355		$cartLink.on('click', function(e){
1356			if (!opened) {
1357				e.preventDefault();
1358				$dropdown[showFn]();
1359				$us.$body.on('touchstart', outsideClickEvent);
1360			} else {
1361				$dropdown[hideFn]();
1362				$us.$body.off('touchstart', outsideClickEvent);
1363			}
1364			opened = !opened;
1365		});
1366	} else {
1367		var hideTimer = null;
1368		$cartLink.on('hover', function(){
1369			if (opened) return;
1370			$dropdown[showFn]();
1371			opened = true;
1372		});
1373		$cart.hover(function(){
1374			clearTimeout(hideTimer);
1375		}, function(){
1376			clearTimeout(hideTimer);
1377			hideTimer = setTimeout(function(){
1378				if (!opened) return;
1379				$dropdown[hideFn]();
1380				opened = false;
1381			}, 250);
1382		});
1383	}
1384});
1385
1386
1387/**
1388 * UpSolution Login Widget: widget_us_login
1389 *
1390 */
1391!function($){
1392	"use strict";
1393
1394	$us.wUsLogin = function(container, options){
1395		this.$container = $(container);
1396		this.$form = this.$container.find('.w-form');
1397		this.$profile = this.$container.find('.w-profile');
1398
1399		var $jsonContainer = this.$container.find('.w-profile-json');
1400
1401		this.jsonData = $jsonContainer[0].onclick() || {};
1402		$jsonContainer.remove();
1403
1404		this.ajaxUrl = this.jsonData.ajax_url || '';
1405		this.logoutRedirect = this.jsonData.logout_redirect || '';
1406
1407		$.ajax({
1408			type: 'post',
1409			url: this.ajaxUrl,
1410			data: {
1411				action: 'us_ajax_user_info',
1412				logout_redirect: this.logoutRedirect
1413			},
1414			success: function(result){
1415				if (result.success) {
1416					var $avatar = this.$profile.find('.w-profile-avatar'),
1417						$name = this.$profile.find('.w-profile-name'),
1418						$logoutLink = this.$profile.find('.w-profile-link.for_logout')
1419
1420					$avatar.html(result.data.avatar);
1421					$name.html(result.data.name);
1422					$logoutLink.attr('href', result.data.logout_url);
1423
1424					this.$profile.removeClass('hidden');
1425				} else {
1426					this.$form.removeClass('hidden');
1427				}
1428			}.bind(this)
1429		});
1430	};
1431
1432	$.fn.wUsLogin = function(options){
1433		return this.each(function(){
1434			$(this).data('wUsLogin', new $us.wUsLogin(this, options));
1435		});
1436	};
1437
1438	$(function(){
1439		$('.widget_us_login').wUsLogin();
1440	});
1441}(jQuery);
1442
1443
1444/**
1445 * UpSolution Widget: w-maps
1446 *
1447 * Used for [us_gmaps] shortcode
1448 */
1449!function($){
1450	"use strict";
1451
1452	$us.WMapsGeocodesCounter = 0; // counter of total geocode requests number
1453	$us.WMapsGeocodesRunning = false;
1454	$us.WMapsCurrentGeocode = 0; // current processing geocode
1455	$us.WMapsGeocodesMax = 5; // max number of simultaneous geocode requests allowed
1456	$us.WMapsGeocodesStack = {};
1457
1458	$us.WMapsRunGeoCode = function(){
1459		if ($us.WMapsCurrentGeocode <= $us.WMapsGeocodesCounter) {
1460			$us.WMapsGeocodesRunning = true;
1461			if ($us.WMapsGeocodesStack[$us.WMapsCurrentGeocode] != null)
1462				$us.WMapsGeocodesStack[$us.WMapsCurrentGeocode]();
1463		} else {
1464			$us.WMapsGeocodesRunning = false;
1465		}
1466	};
1467
1468	$us.WMaps = function(container, options){
1469
1470		this.$container = $(container);
1471
1472		var $jsonContainer = this.$container.find('.w-map-json'),
1473			jsonOptions = $jsonContainer[0].onclick() || {},
1474			$jsonStyleContainer = this.$container.find('.w-map-style-json'),
1475			jsonStyleOptions,
1476			markerOptions,
1477			shouldRunGeoCode = false;
1478		$jsonContainer.remove();
1479		if ($jsonStyleContainer.length) {
1480			jsonStyleOptions = $jsonStyleContainer[0].onclick() || {};
1481			$jsonStyleContainer.remove();
1482		}
1483
1484
1485		// Setting options
1486		var defaults = {};
1487		this.options = $.extend({}, defaults, jsonOptions, options);
1488
1489		this._events = {
1490			redraw: this.redraw.bind(this)
1491		};
1492
1493		var gmapsOptions = {
1494			el: '#' + this.$container.attr('id'),
1495			lat: 0,
1496			lng: 0,
1497			zoom: this.options.zoom,
1498			type: this.options.type,
1499			height: this.options.height + 'px',
1500			width: '100%',
1501			mapTypeId: google.maps.MapTypeId[this.options.maptype]
1502		};
1503
1504		if (this.options.hideControls) {
1505			gmapsOptions.disableDefaultUI = true;
1506		}
1507		if (this.options.disableZoom) {
1508			gmapsOptions.scrollwheel = false;
1509		}
1510		if (this.options.disableDragging && ( !$us.$html.hasClass('no-touch'))) {
1511			gmapsOptions.draggable = false;
1512		}
1513		if (this.options.mapBgColor) {
1514			gmapsOptions.backgroundColor = this.options.mapBgColor;
1515		}
1516
1517		this.GMapsObj = new GMaps(gmapsOptions);
1518		if (jsonStyleOptions != null && jsonStyleOptions != {}) {
1519			this.GMapsObj.map.setOptions({styles: jsonStyleOptions});
1520		}
1521
1522		var that = this;
1523
1524		if (this.options.latitude != null && this.options.longitude != null) {
1525			this.GMapsObj.setCenter(this.options.latitude, this.options.longitude);
1526		} else {
1527			var mapGeoCode = function(geocodeNum){
1528				GMaps.geocode({
1529					address: that.options.address,
1530					callback: function(results, status){
1531						if (status == 'OK') {
1532							var latlng = results[0].geometry.location;
1533							that.options.latitude = latlng.lat();
1534							that.options.longitude = latlng.lng();
1535							that.GMapsObj.setCenter(that.options.latitude, that.options.longitude);
1536							$us.WMapsCurrentGeocode++;
1537							$us.WMapsRunGeoCode();
1538						} else if (status == "OVER_QUERY_LIMIT") {
1539							setTimeout(function(){
1540								$us.WMapsRunGeoCode()
1541							}, 2000);
1542						}
1543					}
1544				});
1545			};
1546			shouldRunGeoCode = true;
1547			$us.WMapsGeocodesStack[$us.WMapsGeocodesCounter] = mapGeoCode;
1548			$us.WMapsGeocodesCounter++;
1549		}
1550
1551		$.each(this.options.markers, function(i, val){
1552			markerOptions = {};
1553			if (that.options.icon != null) {
1554				markerOptions.icon = {
1555					url: that.options.icon.url,
1556					size: new google.maps.Size(that.options.icon.size[0], that.options.icon.size[1]),
1557					origin: new google.maps.Point(0, 0),
1558					anchor: new google.maps.Point(that.options.icon.anchor[0], that.options.icon.anchor[1])
1559				};
1560			}
1561
1562			if (that.options.markers[i] != null) {
1563
1564				if (that.options.markers[i].latitude != null && that.options.markers[i].longitude != null) {
1565					markerOptions.lat = that.options.markers[i].latitude;
1566					markerOptions.lng = that.options.markers[i].longitude;
1567					markerOptions.infoWindow = {content: that.options.markers[i].html};
1568					var marker = that.GMapsObj.addMarker(markerOptions);
1569					if (that.options.markers[i].infowindow) {
1570						marker.infoWindow.open(that.GMapsObj.map, marker);
1571					}
1572				} else {
1573					var markerGeoCode = function(geocodeNum){
1574						GMaps.geocode({
1575							address: that.options.markers[i].address,
1576							callback: function(results, status){
1577								if (status == 'OK') {
1578									var latlng = results[0].geometry.location;
1579									markerOptions.lat = latlng.lat();
1580									markerOptions.lng = latlng.lng();
1581									markerOptions.infoWindow = {content: that.options.markers[i].html};
1582									var marker = that.GMapsObj.addMarker(markerOptions);
1583									if (that.options.markers[i].infowindow) {
1584										marker.infoWindow.open(that.GMapsObj.map, marker);
1585									}
1586									$us.WMapsCurrentGeocode++;
1587									$us.WMapsRunGeoCode();
1588								} else if (status == "OVER_QUERY_LIMIT") {
1589									setTimeout(function(){
1590										$us.WMapsRunGeoCode()
1591									}, 2000);
1592								}
1593							}
1594						});
1595					};
1596					shouldRunGeoCode = true;
1597					$us.WMapsGeocodesStack[$us.WMapsGeocodesCounter] = markerGeoCode;
1598					$us.WMapsGeocodesCounter++;
1599				}
1600			}
1601		});
1602
1603		if (shouldRunGeoCode && ( !$us.WMapsGeocodesRunning)) {
1604			$us.WMapsRunGeoCode();
1605		}
1606
1607		$us.$canvas.on('contentChange', this._events.redraw);
1608
1609		// In case some toggler was opened before the actual page load
1610		$us.$window.load(this._events.redraw);
1611	};
1612
1613	$us.WMaps.prototype = {
1614		/**
1615		 * Fixing hidden and other breaking-cases maps
1616		 */
1617		redraw: function(){
1618			if (this.$container.is(':hidden')) return;
1619			this.GMapsObj.refresh();
1620			if (this.options.latitude != null && this.options.longitude != null) {
1621				this.GMapsObj.setCenter(this.options.latitude, this.options.longitude);
1622			}
1623
1624		}
1625	};
1626
1627	$.fn.wMaps = function(options){
1628		return this.each(function(){
1629			$(this).data('wMaps', new $us.WMaps(this, options));
1630		});
1631	};
1632
1633	$(function(){
1634		$('.w-map').wMaps();
1635	});
1636}(jQuery);
1637
1638
1639/**
1640 * UpSolution Widget: w-sharing
1641 */
1642!function($){
1643	"use strict";
1644
1645	$('.w-sharing.type_fixed.align_left, .w-sharing.type_fixed.align_right').each(function(){
1646		var $this = $(this);
1647		$this.css('margin-top', -.5 * $this.height());
1648	});
1649
1650	$('.w-sharing.type_fixed.align_center').each(function(){
1651		var $this = $(this);
1652		$this.css('margin-left', -.5 * $this.width());
1653	});
1654
1655	$('.w-sharing-item').on('click', function(){
1656		var $this = $(this);
1657		var opt = {
1658			url: window.location,
1659			text: document.title,
1660			lang: document.documentElement.lang,
1661			image: $('meta[name="og:image"]').attr('content') || ''
1662		};
1663		if ($this.attr('data-sharing-url') !== undefined && $this.attr('data-sharing-url') != '') {
1664			opt.url = $this.attr('data-sharing-url');
1665		}
1666		if ($this.attr('data-sharing-image') !== undefined && $this.attr('data-sharing-image') != '') {
1667			opt.image = $this.attr('data-sharing-image');
1668		}
1669		if (opt.image == '' || opt.image === undefined) {
1670			var first_image_src = $('img').first().attr('src');
1671			if (first_image_src != undefined && first_image_src != '') {
1672				opt.image = first_image_src;
1673			}
1674		}
1675		if ($this.hasClass('facebook')) {
1676			window.open("http://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(opt.url) + "&t=" + encodeURIComponent(opt.text) + "", "", "toolbar=0, status=0, width=900, height=500");
1677		} else if ($this.hasClass('twitter')) {
1678			window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent(opt.text) + "&url=" + encodeURIComponent(opt.url), "", "toolbar=0, status=0, width=650, height=360");
1679		} else if ($this.hasClass('linkedin')) {
1680			window.open('https://www.linkedin.com/cws/share?url=' + encodeURIComponent(opt.url) + '&token=&isFramed=true', 'linkedin', 'toolbar=no,width=550,height=550');
1681		} else if ($this.hasClass('gplus')) {
1682			window.open("https://plus.google.com/share?hl=" + encodeURIComponent(opt.lang) + "&url=" + encodeURIComponent(opt.url), "", "toolbar=0, status=0, width=900, height=500");
1683		} else if ($this.hasClass('pinterest')) {
1684			window.open('http://pinterest.com/pin/create/button/?url=' + encodeURIComponent(opt.url) + '&media=' + encodeURIComponent(opt.image) + '&description=' + encodeURIComponent(opt.text), 'pinterest', 'toolbar=no,width=700,height=300');
1685		} else if ($this.hasClass('vk')) {
1686			window.open('http://vk.com/share.php?url=' + encodeURIComponent(opt.url) + '&title=' + encodeURIComponent(opt.text), '&description=&image=' + encodeURIComponent(opt.image), 'toolbar=no,width=700,height=300');
1687		} else if ($this.hasClass('email')) {
1688			window.location = 'mailto:?subject=' + opt.text + '&body=' + opt.url;
1689		}
1690	});
1691}(jQuery);
1692
1693
1694/**
1695 * UpSolution Widget: l-preloader
1696 */
1697!function($){
1698	"use strict";
1699
1700	if ($('.l-preloader').length) {
1701		$('document').ready(function(){
1702			setTimeout(function(){
1703				$('.l-preloader').addClass('done');
1704			}, 500);
1705			setTimeout(function(){
1706				$('.l-preloader').addClass('hidden');
1707			}, 1000); // 500 ms after 'done' class is added
1708		});
1709	}
1710}(jQuery);

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.