1/*================================================ 2 Fee Transparency JavaScript 3 Handles room type toggles and pricing display 4================================================ */ 5 6(function($) { 7 'use strict'; 8 9 // Fee Transparency Object 10 const FeeTransparency = { 11 12 /*================================================ 13 Initialize all functionality 14 ================================================ */ 15 init: function() { 16 this.setupRoomTypeToggles(); 17 this.bindEvents(); 18 }, 19 20 /*================================================ 21 Setup room type toggle buttons 22 Uses event delegation for better reliability 23 ================================================ */ 24 setupRoomTypeToggles: function() { 25 // Remove any existing handlers to prevent duplicates 26 $(document).off('click.roomtype'); 27 28 // Use event delegation for both grid and popup 29 $(document).on('click.roomtype', '.room-type-btn', function(e) { 30 e.preventDefault(); 31 e.stopPropagation(); 32 e.stopImmediatePropagation(); 33 34 const $btn = $(this); 35 const roomType = $btn.data('room-type'); 36 37 // Find the closest container (works for both grid and popup) 38 const $container = $btn.closest('.unit_price, .popup-pricing-section, .floor-details'); 39 40 console.log('Room type clicked:', roomType); // Debug 41 42 // Update active button within this container 43 $container.find('.room-type-btn').removeClass('active'); 44 $btn.addClass('active'); 45 46 // Update active content within this container 47 $container.find('.room-type-content').removeClass('active'); 48 $container.find('.room-type-content[data-room-type="' + roomType + '"]').addClass('active'); 49 50 return false; 51 }); 52 53 // Initialize - show first room type by default 54 $('.room-type-toggle').each(function() { 55 const $toggle = $(this); 56 57 // Only initialize if not already initialized 58 if (!$toggle.data('initialized')) { 59 $toggle.data('initialized', true); 60 61 // Activate first button 62 $toggle.find('.room-type-btn').first().addClass('active'); 63 64 // Get first room type 65 const firstRoomType = $toggle.find('.room-type-btn').first().data('room-type'); 66 67 // Find container and activate first content 68 const $container = $toggle.closest('.unit_price, .popup-pricing-section, .floor-details'); 69 $container.find('.room-type-content[data-room-type="' + firstRoomType + '"]').addClass('active'); 70 } 71 }); 72 }, 73 74 /*================================================ 75 Bind additional events 76 ================================================ */ 77 bindEvents: function() { 78 // Handle transparency link clicks 79 $(document).on('click', '.transparency-link-btn', function(e) { 80 // Let the link navigate naturally to /faq/#fees 81 }); 82 83 // Prevent room type button clicks from triggering card/link clicks 84 $(document).on('click', '.room-type-btn', function(e) { 85 e.stopPropagation(); 86 return false; 87 }); 88 89 // Re-initialize when popup opens 90 $(document).on('fancybox.afterShow', function() { 91 FeeTransparency.setupRoomTypeToggles(); 92 }); 93 94 // Re-initialize after any dynamic content loads 95 $(document).on('contentLoaded', function() { 96 FeeTransparency.setupRoomTypeToggles(); 97 }); 98 }, 99 100 /*================================================ 101 Calculate total price (base rent + fees) 102 ================================================ */ 103 calculateTotalPrice: function(baseRent, fee) { 104 return parseFloat(baseRent) + parseFloat(fee); 105 }, 106 107 /*================================================ 108 Format price for display 109 ================================================ */ 110 formatPrice: function(price) {
111 return '$' + Math.round(price).toLocaleString(); 112 }, 113 114 /*================================================ 115 Refresh all floor plan displays 116 ================================================ */ 117 refreshAllPricing: function() { 118 $('.room-type-toggle').removeData('initialized'); 119 this.setupRoomTypeToggles(); 120 } 121 }; 122 123 /*================================================ 124 Initialize on document ready 125 ================================================ */ 126 $(document).ready(function() { 127 FeeTransparency.init(); 128 }); 129 130 /*================================================ 131 Re-initialize after AJAX loads 132 ================================================ */ 133 $(document).ajaxComplete(function() { 134 setTimeout(function() { 135 FeeTransparency.setupRoomTypeToggles(); 136 }, 100); 137 }); 138 139 /*================================================ 140 Make FeeTransparency globally accessible 141 ================================================ */ 142 window.FeeTransparency = FeeTransparency; 143 144})(jQuery);
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.