Guest User

Untitled

a guest
Mar 6th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.85 KB | None | 0 0
  1. /* ----------------- Start Document ----------------- */
  2. (function($){
  3. "use strict";
  4.  
  5. $(document).ready(function(){
  6.  
  7. /*--------------------------------------------------*/
  8. /* Mobile Navigation
  9. /*--------------------------------------------------*/
  10. var jPanelMenu = $.jPanelMenu({
  11. menu: '#responsive',
  12. animated: false,
  13. duration: 200,
  14. keyboardShortcuts: false,
  15. closeOnContentClick: true
  16. });
  17.  
  18.  
  19. // Desktop devices
  20. $('.menu-trigger').on('click', function(){
  21.  
  22. var jpm = $(this);
  23.  
  24. if( jpm.hasClass('active') )
  25. {
  26. jPanelMenu.off();
  27. jpm.removeClass('active');
  28. }
  29. else
  30. {
  31. jPanelMenu.on();
  32. jPanelMenu.open();
  33. jpm.addClass('active');
  34.  
  35. // Removes SuperFish Styles
  36. $('#jPanelMenu-menu').removeClass('menu');
  37. $('ul#jPanelMenu-menu li').removeClass('dropdown');
  38. $('ul#jPanelMenu-menu li ul').removeAttr('style');
  39. $('ul#jPanelMenu-menu li div').removeClass('mega').removeAttr('style');
  40. $('ul#jPanelMenu-menu li div div').removeClass('mega-container');
  41. }
  42. return false;
  43. });
  44.  
  45. $(window).resize(function (){
  46. var winWidth = $(window).width();
  47. if(winWidth>992) {
  48. jPanelMenu.close();
  49. }
  50. });
  51.  
  52.  
  53. /*----------------------------------------------------*/
  54. /* Sticky Header
  55. /*----------------------------------------------------*/
  56. $( "#header" ).not( "#header-container.header-style-2 #header" ).clone(true).addClass('cloned unsticky').insertAfter( "#header" );
  57. $( "#navigation.style-2" ).clone(true).addClass('cloned unsticky').insertAfter( "#navigation.style-2" );
  58.  
  59. // Logo for header style 2
  60. $( "#logo .sticky-logo" ).clone(true).prependTo("#navigation.style-2.cloned ul#responsive");
  61.  
  62.  
  63. // sticky header script
  64. var headerOffset = $("#header-container").height() * 2; // height on which the sticky header will shows
  65.  
  66. $(window).scroll(function(){
  67. if($(window).scrollTop() >= headerOffset){
  68. $("#header.cloned").addClass('sticky').removeClass("unsticky");
  69. $("#navigation.style-2.cloned").addClass('sticky').removeClass("unsticky");
  70. } else {
  71. $("#header.cloned").addClass('unsticky').removeClass("sticky");
  72. $("#navigation.style-2.cloned").addClass('unsticky').removeClass("sticky");
  73. }
  74. });
  75.  
  76.  
  77. /*----------------------------------------------------*/
  78. /* Top Bar Dropdown Menu
  79. /*----------------------------------------------------*/
  80.  
  81. $('.top-bar-dropdown').on('click', function(event){
  82. $('.top-bar-dropdown').not(this).removeClass('active');
  83. if ($(event.target).parent().parent().attr('class') == 'options' ) {
  84. hideDD();
  85. } else {
  86. if($(this).hasClass('active') && $(event.target).is( "span" )) {
  87. hideDD();
  88. } else {
  89. $(this).toggleClass('active');
  90. }
  91. }
  92. event.stopPropagation();
  93. });
  94.  
  95. $(document).on('click', function(e){ hideDD(); });
  96.  
  97. function hideDD(){
  98. $('.top-bar-dropdown').removeClass('active');
  99. }
  100.  
  101.  
  102. /*----------------------------------------------------*/
  103. /* Advanced Search Button
  104. /*----------------------------------------------------*/
  105. $('.adv-search-btn').on('click', function(e){
  106.  
  107. if ( $(this).is(".active") ) {
  108.  
  109. $(this).removeClass("active");
  110. $(".main-search-container").removeClass("active");
  111. setTimeout( function() {
  112. $("#map-container.homepage-map").removeClass("overflow")
  113. }, 0);
  114.  
  115. } else {
  116.  
  117. $(this).addClass("active");
  118. $(".main-search-container").addClass("active");
  119. setTimeout( function() {
  120. $("#map-container.homepage-map").addClass("overflow")
  121. }, 400);
  122.  
  123. }
  124.  
  125. e.preventDefault();
  126. });
  127.  
  128.  
  129.  
  130. /*----------------------------------------------------*/
  131. /* Inline CSS replacement for backgrounds etc.
  132. /*----------------------------------------------------*/
  133. function inlineCSS() {
  134.  
  135. // Common Inline CSS
  136. $(".some-classes, section.fullwidth, .img-box-background, .flip-banner, .property-slider .item, .fullwidth-property-slider .item, .fullwidth-home-slider .item, .address-container").each(function() {
  137. var attrImageBG = $(this).attr('data-background-image');
  138. var attrColorBG = $(this).attr('data-background-color');
  139.  
  140. if(attrImageBG !== undefined) {
  141. $(this).css('background-image', 'url('+attrImageBG+')');
  142. }
  143.  
  144. if(attrColorBG !== undefined) {
  145. $(this).css('background', ''+attrColorBG+'');
  146. }
  147. });
  148.  
  149. }
  150.  
  151. // Init
  152. inlineCSS();
  153.  
  154. function parallaxBG() {
  155.  
  156. $('.parallax').prepend('<div class="parallax-overlay"></div>');
  157.  
  158. $( ".parallax").each(function() {
  159. var attrImage = $(this).attr('data-background');
  160. var attrColor = $(this).attr('data-color');
  161. var attrOpacity = $(this).attr('data-color-opacity');
  162.  
  163. if(attrImage !== undefined) {
  164. $(this).css('background-image', 'url('+attrImage+')');
  165. }
  166.  
  167. if(attrColor !== undefined) {
  168. $(this).find(".parallax-overlay").css('background-color', ''+attrColor+'');
  169. }
  170.  
  171. if(attrOpacity !== undefined) {
  172. $(this).find(".parallax-overlay").css('opacity', ''+attrOpacity+'');
  173. }
  174.  
  175. });
  176. }
  177.  
  178. parallaxBG();
  179.  
  180.  
  181. // Slide to anchor
  182. $('#titlebar .listing-address').on('click', function(e){
  183. e.preventDefault();
  184.  
  185. $('html, body').animate({
  186. scrollTop: $( $.attr(this, 'href') ).offset().top-40
  187. }, 600);
  188. });
  189.  
  190.  
  191. /*----------------------------------------------------*/
  192. /* Tooltips
  193. /*----------------------------------------------------*/
  194.  
  195. $(".tooltip.top").tipTip({
  196. defaultPosition: "top"
  197. });
  198.  
  199. $(".tooltip.bottom").tipTip({
  200. defaultPosition: "bottom"
  201. });
  202.  
  203. $(".tooltip.left").tipTip({
  204. defaultPosition: "left"
  205. });
  206.  
  207. $(".tooltip.right").tipTip({
  208. defaultPosition: "right"
  209. });
  210.  
  211.  
  212.  
  213. /*----------------------------------------------------*/
  214. /* Parallax
  215. /*----------------------------------------------------*/
  216.  
  217. /* detect touch */
  218. if("ontouchstart" in window){
  219. document.documentElement.className = document.documentElement.className + " touch";
  220. }
  221. if(!$("html").hasClass("touch")){
  222. /* background fix */
  223. $(".parallax").css("background-attachment", "fixed");
  224. }
  225.  
  226. /* fix vertical when not overflow
  227. call fullscreenFix() if .fullscreen content changes */
  228. function fullscreenFix(){
  229. var h = $('body').height();
  230. // set .fullscreen height
  231. $(".content-b").each(function(i){
  232. if($(this).innerHeight() > h){ $(this).closest(".fullscreen").addClass("overflow");
  233. }
  234. });
  235. }
  236. $(window).resize(fullscreenFix);
  237. fullscreenFix();
  238.  
  239. /* resize background images */
  240. function backgroundResize(){
  241. var windowH = $(window).height();
  242. $(".parallax").each(function(i){
  243. var path = $(this);
  244. // variables
  245. var contW = path.width();
  246. var contH = path.height();
  247. var imgW = path.attr("data-img-width");
  248. var imgH = path.attr("data-img-height");
  249. var ratio = imgW / imgH;
  250. // overflowing difference
  251. var diff = 100;
  252. diff = diff ? diff : 0;
  253. // remaining height to have fullscreen image only on parallax
  254. var remainingH = 0;
  255. if(path.hasClass("parallax") && !$("html").hasClass("touch")){
  256. //var maxH = contH > windowH ? contH : windowH;
  257. remainingH = windowH - contH;
  258. }
  259. // set img values depending on cont
  260. imgH = contH + remainingH + diff;
  261. imgW = imgH * ratio;
  262. // fix when too large
  263. if(contW > imgW){
  264. imgW = contW;
  265. imgH = imgW / ratio;
  266. }
  267. //
  268. path.data("resized-imgW", imgW);
  269. path.data("resized-imgH", imgH);
  270. path.css("background-size", imgW + "px " + imgH + "px");
  271. });
  272. }
  273.  
  274.  
  275. $(window).resize(backgroundResize);
  276. $(window).focus(backgroundResize);
  277. backgroundResize();
  278.  
  279. /* set parallax background-position */
  280. function parallaxPosition(e){
  281. var heightWindow = $(window).height();
  282. var topWindow = $(window).scrollTop();
  283. var bottomWindow = topWindow + heightWindow;
  284. var currentWindow = (topWindow + bottomWindow) / 2;
  285. $(".parallax").each(function(i){
  286. var path = $(this);
  287. var height = path.height();
  288. var top = path.offset().top;
  289. var bottom = top + height;
  290. // only when in range
  291. if(bottomWindow > top && topWindow < bottom){
  292. //var imgW = path.data("resized-imgW");
  293. var imgH = path.data("resized-imgH");
  294. // min when image touch top of window
  295. var min = 0;
  296. // max when image touch bottom of window
  297. var max = - imgH + heightWindow;
  298. // overflow changes parallax
  299. var overflowH = height < heightWindow ? imgH - height : imgH - heightWindow; // fix height on overflow
  300. top = top - overflowH;
  301. bottom = bottom + overflowH;
  302.  
  303.  
  304. // value with linear interpolation
  305. // var value = min + (max - min) * (currentWindow - top) / (bottom - top);
  306. var value = 0;
  307. if ( $('.parallax').is(".titlebar") ) {
  308. value = min + (max - min) * (currentWindow - top) / (bottom - top) *2;
  309. } else {
  310. value = min + (max - min) * (currentWindow - top) / (bottom - top);
  311. }
  312.  
  313. // set background-position
  314. var orizontalPosition = path.attr("data-oriz-pos");
  315. orizontalPosition = orizontalPosition ? orizontalPosition : "50%";
  316. $(this).css("background-position", orizontalPosition + " " + value + "px");
  317. }
  318. });
  319. }
  320. if(!$("html").hasClass("touch")){
  321. $(window).resize(parallaxPosition);
  322. //$(window).focus(parallaxPosition);
  323. $(window).scroll(parallaxPosition);
  324. parallaxPosition();
  325. }
  326.  
  327. // Jumping background fix for IE
  328. if(navigator.userAgent.match(/Trident\/7\./)) { // if IE
  329. $('body').on("mousewheel", function () {
  330. event.preventDefault();
  331.  
  332. var wheelDelta = event.wheelDelta;
  333. var currentScrollPosition = window.pageYOffset;
  334. window.scrollTo(0, currentScrollPosition - wheelDelta);
  335. });
  336. }
  337.  
  338.  
  339. /*----------------------------------------------------*/
  340. /* Search Type Buttons
  341. /*----------------------------------------------------*/
  342. function searchTypeButtons() {
  343.  
  344. // Radio attr reset
  345. $('.search-type label.active input[type="radio"]').prop('checked',true);
  346.  
  347. // Positioning indicator arrow
  348. var buttonWidth = $('.search-type label.active').width();
  349. var arrowDist = $('.search-type label.active').position().left;
  350. $('.search-type-arrow').css('left', arrowDist + (buttonWidth/2) );
  351.  
  352. $('.search-type label').on('change', function() {
  353. $('.search-type input[type="radio"]').parent('label').removeClass('active');
  354. $('.search-type input[type="radio"]:checked').parent('label').addClass('active');
  355.  
  356. // Positioning indicator arrow
  357. var buttonWidth = $('.search-type label.active').width();
  358. var arrowDist = $('.search-type label.active').position().left;
  359.  
  360. $('.search-type-arrow').css({
  361. 'left': arrowDist + (buttonWidth/2),
  362. 'transition':'left 0.4s cubic-bezier(.87,-.41,.19,1.44)'
  363. });
  364. });
  365.  
  366. }
  367.  
  368. // Init
  369. if ($(".main-search-form").length){ searchTypeButtons(); }
  370.  
  371.  
  372. /*----------------------------------------------------*/
  373. /* Chosen Plugin
  374. /*----------------------------------------------------*/
  375.  
  376. var config = {
  377. '.chosen-select' : {disable_search_threshold: 10, width:"100%"},
  378. '.chosen-select-deselect' : {allow_single_deselect:true, width:"100%"},
  379. '.chosen-select-no-single' : {disable_search_threshold:100, width:"100%"},
  380. '.chosen-select-no-single.no-search' : {disable_search_threshold:10, width:"100%"},
  381. '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
  382. '.chosen-select-width' : {width:"95%"}
  383. };
  384.  
  385. for (var selector in config) {
  386. if (config.hasOwnProperty(selector)) {
  387. $(selector).chosen(config[selector]);
  388. }
  389. }
  390.  
  391.  
  392. /* Custom Input With Select
  393. /*----------------------------------------------------*/
  394. $('.select-input').each(function(){
  395.  
  396. var thisContainer = $(this);
  397. var $this = $(this).children('select'), numberOfOptions = $this.children('option').length;
  398.  
  399. $this.addClass('select-hidden');
  400. $this.wrap('<div class="select"></div>');
  401. $this.after('<div class="select-styled"></div>');
  402. var $styledSelect = $this.next('div.select-styled');
  403. $styledSelect.text($this.children('option').eq(0).text());
  404.  
  405. var $list = $('<ul />', {
  406. 'class': 'select-options'
  407. }).insertAfter($styledSelect);
  408.  
  409. for (var i = 0; i < numberOfOptions; i++) {
  410. $('<li />', {
  411. text: $this.children('option').eq(i).text(),
  412. rel: $this.children('option').eq(i).val()
  413. }).appendTo($list);
  414. }
  415.  
  416. var $listItems = $list.children('li');
  417.  
  418. $list.wrapInner('<div class="select-list-container"></div>');
  419.  
  420.  
  421. $(this).children('input').on('click', function(e){
  422. $('.select-options').hide();
  423. e.stopPropagation();
  424. $styledSelect.toggleClass('active').next('ul.select-options').toggle();
  425. });
  426.  
  427. $(this).children('input').keypress(function() {
  428. $styledSelect.removeClass('active');
  429. $list.hide();
  430. });
  431.  
  432.  
  433. $listItems.on('click', function(e){
  434. e.stopPropagation();
  435. // $styledSelect.text($(this).text()).removeClass('active');
  436. $(thisContainer).children('input').val( $(this).text() ).removeClass('active');
  437. $this.val($(this).attr('rel'));
  438. $list.hide();
  439. //console.log($this.val());
  440. });
  441.  
  442. $(document).on('click', function(e){
  443. $styledSelect.removeClass('active');
  444. $list.hide();
  445. });
  446.  
  447.  
  448. // Unit character
  449. var fieldUnit = $(this).children('input').attr('data-unit');
  450. $(this).children('input').before('<i class="data-unit">'+ fieldUnit + '</i>');
  451.  
  452.  
  453. });
  454.  
  455.  
  456.  
  457. /*----------------------------------------------------*/
  458. /* Searh Form More Options
  459. /*----------------------------------------------------*/
  460. $('.more-search-options-trigger').on('click', function(e){
  461. e.preventDefault();
  462. $('.more-search-options, .more-search-options-trigger').toggleClass('active');
  463. $('.more-search-options.relative').animate({height: 'toggle', opacity: 'toggle'}, 300);
  464. });
  465.  
  466.  
  467. /*----------------------------------------------------*/
  468. /* Like Icon Trigger
  469. /*----------------------------------------------------*/
  470. $('.like-icon, .widget-button').on('click', function(e){
  471. e.preventDefault();
  472. $(this).toggleClass('liked');
  473. $(this).children('.like-icon').toggleClass('liked');
  474. });
  475.  
  476.  
  477. /*----------------------------------------------------*/
  478. /* Show More Button
  479. /*----------------------------------------------------*/
  480. $('.show-more-button').on('click', function(e){
  481. e.preventDefault();
  482. $('.show-more').toggleClass('visible');
  483. });
  484.  
  485.  
  486. /*----------------------------------------------------*/
  487. /* Back to Top
  488. /*----------------------------------------------------*/
  489. var pxShow = 600; // height on which the button will show
  490. var fadeInTime = 300; // how slow / fast you want the button to show
  491. var fadeOutTime = 300; // how slow / fast you want the button to hide
  492. var scrollSpeed = 500; // how slow / fast you want the button to scroll to top.
  493.  
  494. $(window).scroll(function(){
  495. if($(window).scrollTop() >= pxShow){
  496. $("#backtotop").fadeIn(fadeInTime);
  497. } else {
  498. $("#backtotop").fadeOut(fadeOutTime);
  499. }
  500. });
  501.  
  502. $('#backtotop a').on('click', function(){
  503. $('html, body').animate({scrollTop:0}, scrollSpeed);
  504. return false;
  505. });
  506.  
  507.  
  508. /*----------------------------------------------------*/
  509. /* Owl Carousel
  510. /*----------------------------------------------------*/
  511.  
  512. $('.carousel').owlCarousel({
  513. autoPlay: false,
  514. navigation: true,
  515. slideSpeed: 600,
  516. items : 3,
  517. itemsDesktop : [1239,3],
  518. itemsTablet : [991,2],
  519. itemsMobile : [767,1]
  520. });
  521.  
  522.  
  523. $('.logo-carousel').owlCarousel({
  524. autoPlay: false,
  525. navigation: true,
  526. slideSpeed: 600,
  527. items : 5,
  528. itemsDesktop : [1239,4],
  529. itemsTablet : [991,3],
  530. itemsMobile : [767,1]
  531. });
  532.  
  533.  
  534. $('.listing-carousel').owlCarousel({
  535. autoPlay: false,
  536. navigation: true,
  537. slideSpeed: 800,
  538. items : 1,
  539. itemsDesktop : [1239,1],
  540. itemsTablet : [991,1],
  541. itemsMobile : [767,1]
  542. });
  543.  
  544. $('.owl-next, .owl-prev').on("click", function (e) {
  545. e.preventDefault();
  546. });
  547.  
  548.  
  549.  
  550. /*----------------------------------------------------*/
  551. /* Slick Carousel
  552. /*----------------------------------------------------*/
  553. $('.property-slider').slick({
  554. slidesToShow: 1,
  555. slidesToScroll: 1,
  556. arrows: true,
  557. fade: true,
  558. asNavFor: '.property-slider-nav',
  559. centerMode: true,
  560. slide: ".item"
  561. });
  562.  
  563. $('.property-slider-nav').slick({
  564. slidesToShow: 6,
  565. slidesToScroll: 1,
  566. asNavFor: '.property-slider',
  567. dots: false,
  568. arrows: false,
  569. centerMode: false,
  570. focusOnSelect: true,
  571. responsive: [
  572. {
  573. breakpoint: 993,
  574. settings: {
  575. slidesToShow: 4,
  576. }
  577. },
  578. {
  579. breakpoint: 767,
  580. settings: {
  581. slidesToShow: 3,
  582. }
  583. }
  584. ]
  585. });
  586.  
  587.  
  588. $('.fullwidth-property-slider').slick({
  589. centerMode: true,
  590. centerPadding: '20%',
  591. slidesToShow: 1,
  592. responsive: [
  593. {
  594. breakpoint: 1367,
  595. settings: {
  596. centerPadding: '15%'
  597. }
  598. },
  599. {
  600. breakpoint: 993,
  601. settings: {
  602. centerPadding: '0'
  603. }
  604. }
  605. ]
  606. });
  607.  
  608.  
  609. $('.fullwidth-home-slider').slick({
  610. centerMode: true,
  611. centerPadding: '0',
  612. slidesToShow: 1,
  613. responsive: [
  614. {
  615. breakpoint: 1367,
  616. settings: {
  617. centerPadding: '0'
  618. }
  619. },
  620. {
  621. breakpoint: 993,
  622. settings: {
  623. centerPadding: '0'
  624. }
  625. }
  626. ]
  627. });
  628.  
  629.  
  630.  
  631. /*----------------------------------------------------*/
  632. /* Magnific Popup
  633. /*----------------------------------------------------*/
  634. $('body').magnificPopup({
  635. type: 'image',
  636. delegate: 'a.mfp-gallery',
  637.  
  638. fixedContentPos: true,
  639. fixedBgPos: true,
  640.  
  641. overflowY: 'auto',
  642.  
  643. closeBtnInside: false,
  644. preloader: true,
  645.  
  646. removalDelay: 0,
  647. mainClass: 'mfp-fade',
  648.  
  649. gallery:{enabled:true}
  650. });
  651.  
  652.  
  653. $('.popup-with-zoom-anim').magnificPopup({
  654. type: 'inline',
  655.  
  656. fixedContentPos: false,
  657. fixedBgPos: true,
  658.  
  659. overflowY: 'auto',
  660.  
  661. closeBtnInside: true,
  662. preloader: false,
  663.  
  664. midClick: true,
  665. removalDelay: 300,
  666. mainClass: 'my-mfp-zoom-in'
  667. });
  668.  
  669.  
  670. $('.mfp-image').magnificPopup({
  671. type: 'image',
  672. closeOnContentClick: true,
  673. mainClass: 'mfp-fade',
  674. image: {
  675. verticalFit: true
  676. }
  677. });
  678.  
  679. $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
  680. disableOn: 700,
  681. type: 'iframe',
  682. mainClass: 'mfp-fade',
  683. removalDelay: 160,
  684. preloader: false,
  685.  
  686. fixedContentPos: false
  687. });
  688.  
  689.  
  690. /*----------------------------------------------------*/
  691. /* Sticky Footer (footer-reveal.js)
  692. /*----------------------------------------------------*/
  693.  
  694.  
  695. // disable if IE
  696. if(navigator.userAgent.match(/Trident\/7\./)) { // if IE
  697. $('#footer').removeClass("sticky-footer");
  698. }
  699.  
  700. $('#footer.sticky-footer').footerReveal();
  701.  
  702.  
  703. /*----------------------------------------------------*/
  704. /* Image Box
  705. /*----------------------------------------------------*/
  706. $('.img-box').each(function(){
  707.  
  708. // add a photo container
  709. $(this).append('<div class="img-box-background"></div>');
  710.  
  711. // set up a background image for each tile based on data-background-image attribute
  712. $(this).children('.img-box-background').css({'background-image': 'url('+ $(this).attr('data-background-image') +')'});
  713.  
  714. // background animation on mousemove
  715. // $(this).on('mousemove', function(e){
  716. // $(this).children('.img-box-background').css({'transform-origin': ((e.pageX - $(this).offset().left) / $(this).width()) * 100 + '% ' + ((e.pageY - $(this).offset().top) / $(this).height()) * 100 +'%'});
  717. // })
  718. });
  719.  
  720.  
  721. /*----------------------------------------------------*/
  722. /* Listing Layout Switcher
  723. /*----------------------------------------------------*/
  724. function gridLayoutSwitcher() {
  725.  
  726. var listingsContainer = $('.listings-container');
  727.  
  728. // switcher buttons / anchors
  729. if ( $(listingsContainer).is(".list-layout") ) {
  730. owlReload();
  731. $('.layout-switcher a.grid, .layout-switcher a.grid-three').removeClass("active");
  732. $('.layout-switcher a.list').addClass("active");
  733. }
  734.  
  735. if ( $(listingsContainer).is(".grid-layout") ) {
  736. owlReload();
  737. $('.layout-switcher a.grid').addClass("active");
  738. $('.layout-switcher a.grid-three, .layout-switcher a.list').removeClass("active");
  739. gridClear(2);
  740. }
  741.  
  742. if ( $(listingsContainer).is(".grid-layout-three") ) {
  743. owlReload();
  744. $('.layout-switcher a.grid, .layout-switcher a.list').removeClass("active");
  745. $('.layout-switcher a.grid-three').addClass("active");
  746. gridClear(3);
  747. }
  748.  
  749.  
  750. // grid cleaning
  751. function gridClear(gridColumns) {
  752. $(listingsContainer).find(".clearfix").remove();
  753. $(".listings-container > .listing-item:nth-child("+gridColumns+"n)").after("<div class='clearfix'></div>");
  754. }
  755.  
  756.  
  757. // objects that need to resized
  758. var resizeObjects = $('.listings-container .listing-img-container img, .listings-container .listing-img-container');
  759.  
  760. // if list layout is active
  761. function listLayout() {
  762. if ( $('.layout-switcher a').is(".list.active") ) {
  763.  
  764. $(listingsContainer).each(function(){
  765. $(this).removeClass("grid-layout grid-layout-three");
  766. $(this).addClass("list-layout");
  767. });
  768.  
  769. $('.listing-item').each(function(){
  770. var listingContent = $(this).find('.listing-content').height();
  771. $(this).find(resizeObjects).css('height', ''+listingContent+'');
  772. });
  773. }
  774. } listLayout();
  775.  
  776.  
  777. // if grid layout is active
  778. $('.layout-switcher a.grid').on('click', function(e) { gridClear(2); });
  779.  
  780. function gridLayout() {
  781. if ( $('.layout-switcher a').is(".grid.active") ) {
  782.  
  783. $(listingsContainer).each(function(){
  784. $(this).removeClass("list-layout grid-layout-three");
  785. $(this).addClass("grid-layout");
  786. });
  787.  
  788. $('.listing-item').each(function(){
  789. $(this).find(resizeObjects).css('height', 'auto');
  790. });
  791.  
  792. }
  793. } gridLayout();
  794.  
  795.  
  796. // if grid layout is active
  797. $('.layout-switcher a.grid-three').on('click', function(e) { gridClear(3); });
  798.  
  799. function gridThreeLayout() {
  800. if ( $('.layout-switcher a').is(".grid-three.active") ) {
  801.  
  802. $(listingsContainer).each(function(){
  803. $(this).removeClass("list-layout grid-layout");
  804. $(this).addClass("grid-layout-three");
  805. });
  806.  
  807. $('.listing-item').each(function(){
  808. $(this).find(resizeObjects).css('height', 'auto');
  809. });
  810.  
  811. }
  812. } gridThreeLayout();
  813.  
  814.  
  815. // Mobile fixes
  816. $(window).on('resize', function() {
  817. $(resizeObjects).css('height', '0');
  818. listLayout();
  819. gridLayout();
  820. gridThreeLayout();
  821. });
  822.  
  823. $(window).on('load resize', function() {
  824. var winWidth = $(window).width();
  825.  
  826. if(winWidth < 992) {
  827. owlReload();
  828.  
  829. // reset to two columns grid
  830. gridClear(2);
  831. }
  832.  
  833. if(winWidth > 992) {
  834. if ( $(listingsContainer).is(".grid-layout-three") ) {
  835. gridClear(3);
  836. }
  837. if ( $(listingsContainer).is(".grid-layout") ) {
  838. gridClear(2);
  839. }
  840. }
  841.  
  842. if(winWidth < 768) {
  843. if ( $(listingsContainer).is(".list-layout") ) {
  844. $('.listing-item').each(function(){
  845. $(this).find(resizeObjects).css('height', 'auto');
  846. });
  847. }
  848. }
  849.  
  850. if(winWidth < 1366) {
  851. if ( $(".fs-listings").is(".list-layout") ) {
  852. $('.listing-item').each(function(){
  853. $(this).find(resizeObjects).css('height', 'auto');
  854. });
  855. }
  856. }
  857. });
  858.  
  859.  
  860. // owlCarousel reload
  861. function owlReload() {
  862. $('.listing-carousel').each(function(){
  863. $(this).data('owlCarousel').reload();
  864. });
  865. }
  866.  
  867.  
  868. // switcher buttons
  869. $('.layout-switcher a').on('click', function(e) {
  870. e.preventDefault();
  871.  
  872. var switcherButton = $(this);
  873. switcherButton.addClass("active").siblings().removeClass('active');
  874.  
  875. // reset images height
  876. $(resizeObjects).css('height', '0');
  877.  
  878. // carousel reload
  879. owlReload();
  880.  
  881. // if grid layout is active
  882. gridLayout();
  883.  
  884. // if three columns grid layout is active
  885. gridThreeLayout();
  886.  
  887. // if list layout is active
  888. listLayout();
  889.  
  890. });
  891.  
  892. } gridLayoutSwitcher();
  893.  
  894.  
  895.  
  896. /*----------------------------------------------------*/
  897. /* Range Sliders
  898. /*----------------------------------------------------*/
  899.  
  900. // Area Range
  901. $("#area-range").each(function() {
  902.  
  903. var dataMin = $(this).attr('data-min');
  904. var dataMax = $(this).attr('data-max');
  905. var dataUnit = $(this).attr('data-unit');
  906.  
  907. $(this).append( "<input type='text' class='first-slider-value'disabled/><input type='text' class='second-slider-value' disabled/>" );
  908.  
  909. $(this).slider({
  910.  
  911. range: true,
  912. min: dataMin,
  913. max: dataMax,
  914. step: 10,
  915. values: [ dataMin, dataMax ],
  916.  
  917. slide: function( event, ui ) {
  918. event = event;
  919. $(this).children( ".first-slider-value" ).val( ui.values[ 0 ] + " " + dataUnit );
  920. $(this).children( ".second-slider-value" ).val( ui.values[ 1 ] + " " + dataUnit );
  921. }
  922. });
  923. $(this).children( ".first-slider-value" ).val( $( this ).slider( "values", 0 ) + " " + dataUnit );
  924. $(this).children( ".second-slider-value" ).val( $( this ).slider( "values", 1 ) + " " + dataUnit );
  925.  
  926. });
  927.  
  928.  
  929. // Price Range
  930. $("#price-range").each(function() {
  931.  
  932. var dataMin = $(this).attr('data-min');
  933. var dataMax = $(this).attr('data-max');
  934. var dataUnit = $(this).attr('data-unit');
  935.  
  936. $(this).append( "<input type='text' class='first-slider-value' disabled/><input type='text' class='second-slider-value' disabled/>" );
  937.  
  938.  
  939. $(this).slider({
  940.  
  941. range: true,
  942. min: dataMin,
  943. max: dataMax,
  944. values: [ dataMin, dataMax ],
  945.  
  946. slide: function( event, ui ) {
  947. event = event;
  948. $(this).children( ".first-slider-value" ).val( dataUnit + ui.values[ 0 ].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
  949. $(this).children( ".second-slider-value" ).val( dataUnit + ui.values[ 1 ].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
  950. }
  951. });
  952. $(this).children( ".first-slider-value" ).val( dataUnit + $( this ).slider( "values", 0 ).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
  953. $(this).children( ".second-slider-value" ).val( dataUnit + $( this ).slider( "values", 1 ).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
  954.  
  955.  
  956. });
  957.  
  958.  
  959.  
  960. /*----------------------------------------------------*/
  961. /* Masonry
  962. /*----------------------------------------------------*/
  963.  
  964. // Agent Profile Alignment
  965. $(window).on('load resize', function() {
  966.  
  967. $('.agents-grid-container').masonry({
  968. itemSelector: '.grid-item', // use a separate class for itemSelector, other than .col-
  969. columnWidth: '.grid-item',
  970. percentPosition: true
  971. });
  972.  
  973. var agentAvatarHeight = $(".agent-avatar img").height();
  974. var agentContentHeight = $(".agent-content").innerHeight();
  975.  
  976. if ( agentAvatarHeight < agentContentHeight ) {
  977. $('.agent-page').addClass('long-content');
  978. } else {
  979. $('.agent-page').removeClass('long-content');
  980. }
  981. });
  982.  
  983.  
  984.  
  985. /*----------------------------------------------------*/
  986. /* Submit Property
  987. /*----------------------------------------------------*/
  988.  
  989. // Tooltip
  990. $(".tip").each(function() {
  991. var tipContent = $(this).attr('data-tip-content');
  992. $(this).append('<div class="tip-content">'+ tipContent + '</div>');
  993. });
  994.  
  995.  
  996.  
  997. /*----------------------------------------------------*/
  998. /* Tabs
  999. /*----------------------------------------------------*/
  1000.  
  1001. var $tabsNav = $('.tabs-nav'),
  1002. $tabsNavLis = $tabsNav.children('li');
  1003.  
  1004. $tabsNav.each(function() {
  1005. var $this = $(this);
  1006.  
  1007. $this.next().children('.tab-content').stop(true,true).hide()
  1008. .first().show();
  1009.  
  1010. $this.children('li').first().addClass('active').stop(true,true).show();
  1011. });
  1012.  
  1013. $tabsNavLis.on('click', function(e) {
  1014. var $this = $(this);
  1015.  
  1016. $this.siblings().removeClass('active').end()
  1017. .addClass('active');
  1018.  
  1019. $this.parent().next().children('.tab-content').stop(true,true).hide()
  1020. .siblings( $this.find('a').attr('href') ).fadeIn();
  1021.  
  1022. e.preventDefault();
  1023. });
  1024. var hash = window.location.hash;
  1025. var anchor = $('.tabs-nav a[href="' + hash + '"]');
  1026. if (anchor.length === 0) {
  1027. $(".tabs-nav li:first").addClass("active").show(); //Activate first tab
  1028. $(".tab-content:first").show(); //Show first tab content
  1029. } else {
  1030. console.log(anchor);
  1031. anchor.parent('li').click();
  1032. }
  1033.  
  1034.  
  1035. /*----------------------------------------------------*/
  1036. /* Accordions
  1037. /*----------------------------------------------------*/
  1038. var $accor = $('.accordion');
  1039.  
  1040. $accor.each(function() {
  1041. $(this).toggleClass('ui-accordion ui-widget ui-helper-reset');
  1042. $(this).find('h3').addClass('ui-accordion-header ui-helper-reset ui-state-default ui-accordion-icons ui-corner-all');
  1043. $(this).find('div').addClass('ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom');
  1044. $(this).find("div").hide();
  1045.  
  1046. });
  1047.  
  1048. var $trigger = $accor.find('h3');
  1049.  
  1050. $trigger.on('click', function(e) {
  1051. var location = $(this).parent();
  1052.  
  1053. if( $(this).next().is(':hidden') ) {
  1054. var $triggerloc = $('h3',location);
  1055. $triggerloc.removeClass('ui-accordion-header-active ui-state-active ui-corner-top').next().slideUp(300);
  1056. $triggerloc.find('span').removeClass('ui-accordion-icon-active');
  1057. $(this).find('span').addClass('ui-accordion-icon-active');
  1058. $(this).addClass('ui-accordion-header-active ui-state-active ui-corner-top').next().slideDown(300);
  1059. }
  1060. e.preventDefault();
  1061. });
  1062.  
  1063.  
  1064. /*----------------------------------------------------*/
  1065. /* Toggle
  1066. /*----------------------------------------------------*/
  1067.  
  1068. $(".toggle-container").hide();
  1069.  
  1070. $('.trigger, .trigger.opened').on('click', function(a){
  1071. $(this).toggleClass('active');
  1072. a.preventDefault();
  1073. });
  1074.  
  1075. $(".trigger").on('click', function(){
  1076. $(this).next(".toggle-container").slideToggle(300);
  1077. });
  1078.  
  1079. $(".trigger.opened").addClass("active").next(".toggle-container").show();
  1080.  
  1081.  
  1082. /*----------------------------------------------------*/
  1083. /* Notifications
  1084. /*----------------------------------------------------*/
  1085.  
  1086. $("a.close").removeAttr("href").on('click', function(){
  1087. $(this).parent().fadeOut(200);
  1088. });
  1089.  
  1090.  
  1091. /*----------------------------------------------------*/
  1092. /* Contact Form
  1093. /*----------------------------------------------------*/
  1094.  
  1095. var shake = "No";
  1096.  
  1097. $('#message').hide();
  1098.  
  1099. // Add validation parts
  1100. $('#contact input[type=text], #contact input[type=number], #contact input[type=email], #contact input[type=url], #contact input[type=tel], #contact select, #contact textarea').each(function(){
  1101.  
  1102. });
  1103.  
  1104. // Validate as you type
  1105. $('#name, #comments, #subject').focusout(function() {
  1106. if (!$(this).val())
  1107. $(this).addClass('error').parent().find('mark').removeClass('valid').addClass('error');
  1108. else
  1109. $(this).removeClass('error').parent().find('mark').removeClass('error').addClass('valid');
  1110. });
  1111.  
  1112. $('#email').focusout(function() {
  1113. if (!$(this).val() || !isEmail($(this).val()))
  1114. $(this).addClass('error').parent().find('mark').removeClass('valid').addClass('error');
  1115. else
  1116. $(this).removeClass('error').parent().find('mark').removeClass('error').addClass('valid');
  1117. });
  1118.  
  1119. $('#email').focusout(function() {
  1120. $('#submit')
  1121. .prop('disabled', false)
  1122. .removeClass('disabled');
  1123. });
  1124.  
  1125. $('#submit').click(function() {
  1126. $("#contact-message").slideUp(200,function() {
  1127. $('#contact-message').hide();
  1128.  
  1129. // Kick in Validation
  1130. $('#name, #subject, #phone, #comments, #website, #email').triggerHandler("focusout");
  1131.  
  1132. if ($('#contact mark.error').size()>0) {
  1133. if(shake == "Yes") {
  1134. $('#contact').effect('shake', { times:2 }, 75, function(){
  1135. $('#contact input.error:first, #contact textarea.error:first').focus();
  1136. });
  1137. } else $('#contact input.error:first, #contact textarea.error:first').focus();
  1138.  
  1139. return false;
  1140. }
  1141.  
  1142. });
  1143. });
  1144.  
  1145. $('#contactform').submit(function(){
  1146.  
  1147. if ($('#contact mark.error').size()>0) {
  1148. if(shake == "Yes") {
  1149. $('#contact').effect('shake', { times:2 }, 75);
  1150. }
  1151. return false;
  1152. }
  1153.  
  1154. var action = $(this).attr('action');
  1155.  
  1156. $('#contact #submit').after('<img src="images/loader.gif" class="loader" />')
  1157.  
  1158. $('#submit')
  1159. .prop('disabled',true)
  1160. .addClass('disabled');
  1161.  
  1162. $.post(action, $('#contactform').serialize(),
  1163. function(data){
  1164. $('#contact-message').html( data );
  1165. $('#contact-message').slideDown();
  1166. $('#contactform img.loader').fadeOut('slow',function(){$(this).remove()});
  1167. // $('#contactform #submit').removeAttr('disabled');
  1168. if(data.match('success') != null) $('#contactform').slideUp('slow');
  1169.  
  1170. }
  1171. );
  1172.  
  1173. return false;
  1174.  
  1175. });
  1176.  
  1177. function isEmail(emailAddress) {
  1178.  
  1179. var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
  1180.  
  1181. return pattern.test(emailAddress);
  1182. }
  1183.  
  1184. function isNumeric(input) {
  1185. return (input - 0) == input && input.length > 0;
  1186. }
  1187.  
  1188.  
  1189.  
  1190. // ------------------ End Document ------------------ //
  1191. });
  1192.  
  1193. })(this.jQuery);
  1194.  
  1195.  
  1196.  
  1197. (function($) {
  1198.  
  1199. $.fn.footerReveal = function(options) {
  1200.  
  1201. $('#footer.sticky-footer').before('<div class="footer-shadow"></div>');
  1202.  
  1203. var $this = $(this),
  1204. $prev = $this.prev(),
  1205. $win = $(window),
  1206.  
  1207. defaults = $.extend ({
  1208. shadow : true,
  1209. shadowOpacity: 0.12,
  1210. zIndex : -10
  1211. }, options ),
  1212.  
  1213. settings = $.extend(true, {}, defaults, options);
  1214.  
  1215. $this.before('<div class="footer-reveal-offset"></div>');
  1216.  
  1217. if ($this.outerHeight() <= $win.outerHeight()) {
  1218. $this.css({
  1219. 'z-index' : defaults.zIndex,
  1220. position : 'fixed',
  1221. bottom : 0
  1222. });
  1223.  
  1224. $win.on('load resize', function() {
  1225. $this.css({
  1226. 'width' : $prev.outerWidth()
  1227. });
  1228. $prev.css({
  1229. 'margin-bottom' : $this.outerHeight()
  1230. });
  1231. });
  1232. }
  1233.  
  1234. return this;
  1235.  
  1236. };
  1237.  
  1238. }) (this.jQuery);
Advertisement
Add Comment
Please, Sign In to add comment