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 this.$line_charts = this.$container.find(".vc_line-chart"); 393 394 // Class variables 395 this.width = 0; 396 this.tabWidths = []; 397 this.isTogglable = (this.$container.usMod('type') == 'togglable'); 398 // Basic layout 399 this.basicLayout = this.$container.hasClass('accordion') ? 'accordion' : (this.$container.usMod('layout') || 'default'); 400 // Current active layout (may be switched to 'accordion') 401 this.curLayout = this.basicLayout; 402 this.responsive = $us.canvas.options.responsive; 403 // Array of active tabs indexes 404 this.active = []; 405 this.count = this.$tabs.length; 406 // Container width at which we should switch to accordion layout 407 this.minWidth = 0; 408 409 if (this.count == 0) return; 410 411 // Preparing arrays of jQuery objects for easier manipulating in future 412 this.tabs = $.map(this.$tabs.toArray(), $); 413 this.sections = $.map(this.$sections.toArray(), $); 414 this.headers = $.map(this.$headers.toArray(), $); 415 this.contents = $.map(this.$contents.toArray(), $); 416 417 $.each(this.tabs, function(index){ 418 if (this.tabs[index].hasClass('active')) { 419 this.active.push(index); 420 } 421 this.tabs[index].add(this.headers[index]).on('click', function(e){ 422 e.preventDefault(); 423 // Toggling accordion sections 424 if (this.curLayout == 'accordion' && this.isTogglable) { 425 // Cannot toggle the only active item 426 this.toggleSection(index); 427 } 428 // Setting tabs active item 429 else if (index != this.active[0]) { 430 this.openSection(index); 431 } 432 }.bind(this)); 433 }.bind(this)); 434 435 this.$tabsH.on('click', function(e){ 436 e.preventDefault(); 437 }); 438 439 // Boundable events 440 this._events = { 441 resize: this.resize.bind(this), 442 contentChanged: function(){ 443 $us.$canvas.trigger('contentChange'); 444 this.$line_charts.length&&jQuery.fn.vcLineChart&&this.$line_charts.vcLineChart({reload:!1});// TODO: check if we can do this without hardcoding line charts init here; 445 }.bind(this) 446 }; 447 448 // Starting everything 449 this.switchLayout(this.curLayout); 450 if (this.curLayout != 'accordion' || !this.isTogglable) { 451 this.openSection(this.active[0]); 452 } 453 454 setTimeout(this._events.resize, 50); 455 $us.$window.on('resize load', this._events.resize); 456 457 // Open tab on page load by hash 458 if (window.location.hash) { 459 var hash = window.location.hash.substr(1), 460 $linkedSection = this.$container.find('.w-tabs-section[id="' + hash + '"]'); 461 if ($linkedSection.length && ( !$linkedSection.hasClass('active'))) { 462 var $header = $linkedSection.find('.w-tabs-section-header'); 463 $header.click(); 464 } 465 }
466 // Support for external links to tabs 467 $.each(this.tabs, function(index){ 468 if (this.headers[index].attr('href') != undefined) { 469 var tabHref = this.headers[index].attr('href'), 470 tabHeader = this.headers[index]; 471 $('a[href=' + tabHref + ']').on('click', function(e){ 472 e.preventDefault(); 473 if ($(this).hasClass('w-tabs-section-header', 'w-tabs-item-h')) { 474 return; 475 } 476 tabHeader.click(); 477 }); 478 } 479 }.bind(this)); 480 }, 481 482 switchLayout: function(to){ 483 this.cleanUpLayout(this.curLayout); 484 this.prepareLayout(to); 485 this.curLayout = to; 486 }, 487 488 /** 489 * Clean up layout's special inline styles and/or dom elements 490 * @param from 491 */ 492 cleanUpLayout: function(from){ 493 if (from == 'default' || from == 'timeline' || from == 'modern' || from == 'trendy') { 494 this.$sectionsWrapper.clearPreviousTransitions().resetInlineCSS('width', 'height'); 495 this.$sectionsHelper.clearPreviousTransitions().resetInlineCSS('position', 'width', 'left'); 496 this.$sections.resetInlineCSS('width'); 497 this.$container.removeClass('autoresize'); 498 } 499 else if (from == 'accordion') { 500 this.$container.removeClass('accordion'); 501 this.$contents.resetInlineCSS('height', 'padding-top', 'padding-bottom', 'display', 'opacity'); 502 } 503 else if (from == 'ver') { 504 this.$contents.resetInlineCSS('height', 'padding-top', 'padding-bottom', 'display', 'opacity'); 505 } 506 }, 507 508 /** 509 * Apply layout's special inline styles and/or dom elements 510 * @param to 511 */ 512 prepareLayout: function(to){ 513 if (to == 'default' || to == 'timeline' || to == 'modern' || to == 'trendy') { 514 this.$container.addClass('autoresize'); 515 this.$sectionsHelper.css('position', 'absolute'); 516 } 517 else if (to == 'accordion') { 518 this.$container.addClass('accordion'); 519 this.$contents.hide(); 520 for (var i = 0; i < this.active.length; i++) { 521 if (this.contents[this.active[i]] !== undefined) { 522 this.contents[this.active[i]].show(); 523 } 524 } 525 } 526 else if (to == 'ver') { 527 this.$contents.hide(); 528 this.contents[this.active[0]].show(); 529 } 530 }, 531 532 /** 533 * Measure needed sizes and store them to this.tabWidths variable 534 * 535 * TODO Count minWidth here as well 536 */ 537 measure: function(){ 538 if (this.basicLayout == 'ver') { 539 // Measuring minimum tabs width 540 this.$tabsList.css('width', 0); 541 var minTabWidth = this.$tabsList.outerWidth(true); 542 this.$tabsList.css('width', ''); 543 // Measuring the mininum content width 544 this.$container.addClass('measure'); 545 var minContentWidth = this.$sectionsWrapper.outerWidth(true); 546 this.$container.removeClass('measure'); 547 // Measuring minimum tabs width for percent-based sizes 548 var navWidth = this.$container.usMod('navwidth'); 549 if (navWidth != 'auto') { 550 // Percent-based measure 551 minTabWidth = Math.max(minTabWidth, minContentWidth * parseInt(navWidth) / (100 - parseInt(navWidth))); 552 } 553 this.minWidth = Math.max(480, minContentWidth + minTabWidth + 1); 554 } else { 555 this.tabWidths = []; 556 // We hide active line temporarily to count tab sizes properly 557 this.$container.addClass('measure'); 558 for (var index = 0; index < this.tabs.length; index++) { 559 this.tabWidths.push(this.tabs[index].outerWidth(true)); 560 } 561 this.$container.removeClass('measure'); 562 if (this.basicLayout == 'default' || this.basicLayout == 'timeline' || this.basicLayout == 'modern' || this.basicLayout == 'trendy') { 563 // Array sum 564 this.minWidth = this.tabWidths.reduce(function(pv, cv){ 565 return pv + cv; 566 }, 0); 567 } 568 } 569 }, 570 571 /** 572 * Open tab section 573 * 574 * @param index int 575 */ 576 openSection: function(index){ 577 if (this.sections[index] === undefined) return; 578 if (this.curLayout == 'default' || this.curLayout == 'timeline' || this.curLayout == 'modern' || this.curLayout == 'trendy') { 579 this.$container.removeClass('autoresize'); 580 var height = this.sections[index].height(); 581 this.$sectionsHelper.performCSSTransition({ 582 left: -this.width * (this.isRtl ? (this.count - index - 1 ) : index) 583 }, this.options.duration, this._events.contentChanged, this.options.easing); 584 this.$sectionsWrapper.performCSSTransition({ 585 height: height 586 }, this.options.duration, function(){ 587 this.$container.addClass('autoresize'); 588 }.bind(this), this.options.easing); 589 } 590 else if (this.curLayout == 'accordion' || this.curLayout == 'ver') { 591 if (this.contents[this.active[0]] !== undefined) { 592 this.contents[this.active[0]].css('display', 'block').slide
592Up(this.options.duration); 593 } 594 this.contents[index].css('display', 'none').slideDown(this.options.duration, this._events.contentChanged); 595 // Scrolling to the opened section at small window dimensions 596 if (this.curLayout == 'accordion' && $us.canvas.winWidth < 768) { 597 var newTop = this.headers[0].offset().top; 598 for (var i = 0; i < index; i++) { 599 newTop += this.headers[i].outerHeight(); 600 } 601 $us.scroll.scrollTo(newTop, true); 602 } 603 } 604 this._events.contentChanged(); 605 this.$tabs.removeClass('active'); 606 this.tabs[index].addClass('active'); 607 this.$sections.removeClass('active'); 608 this.sections[index].addClass('active'); 609 this.active[0] = index; 610 }, 611 612 /** 613 * Toggle some togglable accordion section 614 * 615 * @param index 616 */ 617 toggleSection: function(index){ 618 // (!) Can only be used within accordion state 619 var indexPos = $.inArray(index, this.active); 620 if (indexPos != -1) { 621 this.contents[index].css('display', 'block').slideUp(this.options.duration, this._events.contentChanged); 622 this.tabs[index].removeClass('active'); 623 this.sections[index].removeClass('active'); 624 this.active.splice(indexPos, 1); 625 } 626 else { 627 this.contents[index].css('display', 'none').slideDown(this.options.duration, this._events.contentChanged); 628 this.tabs[index].addClass('active'); 629 this.sections[index].addClass('active'); 630 this.active.push(index); 631 } 632 }, 633 634 /** 635 * Resize-driven logics 636 */ 637 resize: function(){ 638 this.width = this.$container.width(); 639 this.$tabsList.removeClass('hidden'); 640 641 // Basic layout may be overriden 642 if (this.responsive) { 643 if (this.basicLayout == 'ver' && this.curLayout != 'ver') this.switchLayout('ver'); 644 if (this.curLayout != 'accordion') this.measure(); 645 var nextLayout = (this.width < this.minWidth) ? 'accordion' : this.basicLayout; 646 if (nextLayout !== this.curLayout) this.switchLayout(nextLayout); 647 } 648 649 // Fixing tabs display 650 if (this.curLayout == 'default' || this.curLayout == 'timeline' || this.curLayout == 'modern' || this.curLayout == 'trendy') { 651 this.$container.addClass('autoresize'); 652 this.$sectionsWrapper.css('width', this.width); 653 this.$sectionsHelper.css('width', this.count * this.width); 654 this.$sections.css('width', this.width); 655 if (this.contents[this.active[0]] !== undefined) { 656 this.$sectionsHelper.css('left', -this.width * (this.isRtl ? (this.count - this.active[0] - 1) : this.active[0])); 657 var height = this.sections[this.active[0]].height(); 658 this.$sectionsWrapper.css('height', height); 659 } 660 } else if (this.curLayout == 'ver') { 661 var sectionsWrapperWidth = this.$sectionsWrapper.width(); 662 } 663 this._events.contentChanged(); 664 } 665 666 }; 667 668 $.fn.wTabs = function(options){ 669 return this.each(function(){ 670 $(this).data('wTabs', new $us.WTabs(this, options)); 671 }); 672 }; 673 674}(jQuery); 675 676 677/** 678 * UpSolution Shortcode: us_logos 679 */ 680jQuery(function($){ 681 $(".w-logos.type_carousel .w-logos-list").each(function(){ 682 var $list = $(this), 683 items = parseInt($list.data('items')); 684 $list.owlCarousel({ 685 items: items, 686 center: (items == 1), 687 loop: true, 688 rtl: $('.l-body').hasClass('rtl'), 689 nav: $list.data('nav'), 690 autoplay: $list.data('autoplay'), 691 autoplayTimeout: $list.data('timeout'), 692 autoplayHoverPause: true, 693 responsive: { 694 0: {items: 1, center: true}, 695 480: {items: Math.min(items, 2)}, 696 768: {items: Math.min(items, 3)}, 697 900: {items: Math.min(items, 4)}, 698 1200: {items: items} 699 } 700 }); 701 }); 702}); 703 704 705/** 706 * UpSolution Shortcode: us_feedback 707 */ 708jQuery(function($){ 709 710 $('.w-form.for_cform').each(function(){ 711 var $container = $(this), 712 $form = $container.find('form:first'), 713 $submitBtn = $form.find('.w-btn'), 714 $resultField = $form.find('.w-form-message'), 715 options = $container.find('.w-form-json')[0].onclick(); 716 717 $form.submit(function(event){ 718 event.preventDefault(); 719 720 // Prevent double-sending 721 if ($submitBtn.hasClass('loading')) return; 722 723 $resultField.usMod('type', false).html(''); 724 // Validation 725 var errors = 0; 726 $form.find('[data-required="true"]').each(function(){ 727 var $input = $(this), 728 isEmpty = ($input.val() == ''), 729 $row = $input.closest('.w-form-row'), 730 errorText = options.errors[$input.attr('name')] || ''; 731 $row.toggleClass('check_wrong', isEmpty); 732 $row.find('.w-form-row-state').html(isEmpty ? errorText : ''); 733 if (isEmpty) { 734 errors++; 735 } 736 }); 737 738 if (errors != 0) return; 739 740 $submitBtn.addClass('loading'); 741 $.ajax({ 742 type: 'POST', 743 url: options.ajaxurl, 744 dataType: 'json', 745 data: $form.serialize(), 746 success: function(result){ 747 if (result.success) { 748 $resultField.usMod('type', 'success').html(result.data); 749 $form.find('.w-form-row.check_wrong').removeClass('check_wrong'); 750 $form.find('.w-form-row.not-empty').removeClass('not-empty'); 751 $form.find('.w-form-state').html(''); 752 $form.find('input[type="text"], input[type="email"], textarea').val(''); 753 } else { 754 $form.find('.w-form-row.check_wrong').removeClass('check_wrong'); 755 $form.find('.w-form-state').html(''); 756 if (result.data && typeof result.data == 'object') { 757 for (var fieldName in result.data) { 758 if (fieldName == 'empty_message') { 759 var errorText = result.data[fieldName]; 760 $resultField.usMod('type', 'error').html(errorText); 761 continue; 762 } 763 if (!result.data.hasOwnProperty(fieldName)) continue; 764 var $input = $form.find('[name="' + fieldName + '"]'), 765 errorText = result.data[fieldName]; 766 $input.closest('.w-form-row').addClass('check_wrong') 767 .find('.w-form-row-state').html(errorText); 768 } 769 } else { 770 $resultField.usMod('type', 'error').html(result.data); 771 } 772 } 773 }, 774 complete: function(){ 775 $submitBtn.removeClass('loading'); 776 } 777 }); 778 }); 779 780 }); 781}); 782 783 784/** 785 * UpSolution Shortcode: us_counter 786 */ 787jQuery(function($){ 788 $('.w-counter').each(function(index, elm){ 789 var $container = $(this), 790 $number = $container.find('.w-counter-number'), 791 initial = ($container.data('initial') || '0') + '', 792 target = ($container.data('target') || '10') + '', 793 prefix = $container.data('prefix') || '', 794 suffix = $container.data('suffix') || '', 795 // 0 for integers, 1+ for floats (number of digits after the decimal) 796 precision = 0, 797 usingComma = false;
798 if (target.indexOf('.') != -1) { 799 precision = target.length - 1 - target.indexOf('.'); 800 } else if (target.indexOf(',') != -1) { 801 precision = target.length - 1 - target.indexOf(','); 802 usingComma = true; 803 target = target.replace(',', '.'); 804 } 805 initial = window[precision ? 'parseFloat' : 'parseInt'](initial, 10); 806 target = window[precision ? 'parseFloat' : 'parseInt'](target, 10); 807 808 if ( /bot|googlebot|crawler|spider|robot|crawling/i.test(navigator.userAgent) ) { 809 if (usingComma) { 810 $number.html(prefix + target.toFixed(precision).replace('\.', ',') + suffix); 811 } else { 812 $number.html(prefix + target.toFixed(precision) + suffix); 813 } 814 815 return; 816 } 817 818 if (usingComma) { 819 $number.html(prefix + initial.toFixed(precision).replace('\.', ',') + suffix); 820 } else { 821 $number.html(prefix + initial.toFixed(precision) + suffix); 822 } 823 $us.scroll.addWaypoint(this, '15%', function(){ 824 var current = initial, 825 step = 25, 826 stepValue = (target - initial) / 25, 827 interval = setInterval(function(){ 828 current += stepValue; 829 step--; 830 if (usingComma) { 831 $number.html(prefix + current.toFixed(precision).replace('\.', ',') + suffix); 832 } else { 833 $number.html(prefix + current.toFixed(precision) + suffix); 834 } 835 if (step <= 0) { 836 if (usingComma) { 837 $number.html(prefix + target.toFixed(precision).replace('\.', ',') + suffix); 838 } else { 839 $number.html(prefix + target.toFixed(precision) + suffix); 840 } 841 window.clearInterval(interval); 842 } 843 }, 40); 844 }); 845 }); 846}); 847 848 849/** 850 * UpSolution Shortcode: us_progbar 851 */ 852jQuery(function($){ 853 $('.w-progbar').each(function(index, elm){ 854 var $container = $(this), 855 $bar = $container.find('.w-progbar-bar-h'), 856 count = $container.data('count') + '', 857 $titleCount = $container.find('.w-progbar-title-count'), 858 $barCount = $container.find('.w-progbar-bar-count'); 859 860 if (count === null) { 861 count = 50; 862 } 863 864 if ( /bot|googlebot|crawler|spider|robot|crawling/i.test(navigator.userAgent) ) { 865 $container.removeClass('initial'); 866 $titleCount.html(count + '%'); 867 $barCount.html(count + '%'); 868 return; 869 } 870 871 $titleCount.html('0%'); 872 $barCount.html('0%'); 873 874 $us.scroll.addWaypoint(this, '15%', function(){ 875 var current = 0, 876 step = 40, 877 stepValue = count / 40, 878 interval = setInterval(function(){ 879 current += stepValue; 880 step--; 881 $titleCount.html(current.toFixed(0) + '%'); 882 $barCount.html(current.toFixed(0) + '%'); 883 if (step <= 0) { 884 $titleCount.html(count + '%'); 885 $barCount.html(count + '%'); 886 window.clearInterval(interval); 887 } 888 }, 20); 889 890 $container.removeClass('initial'); 891 }); 892 }); 893}); 894 895 896/** 897 * UpSolution Shortcode: us_gallery 898 */ 899jQuery(function($){ 900 if ($.fn.magnificPopup) { 901 $('.w-gallery.link_media .w-gallery-list').each(function(){ 902 $(this).magnificPopup({ 903 type: 'image', 904 delegate: 'a.w-gallery-item', 905 gallery: { 906 enabled: true, 907 navigateByImgClick: true, 908 preload: [0, 1], 909 tPrev: $us.langOptions.magnificPopup.tPrev, // Alt text on left arrow 910 tNext: $us.langOptions.magnificPopup.tNext, // Alt text on right arrow 911 tCounter: $us.langOptions.magnificPopup.tCounter // Markup for "1 of 7" counter 912 }, 913 removalDelay: 300, 914 mainClass: 'mfp-fade', 915 fixedContentPos: false 916 }); 917 }); 918 } 919 if ($.fn.isotope) { 920 // Applying isotope to gallery 921 $('.w-gallery.layout_masonry').each(function(index, gallery){ 922 if ($(gallery).hasClass('cols_1')) return; // TODO: check if we can replace this condition with CSS :not(.cols_1) selector 923 924 var $container = $($(gallery).find('.w-gallery-list')), 925 isotopeOptions = { 926 layoutMode: 'masonry', 927 isOriginLeft: !$('body').hasClass('rtl') 928 }; 929 if ($container.parents('.w-tabs-section-content-h').length) { 930 isotopeOptions.transitionDuration = 0; 931 } 932 $container.imagesLoaded(function(){ 933 $container.isotope(isotopeOptions); 934 $container.isotope(); 935 }); 936 $us.$canvas.on('contentChange', function(){ 937 $container.imagesLoaded(function(){ 938 $container.isotope(); 939 }); 940 }); 941 }); 942 } 943}); 944 945 946/** 947 * UpSolution Shortcode: us_slider 948 */ 949(function($){ 950 $.fn.wSlider = function(){ 951 return this.each(function(){ 952 var $this = $(this), 953 $slider = $this.find('.royalSlider'), 954 $options = $this.find('.w-slider-json'), 955 options = $options[0].onclick() || {}; 956 $options.remove(); 957 if (!$.fn.royalSlider) { 958 return; 959 } 960 // Always apply certain fit options for blog listing slider 961 if ($this.parent().hasClass('w-blog-post-preview')) { 962 options['imageScaleMode'] = 'fill'; 963 } 964 $slider.royalSlider(options); 965 var slider = $slider.data('royalSlider'); 966 if (options.fullscreen && options.fullscreen.enabled) { 967 // Moving royal slider to the very end of body element to allow a proper fullscreen 968 var rsEnterFullscreen = function(){ 969 $slider.appendTo($('body')); 970 slider.ev.off('rsEnterFullscreen', rsEnterFullscreen); 971 slider.exitFullscreen(); 972 slider.enterFullscreen(); 973 slider.ev.on('rsEnterFullscreen', rsEnterFullscreen); 974 slider.ev.on('rsExitFullscreen', rsExitFullscreen); 975 }; 976 slider.ev.on('rsEnterFullscreen', rsEnterFullscreen); 977 var rsExitFullscreen = function(){ 978 $slider.prependTo($this); 979 slider.ev.off('rsExitFullscreen', rsExitFullscreen); 980 slider.exitFullscreen(); 981 }; 982 } 983 $us.$canvas.on('contentChange', function(){ 984 $slider.parent().imagesLoaded(function(){ 985 slider.updateSliderSize(); 986 }); 987 }); 988 }); 989 }; 990 $(function(){ 991 jQuery('.w-slider').wSlider(); 992 }); 993})(jQuery); 994 995 996/** 997 * UpSolution Widget: w-portfolio 998 */ 999!function($){ 1000 "use strict"; 1001 1002 $us.WPortfolio = function(container, options){ 1003 this.init(container, options); 1004 }; 1005 1006 $us.WPortfolio.prototype = { 1007 1008 init: function(container, options){ 1009 // Commonly used dom elements 1010 this.$container = $(container); 1011 1012 if (this.$container.usMod('position') != 'isotope' || !$.fn.isotope) { 1013 // No scripts needed 1014 return; 1015 } 1016 1017 this.$filters = this.$container.find('.g-filters-item'); 1018 this.$list = this.$container.find('.w-portfolio-list'); 1019 this.$items = this.$container.find('.w-portfolio-item'); 1020 this.$pagination = this.$container.find('.g-pagination'); 1021 this.$loadmore = this.$container.find('.g-loadmore'); 1022 this.paginationType = this.$pagination.length ? 'regular' : (this.$loadmore.length ? 'ajax' : 'none'); 1023 this.items = {}; 1024 this.curCategory = '*'; 1025 this.loading = false;
1026 1027 this.$items.each(function(index, item){ 1028 this.items[parseInt(item.getAttribute('data-id'))] = $(item); 1029 }.bind(this)); 1030 1031 this.isotopeOptions = { 1032 itemSelector: '.w-portfolio-item', 1033 layoutMode: 'masonry', 1034 masonry: {}, 1035 isOriginLeft: !$('.l-body').hasClass('rtl') 1036 }; 1037 1038 if (this.$container.find('.w-portfolio-item.size_1x1').length) { 1039 this.itemWidth = 1; 1040 this.isotopeOptions.masonry.columnWidth = '.size_1x1'; 1041 } else if (this.$container.find('.w-portfolio-item.size_1x2').length) { 1042 this.itemWidth = 1; 1043 this.isotopeOptions.masonry.columnWidth = '.size_1x2'; 1044 } else { 1045 this.itemWidth = 2; 1046 this.isotopeOptions.masonry.columnWidth = '.w-portfolio-item'; 1047 } 1048 1049 if (this.paginationType != 'none') { 1050 var $jsonContainer = this.$container.find('.w-portfolio-json'); 1051 if ($jsonContainer.length == 0) return; 1052 this.jsonData = $jsonContainer[0].onclick() || {}; 1053 this.ajaxUrl = this.jsonData.ajax_url || ''; 1054 this.templateVars = JSON.stringify(this.jsonData.template_vars || {}); 1055 this.perpage = this.jsonData.perpage || this.$items.length; 1056 this.order = this.jsonData.order || {}; 1057 this.sizes = this.jsonData.sizes || {}; 1058 this.curPage = this.jsonData.page || 1; 1059 this.infiniteScroll = this.jsonData.infinite_scroll || 0; 1060 $jsonContainer.remove(); 1061 this.isotopeOptions.sortBy = 'number'; 1062 this.isotopeOptions.getSortData = { 1063 number: function(elm){ 1064 return this.order['*'].indexOf(parseInt(elm.getAttribute('data-id'))); 1065 }.bind(this) 1066 }; 1067 } 1068 1069 if (this.paginationType == 'ajax') { 1070 this.$loadmore.on('click', function(){ 1071 var maxPage = Math.ceil(this.order[this.curCategory].length / this.perpage); 1072 if (this.curPage < maxPage) { 1073 this.setState(this.curPage + 1); 1074 } 1075 }.bind(this)); 1076 } 1077 else if (this.paginationType == 'regular') { 1078 this.paginationPcre = new RegExp('/page/([0-9]+)/$'); 1079 this.location = location.href.replace(this.paginationPcre, '/'); 1080 this.$navLinks = this.$container.find('.nav-links'); 1081 var self = this; 1082 this.$navLinks.on('click', 'a', function(e){ 1083 e.preventDefault(); 1084 var arr, 1085 pageNum = (arr = self.paginationPcre.exec(this.href)) ? parseInt(arr[1]) : 1; 1086 self.setState(pageNum); 1087 }); 1088 this.renderPagination(this.curPage); 1089 } 1090 1091 this.$filters.each(function(index, filter){ 1092 var $filter = $(filter), 1093 category = $filter.data('category'); 1094 $filter.on('click', function(){ 1095 if (category != this.curCategory) { 1096 this.setState((this.paginationType == 'regular') ? 1 : this.curPage, category); 1097 this.$filters.removeClass('active'); 1098 $filter.addClass('active'); 1099 } 1100 }.bind(this)) 1101 }.bind(this)); 1102 1103 // Applying isotope 1104 this.loading = true; 1105 this.$list.imagesLoaded(function(){ 1106 this.$list.isotope(this.isotopeOptions); 1107 this.$list.isotope(); 1108 this.loading = false; 1109 $us.$canvas.on('contentChange', function(){ 1110 this.$list.isotope('layout'); 1111 }.bind(this)); 1112 $(window).on('resize', function(){ 1113 this.$list.isotope('layout'); 1114 }.bind(this)); 1115 1116 1117 if (this.paginationType == 'ajax' && this.infiniteScroll) { 1118 $us.scroll.addWaypoint(this.$loadmore, '-70%', function(){ 1119 this.$loadmore.click(); 1120 }.bind(this)); 1121 } 1122 }.bind(this)); 1123 }, 1124 1125 setState: function(page, category){ 1126 if (this.paginationType == 'none') { 1127 // Simple state changer 1128 this.$list.isotope({filter: (category == '*') ? '*' : ('.' + category)}); 1129 this.curCategory = category; 1130 return; 1131 } 1132 1133 if (this.loading) return; 1134 category = category || this.curCategory; 1135 var start = (this.paginationType == 'ajax') ? 0 : ((page - 1) * this.perpage), 1136 length = page * this.perpage, 1137 showIds = (this.order[category] || []).slice(start, length), 1138 loadIds = [], 1139 $newItems = []; 1140 $.each(showIds, function(i, id){ 1141 // Determining which items we need to load via ajax and creating temporary stubs for them 1142 if (this.items[id] !== undefined) return; 1143 var itemSize = (this.sizes[id] || '1x1'), 1144 itemHtml = '<div class="w-portfolio-item size_' + itemSize + ' loading" data-id="' + id + '">' + 1145 '<div class="w-portfolio-item-anchor"><div class="g-preloader type_1"></div></div></div>'; 1146 this.items[id] = $(itemHtml).appendTo(this.$list); 1147 $newItems.push(this.items[id][0]); 1148 loadIds.push(showIds[i]); 1149 }.bind(this)); 1150 if (loadIds.length > 0) { 1151 // Loading new items 1152 var $insertedItems = $(); 1153 $.ajax({ 1154 type: 'post', 1155 url: this.ajaxUrl, 1156 data: { 1157 action: 'us_ajax_portfolio', 1158 ids: loadIds.join(','), 1159 template_vars: this.templateVars 1160 }, 1161 success: function(html){
1162 var $container = $('<div>', {html: html}), 1163 $items = $container.children(), 1164 isotope = this.$list.data('isotope'); 1165 $items.each(function(index, item){ 1166 var $item = $(item), 1167 itemID = parseInt($item.data('id')); 1168 $item.imagesLoaded(function(){ 1169 this.items[itemID].attr('class', $item.attr('class')).attr('style', $item.attr('style')); 1170 this.itemLoaded(itemID, $item); 1171 this.items[itemID].html($item.html()); 1172 $insertedItems = $insertedItems.add(this.items[itemID]); 1173 if ($insertedItems.length >= loadIds.length) { 1174 $container.remove(); 1175 this.itemsLoaded($insertedItems); 1176 } 1177 if (isotope) { 1178 if (this.itemWidth != 1) { 1179 if (this.$container.find('.w-portfolio-item.size_1x1').length) { 1180 this.itemWidth = 1; 1181 this.isotopeOptions.masonry.columnWidth = '.size_1x1'; 1182 } else if (this.$container.find('.w-portfolio-item.size_1x2').length) { 1183 this.itemWidth = 1; 1184 this.isotopeOptions.masonry.columnWidth = '.size_1x2'; 1185 } else { 1186 this.itemWidth = 2; 1187 this.isotopeOptions.masonry.columnWidth = '.w-portfolio-item'; 1188 } 1189 if (this.itemWidth == 1) { 1190 this.$list.isotope(this.isotopeOptions); 1191 } 1192 } 1193 1194 this.$list.isotope('layout'); 1195 } 1196 }.bind(this)); 1197 }.bind(this)); 1198 1199 }.bind(this) 1200 }); 1201 } 1202 this.$list.isotope({ 1203 filter: function(){ 1204 return (showIds.indexOf(parseInt(this.getAttribute('data-id'))) != -1); 1205 } 1206 }); 1207 if (loadIds.length > 0) { 1208 this.$list.isotope('insert', $newItems); 1209 } 1210 if (this.infiniteScroll) { 1211 $us.scroll.addWaypoint(this.$loadmore, '-70%', function(){ 1212 this.$loadmore.click(); 1213 }.bind(this)); 1214 } 1215 this.curPage = page; 1216 this.curCategory = category; 1217 this.renderPagination(); 1218 }, 1219 1220 renderPagination: function(){ 1221 if (this.paginationType == 'ajax') { 1222 var maxPage = Math.ceil(this.order[this.curCategory].length / this.perpage); 1223 this.$loadmore[(this.curPage < maxPage) ? 'removeClass' : 'addClass']('done'); 1224 } 1225 else if (this.paginationType == 'regular') { 1226 var maxPage = Math.ceil(this.order[this.curCategory].length / this.perpage), 1227 html = ''; 1228 if (maxPage > 1) { 1229 if (this.curPage > 1) { 1230 html += '<a href="' + this.pageUrl(this.curPage - 1) + '" class="prev page-numbers"><span><</span></a>'; 1231 } else { 1232 html += '<span class="prev page-numbers"><</span>'; 1233 } 1234 for (var i = 1; i <= maxPage; i++) { 1235 if (i != this.curPage) { 1236 html += '<a href="' + this.pageUrl(i) + '" class="page-numbers"><span>' + i + '</span></a>'; 1237 } else { 1238 html += '<span class="page-numbers current"><span>' + i + '</span></span>'; 1239 } 1240 } 1241 if (this.curPage < maxPage) { 1242 html += '<a href="' + this.pageUrl(this.curPage + 1) + '" class="next page-numbers"><span>></span></a>'; 1243 } else { 1244 html += '<span class="next page-numbers">></span>'; 1245 } 1246 } 1247 this.$navLinks.html(html); 1248 } 1249 }, 1250 1251 pageUrl: function(page){ 1252 return (page == 1) ? this.location : (this.location + 'page/' + page + '/'); 1253 }, 1254 1255 /** 1256 * Overloadable function for themes 1257 * @param $item 1258 */ 1259 itemLoaded: function($item){ 1260 }, 1261 1262 /** 1263 * Overloadable function for themes 1264 * @param $item 1265 */ 1266 itemsLoaded: function($items){ 1267 } 1268 1269 }; 1270 1271 $.fn.wPortfolio = function(options){ 1272 return this.each(function(){ 1273 $(this).data('wPortfolio', new $us.WPortfolio(this, options)); 1274 }); 1275 }; 1276 1277 if ($.fn.magnificPopup) { 1278 $('.w-portfolio-list').each(function(){ 1279 $(this).magnificPopup({ 1280 type: 'image', 1281 delegate: 'a[ref=magnificPopupPortfolio]:visible', 1282 gallery: { 1283 enabled: true, 1284 navigateByImgClick: true, 1285 preload: [0, 1], 1286 tPrev: $us.langOptions.magnificPopup.tPrev, // Alt text on left arrow 1287 tNext: $us.langOptions.magnificPopup.tNext, // Alt text on right arrow 1288 tCounter: $us.langOptions.magnificPopup.tCounter // Markup for "1 of 7" counter 1289 }, 1290 removalDelay: 300, 1291 mainClass: 'mfp-fade',
1292 fixedContentPos: false 1293 }); 1294 }); 1295 } 1296 1297}(jQuery); 1298 1299/** 1300 * UpSolution Widget: w-cart 1301 * 1302 * @requires $us.canvas 1303 * @requires $us.nav 1304 */ 1305jQuery(function($){ 1306 var $cart = $('.w-cart'); 1307 if ($cart.length == 0) return; 1308 var $quantity = $cart.find('.w-cart-quantity'); 1309 1310 var updateCart = function(){ 1311 var $mini_cart_amount = $cart.find('.us_mini_cart_amount'), 1312 mini_cart_amount = $mini_cart_amount.text(); 1313 1314 if (mini_cart_amount !== undefined) { 1315 mini_cart_amount = mini_cart_amount + ''; 1316 mini_cart_amount = mini_cart_amount.match(/\d+/g); 1317 1318 if (mini_cart_amount > 0) { 1319 $quantity.html(mini_cart_amount); 1320 $cart.removeClass('empty'); 1321 } else { 1322 $quantity.html('0'); 1323 $cart.addClass('empty'); 1324 } 1325 1326 } else { 1327 // fallback in case our action wasn't fired somehow 1328 var $quantities = $cart.find('.quantity'), 1329 total = 0; 1330 $quantities.each(function(){ 1331 var quantity, 1332 text = $(this).text() + '', 1333 matches = text.match(/\d+/g); 1334 1335 if (matches) { 1336 quantity = parseInt(matches[0], 10); 1337 total += quantity; 1338 } 1339 1340 }); 1341 1342 if (total > 0) { 1343 $quantity.html(total); 1344 $cart.removeClass('empty'); 1345 } else { 1346 $quantity.html('0'); 1347 $cart.addClass('empty'); 1348 } 1349 1350 } 1351 1352 }; 1353 1354 updateCart(); 1355 1356 $(document.body).bind('wc_fragments_loaded', function(){ 1357 updateCart(); 1358 }); 1359 1360 $(document.body).bind('wc_fragments_refreshed', function(){ 1361 updateCart(); 1362 }); 1363 1364 var $notification = $cart.find('.w-cart-notification'), 1365 $productName = $notification.find('.product-name'), 1366 $cartLink = $cart.find('.w-cart-link'), 1367 $dropdown = $cart.find('.w-cart-dropdown'), 1368 $quantity = $cart.find('.w-cart-quantity'), 1369 productName = $productName.text(), 1370 animationType = (window.$us !== undefined && window.$us.nav !== undefined) ? $us.nav.animationType : 'opacity', 1371 showFn = 'fadeInCSS', 1372 hideFn = 'fadeOutCSS', 1373 opened = false; 1374 1375 if (animationType == 'height') { 1376 showFn = 'slideDownCSS'; 1377 hideFn = 'slideUpCSS'; 1378 } 1379 else if (animationType == 'mdesign') {
1380 showFn = 'showMD'; 1381 hideFn = 'hideMD'; 1382 } 1383 1384 $notification.on('click', function(){ 1385 $notification[hideFn](); 1386 }); 1387 1388 jQuery('body').bind('added_to_cart', function(event, fragments, cart_hash, $button){ 1389 if (event === undefined) return; 1390 1391 updateCart(); 1392 1393 productName = $button.closest('.product').find('.product-meta h3:first').text(); 1394 $productName.html(productName); 1395 1396 $notification[showFn](undefined, function(){ 1397 var newTimerId = setTimeout(function(){ 1398 $notification[hideFn](); 1399 }, 3000); 1400 $notification.data('animation-timers', $notification.data('animation-timers') + ',' + newTimerId); 1401 }); 1402 }); 1403 1404 if ($.isMobile) { 1405 var outsideClickEvent = function(e){ 1406 if (jQuery.contains($cart[0], e.target)) return; 1407 $dropdown[hideFn](); 1408 $us.$body.off('touchstart', outsideClickEvent); 1409 opened = false; 1410 }; 1411 $cartLink.on('click', function(e){ 1412 if (!opened) { 1413 e.preventDefault(); 1414 $dropdown[showFn](); 1415 $us.$body.on('touchstart', outsideClickEvent); 1416 } else { 1417 $dropdown[hideFn](); 1418 $us.$body.off('touchstart', outsideClickEvent); 1419 } 1420 opened = !opened; 1421 }); 1422 } else { 1423 var hideTimer = null; 1424 $cartLink.on('hover', function(){ 1425 if (opened) return; 1426 $dropdown[showFn](); 1427 opened = true; 1428 }); 1429 $cart.hover(function(){ 1430 clearTimeout(hideTimer); 1431 }, function(){ 1432 clearTimeout(hideTimer); 1433 hideTimer = setTimeout(function(){ 1434 if (!opened) return; 1435 $dropdown[hideFn](); 1436 opened = false; 1437 }, 250); 1438 }); 1439 } 1440}); 1441 1442 1443/** 1444 * UpSolution Login Widget: widget_us_login 1445 * 1446 */ 1447!function($){ 1448 "use strict"; 1449 1450 $us.wUsLogin = function(container, options){ 1451 this.$container = $(container); 1452 this.$form = this.$container.find('.w-form'); 1453 this.$profile = this.$container.find('.w-profile'); 1454 1455 var $jsonContainer = this.$container.find('.w-profile-json'); 1456 1457 this.jsonData = $jsonContainer[0].onclick() || {}; 1458 $jsonContainer.remove(); 1459 1460 this.ajaxUrl = this.jsonData.ajax_url || ''; 1461 this.logoutRedirect = this.jsonData.logout_redirect || ''; 1462 1463 $.ajax({ 1464 type: 'post', 1465 url: this.ajaxUrl, 1466 data: { 1467 action: 'us_ajax_user_info', 1468 logout_redirect: this.logoutRedirect 1469 }, 1470 success: function(result){ 1471 if (result.success) { 1472 var $avatar = this.$profile.find('.w-profile-avatar'), 1473 $name = this.$profile.find('.w-profile-name'), 1474 $logoutLink = this.$profile.find('.w-profile-link.for_logout') 1475 1476 $avatar.html(result.data.avatar); 1477 $name.html(result.data.name); 1478 $logoutLink.attr('href', result.data.logout_url); 1479 1480 this.$profile.removeClass('hidden'); 1481 } else { 1482 this.$form.removeClass('hidden'); 1483 } 1484 }.bind(this) 1485 }); 1486 }; 1487 1488 $.fn.wUsLogin = function(options){ 1489 return this.each(function(){ 1490 $(this).data('wUsLogin', new $us.wUsLogin(this, options)); 1491 }); 1492 }; 1493 1494 $(function(){ 1495 $('.widget_us_login').wUsLogin(); 1496 }); 1497}(jQuery); 1498 1499 1500/** 1501 * UpSolution Widget: w-maps 1502 * 1503 * Used for [us_gmaps] shortcode 1504 */ 1505!function($){ 1506 "use strict"; 1507 1508 $us.WMapsGeocodesCounter = 0; // counter of total geocode requests number 1509 $us.WMapsGeocodesRunning = false; 1510 $us.WMapsCurrentGeocode = 0; // current processing geocode 1511 $us.WMapsGeocodesMax = 5; // max number of simultaneous geocode requests allowed 1512 $us.WMapsGeocodesStack = {}; 1513 1514 $us.WMapsRunGeoCode = function(){ 1515 if ($us.WMapsCurrentGeocode <= $us.WMapsGeocodesCounter) { 1516 $us.WMapsGeocodesRunning = true; 1517 if ($us.WMapsGeocodesStack[$us.WMapsCurrentGeocode] != null) 1518 $us.WMapsGeocodesStack[$us.WMapsCurrentGeocode](); 1519 } else { 1520 $us.WMapsGeocodesRunning = false; 1521 } 1522 }; 1523 1524 $us.WMaps = function(container, options){ 1525 1526 this.$container = $(container); 1527 1528 var $jsonContainer = this.$container.find('.w-map-json'), 1529 jsonOptions = $jsonContainer[0].onclick() || {}, 1530 $jsonStyleContainer = this.$container.find('.w-map-style-json'), 1531 jsonStyleOptions, 1532 markerOptions, 1533 shouldRunGeoCode = false; 1534 $jsonContainer.remove(); 1535 if ($jsonStyleContainer.length) { 1536 jsonStyleOptions = $jsonStyleContainer[0].onclick() || {}; 1537 $jsonStyleContainer.remove(); 1538 } 1539 1540 1541 // Setting options 1542 var defaults = {}; 1543 this.options = $.extend({}, defaults, jsonOptions, options); 1544 1545 this._events = { 1546 redraw: this.redraw.bind(this) 1547 }; 1548 1549 var gmapsOptions = { 1550 el: '#' + this.$container.attr('id'), 1551 lat: 0, 1552 lng: 0, 1553 zoom: this.options.zoom, 1554 type: this.options.type, 1555 height: this.options.height + 'px', 1556 width: '100%', 1557 mapTypeId: google.maps.MapTypeId[this.options.maptype] 1558 }; 1559 1560 if (this.options.hideControls) { 1561 gmapsOptions.disableDefaultUI = true; 1562 } 1563 if (this.options.disableZoom) { 1564 gmapsOptions.scrollwheel = false;
1565 } 1566 if (this.options.disableDragging && ( !$us.$html.hasClass('no-touch'))) { 1567 gmapsOptions.draggable = false; 1568 } 1569 if (this.options.mapBgColor) { 1570 gmapsOptions.backgroundColor = this.options.mapBgColor; 1571 } 1572 1573 this.GMapsObj = new GMaps(gmapsOptions); 1574 if (jsonStyleOptions != null && jsonStyleOptions != {}) { 1575 this.GMapsObj.map.setOptions({styles: jsonStyleOptions}); 1576 } 1577 1578 var that = this; 1579 1580 if (this.options.latitude != null && this.options.longitude != null) { 1581 this.GMapsObj.setCenter(this.options.latitude, this.options.longitude); 1582 } else { 1583 var mapGeoCode = function(geocodeNum){ 1584 GMaps.geocode({ 1585 address: that.options.address, 1586 callback: function(results, status){ 1587 if (status == 'OK') { 1588 var latlng = results[0].geometry.location; 1589 that.options.latitude = latlng.lat(); 1590 that.options.longitude = latlng.lng(); 1591 that.GMapsObj.setCenter(that.options.latitude, that.options.longitude); 1592 $us.WMapsCurrentGeocode++; 1593 $us.WMapsRunGeoCode(); 1594 } else if (status == "OVER_QUERY_LIMIT") { 1595 setTimeout(function(){ 1596 $us.WMapsRunGeoCode() 1597 }, 2000); 1598 } 1599 } 1600 }); 1601 }; 1602 shouldRunGeoCode = true; 1603 $us.WMapsGeocodesStack[$us.WMapsGeocodesCounter] = mapGeoCode; 1604 $us.WMapsGeocodesCounter++; 1605 } 1606 1607 $.each(this.options.markers, function(i, val){ 1608 markerOptions = {}; 1609 if (that.options.icon != null) { 1610 markerOptions.icon = { 1611 url: that.options.icon.url, 1612 size: new google.maps.Size(that.options.icon.size[0], that.options.icon.size[1]), 1613 origin: new google.maps.Point(0, 0),
1614 anchor: new google.maps.Point(that.options.icon.anchor[0], that.options.icon.anchor[1]) 1615 }; 1616 } 1617 1618 if (that.options.markers[i] != null) { 1619 1620 if (that.options.markers[i].latitude != null && that.options.markers[i].longitude != null) { 1621 markerOptions.lat = that.options.markers[i].latitude; 1622 markerOptions.lng = that.options.markers[i].longitude; 1623 markerOptions.infoWindow = {content: that.options.markers[i].html}; 1624 var marker = that.GMapsObj.addMarker(markerOptions); 1625 if (that.options.markers[i].infowindow) { 1626 marker.infoWindow.open(that.GMapsObj.map, marker); 1627 } 1628 } else { 1629 var markerGeoCode = function(geocodeNum){ 1630 GMaps.geocode({ 1631 address: that.options.markers[i].address, 1632 callback: function(results, status){ 1633 if (status == 'OK') { 1634 var latlng = results[0].geometry.location; 1635 markerOptions.lat = latlng.lat(); 1636 markerOptions.lng = latlng.lng(); 1637 markerOptions.infoWindow = {content: that.options.markers[i].html}; 1638 var marker = that.GMapsObj.addMarker(markerOptions); 1639 if (that.options.markers[i].infowindow) { 1640 marker.infoWindow.open(that.GMapsObj.map, marker); 1641 } 1642 $us.WMapsCurrentGeocode++; 1643 $us.WMapsRunGeoCode(); 1644 } else if (status == "OVER_QUERY_LIMIT") { 1645 setTimeout(function(){ 1646 $us.WMapsRunGeoCode() 1647 }, 2000); 1648 } 1649 } 1650 }); 1651 }; 1652 shouldRunGeoCode = true; 1653 $us.WMapsGeocodesStack[$us.WMapsGeocodesCounter] = markerGeoCode; 1654 $us.WMapsGeocodesCounter++; 1655 } 1656 } 1657 }); 1658 1659 if (shouldRunGeoCode && ( !$us.WMapsGeocodesRunning)) { 1660 $us.WMapsRunGeoCode(); 1661 } 1662 1663 $us.$canvas.on('contentChange', this._events.redraw); 1664 1665 // In case some toggler was opened before the actual page load 1666 $us.$window.load(this._events.redraw); 1667 }; 1668 1669 $us.WMaps.prototype = { 1670 /** 1671 * Fixing hidden and other breaking-cases maps 1672 */ 1673 redraw: function(){ 1674 if (this.$container.is(':hidden')) return; 1675 this.GMapsObj.refresh(); 1676 if (this.options.latitude != null && this.options.longitude != null) { 1677 this.GMapsObj.setCenter(this.options.latitude, this.options.longitude); 1678 } 1679 1680 } 1681 }; 1682 1683 $.fn.wMaps = function(options){ 1684 return this.each(function(){ 1685 $(this).data('wMaps', new $us.WMaps(this, options)); 1686 }); 1687 }; 1688 1689 $(function(){ 1690 $('.w-map').wMaps(); 1691 }); 1692}(jQuery); 1693 1694 1695/** 1696 * UpSolution Widget: w-sharing 1697 */ 1698!function($){ 1699 "use strict"; 1700 1701 $('.w-sharing.type_fixed.align_left, .w-sharing.type_fixed.align_right').each(function(){ 1702 var $this = $(this); 1703 $this.css('margin-top', -.5 * $this.height()); 1704 }); 1705 1706 $('.w-sharing.type_fixed.align_center').each(function(){ 1707 var $this = $(this); 1708 $this.css('margin-left', -.5 * $this.width()); 1709 }); 1710 1711 $('.w-sharing-item').on('click', function(){ 1712 var $this = $(this); 1713 var opt = { 1714 url: window.location, 1715 text: document.title, 1716 lang: document.documentElement.lang, 1717 image: $('meta[name="og:image"]').attr('content') || '' 1718 }; 1719 if ($this.attr('data-sharing-url') !== undefined && $this.attr('data-sharing-url') != '') { 1720 opt.url = $this.attr('data-sharing-url'); 1721 } 1722 if ($this.attr('data-sharing-image') !== undefined && $this.attr('data-sharing-image') != '') { 1723 opt.image = $this.attr('data-sharing-image'); 1724 } 1725 if (opt.image == '' || opt.image === undefined) { 1726 var first_image_src = $('img').first().attr('src'); 1727 if (first_image_src != undefined && first_image_src != '') { 1728 opt.image = first_image_src; 1729 } 1730 } 1731 if ($this.hasClass('facebook')) { 1732 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"); 1733 } else if ($this.hasClass('twitter')) { 1734 window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent(opt.text) + "&url=" + encodeURIComponent(opt.url), "", "toolbar=0, status=0, width=650, height=360"); 1735 } else if ($this.hasClass('linkedin')) { 1736 window.open('https://www.linkedin.com/cws/share?url=' + encodeURIComponent(opt.url) + '&token=&isFramed=true', 'linkedin', 'toolbar=no,width=550,height=550'); 1737 } else if ($this.hasClass('gplus')) { 1738 window.open("https://plus.google.com/share?hl=" + encodeURIComponent(opt.lang) + "&url=" + encodeURIComponent(opt.url), "", "toolbar=0, status=0, width=900, height=500"); 1739 } else if ($this.hasClass('pinterest')) { 1740 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'); 1741 } else if ($this.hasClass('vk')) { 1742 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'); 1743 } else if ($this.hasClass('email')) { 1744 window.location = 'mailto:?subject=' + opt.text + '&body=' + opt.url; 1745 } 1746 }); 1747}(jQuery); 1748 1749 1750/** 1751 * UpSolution Widget: l-preloader 1752 */ 1753!function($){ 1754 "use strict"; 1755 1756 if ($('.l-preloader').length) { 1757 $('document').ready(function(){ 1758 setTimeout(function(){ 1759 $('.l-preloader').addClass('done'); 1760 }, 500); 1761 setTimeout(function(){ 1762 $('.l-preloader').addClass('hidden'); 1763 }, 1000); // 500 ms after 'done' class is added 1764 }); 1765 } 1766}(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.