1(function ($) { 2 $(document).ready(function() { 3 4 $.fn.is_on_screen = function(){ 5 var win = $(window); 6 var viewport = { 7 top : win.scrollTop(), 8 left : win.scrollLeft() 9 }; 10 viewport.right = viewport.left + win.width(); 11 viewport.bottom = viewport.top + win.height(); 12 13 var bounds = this.offset(); 14 bounds.right = bounds.left + this.outerWidth(); 15 bounds.bottom = bounds.top + this.outerHeight(); 16 17 return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); 18 }; 19 20 //Default plugins 21 $("select:not(.hide)").each(function () { 22 $(this).select2({ 23 width: '100%', 24 minimumResultsForSearch: Infinity 25 }); 26 }); 27 28 $("select:not(.hide)").on("select2:open", function() { 29 30 //$('.select2-search input').prop('focus',false); 31 32 var stmClass = $(this).data('class'); 33 $('.select2-dropdown--below').parent().addClass(stmClass); 34 35 window.scrollTo(0, $(window).scrollTop() + 1); 36 window.scrollTo(0, $(window).scrollTop() - 1); 37 }); 38 39 $('img.lazy').lazyload({ 40 effect: "fadeIn", 41 failure_limit: Math.max('img'.length - 1, 0) 42 }); 43 44 var uniform_selectors = ':checkbox:not("#createaccount"),' + 45 ':radio:not(".input-radio")'; 46 47 $(uniform_selectors).not('#make_featured').uniform({}); 48 49 /*var yLG = $('#youtube-play-video-wrap'); 50 yLG.on('click', function(e) { 51 e.stopPropagation(); 52 e.preventDefault(); 53 54 $(this).lightGallery({ 55 iframe: true, 56 youtubePlayerParams: { 57 modestbranding: 1, 58 showinfo: 0, 59 rel: 0, 60 controls: 0 61 }, 62 dynamic: true, 63 dynamicEl: [{ 64 src : $('.video-popup-wrap').find('iframe').attr('src') 65 }], 66 download: false, 67 mode: 'lg-fade', 68 }); 69 })*/ 70 71 $('.owl-stage, .stm-single-image, .boat-gallery').lightGallery({ 72 selector: '.stm_fancybox', 73 mode : 'lg-fade', 74 download: false 75 }); 76 77 $('.owl-stage').lightGallery({ 78 selector: '.fancy-iframe', 79 mode: 'lg-fade', 80 download: false 81 }) 82 83 $('.fancy-iframe').lightGallery({ 84 selector: 'this', 85 iframeMaxWidth: '80%', 86 mode: 'lg-fade', 87 download: false 88 }) 89 90 $('#stm-google-map').lightGallery({ 91 selector: 'this', 92 iframeMaxWidth: '80%', 93 mode: 'lg-fade', 94 download: false 95 }) 96 97 $('.stm-carousel').lightGallery({ 98 selector: '.stm_fancybox', 99 mode : 'lg-fade', 100 download: false 101 }); 102 103 $('.stm-menu-trigger').on('click', function(){ 104 105 $('.stm-opened-menu-listing').toggleClass('opened'); 106 $(this).toggleClass('opened'); 107 if($(this).hasClass('opened') && $(this).hasClass('stm-body-fixed')) { 108 $('body').addClass('body-noscroll'); 109 } else { 110 $('body').removeClass('body-noscroll'); 111 } 112 }); 113 114 $('.stm-share').on('click', function (e) { 115 e.preventDefault(); 116 }); 117 118 $('.stm-shareble').on({ 119 mouseenter: function () { 120 $(this).parent().find('.stm-a2a-popup').addClass('stm-a2a-popup-active'); 121 }, 122 mouseleave: function () { 123 $(this).parent().find('.stm-a2a-popup').removeClass('stm-a2a-popup-active'); 124 } 125 }); 126 127 $("select[name='stm-multi-currency']").on("select2:select", function () { 128 var currency = $(this).val(); 129 130 $.cookie('stm_current_currency', encodeURIComponent(currency), { expires: 7, path: '/' }); 131 var data = $(this).select2('data'); 132 var selectedText = $(this).attr("data-translate").replace("%s", data[0].text); 133 134 $(".stm-multiple-currency-wrap").find("span.select2-selection__rendered").text(selectedText); 135 location.reload(); 136 }); 137 138 $('.sell-a-car-proceed').on('click', function(e){ 139 e.preventDefault(); 140 var step = $(this).data(step); 141 step = step.step; 142 143 if(step == '2') { 144 stm_validateFirstStep(); 145 var errorsLength = Object.keys(errorFields.firstStep).length; 146 if(errorsLength == 0) { 147 $('a[href="#step-one"]').removeClass('active'); 148 $('a[href="#step-two"]').addClass('active'); 149 $('.form-content-unit').slideUp(); 150 $('#step-two').slideDown(); 151 } 152 } 153 if(step == '3') { 154 $('a[href="#step-two"]').removeClass('active'); 155 $('a[href="#step-three"]').addClass('active'); 156 $('.form-content-unit').slideUp(); 157 $('#step-three').slideDown(); 158 $('a[href="#step-two"]').addClass('validated'); 159 } 160 }); 161 162 $('.stm-sell-a-car-form input[type="submit"]').on('click', function(e){ 163 stm_validateFirstStep(); 164 stm_validateThirdStep(); 165 166 $('a[href="#step-two"]').addClass('validated'); 167 168 var errorsLength = Object.keys(errorFields.firstStep).length; 169 var errorsLength2 = Object.keys(errorFields.thirdStep).length; 170 if(errorsLength != 0) { 171 e.preventDefault(); 172 $('.form-navigation-unit').removeClass('active'); 173 $('a[href="#step-one"]').addClass('active'); 174 $('#step-three').slideUp(); 175 $('#step-one').slideDown(); 176 } 177 178 if(errorsLength2 != 0) { 179 e.preventDefault(); 180 } else { 181 $('a[href="#step-three"]').addClass('validated'); 182 } 183 }) 184 185 stmShowListingIconFilter(); 186 }); 187 188 $(window).on('load',function () { 189 stmPreloader(); 190 stm_listing_mobile_functions(); 191 }); 192 193 function stmPreloader() { 194 if($('html').hasClass('stm-site-preloader')){ 195 $('html').addClass('stm-site-loaded'); 196 197 setTimeout(function(){ 198 $('html').removeClass('stm-site-preloader stm-site-loaded'); 199 }, 250); 200 } 201 } 202 203 function stm_listing_mobile_functions() { 204 $('.listing-menu-mobile > li.menu-item-has-children > a').append('<span class="stm_frst_lvl_trigger"></span>'); 205 $('body').on('click', '.stm_frst_lvl_trigger', function(e){ 206 e.preventDefault(); 207 $(this).closest('li').find('ul.sub-menu').slideToggle(); 208 $(this).parent().parent().toggleClass('show_submenu'); 209 $(this).parent().parent().toggleClass('active'); 210 $(this).toggleClass('active'); 211 }); 212 213 $('body').on('click', 'a.has-child', function(e){ 214 215 if($(this).hasClass('active')) { 216 $(this).parent().blur(); 217 $(this).toggleClass('active'); 218 } else { 219 e.preventDefault(); 220 $(this).toggleClass('active'); 221 } 222 }); 223 } 224 225 function stmShowListingIconFilter() { 226 $('.stm_icon_filter_label').on('click', function(){ 227 228 if(!$(this).hasClass('active')) { 229 $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter').toggleClass('active'); 230 $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter .image').hide(); 231 232 $(this).addClass('active'); 233 } else { 234 $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter').toggleClass('active'); 235 $(this).closest('.stm_icon_filter_unit').find('.stm_listing_icon_filter .image').show(); 236 237 $(this).removeClass('active'); 238 } 239 240 }); 241 } 242 243 window.STMCascadingSelect = function STMCascadingSelect(container, relations) { 244 this.relations = relations; 245 this.ctx = container; 246 this.options = { 247 selectBoxes: [] 248 }; 249 250 var self = this; 251 $.each(this.relations, function (slug, options) { 252 var selectbox = self.selectbox(slug, options); 253 254 if (selectbox && typeof selectbox === 'object') { 255 self.options.selectBoxes.push(selectbox); 256 } 257 }); 258 259 $(container).cascadingDropdown(this.options); 260 }; 261 262 STMCascadingSelect.prototype.selectbox = function (slug, config) { 263 var parent = config.dependency; 264 265 /*if (!$(this.selector(slug), this.ctx).length || (parent && !$(this.selector(parent), this.ctx).length)) { 266 return null; 267 }*/ 268 269 var $select = $(this.selector(slug), this.ctx); 270 var selected = $select.data('selected'); 271 272 if ($select.prop('multiple')) { 273 selected = selected ? selected.split(',') : []; 274 } 275 276 return { 277 selector: this.selector(slug), 278 paramName: slug, 279 requires: parent ? [this.selector(parent)] : null, 280 allowAll: config.allowAll, 281 selected: selected, 282 source: function (request, response) { 283 var selected = request[parent]; 284 var options = []; 285 $.each(config.options, function (i, option) { 286 if ((config.allowAll && !selected) || (option.deps && option.deps.indexOf(selected) >= 0)) { 287 options.push(option); 288 } 289 }); 290 291 response(options); 292 } 293 }; 294 }; 295 296 STMCascadingSelect.prototype.selector = function (slug) { 297 if (this.relations[slug].selector) { 298 return this.relations[slug].selector; 299 } 300 301 return '[name="' + slug + '"]'; 302 } 303 304})(jQuery) 305 306var errorFields = { 307 firstStep: {}, 308 secondStep: {}, 309 thirdStep: {} 310}; 311 312function stm_validateFirstStep() { 313 errorFields.firstStep = {}; 314 var $ = jQuery; 315 $('#step-one input[type="text"]').each(function(){ 316 var required = $(this).data('need'); 317 if(typeof required !== 'undefined') { 318 if($(this).attr('name') != 'video_url') { 319 if($(this).val() == '') { 320 $(this).addClass('form-error'); 321 322 errorFields.firstStep[$(this).attr('name')] = $(this).closest('.form-group').find('.contact-us-label').text(); 323 } else { 324 $(this).removeClass('form-error'); 325 } 326 } 327 } 328 }); 329 var errorsLength = Object.keys(errorFields.firstStep).length; 330 if(errorsLength == 0) { 331 $('a[href="#step-one"]').addClass('validated'); 332 } else { 333 $('a[href="#step-one"]').removeClass('validated'); 334 } 335} 336 337function stm_validateThirdStep() { 338 errorFields.thirdStep = {}; 339 var $ = jQuery; 340 $('.contact-details input[type="text"],.contact-details input[type="email"]').each(function(){ 341 if($(this).val() == '') { 342 $(this).addClass('form-error'); 343 344 errorFields.thirdStep[$(this).attr('name')] = $(this).closest('.form-group').find('.contact-us-label').text(); 345 } else { 346 $(this).removeClass('form-error'); 347 } 348 }) 349}
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.