PageSourceSearch

https://spotphone.ru/wp-content/themes/rehub/js/custom.js?ver=4.9.33

js spotphone.ru collected 2026-10-02 18:20:41 UTC 72,048 bytes, 1,455 lines download raw bytes

1/*
2   Author: Igor Sunzharovskyi.
3   Author URI: http://sizam-design.com/
4*/
5/****** Helpers JS *****/
6
7/* hover Intent r7 */
8(function($){$.fn.hoverIntent=function(handlerIn,handlerOut,selector){var cfg={interval:100,sensitivity:7,timeout:0};if(typeof handlerIn==="object"){cfg=$.extend(cfg,handlerIn)}else if($.isFunction(handlerOut)){cfg=$.extend(cfg,{over:handlerIn,out:handlerOut,selector:selector})}else{cfg=$.extend(cfg,{over:handlerIn,out:handlerIn,selector:handlerOut})}var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).off("mousemove.hoverIntent",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).on("mousemove.hoverIntent",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).off("mousemove.hoverIntent",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover},cfg.selector)}})(jQuery);
9/* equalHeightColumns.js 1.2, https://github.com/PaulSpr/jQuery-Equal-Height-Columns */
10(function(e){e.fn.equalHeightColumns=function(t){defaults={minWidth:-1,maxWidth:99999,setHeightOn:"min-height",defaultVal:0,equalizeRows:false,checkHeight:"height"};var n=e(this);t=e.extend({},defaults,t);var r=function(){var r=e(window).width();var i=Array();if(t.minWidth<r&&t.maxWidth>r){var s=0;var o=0;var u=0;n.css(t.setHeightOn,t.defaultVal);n.each(function(){if(t.equalizeRows){var n=e(this).position().top;if(n!=u){if(i.length>0){e(i).css(t.setHeightOn,o);o=0;i=[]}u=e(this).position().top}i.push(this)}s=e(this)[t.checkHeight]();if(s>o){o=s}});if(!t.equalizeRows){n.css(t.setHeightOn,o)}else{e(i).css(t.setHeightOn,o)}}else{n.css(t.setHeightOn,t.defaultVal)}};r();e(window).resize(r);n.find("img").load(r);if(typeof t.afterLoading!=="undefined"){n.find(t.afterLoading).load(r)}if(typeof t.afterTimeout!=="undefined"){setTimeout(function(){r();if(typeof t.afterLoading!=="undefined"){n.find(t.afterLoading).load(r)}},t.afterTimeout)}}})(jQuery);
11!function(t){function e(){var e,i,n={height:a.innerHeight,width:a.innerWidth};
11return n.height||(e=r.compatMode,(e||!t.support.boxModel)&&(i="CSS1Compat"===e?f:r.body,n={height:i.clientHeight,width:i.clientWidth})),n}function i(){return{top:a.pageYOffset||f.scrollTop||r.body.scrollTop,left:a.pageXOffset||f.scrollLeft||r.body.scrollLeft}}function n(){var n,l=t(),r=0;if(t.each(d,function(t,e){var i=e.data.selector,n=e.$element;l=l.add(i?n.find(i):n)}),n=l.length)for(o=o||e(),h=h||i();n>r;r++)if(t.contains(f,l[r])){var a,c,p,s=t(l[r]),u={height:s.height(),width:s.width()},g=s.offset(),v=s.data("inview");if(!h||!o)return;g.top+u.height>h.top&&g.top<h.top+o.height&&g.left+u.width>h.left&&g.left<h.left+o.width?(a=h.left>g.left?"right":h.left+o.width<g.left+u.width?"left":"both",c=h.top>g.top?"bottom":h.top+o.height<g.top+u.height?"top":"both",p=a+"-"+c,v&&v===p||s.data("inview",p).trigger("inview",[!0,a,c])):v&&s.data("inview",!1).trigger("inview",[!1])}}var o,h,l,d={},r=document,a=window,f=r.documentElement,c=t.expando;t.event.special.inview={add:function(e){d[e.guid+"-"+this[c]]={data:e,$element:t(this)},l||t.isEmptyObject(d)||(l=setInterval(n,250))},remove:function(e){try{delete d[e.guid+"-"+this[c]]}catch(i){}t.isEmptyObject(d)&&(clearInterval(l),l=null)}},t(a).bind("scroll resize scrollstop",function(){o=h=null}),!f.addEventListener&&f.attachEvent&&f.attachEvent("onfocusin",function(){h=null})}(jQuery);
12/** jquery.dlmenu.js v1.0.1 http://www.codrops.com Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php Copyright 2013, Codrops*/
13(function($,window,undefined){'use strict';var $body=$('body');$.DLMenu=function(options,element){this.$el=$(element);this._init(options)};$.DLMenu.defaults={animationClasses:{classin:'dl-animate-in-5',classout:'dl-animate-out-5'},onLevelClick:function(el,name){return false},onLinkClick:function(el,ev){return false}};$.DLMenu.prototype={_init:function(options){this.options=$.extend(true,{},$.DLMenu.defaults,options);this._config();var animEndEventNames={'WebkitAnimation':'webkitAnimationEnd','OAnimation':'oAnimationEnd','msAnimation':'MSAnimationEnd','animation':'animationend'},transEndEventNames={'WebkitTransition':'webkitTransitionEnd','MozTransition':'transitionend','OTransition':'oTransitionEnd','msTransition':'MSTransitionEnd','transition':'transitionend'};this._initEvents()},_config:function(){this.open=false;this.$trigger=this.$el.children('.dl-trigger');this.$menu=this.$el.children('ul.dl-menu');this.$menuitems=this.$menu.find('li:not(.dl-back)');this.$el.find('ul.dl-submenu').prepend('<li class="dl-back"><a href="#">'+translation.back+'</a></li>');this.$back=this.$menu.find('li.dl-back')},_initEvents:function(){var self=this;this.$trigger.on('click.dlmenu',function(){if(self.open){self._closeMenu()}else{self._openMenu()}return false});this.$menuitems.on('click.dlmenu',function(event){event.stopPropagation();var $item=$(this),$submenu=$item.children('ul.dl-submenu');if($submenu.length>0){var $flyin=$submenu.clone().css('opacity',0).insertAfter(self.$menu),onAnimationEndFn=function(){self.$menu.off(self.animEndEventName).removeClass(self.options.animationClasses.classout).addClass('dl-subview');$item.addClass('dl-subviewopen').parents('.dl-subviewopen:first').removeClass('dl-subviewopen').addClass('dl-subview');$flyin.remove()};setTimeout(function(){$flyin.addClass(self.options.animationClasses.classin);self.$menu.addClass(self.options.animationClasses.classout);if(self.supportAnimations){self.$menu.on(self.animEndEventName,onAnimationEndFn)}else{onAnimationEndFn.call()}self.options.onLevelClick($item,$item.children('a:first').text())});return false}else{self.options.onLinkClick($item,event)}});this.$back.on('click.dlmenu',function(event){var $this=$(this),$submenu=$this.parents('ul.dl-submenu:first'),$item=$submenu.parent(),$flyin=$submenu.clone().insertAfter(self.$menu);var onAnimationEndFn=function(){self.$menu.off(self.animEndEventName).removeClass(self.options.animationClasses.classin);$flyin.remove()};setTimeout(function(){$flyin.addClass(self.options.animationClasses.classout);self.$menu.addClass(self.options.animationClasses.classin);if(self.supportAnimations){self.$menu.on(self.animEndEventName,onAnimationEndFn)}else{onAnimationEndFn.call()}$item.removeClass('dl-subviewopen');var $subview=$this.parents('.dl-subview:first');if($subview.is('li')){$subview.addClass('dl-subviewopen')}$subview.removeClass('dl-subview')});return false})},closeMenu:function(){if(this.open){this._closeMenu()}},_closeMenu:function(){var self=this,onTransitionEndFn=function(){self.$menu.off(self.transEndEventName);self._resetMenu()};this.$menu.removeClass('dl-menuopen');
13this.$menu.addClass('dl-menu-toggle');this.$trigger.removeClass('dl-active');if(this.supportTransitions){this.$menu.on(this.transEndEventName,onTransitionEndFn)}else{onTransitionEndFn.call()}this.open=false},openMenu:function(){if(!this.open){this._openMenu()}},_openMenu:function(){var self=this;$body.off('click').on('click.dlmenu',function(){self._closeMenu()});this.$menu.addClass('dl-menuopen dl-menu-toggle').on(this.transEndEventName,function(){$(this).removeClass('dl-menu-toggle')});this.$trigger.addClass('dl-active');this.open=true},_resetMenu:function(){this.$menu.removeClass('dl-subview');this.$menuitems.removeClass('dl-subview dl-subviewopen')}};var logError=function(message){if(window.console){window.console.error(message)}};$.fn.dlmenu=function(options){if(typeof options==='string'){var args=Array.prototype.slice.call(arguments,1);this.each(function(){var instance=$.data(this,'dlmenu');if(!instance){logError("cannot call methods on dlmenu prior to initialization; "+"attempted to call method '"+options+"'");return}if(!$.isFunction(instance[options])||options.charAt(0)==="_"){logError("no such method '"+options+"' for dlmenu instance");return}instance[options].apply(instance,args)})}else{this.each(function(){var instance=$.data(this,'dlmenu');if(instance){instance._init()}else{instance=$.data(this,'dlmenu',new $.DLMenu(options,this))}})}return this}})(jQuery,window);
14/** PgwModal - Version 2.0 Copyright 2014, Jonathan M. Piat http://pgwjs.com - http://pagawa.com Released under the GNU GPLv3 license - http://opensource.org/licenses/gpl-3.0*/
15(function(a){a.pgwModal=function(i){var c={};var g={mainClassName:"pgwModal",backdropClassName:"pgwModalBackdrop",maxWidth:500,titleBar:true,closable:true,closeOnEscape:true,closeOnBackgroundClick:true,closeContent:'<span class="pm-icon"></span>',loadingContent:"Loading in progress...",errorContent:"An error has occured. Please try again in a few moments."};if(typeof window.pgwModalObject!="undefined"){c=window.pgwModalObject}if((typeof i=="object")&&(!i.pushContent)){if(!i.url&&!i.target&&!i.content){throw new Error('PgwModal - There is no content to display, please provide a config parameter : "url", "target" or "content"')}c.config={};c.config=a.extend({},g,i);window.pgwModalObject=c}var k=function(){var o='<div id="pgwModalBackdrop"></div><div id="pgwModal"><div class="pm-container"><div class="pm-body"><span class="pm-close"></span><div class="pm-title"></div><div class="pm-content"></div></div></div></div>';a("body").append(o);a(document).trigger("PgwModal::Create");return true};var l=function(){a("#pgwModal .pm-title, #pgwModal .pm-content").html("");a("#pgwModal .pm-close").html("").unbind("click");return true};var f=function(){angular.element('body').injector().invoke(function($compile){var scope=angular.element($('#pgwModal .pm-content')).scope();$compile($('#pgwModal .pm-content'))(scope);scope.$digest()});return true};var d=function(o){a("#pgwModal .pm-content").html(o);if(c.config.angular){f()}m();a(document).trigger("PgwModal::PushContent");return true};var m=function(){a("#pgwModal, #pgwModalBackdrop").show();var q=a(window).height();var o=a("#pgwModal .pm-body").height();var p=Math.round((q-o)/3);if(p<=0){p=0}a("#pgwModal .pm-body").animate({marginTop: p}, 200);return true};var h=function(){return c.config.modalData};var e=function(){var o=a('<div style="width:50px;height:50px;overflow:auto"><div></div></div>').appendTo("body");var q=o.children();if(typeof q.innerWidth!="function"){return 0}var p=q.innerWidth()-q.height(90).innerWidth();o.remove();return p};var b=function(){return a("body").hasClass("pgwModalOpen")};var n=function(){a("#pgwModal, #pgwModalBackdrop").removeClass().hide();a("body").css("padding-right","").removeClass("pgwModalOpen");l();a(window).unbind("resize.PgwModal");a(document).unbind("keyup.PgwModal");a("#pgwModal").unbind("click.PgwModalBackdrop");try{delete window.pgwModalObject}catch(o){window.pgwModalObject=undefined}a(document).trigger("PgwModal::Close");return true};var j=function(){if(a("#pgwModal").length==0){k()}else{l()}a("#pgwModal").removeClass().addClass(c.config.mainClassName);a("#pgwModalBackdrop").removeClass().addClass(c.config.backdropClassName);if(!c.config.closable){a("#pgwModal .pm-close").html("").unbind("click").hide()}else{a("#pgwModal .pm-close").html(c.config.closeContent).click(function(){n()}).show()}if(!c.config.titleBar){a("#pgwModal .pm-title").hide()}else{a("#pgwModal .pm-title").show()}if(c.config.title){a("#pgwModal .pm-title").text(c.config.title)}if(c.config.maxWidth){a("#pgwModal .pm-body").css("max-width",c.config.maxWidth)}if(c.config.url){if(c.config.loadingContent){a("#pgwModal .pm-content").html(c.config.loadingContent)}var o={url:i.url,success:function(q){d(q)},error:function(){a("#pgwModal .pm-content").html(c.config.errorContent)}};if(c.config.ajaxOptions){o=a.extend({},o,c.config.ajaxOptions)}a.ajax(o)}else{if(c.config.target){d(a(c.config.target).html())}else{if(c.config.content){d(c.config.content)}}}if(c.config.closeOnEscape&&c.config.closable){a(document).bind("keyup.PgwModal",function(q){if(q.ke
15yCode==27){n()}})}if(c.config.closeOnBackgroundClick&&c.config.closable){a("#pgwModal").bind("click.PgwModalBackdrop",function(s){var r=a(s.target).hasClass("pm-container");var q=a(s.target).attr("id");if(r||q=="pgwModal"){n()}})}a("body").addClass("pgwModalOpen");var p=e();if(p>0){a("body").css("padding-right",p)}a(window).bind("resize.PgwModal",function(){m()});a(document).trigger("PgwModal::Open");return true};if((typeof i=="string")&&(i=="close")){return n()}else{if((typeof i=="string")&&(i=="reposition")){return m()}else{if((typeof i=="string")&&(i=="getData")){return h()}else{if((typeof i=="string")&&(i=="isOpen")){return b()}else{if((typeof i=="object")&&(i.pushContent)){return d(i.pushContent)}else{if(typeof i=="object"){return j()}}}}}}}})(window.Zepto||window.jQuery);
16/*Fitvid http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ */
17(function(e){"use strict";e.fn.fitVids=function(t){var n={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var r=document.head||document.getElementsByTagName("head")[0];var i=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";var s=document.createElement("div");s.innerHTML='<p>x</p><style id="fit-vids-style">'+i+"</style>";r.appendChild(s.childNodes[1])}if(t){e.extend(n,t)}return this.each(function(){var t=["iframe[src*='player.vimeo.com']","iframe[src*='youtube.com']","iframe[src*='youtube-nocookie.com']","iframe[src*='kickstarter.com'][src*='video.html']","object","embed"];if(n.customSelector){t.push(n.customSelector)}var r=".fitvidsignore";if(n.ignore){r=r+", "+n.ignore}var i=e(this).find(t.join(","));i=i.not("object object");i=i.not(r);i.each(function(){var t=e(this);if(t.parents(r).length>0){return}if(this.tagName.toLowerCase()==="embed"&&t.parent("object").length||t.parent(".fluid-width-video-wrapper").length){return}if(!t.css("height")&&!t.css("width")&&(isNaN(t.attr("height"))||isNaN(t.attr("width")))){t.attr("height",9);t.attr("width",16)}var n=this.tagName.toLowerCase()==="object"||t.attr("height")&&!isNaN(parseInt(t.attr("height"),10))?parseInt(t.attr("height"),10):t.height(),i=!isNaN(parseInt(t.attr("width"),10))?parseInt(t.attr("width"),10):t.width(),s=n/i;if(!t.attr("id")){var o="fitvid"+Math.floor(Math.random()*999999);t.attr("id",o)}t.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",s*100+"%");t.removeAttr("height").removeAttr("width")})})}})(window.jQuery||window.Zepto)
18/*! jQuery Unveil http://luis-almeida.github.com/unveil Licensed under the MIT license. */
19!function(t){t.fn.unveil=function(i,e){function n(){var i=a.filter(function(){var i=t(this);if(!i.is(":hidden")){var e=o.scrollTop(),n=e+o.height(),r=i.offset().top,s=r+i.height();return s>=e-u&&n+u>=r}});r=i.trigger("unveil"),a=a.not(r)}var r,o=t(window),u=i||0,s=window.devicePixelRatio>1,l=s?"data-src-retina":"data-src",a=this;return this.one("unveil",function(){var t=this.getAttribute(l);t=t||this.getAttribute("data-src"),t&&(this.setAttribute("src",t),"function"==typeof e&&e.call(this))}),o.on("scroll.unveil resize.unveil lookup.unveil",n),n(),this}}(window.jQuery||window.Zepto);
20
21/***** BASIC CUSTOM JS *****/
22
23//CHARTS
24var table_charts = function() {
25   jQuery('.table_view_charts').each(function(index){
26      var rowcount = jQuery(this).find('.top_chart_row_found').data('rowcount');
27      for (var rowcountindex = 0; rowcountindex < rowcount; rowcountindex++) {
28
29         //Equal height for each row
30         var heightArray = jQuery(this).find('li.row_chart_'+ rowcountindex +'').map( function(){
31            return  jQuery(this).height();
32         }).get();
33         var maxHeight = Math.max.apply( Math, heightArray);
34         jQuery(this).find('li.row_chart_'+ rowcountindex +'').height(maxHeight);
35
36         //Find differences
37         var recomparecolvalue;
38         jQuery(this).find('.top_chart_wrap li.row_chart_'+ rowcountindex +'').each(function(n) {
39            if (jQuery(this).html() != recomparecolvalue && n > 0) {
40               jQuery(this).closest('.table_view_charts').find('li.row_chart_'+ rowcountindex +'').addClass('row-is-different');
41            }
42            else {
43               recomparecolvalue = jQuery(this).html();
44            }
45         });
46      }
47   });
48}
49
50//FOR VC ROW
51var re_sizebg = function(){
52   'use strict';
53   jQuery('.vc_custom_row_width').each(function() {
54   var ride = jQuery(this).data('bg-width');
55   var ancenstor,parent;
56   parent = jQuery(this).parent();
57   if(ride=='container_width'){
58      ancenstor = jQuery('.main-side').parent().parent();
59   }
60   else if(ride == 'window_width'){
61      ancenstor = jQuery('html');
62   }
63   var al= parseInt( ancenstor.css('paddingLeft') );
64   var ar= parseInt( ancenstor.css('paddingRight') )
65   var w = al+ar + ancenstor.width();
66   var bl = - ( parent.offset().left - ancenstor.offset().left );
67   if ( bl > 0 ) { left = 0; }
68   if (jQuery('body.rtl').length > 0) {
69      jQuery(this).css({'width': w,'margin-right': bl });
70   }
71   else {
72      jQuery(this).css({'width': w,'margin-left': bl }) ;
73   } 
74});
75};
76
77function isVisibleOnScroll(elem)
78{
79   var $elem = jQuery(elem);
80   var $window = jQuery(window);
81   var docViewTop = $window.scrollTop();
82   var docViewBottom = docViewTop + $window.height();
83   var elemTop = $elem.offset().top;
84   var elemBottom = elemTop + $elem.height();
85   return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop));
86}
87
88//Here we will cache data from ajax calls
89var re_ajax_cache = {
90    data: {},
91    remove: function (cache_id) {
92        delete re_ajax_cache.data[cache_id];
93    },
94    exist: function (cache_id) {
95        return re_ajax_cache.data.hasOwnProperty(cache_id) && re_ajax_cache.data[cache_id] !== null;
96    },
97    get: function (cache_id) {
98        return re_ajax_cache.data[cache_id];
99    },
100    set: function (cache_id, cachedData) {
101        re_ajax_cache.remove(cache_id);
102        re_ajax_cache.data[cache_id] = cachedData;
103    }
104};
105
106var re_ajax_search = {
107
108    // Some variables
109    _current_selection_index:0,
110    _last_request_results_count:0,
111    _first_down_up:true,
112    _is_search_open:false,
113
114    init: function init() {
115
116        // Search icon show/hide
117        jQuery(document).on( 'click', '.icon-search-onclick', function(e) {
118            e.stopPropagation();
119            jQuery( '.main-nav' ).toggleClass( 'top-search-onclick-open' );
120            if (re_ajax_search._is_search_open === true) {
121                re_ajax_search._is_search_open = false;
122            }
123            else {
124                re_ajax_search._is_search_open = true;
125                if (jQuery('html').hasClass('flash')) {
126                    setTimeout(function(){
127                        jQuery( '.main-nav .search-header-contents input[name="s"]' ).focus();
128                    }, 200);
129                }                
130            }
131        });
132  
133        jQuery(document).click( function(e){ 
134            if( jQuery(e.target).closest(".head_search").length || jQuery(e.target).closest(".custom_search_box").length) 
135                return;
136            jQuery( '.head_search .re-aj-search-wrap' ).removeClass( 're-aj-search-open' ).empty();
137            jQuery( '.custom_search_box .re-aj-search-wrap' ).removeClass( 're-aj-search-open' ).empty();
138            e.stopPropagation();
139            if (re_ajax_search._is_search_open === true) {
140                re_ajax_search._is_search_open = false;
141            }            
142        });
143
144        jQuery(document).click( function(e){ 
145            if( jQuery(e.target).closest(".search-header-contents").length ) 
146                return;
147            jQuery( '.main-nav' ).removeClass( 'top-search-onclick-open' );
148            e.stopPropagation();
149            if (re_ajax_search._is_search_open === true) {
150                re_ajax_search._is_search_open = false;
151            }            
152        });        
153
154        // keydown on the text box
155        jQuery('.re-ajax-search').keydown(function(event) {
156            var ajaxsearchitem = jQuery(this);
157            if (
158                (event.which && event.which == 39)
159                || (event.keyCode && event.keyCode == 39)
160                || (event.which && event.which == 37)
161                || (event.keyCode && event.keyCode == 37))
162            {
163                //do nothing on left and right arrows
164                re_ajax_search.re_ajax_set_focus(ajaxsearchitem);
165                return;
166            }
167
168            if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
169                // on enter
170                var re_ajax_search_cur = jQuery(this).parent().parent().find('.re-sch-cur-element');
171                if (re_ajax_search_cur.length > 0) {
172                    var re_searchopen_url = re_ajax_search_cur.find('.re-search-result-title a').attr('href');
173                    window.location = re_searchopen_url;
174                } else {
175                    jQuery(this).parent().submit();
176                }
177                return false; //redirect for search on enter
178            } else {
179
180                if ((event.which && event.which == 40) || (event.keyCode && event.keyCode == 40)) {
181                    // down
182                    re_ajax_search.re_aj_search_move_key_down(ajaxsearchitem);
183                    return false; //disable the envent
184
185                } else if((event.which && event.which == 38) || (event.keyCode && event.keyCode == 38)) {
186                    //up
187                    re_ajax_search.re_aj_search_move_key_up(ajaxsearchitem);
188                    return false; //disable the envent
189                } else {
190
191                    //for backspace we have to check if the search query is empty and if so, clear the list
192                    if ((event.which && event.which == 8) || (event.keyCode && event.keyCode == 8)) {
193                        //if we have just one character left, that means it will be deleted now and we also have to clear the search results list
194                        var search_query = jQuery(this).val();
195                        if (search_query.length == 1) {
196                            jQuery(this).parent().parent().find('.re-aj-search-wrap').removeClass( 're-aj-search-open' ).empty();
197                        }
198
199                    }
200
201                    //various keys
202                    re_ajax_search.re_ajax_set_focus(ajaxsearchitem);
203                    //jQuery('.re-aj-search-wrap').empty();
204                    setTimeout(function(){
205                        re_ajax_search.do_ajax_call(ajaxsearchitem);
206                    }, 100);
207                }
208                return true;
209            }
210        });
211
212    },
213
214    /**
215     * moves the select up
216     */
217    re_aj_search_move_key_up: function re_aj_search_move_key_up(elem) {
218        if (re_ajax_search._first_down_up === true) {
219            re_ajax_search._first_down_up = false;
220            if (re_ajax_search._current_selection_index === 0) {
221                re_ajax_search._current_selection_index = re_ajax_search._last_request_results_count - 1;
222            } else {
223                re_ajax_search._current_selection_index--;
224            }
225        } else {
226            if (re_ajax_search._current_selection_index === 0) {
227                re_ajax_search._current_selection_index = re_ajax_search._last_request_results_count;
228            } else {
229                re_ajax_search._current_selection_index--;
230            }
231        }
232        elem.parent().parent().find('.re-search-result-div').removeClass('re-sch-cur-element');
233        if (re_ajax_search._current_selection_index  > re_ajax_search._last_request_results_count -1) {
234            //the input is selected
235            elem.closest('form').fadeTo(100, 1);
236        } else {
237            re_ajax_search.re_search_input_remove_focus(elem);
238            elem.parent().parent().find('.re-search-result-div').eq(re_ajax_search._current_selection_index).addClass('re-sch-cur-element');
239        }
240    },
241
242    /**
243     * moves the select prompt down
244     */
245    re_aj_search_move_key_down: function re_aj_search_move_key_down(elem) {
246        if (re_ajax_search._first_down_up === true) {
247            re_ajax_search._first_down_up = false;
248        } else {
249            if (re_ajax_search._current_selection_index === re_ajax_search._last_request_results_count) {
250                re_ajax_search._current_selection_index = 0;
251            } else {
252                re_ajax_search._current_selection_index++;
253            }
254        }
255        elem.parent().parent().find('.re-search-result-div').removeClass('re-sch-cur-element');
256        if (re_ajax_search._current_selection_index > re_ajax_search._last_request_results_count - 1 ) {
257            //the input is selected
258            elem.closest('form').fadeTo(100, 1);
259        } else {
260            re_ajax_search.re_search_input_remove_focus(elem);
261            elem.parent().parent().find('.re-search-result-div').eq(re_ajax_search._current_selection_index).addClass('re-sch-cur-element');
262        }
263    },
264
265    /**
266     * puts the focus on the input box
267     */
268    re_ajax_set_focus: function re_ajax_set_focus(elem) {
269        re_ajax_search._current_selection_index = 0;
270        re_ajax_search._first_down_up = true;
271        elem.closest('form').fadeTo(100, 1);
272        elem.parent().parent().find('.re-search-result-div').removeClass('re-sch-cur-element');
273    },
274
275    /**
276     * removes the focus from the input box
277     */
278    re_search_input_remove_focus: function re_search_input_remove_focus(elem) {
279        if (re_ajax_search._last_request_results_count !== 0) {
280            elem.closest('form').css('opacity', 0.5);
281        }
282    },
283
284    /**
285     * AJAX: process the response from the server
286     */
287    process_ajax_response: function (data, callelem) {
288        var current_query = callelem.val();
289
290        //the search is empty - drop results
291        if (current_query == '') {
292            callelem.parent().parent().find('.re-aj-search-wrap').empty();
293            return;
294        }
295
296        var td_data_object = jQuery.parseJSON(data); //get the data object
297        //drop the result - it's from a old query
298        if (td_data_object.re_search_query !== current_query) {
299            return;
300        }
301
302        //reset the current selection and total posts
303        re_ajax_search._current_selection_index = 0;
304        re_ajax_search._last_request_results_count = td_data_object.re_total_inlist;
305        re_ajax_search._first_down_up = true;
306
307
308        //update the query
309        callelem.parent().parent().find('.re-aj-search-wrap').addClass( 're-aj-search-open' ).html(td_data_object.re_data);
310        var iconsearch = callelem.parent().find('.fa-refresh'); 
311        iconsearch.removeClass('fa-refresh fa-spin').addClass('fa-search');
312        callelem.removeClass('searching-now');
313
314    },
315
316    /**
317     * AJAX: do the ajax request
318     */
319    do_ajax_call: function do_ajax_call(elem) {
320        var posttypes = elem.data('posttype');
321        var callelem = elem;
322        if (elem.val() == '') {
323            re_ajax_search.re_ajax_set_focus(callelem);
324            return;
325        }
326
327        var search_query = elem.val();
328
329        //do we have a cache hit
330        if (re_ajax_cache.exist(search_query)) {
331            re_ajax_search.process_ajax_response(re_ajax_cache.get(search_query), callelem);
332            return;
333        }
334
335        var iconsearch =  elem.parent().find('.fa-search');     
336        iconsearch.removeClass('fa-search').addClass('fa-refresh fa-spin');
337        elem.addClass('searching-now');
338
339        jQuery.ajax({
340            type: 'POST',
341            url: translation.ajax_url,
342            data: {
343                action: 'rehub_ajax_search',
344                re_string: search_query,
345                posttypesearch: posttypes,
346            },
347            success: function(data, textStatus, XMLHttpRequest){
348                re_ajax_cache.set(search_query, data);
349                re_ajax_search.process_ajax_response(data, callelem);
350            },
351            error: function(MLHttpRequest, textStatus, errorThrown){
352                //console.log(errorThrown);
353            }
354        });
355    }
356
357};
358
359jQuery(document).ready(function($) {
360   'use strict'; 
361
362   //re_sizebg();
363   re_sizebg(); 
364
365   re_ajax_search.init();   
366
367   // Lazy load images
368   $("img.lazyimages").unveil(40, function() {
369      $(this).load(function() {
370         this.style.opacity = 1;
371      });
372   });
373   $('.tabs, .vc_tta, .wpsm-tabs').find('img.lazyimages').trigger("unveil");
374   
375   var res_nav = $("header .top_menu").html();
376   $("header .responsive_nav_wrap").append(res_nav);
377   $('header .responsive_nav_wrap' ).wrapInner(function() {
378      return "<div id='dl-menu' class='dl-menuwrapper'></div>";
379   });
380   $( 'header .responsive_nav_wrap ul.menu' ).attr('class', 'dl-menu');
381   if ($('.rehub-custom-menu-item.top-search-onclick').length > 0) { 
382      $( "header .responsive_nav_wrap #dl-menu .rehub-custom-menu-item" ).remove();
383   }
384   if ($('.rehub-custom-menu-item.rehub-top-login-onclick .act-rehub-login-popup').length > 0) {
385      $( "header .responsive_nav_wrap #dl-menu" ).prepend( "<button class='act-rehub-login-popup' data-type='login'><i class='fa fa-sign-in'></i></button>" ); 
386      $( "header .responsive_nav_wrap #dl-menu .rehub-custom-menu-item" ).remove();
387   } 
388   if ($('.rehub-custom-menu-item.rehub-top-login-onclick .user-dropdown-intop').length > 0) {
389      $( "header .responsive_nav_wrap #dl-menu" ).prepend( $(".rehub-custom-menu-item.rehub-top-login-onclick").html()); 
390      $( "header .responsive_nav_wrap #dl-menu .rehub-custom-menu-item" ).remove();
391   } 
392   if ($('.logo-section .wpsm-button.mobileinmenu').length > 0) {
393      $( "header .responsive_nav_wrap #dl-menu" ).prepend( $(".logo-section .mobileinmenu").clone()); 
394      //$( "header .responsive_nav_wrap #dl-menu .rehub-custom-menu-item" ).remove();
395   }        
396   //if ($(".main-nav").find(".subline") == undefined) {
397      //$(".main-nav").find(".logo_image_inmenu").addClass('padding5');
398   //}
399   if ($(".main-nav .subline").length > 0) {
400      $(".main-nav").addClass("subline-enabled");
401   } 
402   if ($('#logo_mobile_wrapper').length > 0) { 
403      $( "header .responsive_nav_wrap #dl-menu" ).prepend($('#logo_mobile_wrapper').html() );
404   }       
405   if ($('.main-nav .logo-inmenu').length > 0) { 
406      $( "header .responsive_nav_wrap #dl-menu .menu-item.logo-inmenu" ).remove();
407   }   
408   $( "header .responsive_nav_wrap #dl-menu" ).prepend( "<button class='dl-trigger'><i class='fa fa-bars'></i></button>" );
409   $( "header .responsive_nav_wrap #dl-menu" ).prepend( "<button class='icon-search-onclick'><i class='fa fa-search'></i></button>" );
410   $( "header .responsive_nav_wrap #dl-menu" ).find('.sub-menu').attr('class', 'dl-submenu');
411
412   /* responsive menu init */
413   $( '#dl-menu' ).dlmenu();
414
415   /* scroll to # */
416   $('.rehub_scroll, #kcmenu a, .kc-gotop').bind('click.smoothscroll',function (e) {
417      e.preventDefault();
418      if (typeof $(this).data('scrollto') !== 'undefined') {
419         var target = $(this).data('scrollto');
420         var hash = $(this).data('scrollto');
421      } 
422      else {
423         var target = $(this.hash + ', a[name="'+ this.hash.replace(/#/,"") +'"]').first();
424         var hash = this.hash;
425      }
426      var $target = $(target);
427      $('html, body').stop().animate({
428         'scrollTop': $target.offset().top
429      }, 500, 'swing', function () {
430         window.location.hash = hash;
431      });
432   });   
433   
434   /* tabs */
435   $('.tabs-menu').delegate('li:not(.current)', 'click', function() {
436      $(this).addClass('current').siblings().removeClass('current').parents('.tabs').find('.tabs-item').hide().eq($(this).index()).fadeIn(700);
437   })
438   $('.tabs-menu li:first-child').trigger('click');
439
440   $('.wpsm-tabs:not(.vc_tta)').each(function(){
441      $(this).tabs();
442   }); 
443
444   /*bar*/  
445   $('.wpsm-bar').each(function(){
446      $(this).find('.wpsm-bar-bar').animate({ width: $(this).attr('data-percent') }, 1500 );
447   });   
448
449   /* accordition */
450   $(".wpsm-accordion").each(function(){
451      $(this).accordion({heightStyle: "content" });
452   });
453
454   /* toggle */
455   $("h3.wpsm-toggle-trigger").click(function(){
456      $(this).toggleClass("active").next().slideToggle("fast");return false;
457   });
458
459   /* review woo tabs */
460   $('.rehub_woo_tabs_menu').delegate('li:not(.current)', 'click', function() {
461      $(this).addClass('current').siblings().removeClass('current').parents('.rehub_woo_review').find('.rehub_woo_review_tabs').hide().eq($(this).index()).fadeIn(700);
462   })
463   $('.rehub_woo_tabs_menu li:first-child').trigger('click');
464   $('.btn_offer_block.choose_offer_woo').click(function(event){     
465      event.preventDefault();
466      $('.rehub_woo_tabs_menu li.woo_deals_tab').trigger('click');
467   });
468    
469   /* widget dropdown */
470   $('.cat_widget_custom .children').parent().find('a').append('<span class="drop_list">&nbsp; +</span>');  
471      $('.tabs-item .drop_list').click(function() {
472       $(this).parent().parent().find('.children').slideToggle();
473        return false
474    });  
475
476    /* offer archive dropdown */  
477   $('.r_offer_details .r_show_hide').click(function() {
478      $(this).parent().find('.open_dls_onclk').slideToggle();
479    });        
480
481   // Coupon Modal
482   $( 'body' ).on("click", ".rehub_offer_coupon.masked_coupon:not(.expired_coupon)", function(e){
483      var $this = $(this);
484      var codeid = $this.data('codeid');
485      var codetext = $this.data('codetext');
486      if (typeof $this.data('codeid') !== 'undefined') {var couponpage = window.location.pathname + "?codeid=" + codeid;}
487      if (typeof $this.data('codetext') !== 'undefined') {var couponpage = window.location.pathname + "?codetext=" + codetext;}
488      var couponcode = $this.data('clipboard-text'); 
489      var destination = $this.data('dest'); 
490      if( destination != "" || destination != "#" ){
491         window.location.href= destination;
492      }
493      window.open(couponpage);
494   });
495
496   function GetURLParameter(sParam){
497      var sPageURL = window.location.search.substring(1);
498      var sURLVariables = sPageURL.split('&');
499      for (var i = 0; i < sURLVariables.length; i++) 
500      {
501         var sParameterName = sURLVariables[i].split('=');
502         if (sParameterName[0] == sParam) 
503         {
504            return sParameterName[1];
505         }
506      }
507   }  
508
509   var coupontrigger = GetURLParameter("codeid");
510   if(coupontrigger){
511      var $change_code = $(".rehub_offer_coupon.masked_coupon:not(.expired_coupon)[data-codeid='" + coupontrigger +"']");
512      var couponcode = $change_code.data('clipboard-text'); 
513      $change_code.removeClass('masked_coupon').removeClass('btn_offer_block').addClass('not_masked_coupon').html( '<i class="fa fa-scissors fa-rotate-180"></i><span class="coupon_text">'+ couponcode +'</span>' );                
514      $.pgwModal({
515         url: translation.ajax_url + "?action=ajax_code&codeid=" + coupontrigger,
516         titleBar: false,
517         mainClassName : 'pgwModal coupon-reveal-popup',
518         ajaxOptions : {
519            success : function(response) {
520               if (response) {
521                  $.pgwModal({ pushContent: response });
522               } else {
523                  $.pgwModal({ pushContent: 'An error has occured' });
524               }
525            }
526         }
527      });
528   };
529
530   //Coupons copy code function
531   $('.rehub_offer_coupon:not(.expired_coupon)').each(function(){
532      ZeroClipboard.config( { swfPath: translation.templateurl+"/js/zeroclipboard/ZeroClipboard.swf" } );
533      var $this = $(this);
534      var couponcode = $this.data('clipboard-text');    
535      var client = new ZeroClipboard( $this );
536      client.on( 'ready', function(event) {
537         //console.log( 'movie is loaded' );
538         client.on( 'copy', function(event) {
539            event.clipboardData.setData('text/plain', couponcode);
540         });  
541         client.on( 'aftercopy', function(event) {
542            $this.find('i.fa').replaceWith( '<i class="fa fa-check-square"></i>' );
543            $this.find('i.fa').fadeOut( 2500, function() {
544               $this.find('i.fa').replaceWith( '<i class="fa fa-scissors fa-rotate-180"></i>' ).fadeIn('slow');
545            });
546         });
547      });  
548      client.on( 'error', function(event) {
549         ZeroClipboard.destroy();         
550      });
551   });
552
553   $(".rehub_offer_coupon.masked_coupon.expired_coupon").each(function() {
554      var couponcode = $(this).data('clipboard-text');
555      $(this).text(couponcode);
556   });
557
558   //external links
559   $('.ext-source').replaceWith(function(){
560        return '<a href="' + $(this).data('dest') + '" target="_blank" rel="nofollow">' + $(this).html() + '</a>';
561    });
562
563   //Infinite scroll js
564   $('.inf_scr_wrap_auto').each(function() {
565      var $this = $(this);
566      $this.infinitescroll({
567         navSelector: ".more_post",
568         nextSelector: ".more_post a",
569         itemSelector: ".inf_scr_item",
570         loading: {
571            finishedMsg: '<em>' + translation.fin + '</em>',
572            msgText: '',
573            img: translation.templateurl + '/images/preload.gif',
574         },        
575      }, function(){
576         $this.find('img.lazyimages').each(function(){
577            var source = $(this).attr("data-src");
578            $(this).attr("src", source).css({'opacity': '1'});
579         });      
580      }
581      );      
582   });   
583
584   //fix for VC responsive sidebar
585   //$('.vc_col-sm-4, .vc_col-sm-3').find('.sidebar').closest('.vc_row').addClass('vc_rehub_container'); 
586
587   $('.eq_height_post').equalHeightColumns({
588      minWidth: 767,
589      afterTimeout: 500,
590      checkHeight: 'innerHeight'
591   });  
592   $('.eq_height_inpost').equalHeightColumns({
593      minWidth: 767,
594      afterTimeout: 500,
595      checkHeight: 'innerHeight'
596   });    
597
598    //category pager
599   $('.cat-pagination').on('click', 'a:not(.active) ', function(){
600      var multi_cat = $(this).closest('.multi_cat');
601      var multi_cat_wrap = multi_cat.find('.multi_cat_wrap');
602      var page = $(this).data('paginated');
603      var data = {
604         'action': 'multi_cat',
605         'page': page,
606         'tax': multi_cat.data('tax'),
607         'term': multi_cat.data('term'),
608         'nonce' : translation.nonce,
609      };
610
611      multi_cat_wrap.addClass('loading');
612
613      $.post(translation.ajax_url, data, function(response) {
614         if (response !== 'fail') {
615            multi_cat_wrap.html(response);
616            multi_cat.find('.cat-pagination a').removeClass('active');
617            multi_cat.find('.cat-pagination a[data-paginated="' + page + '"]').addClass('active');
618         }
619         multi_cat_wrap.removeClass('loading');
620      });
621   }); 
622
623   //Sharing popups JS
624   jQuery( 'body').on( 'click', '.share-link-image', function( event ) {
625      var href    = jQuery( this ).attr( "href" ),
626         service = jQuery( this ).data( 'service' ),
627         width   = 'pinterest' == service ? 750 : 600,
628         height  = 'twitter' == service ? 250 : 'pinterest' == service ? 320 : 300,
629         top     = ( screen.height / 2 ) - height / 2,
630         left    = ( screen.width / 2 ) - width / 2;
631      var options = 'top=' + top + ',left=' + left + ',width=' + width + ',height=' + height;
632      event.preventDefault();
633      event.stopPropagation();
634      window.open( href, service, options );
635   });   
636
637   //Comment filtering
638   $('body').on('click', '#rehub-comments-tabs span', function() {
639      if(typeof rating_tabs_ajax_send!=='undefined' && rating_tabs_ajax_send)
640         return;
641      var post_id = $('#rehub-comments-tabs').data('postid');
642      var rating_tabs_ajax_send = true;
643      var p = $(this).parent().children().removeClass('active');
644      $(this).addClass('active');
645      if ($(this).data('tabid')==1) {
646         $('#loadcomment-list').html('');
647         $('#tab-1').show();
648         rating_tabs_ajax_send = false;
649         return;
650      }
651      $.ajax({
652         type: 'post',
653         data: 'action=show_tab&post_id='+post_id+'&tab_number='+$(this).data('tabid')+'&rating_tabs_id='+translation.rating_tabs_id,
654         url: translation.ajax_url,
655         beforeSend: function() {
656            $('#tab-1').hide();
657            $('#loadcomment-list').html('<div class="text-center loadingcomment"><i class="fa fa-refresh fa-spin"></i></div>');
658         },
659         error: function(jqXHR, textStatus, errorThrown) {
660            $('#loadcomment-list').html('error: '+errorThrown);
661         },
662         success : function(html_data) {
663            rating_tabs_ajax_send = false;
664            $("#loadcomment-list").html(html_data);
665         }
666      });
667   });  
668
669   // Search icon show/hide
670
671   //Collapse top small menu
672   $(document).on('click', '.re-top-menu-collapse', function(e) {
673         e.preventDefault();
674         $('.header-top .top-nav ul').slideToggle();
675   });  
676   $(window).resize(function(){
677      var w = $(window).width();
678      if(w > 320 && $('.header-top .top-nav ul').is(':hidden')) {
679         $('.header-top .top-nav ul').removeAttr('style');
680      }
681   });  
682
683   // Add modal on links for non logged
684
685   if ($('.ap-login-message-wrapper').length > 0) {
686      if ($('#rehub-login-popup').length > 0) {
687         $( ".ap-login-message-wrapper .ap-login-message + a" ).addClass('act-rehub-login-popup'); 
688      }   
689   }   
690
691   if ($('#respond .must-log-in a').length > 0) {
692      if ($('#rehub-login-popup').length > 0) {
693         $( "#respond .must-log-in a" ).addClass('act-rehub-login-popup'); 
694      }   
695   }    
696
697   // Open login/register modal
698   $(document).on('click', 'body:not(.logged-in) .act-rehub-login-popup', function(e) {
699      e.preventDefault();
700      var acttype = $(this).data('type');
701      if (acttype == 'login') {
702         $.pgwModal({
703            titleBar: false,
704            target: '#rehub-login-popup',
705            mainClassName : 'pgwModal re-user-popup-wrap',
706         });
707         $('.re-user-popup-wrap .rehub-errors').html('');
708      }
709      else if(acttype == 'register') {
710         $.pgwModal({
711            titleBar: false,
712            target: '#rehub-register-popup',
713            mainClassName : 'pgwModal re-user-popup-wrap',
714         });  
715         $('.re-user-popup-wrap .rehub-errors').html('');
716         $('.re-user-popup-wrap .recaptchamodail').attr('id', 'recaptchamodail');       
717      }
718      else if(acttype == 'resetpass') {
719         $.pgwModal({
720            titleBar: false,
721            target: '#rehub-reset-popup',
722            mainClassName : 'pgwModal re-user-popup-wrap',
723         }); 
724         $('.re-user-popup-wrap .rehub-errors').html('');        
725      } 
726      else if(acttype == 'restrict') {
727         $.pgwModal({
728            titleBar: false,
729            target: '#rehub-restrict-login-popup',
730            mainClassName : 'pgwModal re-user-popup-wrap',
731         });         
732      } 
733      else if(acttype == 'url') {
734         window.location.href= $(this).attr('href');         
735      }       
736      else {
737         $.pgwModal({
738            titleBar: false,
739            target: '#rehub-login-popup',
740            mainClassName : 'pgwModal re-user-popup-wrap',
741         });
742         $('.re-user-popup-wrap .rehub-errors').html('');
743      }                
744   });
745
746   // Post login form submit
747   $(document).on('submit','.re-user-popup-wrap #rehub_login_form_modal',function(e){
748      e.preventDefault();
749      var button = $(this).find('button.rehub_main_btn');
750      button.addClass('loading');
751      $.post(translation.ajax_url, $('.re-user-popup-wrap #rehub_login_form_modal').serialize(), function(data){
752         var obj = $.parseJSON(data);
753         $('.rehub-login-popup .rehub-errors').html(obj.message);       
754         if(obj.error == false){
755            window.setTimeout(function(){location.reload()},200);
756            button.hide();
757         }
758         button.removeClass('loading');
759      });
760   });
761
762   // Post register form
763   $(document).on('submit','.re-user-popup-wrap #rehub_registration_form_modal',function(e){
764      e.preventDefault();
765      var button = $(this).find('button.rehub_main_btn');
766      button.addClass('loading');
767      $.post(translation.ajax_url, $('.re-user-popup-wrap #rehub_registration_form_modal').serialize(), function(data){       
768         var obj = $.parseJSON(data);
769         $('.rehub-register-popup .rehub-errors').html(obj.message);       
770         if(obj.error == false){
771            $('.rehub-register-popup').addClass('registration-complete');
772            window.setTimeout(function(){location.reload()},4000);
773            //button.hide();
774         }
775         $('.rehub-register-popup').removeClass('registration-complete');
776         button.removeClass('loading');       
777      });
778   });
779
780   // Reset Password
781   $(document).on('submit','.re-user-popup-wrap #rehub_reset_password_form_modal',function(e){
782      e.preventDefault();
783      var button = $(this).find('button.rehub_main_btn');
784      button.addClass('loading');
785      $.post(translation.ajax_url, $('.re-user-popup-wrap #rehub_reset_password_form_modal').serialize(), function(data){
786         var obj = $.parseJSON(data);
787         $('.rehub-reset-popup .rehub-errors').html(obj.message);    
788         if(obj.error == false){
789            window.setTimeout(function(){location.reload()},3000);  
790         }
791         button.removeClass('loading');
792      });
793   });
794
795   // drop down for user menu
796   $( '.user-ava-intop' ).click(function(e) {
797      e.stopPropagation();
798      $( this ).parent().find( '.user-dropdown-intop-menu' ).toggleClass('user-dropdown-intop-open');
799      $(this).toggleClass('user-ava-intop-open');
800   });
801   $( '.user-dropdown-intop-menu' ).click(function(e) {
802      e.stopPropagation();
803   });    
804   $( document ).click(function() {
805      $( '.user-dropdown-intop-menu' ).removeClass('user-dropdown-intop-open');
806      $( '.user-ava-intop' ).removeClass('user-ava-intop-open');
807   }); 
808
809   //Compare functions
810   $('#re-compare-panel-heading').on('click', '.re-compare-panel-collapse', function(e) {
811      e.stopPropagation();
812      $( this ).parent().parent().toggleClass('collapsed');
813   });  
814   $('.table_view_charts').on('click', '.re-compare-show-diff', function(e){
815      if ($(this).is(':checked')){
816         $(this).closest('.table_view_charts').find('li[class^="row_chart"]').filter(':not(.heading_row_chart)').filter(':not(.row-is-different)').addClass('low-opacity');
817      } 
818      else {
819         $(this).closest('.table_view_charts').find('li[class^="row_chart"]').filter(':not(.heading_row_chart)').filter(':not(.row-is-different)').removeClass('low-opacity');
820      }     
821
822   });
823
824   if ($('#re-compare-panel').length > 0) { 
825      $.post(translation.ajax_url, {
826         action: 're_compare_panel'
827      }, function (response) {
828         $('#re-compare-wrap').html(response.content);
829         $('#re-compare-panel').addClass(response.cssactive);
830         var compareurl = $('.re-compare-dest').data('compareurl');
831         $('.re-compare-panel-title span').text(response.count);
832         $('.re-compare-dest').attr('data-compareurl', compareurl + '?compareids=' + response.comparing); 
833      });      
834   }  
835   //compare button
836   $('body').on('click', '.wpsm-button-compare', function(e){
837      var thistoggle = $(this);
838      var panel = $('#re-compare-panel');       
839      var compareID = thistoggle.data('addcompare-id');
840      var alltoggles = $('.addcompare-id-' + compareID);
841      var compareurl = $('.re-compare-dest').data('compareurl');      
842      alltoggles.addClass('loading');
843      if(thistoggle.hasClass('not-incompare')) {         
844         $.post(translation.ajax_url, {
845            action: 're_add_compare',
846            compareID: compareID,
847            perform: 'add'    
848         }, function (response) {   
849            panel.addClass('active'); 
850            alltoggles.removeClass('not-incompare').removeClass('loading');
851            alltoggles.addClass('comparing');                 
852            $('#re-compare-wrap').append(response.content).find(".re-compare-item:last").hide().fadeIn('slow');
853            $('.re-compare-panel-title span').text(response.count);
854            alltoggles.removeClass('loading');               
855            $('.re-compare-dest').attr('data-compareurl', compareurl + '?compareids=' + response.comparing);                    
856         }); 
857      } else {
858         $('.compare-item-' + compareID).css({'opacity': '.17'});         
859         $.post(translation.ajax_url, {
860            action: 're_add_compare',
861            compareID: compareID,
862            perform: 'remove'    
863         }, function (response) {
864            alltoggles.addClass('not-incompare');
865            alltoggles.removeClass('comparing').removeClass('loading');                      
866            $('.compare-item-' + compareID).remove();   
867            $('.re-compare-panel-title span').text(response.count);
868            if($('#re-compare-wrap').children().length == 0) {
869               panel.removeClass('active');
870            }
871            else { 
872               $('.re-compare-dest').attr('data-compareurl', compareurl + '?compareids=' + response.comparing);                
873            }
874         });                
875      } 
876   });  
877   //Compare close button
878   $('body').on('click', '.re-compare-close', function(e){
879      var block = $(this).parent();
880      var panel = $('#re-compare-panel');       
881      var compareID = block.data('compareid');
882      var alltoggles = $('.addcompare-id-' + compareID);
883      var compareurl = $('.re-compare-dest').data('compareurl');      
884      block.css({'opacity': '.17'});
885      $.post(translation.ajax_url, {
886         action: 're_add_compare',
887         compareID: compareID,
888         perform: 'remove'    
889      }, function (response) { 
890         alltoggles.addClass('not-incompare').removeClass('comparing');           
891         block.remove(); 
892         $('.re-compare-panel-title span').text(response.count);
893         if($('#re-compare-wrap').children().length == 0) {
894            panel.removeClass('active');
895         }
896         else { 
897            $('.re-compare-dest').attr('data-compareurl', compareurl + '?compareids=' + response.comparing);                
898         }           
899      });   
900   }); 
901   //Compare close button in chart
902   $('body').on('click', '.re-compare-close-in-chart', function(e){
903      var block = $(this).closest('.top_rating_item'); 
904      $(this).closest('.table_view_charts').find('li').removeClass('row-is-different');      
905      var compareID = block.data('compareid');      
906      block.css({'opacity': '.17'});
907      $.post(translation.ajax_url, {
908         action: 're_add_compare',
909         compareID: compareID,
910         perform: 'remove'    
911      }, function (response) {           
912         block.remove();
913         table_charts();
914         if (typeof (history.pushState) != "undefined") {
915            var obj = { Page: 'Compare items', Url: window.location.pathname + '?compareids=' + response.comparing };
916            history.pushState(obj, obj.Page, obj.Url);
917         } else {
918            window.location.href= window.location.pathname + '?compareids=' + response.comparing;
919         }                                    
920      }); 
921                 
922   });    
923   // Compare click button
924   $( 'body' ).on("click", ".re-compare-dest", function(e){
925      var $this = $(this);
926      var compareurl = $this.attr('data-compareurl'); 
927      if( compareurl != "" || compareurl != "#" ){
928         window.location.href= compareurl;
929      }
930   });  
931
932   if ($('.content').length > 0 && $('#re-compare-panel').length > 0) {
933      var contwidthout = $('.content').outerWidth();
934      $('#re-compare-panel').css({'width': contwidthout,'margin-left': - (contwidthout/2), 'left' : '50%'});
935   }  
936
937   /* gallery hover */
938   $(".media_owl_carousel .photo-item").hover(function(){
939      $(this).children('.gp-overlay').stop(true, true).fadeIn(500);
940   }, function(){
941      $(this).children('.gp-overlay').stop(true, true).fadeOut(500);
942   });
943
944}); //END Document.ready
945
946/* menu */
947showNav = function(){'use strict'; jQuery(this).find('> .sub-menu').slideDown(); }
948hideNav = function(){'use strict'; jQuery(this).find('> .sub-menu').slideUp();}
949jQuery('nav.top_menu > ul > li.menu-item-has-children').hoverIntent({
950   sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
951   interval: 100, // number = milliseconds of polling interval
952   over: showNav, // function = onMouseOver callback (required)
953   timeout: 120, // number = milliseconds delay before onMouseOut function call
954   out: hideNav // function = onMouseOut callback (required)
955})
956
957// User Rate functions
958jQuery(document).on('mousemove', '.user-rate-active' , function (e) {
959    var rated = jQuery(this);
960    if( rated.hasClass('rated-done') ){
961      return false;
962    }
963    if (!e.offsetX){
964      e.offsetX = e.clientX - jQuery(e.target).offset().left;
965    }
966    var offset = e.offsetX + 4;
967    if (offset > 100) {
968      offset = 100;
969    }
970    rated.find('.user-rate-image span').css('width', offset + '%');
971    var score = Math.floor(((offset / 10) * 5)) / 10;
972    if (score > 5) {
973      score = 5;
974    }
975});
976jQuery(document).on('click', '.user-rate-active' , function (e) {
977    var rated = jQuery(this);
978    if( rated.hasClass('rated-done') ){
979      return false;
980    }
981    var gg = rated.find('.user-rate-image span').width();
982    rated.find('.user-rate-image').hide();
983    rated.append('<span class="rehub-rate-load"></span>');
984    if (gg > 100) {
985      gg = 100;
986    }
987    ngg = (gg*5)/100;
988    var post_id = rated.attr('data-id');
989    var rate_type = rated.attr('data-ratetype');
990    var numVotes = rated.parent().find('.userrating-count').text();
991    jQuery.post(translation.ajax_url, { action:'rehub_rate_post' , post:post_id , type:rate_type , value:ngg}, function(data) {
992    var post_rateed = '.rate-post-'+post_id;
993      jQuery( post_rateed ).addClass('rated-done').attr('data-rate',gg);
994      rated.find('.user-rate-image span').width(gg+'%');
995      
996      jQuery(".rehub-rate-load").fadeOut(function () {
997
998        rated.parent().find('.userrating-score').html( ngg );
999        
1000        if( (jQuery(rated.parent().find('.userrating-count'))).length > 0 ){
1001          numVotes =  parseInt(numVotes)+1;
1002          rated.parent().find('.userrating-count').html(numVotes);
1003        }else{
1004          rated.parent().find('small').hide();
1005        }
1006        rated.parent().find('strong').html(translation.your_rating);
1007        
1008        rated.find('.user-rate-image').fadeIn();
1009      });
1010    }, 'html');
1011    return false;
1012});
1013jQuery(document).on('mouseleave', '.user-rate-active' , function (e) {
1014    var rated = jQuery(this);
1015    if( rated.hasClass('rated-done') ){
1016      return false;
1017    }
1018    var post_rate = rated.attr('data-rate');
1019    rated.find(".user-rate-image span").css('width', post_rate + '%');
1020});
1021
1022// Rate bar annimation
1023jQuery(function($){
1024'use strict';  
1025  $(document).ready(function(){   
1026    $('.rate_bar_wrap').bind('inview', function(event, visible) {
1027      if (visible) {
1028        $('.rate-bar').each(function(){
1029         $(this).find('.rate-bar-bar').animate({ width: $(this).attr('data-percent') }, 1500 );
1030         $('.rate_bar_wrap').unbind('inview');
1031        });
1032      }
1033    });
1034
1035    $('.rate-line').bind('inview', function(event, visible) {
1036      if (visible) {
1037        $('.rate-line .line').each(function(){
1038         $(this).find('.filled').animate({ width: $(this).attr('data-percent') }, 1500 );
1039         $('.rate-line').unbind('inview');
1040        });
1041      }
1042    });
1043
1044   $(document).on('inview', '.top_rating_block, .top_table_block, .top_chart', function(event, visible) {
1045      if (visible) {
1046        $('.radial-progress').each(function(){
1047          $(this).find('.circle .mask.full, .circle .fill:not(.fix)').animate({  borderSpacing: $(this).attr('data-rating')*18 }, {
1048              step: function(now,fx) {
1049                $(this).css('-webkit-transform','rotate('+now+'deg)'); 
1050                $(this).css('-moz-transform','rotate('+now+'deg)');
1051                $(this).css('transform','rotate('+now+'deg)');
1052              },
1053              duration:'slow'
1054          },'linear');
1055
1056          $(this).find('.circle .fill.fix').animate({  borderSpacing: $(this).attr('data-rating')*36 }, {
1057              step: function(now,fx) {
1058                $(this).css('-webkit-transform','rotate('+now+'deg)'); 
1059                $(this).css('-moz-transform','rotate('+now+'deg)');
1060                $(this).css('transform','rotate('+now+'deg)');
1061              },
1062              duration:'slow'
1063          },'linear');                   
1064  
1065        });
1066      }
1067   }); 
1068
1069  });
1070});  
1071  
1072   
1073//Scroll To top
1074var pretimer;
1075jQuery(window).scroll(function(){
1076'use strict';
1077
1078   var postheight = jQuery('.post-inner').height() + jQuery('#main_header').height() - 100;
1079   if (jQuery(this).scrollTop() > 500) {
1080      clearTimeout(pretimer); 
1081      jQuery('#topcontrol, #float-posts-nav').addClass('scrollvisible');
1082      var refresh=function(){jQuery('#topcontrol:not(:hover), #float-posts-nav:not(:hover)').removeClass('scrollvisible');}      
1083      pretimer=setTimeout(refresh,4000);
1084
1085   } else {
1086      jQuery('#topcontrol').removeClass('scrollvisible');
1087      jQuery('#float-posts-nav').removeClass('scrollvisible');
1088   }
1089   if (jQuery(this).scrollTop() > postheight) {
1090      jQuery('#float-posts-nav').addClass('openedprevnext');
1091   } else {
1092      jQuery('#float-posts-nav').removeClass('openedprevnext');
1093   } 
1094
1095   if (jQuery('.footer-bottom').length > 0) {
1096      if (jQuery('#re-compare-panel').length > 0) {
1097         if(isVisibleOnScroll(jQuery('.footer-bottom'))) {
1098            jQuery('#re-compare-panel').addClass('collapsed-onscroll');
1099         }
1100         else {
1101            jQuery('#re-compare-panel').removeClass('collapsed-onscroll');
1102         }
1103      }
1104   }
1105
1106});
1107
1108
1109
1110
1111jQuery(window).load(function() {
1112
1113   //CAROUSELS
1114   var makesiteCarousel = function() {
1115      if(jQuery().carouFredSel) {                 
1116
1117         jQuery('.top_chart_wrap').each(function() {
1118            var carousel = jQuery(this).find('.top_chart_carousel');
1119            var directionrtl = (jQuery('body.rtl').length > 0) ? "right" : "left";
1120            var windowsize = jQuery(this).width();                      
1121            if (windowsize <= 280) {
1122               var passItems = 1;
1123            } else if (windowsize > 280 && windowsize <= 480) {
1124               var passItems = 2;               
1125            } else if (windowsize > 480) {
1126               var passItems = 4;
1127            }            
1128            carousel.carouFredSel({
1129               circular: false,
1130               infinite: false,                
1131               responsive: true,
1132               direction: directionrtl,
1133               auto: {
1134                  play: false
1135               },
1136               swipe: {
1137                  onTouch: true,
1138                  onMouse: true,
1139                  onAfter : function () {
1140                     var items = carousel.triggerHandler("currentVisible");
1141                     carousel.children().removeClass( "activecol" );
1142                     items.addClass( "activecol" );
1143                  }                  
1144               },               
1145               items: {
1146                  height: 'variable',
1147                  width: 220,  
1148                  visible   : {
1149                     min      : 1,
1150                     max      : passItems
1151                  },
1152               },
1153               scroll : {
1154                  onAfter : function () {
1155                     var items = carousel.triggerHandler("currentVisible");
1156                     carousel.children().removeClass( "activecol" );
1157                     items.addClass( "activecol" );
1158                  }          
1159               },               
1160               prev: {
1161                  button: function() {return jQuery(this).parent().parent().parent().children(".top_chart_controls").find(".prev");} 
1162               },
1163               next: {
1164                  button: function() {return jQuery(this).parent().parent().parent().children(".top_chart_controls").find(".next");}
1165               },
1166               pagination  : function() {return jQuery(this).parent().parent().parent().children(".top_chart_controls").find(".top_chart_pagination");},
1167               height: 'variable',
1168               width: "100%", 
1169               onCreate: function () {
1170                  var items = carousel.triggerHandler("currentVisible");
1171                  items.addClass( "activecol" );
1172               }                              
1173            });
1174         });         
1175
1176      }
1177   }   
1178   table_charts();
1179   makesiteCarousel(); 
1180   jQuery(".sticky-cell").parent().each(function() {
1181      var stickyheight = (jQuery('.re-stickyheader').length > 0) ? jQuery('.re-stickyheader').height() : 0; 
1182      var length = jQuery(this).closest('.table_view_charts').height() - jQuery(this).height() - stickyheight + jQuery(this).closest('.table_view_charts').offset().top;
1183      var cell = jQuery(this);
1184      var width = cell.width();
1185      var height = cell.height() + 'px';
1186      var outerheight = cell.outerHeight() + 'px';
1187      cell.wrap(function() {
1188         return '<div class="sticky-wrapper" style="height:'+ outerheight +'"></div>';
1189      });
1190
1191      jQuery(window).scroll(function () {
1192         var scroll = jQuery(this).scrollTop();
1193        
1194         if (scroll < jQuery('.table_view_charts').offset().top) {
1195            cell.closest('.sticky-wrapper').removeClass('is-sticky');
1196            cell.css({
1197               'position': '',
1198               'top': '',
1199               'width': '',
1200            });             
1201
1202         } else if (scroll > length) { 
1203            cell.closest('.sticky-wrapper').removeClass('is-sticky');
1204            cell.css({
1205               'position': '',
1206               'top': '',
1207               'width': '',
1208            });                     
1209         } else {
1210            cell.closest('.sticky-wrapper').addClass('is-sticky');
1211            cell.css({
1212               'position': 'fixed',
1213               'top': stickyheight + 'px',
1214               'width': width
1215            });
1216         }
1217      });
1218   });  
1219   jQuery(".table_view_charts").each(function() {
1220      jQuery(this).removeClass('loading');
1221   });  
1222
1223   /* OWL CAROUSEL */
1224   jQuery(".re_carousel").each(function(){
1225      jQuery(this).on('initialized.owl.carousel', function(e) {jQuery(this).parent().removeClass('loading')});
1226      var carouselplay = (jQuery(this).data('auto')==1) ? true : false;
1227      var showrow = (jQuery(this).data('showrow') !='') ? jQuery(this).data('showrow') : 4;
1228      var laizy = (jQuery(this).data('laizy') == 1) ? true : false;
1229      var navdisable = (jQuery(this).data('navdisable') == 1) ? false : true;
1230
1231      jQuery(this).owlCarousel({
1232         loop:true,
1233         dots:false,
1234         nav: navdisable,
1235         lazyLoad: laizy,
1236         autoplay: carouselplay,
1237         responsiveClass:true,
1238         navText :["", ""],
1239         navClass: ["controls prev","controls next"],
1240         responsive:{
1241            0:{
1242               items:1,
1243               nav:true,
1244            },
1245            378:{
1246               items:2,
1247            },
1248            600:{
1249               items:3,
1250            },            
1251            1024:{
1252               items:showrow,
1253            }
1254         }
1255      });    
1256   });     
1257
1258   var canSlide = true;
1259
1260    // Setup a callback for the YouTube api to attach video event handlers
1261   window.onYouTubeIframeAPIReady = function(){
1262      // Iterate through all videos
1263      jQuery('.gallery_top_slider iframe').each(function(){
1264         var slider = jQuery('.gallery_top_slider');
1265         // Create a new player pointer;
1265 "this" is a DOMElement of the player's iframe
1266         var player = new YT.Player(this, {
1267            playerVars: {
1268               autoplay: 0
1269            }
1270         });
1271 
1272         // Watch for changes on the player
1273         player.addEventListener("onStateChange", function(state){
1274            switch(state.data)
1275            {
1276               // If the user is playing a video, stop the slider
1277               case YT.PlayerState.PLAYING:
1278                  slider.flexslider("stop");
1279                  canSlide = false;
1280                  break;
1281               // The video is no longer player, give the go-ahead to start the slider back up
1282               case YT.PlayerState.ENDED:
1283               case YT.PlayerState.PAUSED:
1284                  slider.flexslider("play");
1285                  canSlide = true;
1286                  break;
1287            }
1288         });
1289 
1290         jQuery(this).data('player', player);
1291      });
1292   }          
1293
1294   //SLIDER
1295   var flexslidersiteInit = function() {
1296   if(jQuery().flexslider) {
1297
1298      jQuery('.featured_slider').each(function() {
1299         var slider = jQuery(this);
1300         slider.flexslider({
1301            animation: "slide",
1302            selector: ".slides > .slide",
1303            slideshow: false,   
1304         });
1305      });
1306
1307      jQuery('.blog_slider').each(function() {
1308         var slider = jQuery(this); 
1309         slider.flexslider({
1310            animation: "slide",
1311            smoothHeight: true,
1312            slideshow: false,
1313            start: function(slider) {
1314               slider.removeClass('loading');
1315               var first_height = jQuery('.blog_slider .slides li:last-child img').height();
1316               jQuery('.flex-viewport').height(first_height);
1317            }      
1318         });
1319      }); 
1320      
1321      jQuery('.gallery_top_slider').each(function() {
1322         var tag = document.createElement('script');
1323         tag.src = "//www.youtube.com/iframe_api";
1324         var firstScriptTag = document.getElementsByTagName('script')[0];
1325         firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);         
1326         var slider = jQuery(this); 
1327         slider.flexslider({
1328            animation: "fade",
1329            controlNav: "thumbnails",
1330            slideshow: false,
1331            video: true,
1332            //useCSS: false, 
1333            before: function(){                 
1334               if(!canSlide)
1335                  slider.flexslider("stop");
1336            },            
1337            start: function(slider) {
1338               slider.find('img.lazyimages').trigger("unveil");               
1339               slider.removeClass('loading');
1340               jQuery('.flex-control-thumbs img').each(function() {
1341                  var widththumb = jQuery(this).width();
1342                  jQuery(this).height(widththumb);
1343               });                
1344            }
1345         });
1346         slider.on("click", ".flex-prev, .flex-next, .flex-control-nav", function(){
1347            canSlide = true;
1348            jQuery('.gallery_top_slider iframe').each(function(){
1349               jQuery(this).data('player').pauseVideo();
1350            });
1351            if (jQuery('.gallery_top_slider .flex-active-slide iframe').length > 0) {
1352               jQuery('.gallery_top_slider .flex-active-slide iframe').data('player').playVideo();
1353            }
1354         });  
1355         jQuery(".play3").fitVids();          
1356      }); 
1357
1358      jQuery('.main_slider').each(function() {
1359         var slider = jQuery(this);
1360         slider.flexslider({
1361            animation: "slide", 
1362            start: function(slider) {
1363               slider.removeClass('loading');
1364            }                
1365         });
1366      });
1367
1368      jQuery('.rtl .main_slider').each(function() {
1369         var slider = jQuery(this);
1370         slider.flexslider({
1371            animation: "slide",
1372            rtl: true, 
1373            start: function(slider) {
1374               slider.removeClass('loading');
1375            }                
1376         });
1377      });      
1378
1379      jQuery('.re_thing_slider').each(function() {
1380         var slider = jQuery(this);
1381         slider.flexslider({
1382            animation: "slide", 
1383            start: function(slider) {
1384               slider.removeClass('loading');
1385            }                
1386         });
1387      });      
1388
1389      jQuery('.flexslider').each(function() {
1390         var slider = jQuery(this);
1391         slider.flexslider({
1392            animation: "slide",
1393            start: function(slider) {
1394               jQuery( slider ).removeClass( 'loading' );
1395            }                 
1396         });
1397      });                        
1398
1399   }}
1400
1401   flexslidersiteInit();   
1402}); 
1403
1404jQuery(window).resize(function(){
1405   re_sizebg();
1406   if (jQuery('.content').length > 0 && jQuery('#re-compare-panel').length > 0) {
1407      var contwidthout = jQuery('.content').outerWidth();
1408      jQuery('#re-compare-panel').css({'width': contwidthout,'margin-left': - (contwidthout/2), 'left' : '50%'});
1409   }    
1410});
1411
1412//Woocommerce slider
1413jQuery( document ).ready( function() {
1414   if(jQuery().flexslider && jQuery('.woocommerce .images #re_woocarousel').length >= 1) {
1415      var WooThumbWidth = 100;
1416      if(jQuery('body.woocommerce .sidebar').is(':visible')) {
1417         wooThumbWidth = 100;
1418      } else {
1419         wooThumbWidth = 118;
1420      }
1421
1422      if(typeof jQuery('.woocommerce .images #re_woocarousel').data('flexslider') !== 'undefined') {
1423         jQuery('.woocommerce .images #re_woocarousel').flexslider('destroy');
1424         jQuery('.woocommerce .images #re_wooslider').flexslider('destroy');
1425      }
1426
1427      jQuery('.woocommerce .images #re_woocarousel').flexslider({
1428         animation: 'slide',
1429         controlNav: false,
1430         directionNav: false,
1431         animationLoop: false,
1432         slideshow: false,
1433         itemWidth: wooThumbWidth,
1434         itemMargin: 10,
1435         touch: false,
1436         useCSS: false,
1437         asNavFor: '.woocommerce .images #re_wooslider',
1438         smoothHeight: false,
1439      });
1440
1441      jQuery('.woocommerce .images #re_wooslider').flexslider({
1442         animation: 'slide',
1443         controlNav: false,
1444         animationLoop: false,
1445         slideshow: false,
1446         smoothHeight: true,
1447         touch: true,
1448         useCSS: false,
1449         sync: '.woocommerce .images #re_woocarousel',
1450         start: function(slider) {
1451            jQuery( slider ).removeClass( 'loading' );
1452         }
1453      });
1454   }
1455});

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.