Created
January 3, 2014 16:08
-
-
Save lswilson/8240505 to your computer and use it in GitHub Desktop.
Find a Rental: advice.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($){ | |
var locOpts = {}, | |
$locAutocomplete = $('#location-autocomplete'); | |
if(typeof window.baseSvcUrl !== 'undefined') | |
locOpts.baseSvcUrl = window.baseSvcUrl; | |
if(typeof window.baseValidationUrl !== 'undefined') | |
locOpts.baseValidationUrl = window.baseValidationUrl; | |
// Use our jq plugin above that leverages jq ui | |
if($locAutocomplete.length){ | |
$locAutocomplete.locationAutocomplete(locOpts); | |
} | |
// Make placeholders work for browsers that don't support them | |
if(!Modernizr.input.placeholder){ | |
$('input[type=text]').each(function(){ | |
var $input = $(this), | |
placeholder = $input.attr('placeholder'); | |
// If there's no placeholder, move onto next | |
if(!placeholder) | |
return true; | |
$input.setVal = function(){ | |
if($input.is(':focus')){ | |
$input.removeClass('quiet'); | |
if($input.val() === placeholder){ | |
$input.val(''); | |
// triggering focus allows locautocomplete to try again with empty val | |
$input.trigger('focus'); | |
} | |
}else{ | |
if($input.val() === ''){ | |
$input.val(placeholder).addClass('quiet'); | |
}else{ | |
$input.removeClass('quiet'); | |
} | |
} | |
} | |
$input.setVal(); | |
$input.on('focus blur change', function(){ | |
$input.setVal(); | |
}); | |
}); | |
} | |
$(document).ready(function(){ | |
/* For Blogs Only */ | |
var blogLocOpts = { | |
urlPrepend: 'http://www.realtor.com/realestateandhomes-search/', | |
urlAppend: '' | |
}; | |
if(typeof window.baseSvcUrl !== 'undefined') | |
blogLocOpts.baseSvcUrl = window.baseSvcUrl; | |
if(typeof window.baseValidationUrl !== 'undefined') | |
blogLocOpts.baseValidationUrl = window.baseValidationUrl; | |
var $blogFindAHome = $('#find-a-home-loc'),$blogFindARental = $('#find-a-rental-loc'); | |
if($blogFindAHome.length){ | |
$blogFindAHome.locationAutocomplete(blogLocOpts); | |
} | |
if($blogFindARental.length){ | |
$blogFindARental.locationAutocomplete({ | |
urlPrepend: 'http://www.realtor.com/homesforrent/', | |
urlAppend: '' | |
}); | |
} | |
/********************************************* | |
Tweaks to UCS | |
*********************************************/ | |
;(function(){ | |
var $body = $('body'); | |
$('#uscToolbarB').click(function(){ $body.removeClass('ucstoolbar-open ucstoolbar-closed')}); | |
$('#uscToolbarA').click(function(){ $body.removeClass('ucstoolbar-open ucstoolbar-closed')}); | |
// Replace MV Cookie function for UCS | |
if(!window.MV) | |
window.MV = { }; | |
$.extend(true, window.MV, { // attempt not to break anything if an MV lib does get added someday. This recursively merges the getSub function into MV. | |
util: { | |
Cookie: { | |
getSub: function(cookieName, subVar){ | |
try{ | |
var searchID = utils.ReadCookie(cookieName); | |
if(searchID) | |
searchID = utils.parseUrlVars(searchID)[subVar]; | |
return searchID ? searchID : ''; | |
}catch(e){} | |
} | |
} | |
} | |
}); | |
})(); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment