1// featuredWidgets Module Start 2var featuredWidgets = (function($) { 3 // Widget intersection observer 4 var featuredObserver = ''; 5 var intersectionAllowed = (function(){ 6 return ('IntersectionObserver' in window); 7 })(); 8 9 // Keep Track of widgets and common feature settings. 10 var featuredWidgets = []; 11 var settings = { 12 windowSize: parseInt($(window).width()), 13 themeName: '', 14 isMobile: false, 15 imageServer: 'https://storage.sub-ca.incomrealestate.com', 16 noImage: '/images/noImage.jpg', 17 }; 18 19 // When content loaded set props 20 document.addEventListener('DOMContentLoaded', function(e){ 21 var themes = ['urban','elegant','rahcorp','bannertheme','corporate','righthome']; 22 var classes = document.querySelector('body').className.split(' '); 23 settings.isMobile = document.querySelector('body').className.match(/'mobileVersion'/) ? true : false; 24 var themeRes = document.querySelector('body').className.match(/theme[0-9]*/g); 25 settings.themeName = themeRes ? themeRes[0] : null; 26 if(!settings.themeName){ 27 themes.map(function(theme){ 28 classes.includes(theme) && (settings.themeName = theme); 29 }); 30 } 31 }); 32 33 // Intersection observer to manage starting and stopping of autoscroll based on widget being inside viewport 34 var intersectThreshhold = 0.01; 35 if(intersectionAllowed){ 36 featuredObserver = new IntersectionObserver(function(entries, observer){ 37 entries.forEach(function(entry){ 38 // Change status of carousel based on intersection. 39 var widget = entry.target.id.match(/[1-9][0-9]*/g)[0]; 40 if (entry.intersectionRatio > intersectThreshhold) { 41 featuredWidgets['featuredListing-'+widget].carousel.jcarouselAutoscroll('start'); 42 } else { 43 featuredWidgets['featuredListing-'+widget].carousel.jcarouselAutoscroll('stop'); 44 } 45 }); 46 },{rootMargin: '0px',threshold: intersectThreshhold}); 47 }; 48 49 // FeaturedWidgets methods 50 isCarousel = function(properties, total_record){ 51 var minnumber = 3; 52 if ($('body').hasClass('theme14') || $('body').hasClass('theme10')){ minnumber = 4;} 53 if ($('body').hasClass('theme30') || $('body').hasClass('theme31') || $('body').hasClass('theme34') || $('body').hasClass('theme35')){ minnumber = 1;} 54 if ($('body').hasClass('theme12')) { 55 if (properties.length < 1){ 56 minnumber = 4; 57 }else{ minnumber = 8; 58 } 59 } 60 if (($('body').hasClass('inner') || $('body').hasClass('urban')) && $('body').hasClass('office-detail')) { 61 minnumber = 2; 62 } 63 return total_record > minnumber || properties.length > minnumber; 64 }; 65 66 hideWidget = function(widget){ 67 if($(widget.selector).find('.no_widget_result').length>0){ 68 $(widget.selector).hide(); 69 } 70 } 71 // Add featured Widget to Module return reference to this newly added widget. 72 addWidget = function(wid,properties,settings,listingMode,total_record){
73 if(typeof(settings['property_display']) === 'undefined'){ 74 settings['property_display'] = 2; 75 } 76 77 const isProsperTheme = $('body').hasClass('theme9') || $('body').hasClass('theme23'); 78 79 featuredWidgets['featuredListing-'+wid] = { 80 isCarousel : isCarousel(properties,total_record) || isProsperTheme, 81 scrollClass : settings['property_display'] == '1' ? 'vertical_scroll' : 'horizontal_scroll', 82 hasProperties : properties.length, 83 verticalMode : settings['property_display'] != '2', 84 region: settings['region'], 85 officeCarousel : settings.officeCarousel || false, 86 selector: !settings.officeCarousel ? '#featuredListing-0-' + wid : "#office_agent_listings-0-" + wid, 87 imageWidth: null 88 }; 89 if(!featuredWidgets['featuredListing-'+wid].hasProperties && !featuredWidgets['featuredListing-'+wid].officeCarousel){ 90 hideWidget(featuredWidgets['featuredListing-'+wid]); 91 } 92 if(featuredWidgets['featuredListing-'+wid].isCarousel && !(wid == 'broker-agent-listings')){ 93 featuredObserver.observe($(featuredWidgets['featuredListing-'+wid].selector)[0]); 94 }; 95 return featuredWidgets['featuredListing-'+wid]; 96 }; 97 98 // Load Images Seperatly after carousel is initialized. 99 loadImage = function(el,image,_settings){ 100 var imagDownloaded = new Image(); 101 // Onload swap image of element 102 imagDownloaded.onload = function(){ 103 featuredImageUpdate(this.src,el); 104 } 105 // On fail display noImage picture in case we fail to get picture. 106 imagDownloaded.onerror = function () { 107 var pidSelector = el.split(' ').find(function (item) { 108 return item.indexOf('data-pid') !== -1; 109 }); 110 111 var fullSelector = pidSelector + ' .featured_multi_img_wrapper'; 112 var title = $(fullSelector).attr('title'); 113 114 if (title && title.indexOf('commercial') !== -1) { 115 featuredImageUpdate('/images/noImageCommercial.jpg', el); 116 } else { 117 featuredImageUpdate(settings.noImage, el); 118 } 119 }; 120 // Set up common width for all properties of the passed widget. 121 let isThemeExcluded = true; 122 if(!featuredWidgets['featuredListing-'+_settings['widget_id']].imageWidth){ 123 const excludedThemes = ['theme9', 'theme23', 'cpcorp', 'theme28', 'theme29', 'theme32', 'theme33', 'theme35']; 124 excludedThemes.forEach(function(theme) { 125 if($('body').hasClass(theme)) { 126 isThemeExcluded = false; 127 } 128 }) 129 if(isThemeExcluded && _settings['widget_id'] !== 'broker-agent-listings'){ 130 featuredWidgets['featuredListing-'+_settings['widget_id']].imageWidth = $(el).parent('a').width(); 131 } else if (_settings['widget_id'] !== 'broker-agent-listings') { 132 featuredWidgets['featuredListing-'+_settings['widget_id']].imageHeight = $(el).parent('a').height(); 133 } 134 } 135 // Make request to download image. 136 if (isThemeExcluded) { 137 imagDownloaded.src = getImageURL(image,featuredWidgets['featuredListing-'+_settings['widget_id']].imageWidth,0); 138 } else { 139 imagDownloaded.src = getImageURL(image,0,featuredWidgets['featuredListing-'+_settings['widget_id']].imageHeight); 140 } 141 142 }; 143 144 // Helper Event Dispatcher 145 triggerEvent = function (event,evData){ 146 var event = new CustomEvent(event); 147 event.details = evData; 148 document.dispatchEvent(event); 149 }; 150 151 // Update Image 152 featuredImageUpdate = function (img,selector){ 153 var els = document.querySelectorAll(selector); 154 for(var i=0; i < els.length ; i++){
155 if(els[i].src != img){ 156 els[i].src = img; 157 els[i].classList.remove('loading'); 158 } 159 } 160 return; 161 } 162 // Helper to get correct image url 163 getImageURL = function(url, width, height) { 164 var fileName = url.substring(url.lastIndexOf('/') + 1); 165 var returnURL = settings.imageServer + '/' + fileName; 166 var params = [] 167 if(width && width > 0){ 168 params.push(['width', width * window.devicePixelRatio]) 169 } 170 if(height && height > 0){ 171 params.push(['height', height * window.devicePixelRatio]) 172 } 173 if(params.length) { 174 returnURL = returnURL + '?' 175 for(var i in params) { 176 returnURL = returnURL + params[i][0] + '=' + params[i][1] + '&' 177 } 178 returnURL = returnURL.substring(0, returnURL.length - 1); 179 } 180 return returnURL; 181 } 182 183 // Public API 184 return { 185 widgets: featuredWidgets, // Pass Widgets Reference 186 addWidget: addWidget, 187 settings: settings, // Pass Settings Reference 188 triggerEvent: triggerEvent, 189 loadImage: loadImage 190 }; 191 192})(jQuery); 193 194 195function toggleCarouselFunctionality(semiReference_path) { 196 $(semiReference_path+'#scroll_mode').toggleClass('no_carousel');
197 $(semiReference_path).find('a[class*="jcarousel-control-"]').toggle(); 198 const carouselListElement = $(semiReference_path+'#scroll_mode .jcarousel ul') 199 const carouselListPositionValue = carouselListElement.css('position') === 'static'? 'relative':'static'; 200 $(semiReference_path+'#scroll_mode .jcarousel ul').css('position',carouselListPositionValue) 201} 202 203function checkForCarouselToggle(total_record,semiReference_path) { 204 const mobileThemes = ['theme9','theme23']; 205 const SINGLE_RECORD_BREAKPOINT_PX = 600; 206 const DOUBLE_RECORD_BREAKPOINT_PX = 768; 207 const RECORD_LIMIT = 3; 208 const MINIMUM_RECORD_REQUIRED = 1; 209 210 // leaves carousel activated for anything greater than property limit 211 if (total_record < RECORD_LIMIT) { 212 if (mobileThemes.find(theme =>$('body').hasClass(theme))) { 213 // ========================================== 214 // will be enabled for theme, this turns it off for given conditions at page load. 215 // Required or functionality will not be there on resize 216 const isDesktopAtLoad = $(window).width() >= DOUBLE_RECORD_BREAKPOINT_PX; 217 if (total_record <= MINIMUM_RECORD_REQUIRED) { 218 toggleCarouselFunctionality(semiReference_path); 219 // special case where we do not want responsivity 220 return; 221 } else if (isDesktopAtLoad) { 222 toggleCarouselFunctionality(semiReference_path); 223 } 224 225 // ========================================= 226 // responsively toggle carousel 227 $(window).resize(function() { 228 const containsNoCarouselClass = $(semiReference_path+'#scroll_mode').hasClass('no_carousel'); 229 const isMultiPropBreak = $(window).width() >= DOUBLE_RECORD_BREAKPOINT_PX; 230 const isDoublePropBreak = $(window).width() < DOUBLE_RECORD_BREAKPOINT_PX && $(window).width() >= SINGLE_RECORD_BREAKPOINT_PX; 231 if (isMultiPropBreak && !containsNoCarouselClass) { 232 toggleCarouselFunctionality(semiReference_path) 233 } else if (isDoublePropBreak && containsNoCarouselClass) { 234 toggleCarouselFunctionality(semiReference_path) 235 } 236 }); 237 } 238 } 239 240 }; 241 242function initPropertiesList(scrollClass, widget_id, propertiesList, settings) { 243 var fullReference_path = "#featuredListing-0-" 244 + widget_id + " .jcarousel"; 245 if(propertiesList && propertiesList.length) { 246 for(var i in propertiesList) { 247 $(fullReference_path + " ul").append(generatePropertyView(propertiesList[i], settings)); 248 } 249 } 250} 251function initialiseCarousel($scrollClass,$widget_id,$total_record,$region,$listing_mode,$custom_active_li_limit, propertiesList, settings){ 252 var widget = featuredWidgets.addWidget($widget_id,propertiesList,settings,$listing_mode,$total_record); // This Widget Reference 253 var widgetSelector = widget.selector; 254 var deviceSize = featuredWidgets.settings.windowSize; 255 var idleFlag = 1; 256 var scrollClass = widget.scrollClass; 257 $region = widget.region; 258 var fullReference_path = widgetSelector + " ." + scrollClass + " .jcarousel"; 259 var semiReference_path = widgetSelector + " ." + scrollClass; 260 var isBrokerDetailPage = (($('body').hasClass('inner') || $('body').hasClass('urban')) && $('body').hasClass('office-detail')); 261 262 if(!widget.isCarousel){ 263 $(widgetSelector +' #scroll_mode').addClass('no_carousel'); 264 } else {
265 $(widgetSelector).find('a[class*="jcarousel-control-"]').show(); 266 } 267 if($custom_active_li_limit === undefined) { 268 $custom_active_li_limit = false; 269 } 270 if(propertiesList && propertiesList.length) { 271 if($(fullReference_path + " ul").length === 0){ 272 $(fullReference_path).prepend("<ul></ul>"); 273 } 274 settings["index"] = 0; 275 for(var i in propertiesList) { 276 settings["index"] += 1; 277 $(fullReference_path + " ul").append(generatePropertyView(propertiesList[i], settings)); 278 } 279 // Add custom event so that we can detect when featured listing has its properties appended. 280 featuredWidgets.triggerEvent("featuredReady",{"widgetId":widget.selector}); 281 } 282 if(($total_record == 4) && $('body').hasClass('homelife_luxury')){ 283 $(semiReference_path).addClass('fouritems'); 284 } 285 if(($total_record == 5) && $('body').hasClass('homelife_luxury')){ 286 $(semiReference_path).addClass('fiveitems'); 287 } 288 // Workaround for condition. To prevent jcarousel from starting for any theme when there are less than x records. 289 if(featuredWidgets.settings.isMobile){ 290 // any theme which should have a restricted number of records on mobile can go here. We can enhance it later. 291 var restrictRecords = { 292 theme12 : 4, 293 }; 294 if(restrictRecords[featuredWidgets.settings.themeName] !== undefined){ 295 if($total_record <= restrictRecords[featuredWidgets.themeName] ){ 296 $(semiReference_path).addClass('no_carousel'); 297 return; 298 } 299 } 300 } 301 302 checkForCarouselToggle($total_record,semiReference_path); 303 304 if($custom_active_li_limit == false){ 305 var tt_exp = "1"; //set the exp time in min 306 tt_exp = (parseInt(tt_exp) * 60000); //set the time in microsecond 307 $(document).bind("idle.idleTimer", function(){ 308 $(semiReference_path+" .idleState").attr("value",0); 309 }); 310 $(document).bind("active.idleTimer", function(){ 311 $(semiReference_path+" .idleState").attr("value",1); 312 }); 313 $.idleTimer(tt_exp); 314 } 315 316 var wp1='circular'; 317 318 // for theme 10 only 319 if((check_theme_active_li_exist($listing_mode, $custom_active_li_limit)) 320 && (deviceSize <= 1300) 321 && $custom_active_li_limit == 4 322 && widget.verticalMode === true) 323 { 324 wp1='last'; 325 } 326 if(!widget.isCarousel){ 327 return; 328 } 329 $(fullReference_path).jcarousel({ 330 vertical: widget.verticalMode, 331 animation: 2000, 332 wrap: wp1 333 }); 334 if(check_theme_active_li_exist($listing_mode, $custom_active_li_limit)){ 335 $active_li_func = "theme_process_active_li_"+$custom_active_li_limit; 336 eval($active_li_func+"(semiReference_path,deviceSize)"); 337 } 338 339 /* custom carousel start position */ 340 var numitems=$(fullReference_path+" ul li").length; 341 var customNum_items = parseInt(numitems-1); 342 var jumpIndex=parseInt(customNum_items)-11; 343 if($custom_active_li_limit == false){ 344 if(numitems>=6 && jumpIndex>=3 ) 345 $(fullReference_path).jcarousel("scroll",jumpIndex,false); 346 } 347 348 if(check_theme_active_li_exist($listing_mode,$custom_active_li_limit)){ 349 $page_load_last_limit = $custom_active_li_limit * 2; 350 if(numitems > $custom_active_li_limit && numitems < $page_load_last_limit){ 351 check_carousel_last_slide(fullReference_path,deviceSize,$custom_active_li_limit); 352 } 353 } 354 355 $(semiReference_path + " .limit_count").attr("value",numitems); 356 /* custom carousel start position end */ 357 358 $(semiReference_path + " .jcarousel-control-prev").click(function(event){ 359 event.preventDefault(); 360 if(widget.scrollClass=="horizontal_scroll"){ 361 362 if (($('body').hasClass('theme30') || $('body').hasClass('theme31') || $('body').hasClass('theme34')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 363 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 364 } 365 366 if ($('body').hasClass('homelife_luxury')){ 367 if (deviceSize <= 1640 && deviceSize>1060) { 368 $(semiReference_path+" .jcarousel").jcarousel("scroll", "-=2"); 369 } 370 if (deviceSize <= 1060){ 371 $(semiReference_path+" .jcarousel").jcarousel("scroll", "-=1"); 372 } 373 } 374 375 if ($('body').hasClass('theme4') 376 && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 377 if(deviceSize <= 885 && deviceSize > 568){ 378 $(semiReference_path+" .jcarousel").jcarousel("scroll", "-=2"); 379 } 380 } 381 382 if (($('body').hasClass('theme5') || $('body').hasClass('righthome')) && $('body').hasClass('front')){ 383 if (deviceSize <= 1300 && deviceSize>925) { 384 $(semiReference_path+" .jcarousel").jcarousel("scroll", "-=2"); 385 } 386 if (deviceSize <= 925){ 387 $(semiReference_path+" .jcarousel").jcarousel("scroll", "-=1"); 388 } 389 } 390 391 if ($('body').hasClass('theme6') 392 && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 393 if (deviceSize <= 1300 && deviceSize>925) { 394 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 395 } 396 if (deviceSize <= 925){ 397 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 398 } 399 } 400 401 if ($('body').hasClass('theme24') || $('body').hasClass('theme26') || $('body').hasClass('cpcorp') 402 && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 403 if (deviceSize <= 980 && deviceSize>710) { 404 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 405 } 406 if (deviceSize <= 710){ 407 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 408 } 409 } 410 411 if ($('body').hasClass('theme25') || $('body').hasClass('theme27') 412 && $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings")){ 413 if (deviceSize <= 1095 && deviceSize>680) { 414 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 415 } 416 if (deviceSize <= 680){ 417 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 418 } 419 } 420 421 if ($('body').hasClass('theme12') 422 && $('[id*="office_agent_listings"]').length === 1 && semiReference_path.indexOf('office_agent_listings') != -1){ 423 if (deviceSize <= 900 && deviceSize>744) { 424 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 425 } 426 if (deviceSize <= 744){ 427 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 428 } 429 } 430 431 if (($('body').hasClass('theme7') || $('body').hasClass('theme8'))
432 && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 433 if (deviceSize <= 1136 && deviceSize > 835) { 434 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 435 } 436 if (deviceSize <= 835){ 437 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 438 } 439 } 440 441 if (($('body').hasClass('theme9') || $('body').hasClass('theme23')) 442 && $('body').hasClass('front')){ 443 if (deviceSize <= 1050 && deviceSize>720) { 444 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 445 } 446 if (deviceSize <= 720){ 447 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 448 } 449 } 450 451 if (($('body').hasClass('theme15') || $('body').hasClass('theme16') || $('body').hasClass('theme20') || $('body').hasClass('theme21') || $('body').hasClass('theme22')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 452 if (deviceSize <= 1095 && deviceSize>680) { 453 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 454 } 455 if (deviceSize <= 680){ 456 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 457 } 458 } 459 460 if (($('body').hasClass('theme17') || $('body').hasClass('theme19')) && $('body').hasClass('front')){ 461 if (deviceSize <= 1140 && deviceSize>600) { 462 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 463 } 464 if (deviceSize <= 600){ 465 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 466 } 467 } 468 469 if ($('body').hasClass('theme18') && $('body').hasClass('front')){ 470 if (deviceSize <= 1024 && deviceSize>640) { 471 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 472 } 473 } 474 475 476 if ($custom_active_li_limit != 0 && ($('body').hasClass('front') && $listing_mode != 3 || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 477 478 if($custom_active_li_limit > 4){ 479 if (deviceSize <= 770){ 480 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=4"); 481 } 482 else if(deviceSize <= 1070){ 483 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=6"); 484 } 485 else{ 486 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-="+$custom_active_li_limit); 487 } 488 } 489 else{ 490 if (deviceSize <= 1300){ 491 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 492 } else{ 493 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-="+$custom_active_li_limit); 494 } 495 } 496 } 497 498 if($custom_active_li_limit != '' && $listing_mode == 3 && $region != 'wsidebar_right' ){ 499 if (deviceSize <= 500){ 500 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 501 }else if (deviceSize <= 900){ 502 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 503 } 504 } 505 506 507 508 if(deviceSize <= 640){ 509 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 510 } 511 else{ 512 if($region == 'frontpage_center' || $region == 'frontpage_centre' || $region == 'mainColumn' || $region == 'frontpage_main' || $region == 'frontpage_left' || $region == 'frontpage_middle' || $region == 'frontpage_right'){//add regions for 2 column here 513 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=2"); 514 } 515 else if($region == 'wsidebar_right' && $listing_mode == 3 ){ 516 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 517 } 518 else if (isBrokerDetailPage){ 519 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=1"); 520 } 521 else{ 522 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=3"); 523 } 524 } 525 } 526 else{ 527 $(semiReference_path + " .jcarousel").jcarousel("scroll", "-=3"); 528 } 529 530 }); 531
532 $(semiReference_path + " .jcarousel-control-next").click(function(event){ 533 event.preventDefault(); 534 if(widget.scrollClass=="horizontal_scroll"){ 535 536 if ($('body').hasClass('theme4') && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 537 if(deviceSize <= 885 && deviceSize > 568){ 538 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 539 } 540 } 541 542 if (($('body').hasClass('theme30') || $('body').hasClass('theme31') || $('body').hasClass('theme34')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 543 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 544 } 545 546 if ($('body').hasClass('homelife_luxury')){ 547 if (deviceSize <= 1640 && deviceSize>1060) { 548 $(semiReference_path+" .jcarousel").jcarousel("scroll", "+=2"); 549 } 550 if (deviceSize <= 1060){ 551 $(semiReference_path+" .jcarousel").jcarousel("scroll", "+=1"); 552 } 553 } 554 555 if (($('body').hasClass('theme5') || $('body').hasClass('righthome')) && $('body').hasClass('front')){ 556 if (deviceSize <= 1300 && deviceSize>925) { 557 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 558 } 559 if (deviceSize <= 925){ 560 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 561 } 562 } 563 if ($('body').hasClass('theme6') && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 564 if (deviceSize <= 1300 && deviceSize>925) { 565 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 566 } 567 if (deviceSize <= 925){ 568 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 569 } 570 } 571 572 if ($('body').hasClass('theme24') || $('body').hasClass('theme26') || $('body').hasClass('cpcorp') && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 573 if (deviceSize <= 980 && deviceSize>710) { 574 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 575 } 576 if (deviceSize <= 710){ 577 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 578 } 579 } 580 581 if ($('body').hasClass('theme25') || $('body').hasClass('theme27') 582 && $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings")){ 583 if (deviceSize <= 1095 && deviceSize>680) { 584 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 585 } 586 if (deviceSize <= 680){ 587 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 588 } 589 } 590 591 if ($('body').hasClass('theme12') && $('[id*="office_agent_listings"]').length === 1 && semiReference_path.indexOf('office_agent_listings') != -1){ 592 if (deviceSize <= 900 && deviceSize > 744) { 593 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 594 } 595 if (deviceSize <= 744){ 596 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 597 } 598 } 599 600 if (($('body').hasClass('theme7') || $('body').hasClass('theme8')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 601 if (deviceSize <= 1136 && deviceSize>835) { 602 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 603 } 604 if (deviceSize <= 835){ 605 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 606 } 607 } 608 609 if (($('body').hasClass('theme9') || $('body').hasClass('theme23')) && $('body').hasClass('front')){ 610 if (deviceSize <= 1050 && deviceSize>720) { 611 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 612 } 613 if (deviceSize <= 720){ 614 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 615 } 616 } 617 618 if (($('body').hasClass('theme15') || $('body').hasClass('theme16') || $('body').hasClass('theme20') || $('body').hasClass('theme21') || $('body').hasClass('theme22')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 619 if (deviceSize <= 1095 && deviceSize>680) { 620 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 621 } 622 if (deviceSize <= 680){ 623 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 624 } 625 } 626 627 628 if (($('body').hasClass('theme17') || $('body').hasClass('theme19')) && $('body').hasClass('front')){ 629 if (deviceSize <= 1140 && deviceSize>600) { 630 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 631 } 632 if (deviceSize <= 600){ 633 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 634 } 635 } 636 637 638 if ($('body').hasClass('theme18') && $('body').hasClass('front')){ 639 if (deviceSize <= 1024 && deviceSize>640) { 640 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 641 } 642 } 643 644 645 if ($custom_active_li_limit && ($('body').hasClass('front') && $listing_mode != 3 || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 646 if($custom_active_li_limit > 4){ 647 if (deviceSize <= 770){ 648 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=4"); 649 } 650 else if(deviceSize <= 1070){ 651 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=6"); 652 } 653 else{ 654 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+="+$custom_active_li_limit); 655 } 656 } 657 else{ 658 659 if (deviceSize <= 1300){ 660 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 661 }else{ 662 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+="+$custom_active_li_limit); 663 } 664 } 665 } 666 667 if($custom_active_li_limit && $listing_mode == 3 && $region != 'wsidebar_right' ){ 668 if (deviceSize <= 500){ 669 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 670 }else if (deviceSize <= 900){ 671 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 672 } 673 } 674 675 676 if(deviceSize <= 640){ 677 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 678 } 679 else{ 680 if($region == 'frontpage_center' || $region == 'frontpage_centre' || $region == 'mainColumn' || $region == 'frontpage_main' || $region == 'frontpage_left' || $region == 'frontpage_middle' || $region == 'frontpage_right'){//add regions for 2 column here 681 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=2"); 682 } 683 else if($region == 'wsidebar_right' && $listing_mode == 3 ){ 684 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 685 } 686 else if (isBrokerDetailPage){ 687 $(semiReference_path + " .jcarousel").jcarousel("scroll", "+=1"); 688 } 689 else{ 690 $(semiReference_path+" .jcarousel").jcarousel("scroll", "+=3"); 691 } 692 } 693 694 } 695 else{ 696 $(semiReference_path+" .jcarousel").jcarousel("scroll", "+=3"); 697 } 698 }); 699
700 $(fullReference_path).on("jcarousel:animate", function(event, carousel){ 701 if($listing_mode != 2 && $listing_mode != 3 ){ // Properties listing 702 appendNew_carousel_item($total_record,fullReference_path,semiReference_path,$widget_id,carousel,idleFlag,$listing_mode,deviceSize,$custom_active_li_limit, settings); 703 } 704 else if($listing_mode == 2){ // Pre-construction codo listing 705 appendNew_carousel_condo_item($total_record,fullReference_path,semiReference_path,$widget_id,carousel,idleFlag,$listing_mode,deviceSize,$custom_active_li_limit); 706 } 707 else if($listing_mode == 3){ // agents listings 708 appendNew_carousel_agent_listings_item($total_record,fullReference_path,semiReference_path,$widget_id,carousel,idleFlag); 709 } 710 711 }); 712 713 if (isBrokerDetailPage){ 714 $(semiReference_path+" .jcarousel li").eq(0).addClass( "activeLi" ); 715 $(fullReference_path).on('jcarousel:targetin', 'li', function(event, carousel) { 716 this.classList.add('activeLi'); 717 let prevButton = $(semiReference_path + " .jcarousel-control-prev")[0]; 718 let firstItem = carousel._items[0] 719 if (this == firstItem) { 720 prevButton.classList.remove('show'); 721 } else { 722 prevButton.classList.add('show'); 723 } 724 }); 725 $('.jcarousel').on('jcarousel:targetout', 'li', function(event, carousel) { 726 this.classList.remove('activeLi'); 727 }); 728 } 729 730 if(widget.scrollClass=="horizontal_scroll"){ //horizontal autoscroll 731 732 if(deviceSize <= 640 || $region == 'wsidebar_right'){ 733 734 var numScroll='+=1'; 735 var scrollValue=1; 736 } 737 else{ 738 if($region == 'frontpage_center'|| $region == 'frontpage_centre' || $region == 'mainColumn' || $region == 'frontpage_main' || $region == 'frontpage_left' || $region == 'frontpage_middle' || $region == 'frontpage_right'){ //add regions for 2 column here 739 var numScroll='+=2'; 740 var scrollValue=2; 741 } 742 else if($custom_active_li_limit && $region == 'wsidebar_right' && $listing_mode == 3 ){ 743 var numScroll='+=1'; 744 var scrollValue=1; 745 } 746 else{ 747 var numScroll='+=3'; 748 var scrollValue=3; 749 } 750 } 751 752 if (($('body').hasClass('theme30') || $('body').hasClass('theme31') || $('body').hasClass('theme34') || $('body').hasClass('theme35')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 753 if ($('[id*="office_agent_listings"]').length === 1 && semiReference_path.indexOf('office_agent_listings') != -1 && (($total_record <= 4 && deviceSize >= 1025)||($total_record <= 3 && deviceSize >= 551)||($total_record <= 2))) { 754 var numScroll='+=0'; 755 } else { 756 var numScroll='+=1'; 757 } 758 } 759 760 if ($('body').hasClass('theme4') && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 761 if(deviceSize <= 885){ 762 var numScroll='+=2'; 763 var scrollValue=2; 764 if (deviceSize <= 568){ 765 var numScroll='+=1'; 766 var scrollValue=1; 767 } 768 } 769 } 770 771 if (isBrokerDetailPage){ 772 var numScroll='+=1'; 773 var scrollValue=1; 774 } 775 776 if ($('body').hasClass('homelife_luxury')){ 777 if (deviceSize <= 1640 && deviceSize>1060) { 778 var numScroll='+=2'; 779 var scrollValue=2; 780 } 781 if (deviceSize <= 1060){ 782 var numScroll='+=1'; 783 var scrollValue=1; 784 } 785 } 786 787 if (($('body').hasClass('theme5') || $('body').hasClass('righthome')) && $('body').hasClass('front')){ 788 if(deviceSize <= 1300){ 789 var numScroll='+=2'; 790 var scrollValue=2; 791 if (deviceSize <= 925){ 792 var numScroll='+=1'; 793 var scrollValue=1; 794 } 795 } 796 } 797 if ($('body').hasClass('theme6') && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 798 799 if(deviceSize <= 1300){ 800 var numScroll='+=2'; 801 var scrollValue=2; 802 if (deviceSize <= 925){ 803 var numScroll='+=1'; 804 var scrollValue=1; 805 } 806 } 807 } 808 809 810 if ($('body').hasClass('theme24') || $('body').hasClass('theme26') || $('body').hasClass('cpcorp') && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 811 if(deviceSize <= 980 && deviceSize > 710){ 812 var numScroll='+=2'; 813 var scrollValue=2; 814 } 815 if (deviceSize <= 710){ 816 var numScroll='+=1'; 817 var scrollValue=1; 818 } 819 } 820 821 if ($('body').hasClass('theme25') || $('body').hasClass('theme27') 822 && $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings")){ 823 if(deviceSize <= 1095 && deviceSize > 680){ 824 var numScroll='+=2'; 825 var scrollValue=2; 826 } 827 if (deviceSize <= 680){ 828 var numScroll='+=1'; 829 var scrollValue=1; 830 } 831 } 832 833 if ($('body').hasClass('theme12') && $('[id*="office_agent_listings"]').length === 1 && semiReference_path.indexOf('office_agent_listings') != -1){ 834 if(deviceSize <= 900){ 835 var numScroll='+=2'; 836 var scrollValue=2; 837 if (deviceSize <= 744){ 838 var numScroll='+=1'; 839 var scrollValue=1; 840 } 841 } 842 } 843 844 if (($('body').hasClass('theme7') || $('body').hasClass('theme8')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 845 if (deviceSize <= 1136 && deviceSize > 835) { 846 var numScroll='+=2'; 847 var scrollValue=2; 848 } 849 if (deviceSize <= 835){ 850 var numScroll='+=1'; 851 var scrollValue=1; 852 } 853 } 854 855 if (($('body').hasClass('theme9') || $('body').hasClass('theme23')) && $('body').hasClass('front')){ 856 857 if(deviceSize <= 1050){ 858 var numScroll='+=2'; 859 var scrollValue=2; 860 if (deviceSize <= 720){ 861 var numScroll='+=1'; 862 var scrollValue=1; 863 } 864 } 865 } 866 867 if ($custom_active_li_limit && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 868 if($custom_active_li_limit > 4){ // for theme12 869 if (deviceSize <= 770){ 870 var numScroll='+=4'; 871 var scrollValue=4; 872 } 873 else if(deviceSize <= 1070){ 874 var numScroll='+=6'; 875 var scrollValue=6; 876 } 877 else{ 878 var numScroll='+='+$custom_active_li_limit; 879 var scrollValue=$custom_active_li_limit; 880 } 881 } 882 else{ 883 if (deviceSize <= 1300){ 884 var numScroll='+=2'; 885 var scrollValue=2; 886 } else{ 887 var numScroll='+='+$custom_active_li_limit; 888 var scrollValue=$custom_active_li_limit; 889 } 890 } 891 } 892 if($custom_active_li_limit && $listing_mode == 3 && $region != 'wsidebar_right' ){ 893 if (deviceSize <= 500){ 894 var numScroll='+=1'; 895 var scrollValue=1; 896 } else if (deviceSize <= 900){ 897 var numScroll='+=2'; 898 var scrollValue=2; 899 } 900 } 901 902 if (($('body').hasClass('theme15') || $('body').hasClass('theme16') || $('body').hasClass('theme20') || $('body').hasClass('theme21') || $('body').hasClass('theme22')) && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 903 if (deviceSize <= 1095 && deviceSize > 680) { 904 var numScroll='+=2'; 905 var scrollValue=2; 906 } 907 if (deviceSize <= 680){ 908 var numScroll='+=1'; 909 var scrollValue=1; 910 } 911 } 912 913 914 if (($('body').hasClass('theme17') || $('body').hasClass('theme19')) && $('body').hasClass('front')){ 915 if (deviceSize <= 1140) { 916 var numScroll='+=2'; 917 var scrollValue=2; 918 if (deviceSize <= 600){ 919 var numScroll='+=1'; 920 var scrollValue=1; 921 } 922 } 923 } 924 925 926 if ($('body').hasClass('theme18') && $('body').hasClass('front')){ 927 if (deviceSize <= 1024) { 928 var numScroll='+=2'; 929 var scrollValue=2; 930 if (deviceSize <= 640){ 931 var numScroll='+=1'; 932 var scrollValue=1; 933 } 934 } 935 } 936 937 938 939 } 940 941 else if(widget.scrollClass=="vertical_scroll"){ //vertical autoscroll 942 if($region == 'frontpage_left_lavish' || $region =='frontpage_middle_lavish' || $region == 'frontpage_right_lavish' ) 943 { 944 var numScroll='+=1'; 945 var scrollValue=1; 946 } 947 else 948 { 949 var numScroll='+=3'; 950 var scrollValue=3; 951 } 952 953 } 954 // Add Carousel Reference into widget for further manipulation.
955 widget.carousel = $(fullReference_path).jcarouselAutoscroll({ 956 interval: 4000, 957 target: numScroll, 958 autostart: false, 959 scroll:scrollValue 960 }).on('mouseover',function(e){ 961 $(this).jcarouselAutoscroll('stop'); 962 }).on('mouseout',function(e){ 963 $(this).jcarouselAutoscroll('start'); 964 }); 965} 966 967function appendNew_carousel_item(no_of_loadProperty,fullReference_path,semiReference_path,carouselId,carouselObj,idleFlag_val,$listing_mode,deviceSize,$custom_active_li_limit, settings) 968{ 969 var last_Index=carouselObj.index(carouselObj._last); // total element loaded in loaded index starting from 0 970 var upcoming_visibel_elem= carouselObj.items().length-7; // position of first element in the last index carousel 971 var response_end=$(semiReference_path+" .response_end").attr("value"); 972 var idleFlag_val=$(semiReference_path+" .idleState").attr("value"); 973 if(last_Index >= upcoming_visibel_elem){ 974 if(idleFlag_val==1 && no_of_loadProperty >= 6 && response_end==1){ 975 var listing_fl=$(semiReference_path+" .listing_fl").attr("value"); 976 var source=$(semiReference_path+" .source_fl").attr("value"); 977 var type=$(semiReference_path+" .type_fl").attr("value"); 978 var residential_type_val=$(semiReference_path+" .residential_type_fl").attr("value"); 979 var single_mul=$(semiReference_path+" .single_mul_fl").attr("value"); 980 var property_display=$(semiReference_path+" .property_display_fl").attr("value"); 981 var sale_value=$(semiReference_path+" .sale_fl").attr("value"); 982 var rent_value=$(semiReference_path+" .rent_fl").attr("value"); 983 var sold_value=$(semiReference_path+" .sold_fl").attr("value"); 984 var soldconditionally_value=$(semiReference_path+" .sold_conditionally").attr("value"); 985 var min_price_value = $(semiReference_path+" .min_price_fl").attr("value"); 986 var max_price_value = $(semiReference_path+" .max_price_fl").attr("value"); 987 var city=$(semiReference_path+" .city_fl").attr("value"); 988 var mls=$(semiReference_path+" .mls_fl").attr("value"); 989 var postal_code=$(semiReference_path+" .zip_fl").attr("value"); 990 var limit_val=$(semiReference_path+" .limit_count").attr("value"); 991 var orderByreference=$(semiReference_path+" .order_by_reference").attr("value"); 992 var total_count=$(semiReference_path+" .total_count").attr("value"); 993 var specified_aid= $(semiReference_path+" .specified_aid").attr("value"); 994 var new_limit=parseInt(limit_val)+3; 995 var end_limit_diff=0; 996 997 if ($custom_active_li_limit && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 998 if($custom_active_li_limit > 4 && limit_val >=24 && deviceSize > 770 && deviceSize <= 1070){ 999 new_limit =parseInt(limit_val) + 6; 1000 var end_limit_diff = 6; 1001 } 1002 else{ 1003 $custom_limit = parseInt($custom_active_li_limit); 1004 new_limit =parseInt(limit_val) + $custom_limit; 1005 } 1006 } 1007 var host = window.location.host; 1008 var http_or_https = window.location.protocol; 1009 var purl = http_or_https+"//"+host+"/featured_property_loader"; 1010 1011 if(settings) { 1012 settings['skip'] = limit_val; 1013 settings['limit'] = new_limit - limit_val; 1014 $.ajax({
1015 url: purl, 1016 type:"POST", 1017 data: JSON.stringify(settings), 1018 contentType: "application/json; charset=utf-8", 1019 dataType : "json", 1020 success: function(response) { 1021 if(response.properties && response.properties.message ) { 1022 // Stop loading more if reached end of results. 1023 $(semiReference_path+" .response_end").attr("value",0); 1024 } 1025 if(response.properties && response.properties.length) { 1026 for(var i in response.properties) { 1027 settings["index"] += 1; 1028 $(fullReference_path + " ul").append(generatePropertyView(response.properties[i], settings)); 1029 } 1030 // Add custom event so that we can detect when featured listing has its properties appended. 1031 featuredWidgets.triggerEvent("featuredPropertiesAdded",{"widgetId":"#featuredListing-0-"+settings.widget_id}); 1032 $(fullReference_path).jcarousel("reload"); 1033 $(semiReference_path + " .limit_count").attr("value",new_limit); 1034 if(new_limit > 100){ 1035 // Stop loading more if 100 properties loaded. 1036 $(semiReference_path+" .response_end").attr("value",0); 1037 } 1038 if(check_theme_active_li_exist($listing_mode,$custom_active_li_limit)){ 1039 check_carousel_last_slide(fullReference_path,deviceSize,$custom_active_li_limit); 1040 } 1041 return; 1042 } 1043 }, 1044 error: function(data, error) { 1045 } 1046 }); 1047 return; 1048 } 1049 //console.log(purl); 1050 $.ajax({
1051 url: purl, 1052 type:"get", 1053 data:{ 1054 listing_type_val:source, 1055 property_type_val:type, 1056 residential_type:residential_type_val, 1057 single_mul_val:single_mul, 1058 property_display_val:property_display, 1059 sale_val:sale_value, 1060 rent_val:rent_value, 1061 sold_val:sold_value, 1062 soldcondionally_val:soldconditionally_value, 1063 min_price: min_price_value, 1064 max_price: max_price_value, 1065 orderByreference_val:orderByreference, 1066 city_val:city, 1067 mls_val:mls, 1068 zip_val:postal_code, 1069 limit_val_start:limit_val, 1070 end_limit_val:end_limit_diff, 1071 specified_aid:specified_aid 1072 }, 1073 dataType : "json", 1074 success: function(response) { 1075 if(response["html"] != ""){ 1076 $(fullReference_path+" ul").append(response["html"]); 1077 $(fullReference_path).jcarousel("reload"); 1078 $(semiReference_path+" .limit_count").attr("value",new_limit); 1079 //If the type of the listing is All or City based then only 300 properties will load 1080 if((new_limit==300 || new_limit ==304) && (source=='3' || source=='5')){ 1081 $(semiReference_path+" .response_end").attr("value",0); 1082 } 1083 if(check_theme_active_li_exist($listing_mode,$custom_active_li_limit)){ 1084 check_carousel_last_slide(fullReference_path,deviceSize,$custom_active_li_limit); 1085 } 1086 } 1087 else{ 1088 $(semiReference_path+" .response_end").attr("value",0); 1089 if(check_theme_active_li_exist($listing_mode,$custom_active_li_limit)){ 1090 check_carousel_last_slide(fullReference_path,deviceSize,$custom_active_li_limit); 1091 } 1092 } 1093 }, 1094 error: function(data, error) { 1095 } 1096 }); 1097 } 1098 } 1099} 1100 1101function generatePropertyView(property, settings) { 1102 var event = ' onclick="property_view_app(event,' + property.PID + ')"' 1103 var forRequired = ['Lease', 'Sale', 'Rent'] 1104 var listingTypeTitle = ''; 1105 var propertyUrl = encodeURI(property.seoURL); 1106 var isBrokerDetailPage = (($('body').hasClass('inner') || $('body').hasClass('urban')) && $('body').hasClass('office-detail')); 1107 1108 if(forRequired.indexOf(property.listingType) != -1) { 1109 listingTypeTitle = 'for '; 1110 } 1111 listingTypeTitle += property.listingType; 1112 1113 if (settings.agent_name == null){ settings.agent_name = '';} 1114 if (settings.office_name == null){ settings.office_name = '';} 1115 if (settings.partner_agent_name == null){ settings.partner_agent_name = '';} 1116 1117 var seoTitle = property.Address 1118 + ' ' + property.City 1119 + ' ' + property.Province 1120 + ' ' + property.Country 1121 + ' ' + listingTypeTitle 1122 + ' ' + property.searchType 1123 + ' ' + settings.agent_name; 1124 if(settings.partner_agent_name) { 1125 seoTitle += ' ' + settings.partner_agent_name; 1126 } 1127 seoTitle += ' ' + settings.office_name; 1128 1129 var seoAlt = buildImageAltText(property, settings); 1130 1131 var isCommercialProperty = property.searchType === 'commercial'; 1132 1133 var propertyBody = '<li>' 1134 1135 var isVOW = 0; 1136 if(settings.hiddenVOWCLass && property.isVOW) { 1137 isVOW = 1; 1138 1139 // respect domain ids, primarily for perm_adv rules 1140 var domID = parseInt(settings.currentDomainID); 1141 if(typeof property.domainIDs != 'undefined' && property.domainIDs.indexOf(domID) !== -1){ 1142 if(property.BoardIDs.indexOf(29) !== -1 && isSoldProperty(property)){ 1143 isVOW = 1; 1144 } 1145 else{ 1146 isVOW = 0; 1147 } 1148 } 1149 1150 // multi source vow support. check for listings that can be VOW and available between sources 1151 if(typeof window.settings.BoardLimit != 'undefined'){ 1152 var vowBoards = [29, 49, 50, 52, 54, 55]; 1153 var boardids = property.BoardIDs.filter(function(el){ return !vowBoards.includes(el)}); 1154 if(boardids.length !== 0){ 1155 for(var i in boardids) { 1156 if(window.settings.BoardLimit.indexOf(boardids[i]) !== -1){ 1157 isVOW = 0; 1158 } 1159 } 1160 } 1161 } 1162 1163 // sold should always be vow 1164 if(isSoldProperty(property) && window.settings.currentUser.uid == 0){ 1165 isVOW = 1; 1166 } 1167 1168 // catch all 1169 var flagVow = false; 1170 if ((window.settings.currentUser != 'undefined') && (profile.settings.emailconf == 0)){ 1171 if ((window.settings.currentUser.uid != 'undefined') && (window.settings.currentUser.uid != 0) && (window.settings.currentUser.login == 0)){ 1172 flagVow = true; 1173 isVOW = 1; 1174 } 1175 else if((window.settings.currentUser.uid != 'undefined') && (window.settings.currentUser.uid >= 0 && window.settings.currentUser.login == 1)){ 1176 isVOW = 0; 1177 } 1178 } 1179 1180 var textVow1 =''; 1181 var textVow2 = ''; 1182 vowspanClass = ''; 1183 if (flagVow){ 1184 textVow1 ='CONFIRM YOUR EMAIL TO SEE DETAILS OF THE LISTINGS';
1185 textVow2 = '<span class ="vow_desc_small_txt"><strong>Email</strong> Verification Required</span>'; 1186 vowspanClass = ' class="confirmEmail"'; 1187 } else{ 1188 textVow1 ='<span class="vow_account"><strong>VIP</strong> Account required to view additional property information. <strong class="signup">Sign Up Now.</strong></span>'; 1189 textVow2 = ''; 1190 } 1191 1192 1193 if(isVOW == 1){ 1194 seoTitle = ''; 1195 seoAlt = 'Exclusive Listing'; 1196 propertyBody = '<li class= "cls_hidden">' 1197 propertyBody += '<div class="cls_hidden">' 1198 + '<p class="cls_hidden_message"><span class="vow-info">' 1199 + '<span class="vow-city">'+ property.City +'</span>'; 1200 if (property.listingType == "Sold" || property.listingType == "Rented" || property.listingType == "Leased") { 1201 propertyBody += '<span class="vow-status ' + property.listingType.toLowerCase() + '">' + property.listingType + ' On '+ new Date(property.soldOn*1000).toDateString().slice(4) +'</span>'; 1202 } else { 1203 propertyBody += '<span class="vow-status ' + property.listingType.toLowerCase() + '">For '+ property.listingType +'</span>'; 1204 } 1205 propertyBody += '</span><a href="' + propertyUrl + '" ' 1206 + event 1207 + ' data-op="register"'+ vowspanClass + 1208 '"><span class="text_vow_wrapper">' + textVow1 + textVow2 1209 + '</span><span class="vow_locker">' 1210 + '<span class="bg-locker">' 1211 + '</span></span></a>' 1212 + '</p>' 1213 + '</div>' 1214 } 1215 } 1216 1217 propertyStatus = property.listingType ? property.listingType.toLowerCase().replace(/\s+/g, '') : ''; 1218 propertyBody += '<div class="property_div clearfix for' + propertyStatus + '" data-pid="'+property.PID+'">' 1219 propertyBody += '<a href="' + property.seoURL + '"' 1220 + 'class="featured_multi_img_wrapper" ' 1221 + 'alt="' + seoAlt + '" title="' + seoTitle + '"' 1222 + event + '>'; 1223 1224 // For ccs based For Sale, For rent, Sold label 1225 propertyBody += '<span class="listingType"></span>' 1226 1227 // if isVow and User is not logged in. 1228 if(isVOW) { 1229 propertyBody += '<img src="" class="feature_ribbon lock locked-prop" alt="" />'; 1230 } else { 1231 propertyBody += '<img src="/modules/widgets/featured_listing/images/ribbon.png" class="feature_ribbon" alt="Featured Listing" />'; 1232 } 1233 var noImage = '/images/noImage.jpg'; 1234 var imgUrl = noImage; 1235 if (isCommercialProperty) { 1236 imgUrl = '/images/noImageCommercial.jpg'; 1237 } 1238 var loadClass = ''; 1239 if(property.images && property.images.length) { 1240 // If property has images use loader and preload images. 1241 loadClass = 'loading'; 1242 imgUrl = '/modules/widgets/featured_listing/images/loader.svg'; 1243 var imageEl = '#featuredListing-0-'+settings.widget_id+' .property_div[data-pid="'+property.PID+'"] img.featured'; 1244 var events = ['featuredReady','featuredPropertiesAdded']; 1245 for(i in events){ 1246 var loadEvent = document.addEventListener(events[i], function(e){ 1247 featuredWidgets.loadImage(imageEl, property.images[0], settings); 1248 document.removeEventListener(events[i],loadEvent); // cleanup after firing 1249 }); 1250 }; 1251 } 1252 1253 propertyBody += '<img src="' + imgUrl + '" class="featured '+loadClass+'" alt="' + seoAlt + '" title="' + seoTitle + '"/>'; 1254 1255 propertyBody += '</a>' 1256 propertyBody += '<div class="wrapperFeature">' 1257 propertyBody += '<div class="item bookmark"></div>' 1258 1259 if (($('body').hasClass('cpcorp') || $('body').hasClass('righthome')) && $('body').hasClass('front') && property.Address && property.City){ //cpcorp theme and rightathome 1260 property.Address = property.Address + ', ' + property.City; 1261 } 1262 1263 if (($('body').hasClass('theme28') || $('body').hasClass('theme29') || $('body').hasClass('theme30') || $('body').hasClass('theme31') || $('body').hasClass('theme32') || $('body').hasClass('theme33') || $('body').hasClass('theme34') || $('body').hasClass('theme35')) && ($('body').hasClass('front') || ($('body').attr('class').indexOf('buy-homes-for-sale') > -1) || ($('body').attr('class').indexOf('buy-commercial-for-sale') > -1)) && property.Address && property.City){ 1264 property.Address = property.Address + ', ' + property.City; 1265 } 1266 1267 if(($('body').hasClass('buying-tips') && property.Address && property.City)){ 1268 property.Address = property.Address + ', ' + property.City; 1269 } 1270 /*if (($('body').hasClass('theme30') || $('body').hasClass('theme31')) && ($('body').hasClass('front') || ($('body').attr('class').indexOf('buy-homes-for-sale') > -1)) && property.Address){ 1271 const matches = property.Address.match(/(\d+)/ig); 1272 if (matches && matches.length > 1) { 1273 property.Address = property.Address.replace(/(\d)+[^a-z]*(\d)+/ig, "<span>$&</span>"); 1274 } else { 1275 property.Address = property.Address.replace(/(\d+)/ig, "<span>$&</span>"); 1276 } 1277 }*/ 1278 1279 if(property.Address && property.Address.length > 29) {
1280 propertyBody += '<div class="featuredListingAddress">' 1281 + '<a class="tooltip" href="javascript:void(0)">' 1282 + '<span class="shorttip">' + property.Address.substring(0, 25) + ' ...</span>' 1283 + '<span class="fulltip">' + property.Address + '</span>' 1284 + '</a>' 1285 + '</div>' 1286 } else { 1287 propertyBody += '<div class="featuredListingAddress">' + property.Address + '</div>' 1288 } 1289 1290 if(settings['property_extra'] === 1 && property.MarketingRemarks){ 1291 propertyBody += '<div class="property_extra"><p>' 1292 +property.MarketingRemarks.split(" ").splice(0,15).join(" ") 1293 +'...</p></div>'; 1294 } else if (isBrokerDetailPage) { 1295 if (property.MarketingRemarks) { 1296 propertyBody += '<div class="property_extra"><p>' 1297 +property.MarketingRemarks 1298 +'</p></div>'; 1299 } 1300 propertyBody += '<a href="' + propertyUrl + '" class="featured-view-details" ' + event + '>' + 'view details</a>'; 1301 } 1302 1303 var Bedrooms = property.Details.Bedrooms; 1304 if( property.Details.BedroomsAboveGround && property.Details.BedroomsAboveGround > 0) { 1305 if( property.Details.BedroomsBelowGround && property.Details.BedroomsBelowGround > 0) { 1306 Bedrooms = property.Details.BedroomsAboveGround + ' + ' + property.Details.BedroomsBelowGround; 1307 } 1308 } 1309 1310 if(Bedrooms == 0) { 1311 Bedrooms = ''; 1312 } 1313 1314 propertyBody += '<div class="price_bedroom_bathroom">'; 1315 1316 if (settings.widget_id==34748){ //homelife.ca 1317 propertyBody += '<div class="featuredListingPrice">'; 1318 if(property.Price) { 1319 var PropertyPriceUnit = ''; 1320 if(property.listingType == 'Lease' || property.listingType == 'Rent'){ // For lease/rent property only 1321 var actual_price_unit = '/MO'; 1322 if(typeof property.PriceUnits !== 'undefined' && property.PriceUnits != ''){ 1323 var actual_price_unit = _get_actual_price_unit(property.PriceUnits); 1324 } 1325 if(actual_price_unit != ''){ 1326 PropertyPriceUnit = '<span class="price_unit">'+actual_price_unit+'</span>'; 1327 } 1328 } 1329 propertyBody += '<span>' 1330 + '$' 1331 + property.Price.toLocaleString('en', {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(/\.00$/, '') 1332 + PropertyPriceUnit 1333 + '</span>' 1334 } 1335 propertyBody +='</div>'; 1336 } 1337 1338 var propertyLotSquareFootage = property.LotSquareFootage; 1339 if (isCommercialProperty) { 1340 if ( propertyLotSquareFootage && propertyLotSquareFootage > 0) { 1341 propertyBody += '<span class="featuredListingSquareFootage">' + propertyLotSquareFootage + '<span> sqft</span></span>' 1342 } 1343 } else { 1344 if(Bedrooms != '') { 1345 propertyBody += '<span class="featuredListingBedroom">' + Bedrooms + '</span>' 1346 } 1347 if(property.Details.Bathrooms && property.Details.Bathrooms > 0) { 1348 propertyBody += '<span class="featuredListingBathroom">' + property.Details.Bathrooms + '</span>' 1349 } 1350 } 1351 1352 if(property.City && property.City.length > 12) { 1353 propertyBody += '<span class="featuredListingCity">' 1354 + '<a class="tooltipcity" href="javascript:void(0)">' 1355 + '<span>' + property.City.substring(0, 10) + ' ...</span>' 1356 + '<span class="fulltipcity">' + property.City + '</span>' 1357 + '</a>' 1358 + '</span>' 1359 } else { 1360 propertyBody += '<span class="featuredListingCity">' + property.City + '</span>' 1361 } 1362 1363 propertyBody += '</div><!--price_bedroom_bathroom-->' 1364 1365 propertyBody += '<div class="featuredListingPrice">'; 1366 if(property.Price) { 1367 var PropertyPriceUnit = ''; 1368 if(property.listingType == 'Lease' || property.listingType == 'Rent'){ // For lease/rent property only 1369 var actual_price_unit = '/MO'; 1370 if(typeof property.PriceUnits !== 'undefined' && property.PriceUnits != ''){ 1371 var actual_price_unit = _get_actual_price_unit(property.PriceUnits); 1372 } 1373 if(actual_price_unit != ''){ 1374 PropertyPriceUnit = '<span class="price_unit">'+actual_price_unit+'</span>'; 1375 } 1376 } 1377 var isPropSold = property.Status === 'Sold' || property.Status === 'Leased' || property.Status === 'Rented'; 1378 var hasSoldPrice = typeof property.soldPrice === "undefined" || property.soldPrice == '0'; 1379 if (!(isPropSold && hasSoldPrice)) {
1380 propertyBody += '<span class="featuredPricePlaceholder">' 1381 + '$' 1382 + property.Price.toLocaleString('en', {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(/\.00$/, '') 1383 + PropertyPriceUnit 1384 + '</span>' 1385 } 1386 } 1387 propertyBody += '<a href="' + propertyUrl + '" class="featured_readmore" ' + event + '>'; 1388 propertyBody += 'Read More</a>' 1389 propertyBody += '</div><!--featuredListingPrice-->' 1390 propertyBody += '</div><!--wrapper-->' 1391 if (isBrokerDetailPage) { 1392 propertyBody += '<div class="carousel-index">' + ((settings.index < 10 ? '0' : '') + settings.index) +'</div>'; 1393 } 1394 propertyBody += '</div><!--property_div-->' 1395 propertyBody += '</li>' 1396 1397 return propertyBody; 1398} 1399 1400function isSoldProperty(details) { 1401 if (details && details.listingType) { 1402 switch (details.listingType) { 1403 case "Sold": 1404 case "Leased": 1405 case "Rented": { 1406 return true; 1407 } 1408 } 1409 } 1410 return false; 1411} 1412 1413// Pre-construction condo ajax listings function 1414function appendNew_carousel_condo_item(no_of_loadProperty,fullReference_path,semiReference_path,carouselId,carouselObj,idleFlag_val,$listing_mode,deviceSize,$custom_active_li_limit) 1415{ 1416 var last_Index=carouselObj.index(carouselObj._last); // total element loaded in loaded index starting from 0 1417 var upcoming_visibel_elem= carouselObj.items().length-7; // position of first element in the last index carousel 1418 var response_end=$(semiReference_path+" .response_end").attr("value"); 1419 var idleFlag_val=$(semiReference_path+" .idleState").attr("value"); 1420 if(last_Index >= upcoming_visibel_elem){ 1421 if(idleFlag_val==1 && no_of_loadProperty >= 6 && response_end==1){ 1422 var listing_fl=$(semiReference_path+" .listing_fl").attr("value"); 1423 var type_of_condo_listing_val=$(semiReference_path+" .type_of_condo_listing_fl").attr("value"); 1424 var condo_builders_type_val=$(semiReference_path+" .condo_builders_type_fl").attr("value"); 1425 var single_mul=$(semiReference_path+" .single_mul_fl").attr("value"); 1426 var property_display=$(semiReference_path+" .property_display_fl").attr("value"); 1427 var city=$(semiReference_path+" .city_fl").attr("value"); 1428 var limit_val=$(semiReference_path+" .limit_count").attr("value"); 1429 var total_count=$(semiReference_path+" .total_count").attr("value"); 1430 var new_limit=parseInt(limit_val)+3; 1431 var end_limit_diff=0; 1432 var condo_project_nids_val=$(semiReference_path+" .condo_project_nids_fl").attr("value"); 1433 var condo_project_sort_fl_val = $(semiReference_path+" .condo_project_sort_fl").attr("value"); 1434 if ($custom_active_li_limit && ($('body').hasClass('front') || $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 1435 if($custom_active_li_limit > 4 && limit_val >=24 && deviceSize > 770 && deviceSize <= 1070){ 1436 new_limit =parseInt(limit_val) + 6; 1437 var end_limit_diff = 6; 1438 } 1439 else{ 1440 $custom_limit = parseInt($custom_active_li_limit); 1441 new_limit =parseInt(limit_val) + $custom_limit; 1442 } 1443 } 1444 1445 var host = window.location.host; 1446 var http_or_https = window.location.protocol; 1447 $.ajax({
1448 url: http_or_https+'//'+host+"/featured_condo_loader", 1449 type:"get", 1450 data:{ 1451 ajax_mode:'on', 1452 listing_type:listing_fl, 1453 type_of_condo_listing:type_of_condo_listing_val, 1454 condo_builders_type:condo_builders_type_val, 1455 property_single_multiple:single_mul, 1456 property_display_val:property_display, 1457 condo_city:city, 1458 limit_val_start:limit_val, 1459 end_limit_val:end_limit_diff, 1460 condo_project_nids:condo_project_nids_val, 1461 condo_project_sort:condo_project_sort_fl_val 1462 }, 1463 dataType : "json", 1464 success: function(response) { 1465 if(response["html"]!=""){ 1466 $(fullReference_path+" ul").append(response["html"]); 1467 $(fullReference_path).jcarousel("reload"); 1468 $(semiReference_path+" .limit_count").attr("value",new_limit); 1469 //If the type of the listing is All or City based then only 300 properties will load 1470 if((new_limit==300 || new_limit ==304) && (source=='3' || source=='5')){ 1471 $(semiReference_path+" .response_end").attr("value",0); 1472 } 1473 if(check_theme_active_li_exist($listing_mode,$custom_active_li_limit)){ 1474 check_carousel_last_slide(fullReference_path,deviceSize,$custom_active_li_limit); 1475 } 1476 } 1477 else{ 1478 $(semiReference_path+" .response_end").attr("value",0); 1479 if(check_theme_active_li_exist($listing_mode,$custom_active_li_limit)){ 1480 check_carousel_last_slide(fullReference_path,deviceSize,$custom_active_li_limit); 1481 } 1482 } 1483 }, 1484 error: function(data, error) { 1485 } 1486 }); 1487 } 1488 } 1489} 1490 1491// Agents listings ajax callback function 1492function appendNew_carousel_agent_listings_item(no_of_loadProperty,fullReference_path,semiReference_path,carouselId,carouselObj,idleFlag_val) 1493{ 1494 var last_Index=carouselObj.index(carouselObj._last); // total element loaded in loaded index starting from 0 1495 var upcoming_visibel_elem= carouselObj.items().length-7; // position of first element in the last index carousel 1496 var response_end=$(semiReference_path+" .response_end").attr("value"); 1497 var idleFlag_val=$(semiReference_path+" .idleState").attr("value"); 1498 if(last_Index >= upcoming_visibel_elem){ 1499 if(idleFlag_val==1 && no_of_loadProperty >= 6 && response_end==1){ 1500 var sort_by_val = $(semiReference_path+" .sort_by").attr("value"); 1501 var order_by_val = $(semiReference_path+" .order_by").attr("value"); 1502 var limit_val=$(semiReference_path+" .limit_count").attr("value"); 1503 var total_count=$(semiReference_path+" .total_count").attr("value"); 1504 var new_limit=parseInt(limit_val)+3; 1505 var ajax_url = get_https_or_non_https_url('agent_listing_loader'); 1506 if ($('body').hasClass('cpcorp')){ 1507 ajax_url = get_https_or_non_https_url('agent_listing_loader_cpcorp'); 1508 } 1509 var agents_list_string_val = $(fullReference_path+" #broker_agent_list_aids").val(); 1510 $.ajax({ 1511 url: ajax_url, 1512 type:"get", 1513 data:{ 1514 ajax_mode:'on', 1515 agent_listing_sort:sort_by_val, 1516 agent_listing_order:order_by_val, 1517 limit_val_start:limit_val, 1518 agents_list_string:agents_list_string_val, 1519 }, 1520 dataType : "json", 1521 success: function(response) { 1522 if(response["html"]!=""){ 1523 $(fullReference_path+" ul").append(response["html"]); 1524 $(fullReference_path).jcarousel("reload"); 1525 $(semiReference_path+" .limit_count").attr("value",new_limit); 1526 //If the type of the listing is All or City based then only 300 properties will load 1527 if(new_limit==300 && (source=='3' || source=='5')){ 1528 $(semiReference_path+" .response_end").attr("value",0); 1529 } 1530 if(response["random_agent_string"] != ""){ 1531 $(fullReference_path+" #broker_agent_list_aids").val(response["random_agent_string"]); 1532 } 1533 } 1534 else{ 1535 $(semiReference_path+" .response_end").attr("value",0); 1536 } 1537 }, 1538 error: function(data, error) { 1539 } 1540 }); 1541 } 1542 } 1543} 1544 1545function check_carousel_last_slide(fullReference_path,deviceSize,$group_by) { 1546 var $total_elements = ''; 1547 $total_elements = $(fullReference_path+" ul li").length;
1547 // total elements in carousel after ajax processed 1548 1549 if($group_by > 4){ // for theme12 1550 if (deviceSize <= 770){ 1551 $group_by = 4; 1552 } 1553 else if(deviceSize <= 1070){ 1554 $group_by = 6; 1555 } 1556 else{ 1557 $group_by = $group_by; 1558 } 1559 }else{ // for theme10 1560 if(deviceSize > 1300) $group_by = $group_by; else $group_by = 2; 1561 } 1562 1563 $currentIndex = Math.ceil($total_elements / $group_by); // Last slide number of carousel 1564 $expected_elements = $currentIndex * $group_by; // what should be the elements on last slide (group of 4 or 2(Responsive slider)) 1565 $element_diff = $expected_elements - $total_elements; // how many element need more on last slide as a group of 4 1566 1567 if($element_diff != 0){ 1568 for(var i = 1; i <= $element_diff; i++) { 1569 $(fullReference_path+" ul").append('<li class="emptyLi"><div class="property_div clearfix"><a href="#" class="featured_multi_img_wrapper"></a></div></li>'); 1570 } 1571 $(fullReference_path).jcarousel('reload'); 1572 } 1573} 1574 1575function check_theme_active_li_exist($listing_mode,$custom_active_li_limit){ 1576 var $theme_active_li_flag = 0; 1577 if ($custom_active_li_limit != '' && $listing_mode != 3 && ($('body').hasClass('front') || 1578 $('body[class*="buy-homes-for-sale"] div').hasClass("widgets-featuredListings"))){ 1579 $theme_active_li_flag = 1; 1580 } 1581 return $theme_active_li_flag; 1582} 1583 1584function theme_process_active_li_4(semiReference_path,deviceSize){ 1585 1586 $(semiReference_path+" .jcarousel li").eq(0).addClass( "activeLi" ); 1587 $(semiReference_path+" .jcarousel li").eq(1).addClass( "activeLi"); 1588 1589 if(deviceSize > 1300){ 1590 $(semiReference_path+" .jcarousel li").eq(2).addClass( "activeLi" ); 1591 $(semiReference_path+" .jcarousel li").eq(3).addClass( "activeLi" ); 1592 } 1593 else{ 1594 $(semiReference_path+" a.jcarousel-control-prev").addClass('disable_prev'); 1595 } 1596 $(semiReference_path+" .jcarousel").on('jcarousel:targetin', 'li', function(event, carousel) { 1597 if(deviceSize <= 1300){ 1598 var slide_position_no = $(this).index(); 1599 1600 if(slide_position_no == 0){ // If user is on the first slide then prevent PREV link to click 1601 $(semiReference_path+" a.jcarousel-control-prev").addClass('disable_prev'); 1602 } 1603 else{ 1604 $(semiReference_path+" a.jcarousel-control-prev").removeClass('disable_prev'); 1605 } 1606 } 1607 console.log($(this)); 1608 $(this).addClass('activeLi'); 1609 $(this).next().addClass('activeLi'); 1610 if(deviceSize > 1300){ 1611 $(this).next().next().addClass('activeLi'); 1612 $(this).next().next().next().addClass('activeLi'); 1613 } 1614 }); 1615 1616 $(semiReference_path+" .jcarousel").on('jcarousel:targetout', 'li', function() { 1617 $(this).removeClass('activeLi'); 1618 $(this).next().removeClass('activeLi'); 1619 if(deviceSize > 1300){ 1620 $(this).next().next().removeClass('activeLi'); 1621 $(this).next().next().next().removeClass('activeLi'); 1622 } 1623 }); 1624 1625} 1626 1627function theme_process_active_li_8(semiReference_path,deviceSize){ 1628 1629 $(semiReference_path+" .jcarousel li").eq(0).addClass( "activeLi" ); 1630 $(semiReference_path+" .jcarousel li").eq(1).addClass( "activeLi"); 1631 $(semiReference_path+" .jcarousel li").eq(2).addClass( "activeLi" ); 1632 $(semiReference_path+" .jcarousel li").eq(3).addClass( "activeLi"); 1633 1634 if(deviceSize >= 770 && deviceSize <=1070 ){ // 6 properties 1635 $(semiReference_path+" .jcarousel li").eq(4).addClass( "activeLi" ); 1636 $(semiReference_path+" .jcarousel li").eq(5).addClass( "activeLi"); 1637 } 1638 else if(deviceSize > 1070){ // 8 properties case - default case 1639 $(semiReference_path+" .jcarousel li").eq(4).addClass( "activeLi" ); 1640 $(semiReference_path+" .jcarousel li").eq(5).addClass( "activeLi"); 1641 $(semiReference_path+" .jcarousel li").eq(6).addClass( "activeLi" ); 1642 $(semiReference_path+" .jcarousel li").eq(7).addClass( "activeLi" ); 1643 } 1644 1645 $(semiReference_path+" .jcarousel").on('jcarousel:targetin', 'li', function(event, carousel) { 1646 $(this).addClass('activeLi'); 1647 $(this).next().addClass('activeLi'); 1648 $(this).next().next().addClass('activeLi'); 1649 $(this).next().next().next().addClass('activeLi'); 1650 1651 if(deviceSize >= 770 && deviceSize <=1070 ){ // 6 properties 1652 $(this).next().next().next().next().addClass('activeLi'); 1653 $(this).next().next().next().next().next().addClass('activeLi'); 1654 } 1655 else if(deviceSize > 1070){ // 8 properties 1656 $(this).next().next().next().next().addClass('activeLi'); 1657 $(this).next().next().next().next().next().addClass('activeLi'); 1658 $(this).next().next().next().next().next().next().addClass('activeLi'); 1659 $(this).next().next().next().next().next().next().next().addClass('activeLi'); 1660 } 1661 }); 1662
1663 $(semiReference_path+" .jcarousel").on('jcarousel:targetout', 'li', function() { 1664 $(this).removeClass('activeLi flipY'); 1665 $(this).next().removeClass('activeLi flipY'); 1666 $(this).next().next().removeClass('activeLi flipY'); 1667 $(this).next().next().next().removeClass('activeLi flipY'); 1668 1669 if(deviceSize >= 770 && deviceSize <=1070 ){ // 6 properties 1670 $(this).next().next().next().next().removeClass('activeLi flipY'); 1671 $(this).next().next().next().next().next().removeClass('activeLi flipY'); 1672 } 1673 else if(deviceSize > 1070){ // 8 properties 1674 $(this).next().next().next().next().removeClass('activeLi flipY'); 1675 $(this).next().next().next().next().next().removeClass('activeLi flipY'); 1676 $(this).next().next().next().next().next().next().removeClass('activeLi flipY'); 1677 $(this).next().next().next().next().next().next().next().removeClass('activeLi flipY'); 1678 } 1679 }); 1680} 1681 1682function get_https_or_non_https_url(link){ 1683 var https_or_http = window.location.protocol; 1684 if(https_or_http == 'https:'){ // if the domain registered with https: 1685 var host_url = https_or_http+'//'+location.host+'/'+link; 1686 } 1687 else{ 1688 var host_url = '/'+link+'/'; 1689 } 1690 return host_url; 1691} 1692 1693function _get_actual_price_unit($priceUnit){ 1694 $priceUnit = $priceUnit.toLowerCase(); 1695 switch($priceUnit) { 1696 case "square feet": 1697 return '/sq ft'; 1698 break; 1699 case "square meters": 1700 return '/m2'; 1701 break; 1702 case "yearly": 1703 return '/yrly'; 1704 break; 1705 case "yearly/sq ft": 1706 return 'yrly/sq ft'; 1707 break; 1708 case "weekly": 1709 return '/wkly'; 1710 break; 1711 case "monthly/sq ft": 1712 return 'mthly/sq ft'; 1713 break; 1714 default: 1715 return '/'+$priceUnit; 1716 break; 1717 } 1718} 1719 1720function initializeSinglePropertyDisplay({ settings, properties }) { 1721 const widget = featuredWidgets.addWidget(settings.widget_id, properties, settings, properties.length); 1722 if (!properties || !properties.length) { 1723 return; 1724 } 1725 $(widget.selector + " .content").append(generateSinglePropertyView({ settings, property: properties[0] })); 1726 // Add custom event so that we can detect when featured listing has its properties appended. 1727 featuredWidgets.triggerEvent("featuredReady", { widgetId: widget.selector }); 1728} 1729 1730function generateSinglePropertyView({ settings, property }) { 1731 var event = ' onclick="property_view_app(event,' + property.PID + ')"'; 1732 var forRequired = ["Lease", "Sale", "Rent"]; 1733 var listingTypeTitle = ""; 1734 var propertyUrl = encodeURI(property.seoURL); 1735 if (forRequired.indexOf(property.listingType) != -1) { 1736 listingTypeTitle = "for "; 1737 } 1738 listingTypeTitle += property.listingType; 1739 1740 if (settings.agent_name == null) { 1741 settings.agent_name = ""; 1742 } 1743 if (settings.office_name == null) { 1744 settings.office_name = ""; 1745 } 1746 1747 if (settings.partner_agent_name == null) { 1748 settings.partner_agent_name = ""; 1749 } 1750 var seoTitle = 1751 property.Address + 1752 " " + 1753 property.City + 1754 " " + 1755 property.Province + 1756 " " + 1757 property.Country + 1758 " " + 1759 listingTypeTitle + 1760 " " + 1761 property.searchType + 1762 " " + 1763 settings.agent_name; 1764 if(settings.partner_agent_name) { 1765 seoTitle += " " + settings.partner_agent_name; 1766 } 1767 seoTitle += 1768 " " + 1769 settings.office_name; 1770 1771 var seoAlt = buildImageAltText(property, settings); 1772 1773 var isCommercialProperty = property.searchType === "commercial"; 1774 1775 var propertyWrapperStart = ""; 1776 var propertyWrapperEnd = ""; 1777 var propertyVowBody = ""; 1778 var propertyBody = ""; 1779 1780 var isVOW = 0; 1781 if (settings.hiddenVOWCLass && property.isVOW) { 1782 isVOW = 1; 1783 1784 // respect domain ids, primarily for perm_adv rules 1785 var domID = parseInt(settings.currentDomainID); 1786 if (typeof property.domainIDs != "undefined" && property.domainIDs.indexOf(domID) !== -1) { 1787 if (property.BoardIDs.indexOf(29) !== -1 && isSoldProperty(property)) { 1788 isVOW = 1; 1789 } else { 1790 isVOW = 0; 1791 } 1792 } 1793
1794 // multi source vow support. check for listings that can be VOW and available between sources 1795 if (typeof window.settings.BoardLimit != "undefined") { 1796 var vowBoards = [29, 49, 50, 52, 54, 55]; 1797 var boardids = property.BoardIDs.filter(function (el) { 1798 return !vowBoards.includes(el); 1799 }); 1800 if (boardids.length !== 0) { 1801 for (var i in boardids) { 1802 if (window.settings.BoardLimit.indexOf(boardids[i]) !== -1) { 1803 isVOW = 0; 1804 } 1805 } 1806 } 1807 } 1808 1809 // sold should always be vow 1810 if (isSoldProperty(property) && window.settings.currentUser.uid == 0) { 1811 isVOW = 1; 1812 } 1813 1814 // catch all 1815 var flagVow = false; 1816 if (window.settings.currentUser != "undefined" && profile.settings.emailconf == 0) { 1817 if ( 1818 window.settings.currentUser.uid != "undefined" && 1819 window.settings.currentUser.uid != 0 && 1820 window.settings.currentUser.login == 0 1821 ) { 1822 flagVow = true; 1823 isVOW = 1; 1824 } else if ( 1825 window.settings.currentUser.uid != "undefined" && 1826 window.settings.currentUser.uid >= 0 && 1827 window.settings.currentUser.login == 1 1828 ) { 1829 isVOW = 0; 1830 } 1831 } 1832 1833 var textVow1 = ""; 1834 var textVow2 = ""; 1835 var vowspanClass = ""; 1836 if (flagVow) { 1837 textVow1 = "CONFIRM YOUR EMAIL TO SEE DETAILS OF THE LISTINGS"; 1838 textVow2 = '<span class ="vow_desc_small_txt"><strong>Email</strong> Verification Required</span>'; 1839 vowspanClass = ' class="confirmEmail"'; 1840 } else { 1841 textVow1 = '<span class="vow_account"><strong>VIP</strong> Account required to view additional property information. <strong class="signup">Sign Up Now.</strong></span>'; 1842 textVow2 = ''; 1843 } 1844 1845 if (isVOW == 1) { 1846 seoTitle = ""; 1847 seoAlt = "Exclusive Listing"; 1848 propertyVowBody += 1849 '<div class="cls_hidden">' + 1850 '<p class="cls_hidden_message"><span class="vow-info">' + 1851 '<span class="vow-city">'+ property.City +'</span>'; 1852 if (property.listingType == "Sold" || property.listingType == "Rented" || property.listingType == "Leased") { 1853 propertyVowBody += '<span class="vow-status ' + property.listingType.toLowerCase() + '">' + property.listingType + ' On '+ new Date(property.soldOn*1000).toDateString().slice(4) +'</span>'; 1854 } else { 1855 propertyVowBody += '<span class="vow-status ' + property.listingType.toLowerCase() + '">For '+ property.listingType +'</span>'; 1856 } 1857 propertyVowBody += '</span><a href="' + 1858 propertyUrl + 1859 '" ' + 1860 event + 1861 ' data-op="register"' + 1862 vowspanClass + 1863 "><span class='text_vow_wrapper'>" + 1864 textVow1 + 1865 textVow2 + 1866 '</span><span class="vow_locker">' + 1867 '<span class="bg-locker">' + 1868 "</span></span></a>" + 1869 "</p>" + 1870 "</div>"; 1871 } 1872 } 1873 1874 // the following themes follow a different markup 1875 var isAlteredMarkupTheme = ["urban", "elegant", "cpcorp"].find((m) => 1876 document.querySelector("body").classList.contains(m) 1877 ); 1878 if (!isAlteredMarkupTheme) { 1879 propertyWrapperStart += 1880 '<div id="single_record_default"' + (isVOW === 1 ? ' class="vow-single-featured-listing"' : "") + ">"; 1881 propertyWrapperStart += 1882 '<div id="property_div_single"' + (isVOW === 1 ? ' class="cls_hidden single-hidden"' : "") + ">"; 1883 propertyWrapperEnd += "</div>"; 1884 propertyWrapperEnd += "</div>"; 1885 } 1886 1887 if (isAlteredMarkupTheme && isVOW === 1) { 1888 propertyWrapperStart += '<div class="cls_hidden single-hidden">'; 1889 propertyWrapperEnd += "</div>"; 1890 } 1891 1892 // feature display 1893 propertyLinkMarkup = 1894 '<a href="' + 1895 property.seoURL + 1896 '"' + 1897 'class="citylinkimg" ' + 1898 'data-list-type="for' + 1899 (property.listingType ? property.listingType.toLowerCase() : "") + 1900 '" data-pid="' + 1901 property.PID + 1902 '" data-source="' + 1903 property.BoardID + 1904 '" alt="' + 1905 seoAlt + 1906 '" title="' + 1907 seoTitle + 1908 '"' + 1909 event + 1910 ">"; 1911 1912 var noImage = "/images/noImage.jpg"; 1913 var imgUrl = noImage; 1914 if (isCommercialProperty) { 1915 imgUrl = '/images/noImageCommercial.jpg'; 1916 } 1917 var loadClass = ""; 1918 if (property.images && property.images.length) { 1919 // If property has images use loader and preload images. 1920 loadClass = "loading"; 1921 imgUrl = "/modules/widgets/featured_listing/images/loader.svg"; 1922 var imageEl = 1923 "#featuredListing-0-" + settings.widget_id + ' a[data-pid="' + property.PID + '"] img.featured_single'; 1924 var events = ["featuredReady", "featuredPropertiesAdded"]; 1925 for (i in events) { 1926 var loadEvent = document.addEventListener(events[i], function (e) { 1927 featuredWidgets.loadImage(imageEl, property.images[0], settings); 1928 document.removeEventListener(events[i], loadEvent); // cleanup after firing 1929 }); 1930 } 1931 } 1932 1933 var imgMarkup = 1934 '<img src="' + 1935 imgUrl + 1936 '" class="featured_single ' + 1937 loadClass + 1938 '" alt="' + 1939 seoAlt + 1940 '" title="' +
1941 seoTitle + 1942 '"/>'; 1943 1944 if (!isAlteredMarkupTheme) { 1945 imgMarkup = '<div class="main-city-image">' + imgMarkup + "</div>"; 1946 } 1947 1948 propertyLinkMarkup += imgMarkup; 1949 1950 propertyLinkMarkup += "</a>"; 1951 1952 if (!isAlteredMarkupTheme) { 1953 if (propertyVowBody.length) { 1954 propertyLinkMarkup = propertyVowBody + propertyLinkMarkup; 1955 } 1956 } 1957 1958 propertyBody += propertyLinkMarkup; 1959 1960 // details 1961 if (isAlteredMarkupTheme && propertyVowBody.length) { 1962 propertyBody += propertyVowBody; 1963 } 1964 1965 if (isAlteredMarkupTheme) { 1966 propertyBody += '<div class="widgetbottom">'; 1967 } 1968 1969 propertyBody += '<ul class="' + (!isAlteredMarkupTheme ? "featured-single" : "widget-single") + '">'; 1970 1971 // details - city 1972 if (property.City) { 1973 if (property.City.length > 12) { 1974 propertyBody += 1975 '<li class="City">City: ' + 1976 '<a class="tooltipcity" href="javascript:void(0)">' + 1977 "<span>" + 1978 property.City.substring(0, 10) + 1979 " ...</span>" + 1980 '<span class="fulltipcity">' + 1981 property.City + 1982 "</span>" + 1983 "</a>" + 1984 "</li>"; 1985 } else { 1986 propertyBody += '<li class="City">City: ' + property.City + "</li>"; 1987 } 1988 } 1989 1990 // details - price 1991 if (property.Price) { 1992 propertyBody += '<li class="Price">'; 1993 var PropertyPriceUnit = ""; 1994 if (property.listingType == "Lease" || property.listingType == "Rent") { 1995 // For lease/rent property only 1996 var actual_price_unit = "/MO"; 1997 if (typeof property.PriceUnits !== "undefined" && property.PriceUnits != "") { 1998 var actual_price_unit = _get_actual_price_unit(property.PriceUnits); 1999 } 2000 if (actual_price_unit != "") { 2001 PropertyPriceUnit = '<span class="price_unit">' + actual_price_unit + "</span>"; 2002 } 2003 } 2004 var isPropSold = property.Status === "Sold" || property.Status === "Leased" || property.Status === "Rented"; 2005 var hasSoldPrice = typeof property.soldPrice === "undefined" || property.soldPrice == "0"; 2006 if (!(isPropSold && hasSoldPrice)) { 2007 propertyBody += '<span class="PricePlaceholder">' + "Price: $"; 2008 propertyBody += property.Price.toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 }).replace(/\.00$/, ""); 2009 propertyBody += PropertyPriceUnit + "</span>"; 2010 } 2011 propertyBody += "</li>"; 2012 } 2013 2014 // details - property type 2015 if (property.PropertyType && property.PropertyType.length) { 2016 propertyBody += '<li class="Type">'; 2017 propertyBody += "Type: " + property.PropertyType; 2018 propertyBody += "</li>"; 2019 } 2020 // details - beds 2021 var property_bedrooms = property.Details.Bedrooms; 2022 if (property.Details.BedroomsAboveGround && property.Details.BedroomsAboveGround > 0) { 2023 if (property.Details.BedroomsBelowGround && property.Details.BedroomsBelowGround > 0) { 2024 property_bedrooms = property.Details.BedroomsAboveGround + " + " + property.Details.BedroomsBelowGround; 2025 } 2026 } 2027 2028 var property_has_beds = false; 2029 if (typeof property_bedrooms === "number" && property_bedrooms != 0) { 2030 property_has_beds = true; 2031 } else if (typeof property_bedrooms === "string" && property_bedrooms.length) { 2032 property_has_beds = true; 2033 } 2034 2035 // details - baths or sqaurefootage 2036 var footageOrigin = property.LotSquareFootageOrigin; 2037 var propertyLotSquareFootage = footageOrigin > 0 ? footageOrigin : property.LotSquareFootage; 2038 if (isCommercialProperty) { 2039 if (propertyLotSquareFootage && propertyLotSquareFootage > 0) { 2040 propertyBody += '<li class="SquareFootage">Lot Size: ' + propertyLotSquareFootage + "<span> sqft</span></li>"; 2041 } 2042 } else { 2043 if (property_has_beds) { 2044 propertyBody += '<li class="Bedroom">Bedrooms: ' + property_bedrooms + "</li>"; 2045 } 2046 if (property.Details.Bathrooms && property.Details.Bathrooms > 0) { 2047 propertyBody += '<li class="Bathroom">Bathrooms: ' + property.Details.Bathrooms + "</li>"; 2048 } 2049 } 2050 2051 // details - address 2052 propertyAddress = "More"; 2053 if (property.Address) { 2054 propertyAddressMarkup = '<li class="Address">Address: '; 2055 propertyAddressMarkup += '<a href="' + property.seoURL + '"' + event; 2056 if (property.Address.length > 29) { 2057 propertyAddress = property.Address.substring(0, 25); 2058 propertyAddressMarkup += ' class="tooltip"><span class="shorttip">' + propertyAddress;
2059 propertyAddressMarkup += '...</span><span class="fulltip">' + property.Address + "</span></a>"; 2060 } else { 2061 propertyAddress = property.Address; 2062 propertyAddressMarkup += ">" + propertyAddress + "</a>"; 2063 } 2064 propertyAddressMarkup += "</li>"; 2065 propertyBody += propertyAddressMarkup; 2066 } 2067 2068 // details - listing 2069 if (property.ListingID && property.ListingID.length) { 2070 propertyBody += 2071 '<li class="ListingNumber">Listing#: <a href="' + 2072 property.seoURL + 2073 '"' + 2074 event + 2075 ">" + 2076 property.ListingID + 2077 "</a></li>"; 2078 } 2079 propertyBody += "</ul>"; 2080 2081 // details - description 2082 if (property.MarketingRemarks && property.MarketingRemarks.length) { 2083 propertyBody += '<p class="description">' + property.MarketingRemarks + "</p>"; 2084 } 2085 2086 // details - read more 2087 propertyBody += 2088 '<a href="' + property.seoURL + '"' + event + ' class="alllink viewfulllink">View ' + propertyAddress + " </a>"; 2089 if (isAlteredMarkupTheme) { 2090 propertyBody += "</div>"; 2091 } 2092 propertyBody += "</div>"; 2093 2094 if (propertyWrapperStart.length && propertyWrapperEnd.length) { 2095 propertyBody = propertyWrapperStart + propertyBody; 2096 propertyBody += propertyWrapperEnd; 2097 } 2098 2099 return propertyBody; 2100} 2101 2102function buildImageAltText(property, settings) { 2103 var parts = [ 2104 property.Address, 2105 property.City, 2106 property.Province, 2107 property.Country, 2108 property.listingType, 2109 property.searchType 2110 ]; 2111 2112 var seoAlt = parts.map(function(val) { 2113 return (typeof val === 'string') ? val.trim() : ''; 2114 }).filter(function(val) { 2115 return val.length > 0; 2116 }).join(' '); 2117 2118 var agentName = settings.agent_name.trim(); 2119 var partnerAgentName = settings.partner_agent_name.trim(); 2120 2121 if (agentName && partnerAgentName) { 2122 seoAlt += ' - ' + agentName + ' and ' + partnerAgentName; 2123 } else if (agentName) { 2124 seoAlt += ' - ' + agentName; 2125 } 2126 seoAlt += ', ' + settings.office_name; 2127 return seoAlt; 2128} 2129
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.