1/* 2 * Function removed as it clashes with code in madeblocksoffice js/blocksoffice/dest/blocksoffice.basket.js 3 * Code is globally implemented, but overriden for some clients. 4 * 5 * Solution in aforementioned file is prefered, although some of the code here is still required (not related to calculations) 6 * and should probably be moved to the view as it's not global! 7 * 8 */ 9 10/* 11function recalculateBasketTotalIncludingDonation() { 12 // don't want to run this on the order complete page 13 if ($('.order-complete').length) { 14 return; 15 } 16 17 var basketTotal = 0; 18 19 if($("#basket_donation_option").length){ 20 if( $('#basket-total-minus-donation-unformatted').length ) { 21 basketTotal = Number($('.val').data('total-minus-donations')); 22 } else { 23 basketTotal = Number($('.val').data("discounted-total")); 24 } 25 }else if($('#basket-total-unformatted').length){ 26 basketTotal = Number($('#basket-total-unformatted').html()); 27 }else{ 28 basketTotal = Number($('.val').data("discounted-total")); 29 } 30 31 // Get the donation amount from the suggested donation field 32 if($('#basket_suggested_donation').length) { 33 if($('#basket_suggested_donation').val() != '' && $('#basket_suggested_donation').val() !== void 0) { 34 basketTotal += Number($('#basket_suggested_donation').val()); 35 } 36 } 37 38 // Get the donation amount from the other type of donation field 39 if($('#basket_donation_option_other').length) { 40 if($('#basket_donation_option_other').is(':visible')) { 41 basketTotal += Number($('#basket_donation_option_other').val()); 42 } else { 43 basketTotal += Number($('#basket_donation_option').val()); 44 } 45 } 46 47 $('#basket-total .val').text(Number(basketTotal).toFixed(2)); 48}; 49*/ 50 51$(function() { 52 $(document).delegate('a[data-action]', 'click', function(e) { 53 var link = $(this), action = link.data('action'); 54 if(action == "print") { 55 window.print(); 56 return false; 57 } else { 58 return true; 59 } 60 }); 61 62 $(document).delegate('a[data-confirm]', 'click', function(e) { 63 var link = $(this), message = link.data('confirm'); 64 return (confirm(message)); 65 }); 66 67 /* Registration Functions */ 68 var otherSelectRegister = $("#register_other_titles"); 69 if(otherSelectRegister){ 70 var toggleOtherTitleField = function() { 71 otherSelectRegister.parent().css("display", $("#register_title").val() === "Other" ? "block" : "none"); 72 }; 73 toggleOtherTitleField(); 74 $("#register_title").change(function(){ 75 toggleOtherTitleField(); 76 }); 77 } 78 79 if($("#register_country_id").length){ 80 $("#register_country_id").countrystatetoggler({state: $("#register_state")}); 81 } 82 83 if($("#updateaccount_country_id").length){ 84 $("#updateaccount_country_id").countrystatetoggler({state: $("#updateaccount_state")}); 85 } 86 if($("#delivery_new_delivery_country_id").length){ 87 $("#delivery_new_delivery_country_id").countrystatetoggler({state: $("#delivery_new_delivery_state")}); 88 } 89 if($("#oneclick_delivery_new_delivery_country_id").length){ 90 $("#oneclick_delivery_new_delivery_country_id").countrystatetoggler({state: $("#oneclick_delivery_new_delivery_state")}); 91 } 92 if($("#brochure_request_country").length){ 93 $("#brochure_request_country").countrystatetoggler({state: $("#brochure_request_state")}); 94 } 95 96 if($('#address_country_id').length) { 97 $('#address_country_id').countrystatetoggler({state: $('#address_county')}); 98 $('#address_country_id').change(); 99 } 100 101 // Delivery Screen 102 if($('#delivery_new_billing_country_id').length) { 103 $('#delivery_new_billing_country_id').countrystatetoggler({state: $('#delivery_new_billing_state')}); 104 } 105 106 if($('#billing_delivery_billing_new_delivery_country_id').length) { 107 $('#billing_delivery_billing_new_delivery_country_id').countrystatetoggler({state: $('#billing_delivery_billing_new_delivery_state')}); 108 } 109 110 if($(".section-register #main-content form")){ 111 $(".section-register #main-content form").submit(function(){ 112 if($("#field-register_state select:last").val() === 0 && $("#field-register_state").css("display") !== "none" && $("#register_country_id").val()){ 113 window.alert("Please pick your state / county"); 114 return false;
115 } 116 }); 117 } 118 119 /* Basic Booking */ 120 try{ 121 Number.prototype.formatMoney = function(c, d, t){ 122 var n = this, 123 c = isNaN(c = Math.abs(c)) ? 2 : c, 124 d = d == undefined ? "." : d, 125 t = t == undefined ? "," : t, 126 s = n < 0 ? "-" : "", 127 i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", 128 j = (j = i.length) > 3 ? j % 3 : 0; 129 return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); 130 }; 131 132 $("#basic-booking").basicbooking({ 133 onUpdate: function(total){ 134 total = parseFloat(total); 135 total = total.formatMoney(2); 136 $("#booking-total .val").html(total); 137 } 138 }); 139 }catch(e){} 140 141 try { 142 $('#accessibility_requirements_details').removeClass("has-requirements").addClass("visually-hidden"); 143 $('#accessibility_requirements').click(function() { 144 if( $(this).is(":checked") ) { 145 $('#accessibility_requirements_details').removeClass("visually-hidden").addClass("has-requirements"); 146 } else { 147 $('#accessibility_requirements_details').removeClass("has-requirements").addClass("visually-hidden"); 148 } 149 }); 150 } catch( e ) {} 151 152 /* Basket */ 153 try{ 154 $(".remove-line-item").click(function(event){ 155 if($(this).data('confirmation')) { 156 return window.confirm($(this).data('confirmation')); 157 } else { 158 var type = $(this).data('type'); 159 if(type) { 160 return window.confirm("Are you sure you want to remove this " + type + " from your cart?"); 161 } else { 162 return window.confirm("Are you sure you want to remove this item from your cart?"); 163 } 164 } 165 }); 166 167 if($('#basket_suggested_donation').length) { 168 $(document).on('keyup change', '#basket_suggested_donation', function(event) { 169 if($(this).val() != '') { 170 $('#basket_suggested_donation_accepted').prop('checked', true); 171 } else { 172 $('#basket_suggested_donation_accepted').prop('checked', false); 173 } 174 }); 175 $(document).on('click', '#basket_suggested_donation_accepted', function(event) { 176 if(this.checked) { 177 if($('#basket_suggested_donation').val() == '') { 178 $('#basket_suggested_donation').val($('#basket_suggested_donation').attr('placeholder')); 179 } 180 } else { 181 $('#basket_suggested_donation').val(''); 182 } 183 //recalculateBasketTotalIncludingDonation(); 184 }); 185 } else { 186 var toggleVisibilityOfOtherDonationField = function() { 187 if($('#basket_donation_option').val() == 'other') { 188 $('#basket_donation_option_other').parent().show(); 189 } else { 190 $('#basket_donation_option_other').parent().hide(); 191 } 192 }; 193 $(document).on('keyup change', '#basket_donation_option, #basket_donation_option_other', function(event) { 194 toggleVisibilityOfOtherDonationField(); 195 //recalculateBasketTotalIncludingDonation(); 196 }); 197 198 toggleVisibilityOfOtherDonationField(); 199 //recalculateBasketTotalIncludingDonation(); 200 } 201 202 if ($('#programme-vouchers').length) { 203 // $('#programme-vouchers').change(recalculateBasketTotalIncludingDonation); 204 } 205 }catch(e){ 206 // Do nothing! 207 } 208 209 /* Delivery Page */ 210 var toggleAddNewAddress = function() { 211 var newAddNewAddressSection = $("#unit-add-new-address"); 212 if(newAddNewAddressSection.length > 0) { 213 var differentAddressOption = $("#delivery_delivery_address_option_different"); 214 var result = "none"; 215 if(differentAddressOption.length > 0) { 216 var differentAddressIsChecked = differentAddressOption.is(":checked"); 217 result = differentAddressIsChecked ? "block" : "none"; 218 } 219 newAddNewAddressSection.css( 220 "display", 221 result 222 ); 223 } 224 }; 225 var toggleDeliveryInfo = function() { 226 var deliveryInfoElement = $("#unit-delivery-info"); 227 if(deliveryInfoElement.length) { 228 var mailShippingMethods = {1: 'Normal Delivery Method'}; 229 if(window.blocksofficevars && window.blocksofficevars.mailShippingMethods) { 230 mailShippingMethods = window.blocksofficevars.mailShippingMethods; 231 } 232 var postalDeliverySelected = false;
233 $('#delivery_delivery_option input[type="radio"]').each(function(item, index) { 234 if($(this).val() in mailShippingMethods && $(this)[0].checked) { 235 postalDeliverySelected = true; 236 } 237 }); 238 deliveryInfoElement.css("display", postalDeliverySelected ? "block" : "none"); 239 } 240 241 }; 242 var toggleDifferentDeliveryInfo = function() { 243 return; 244 }; 245 var togglePreviousAddressInfo = function() { 246 var previousAddressSection = $("#unit-previous-address"); 247 if(previousAddressSection.length > 0) { 248 var newAddressPreviousOption = $("#delivery_delivery_new_address_option_previous"); 249 previousAddressSection.css( 250 "display", 251 newAddressPreviousOption[0].checked ? "block" : "none" 252 ); 253 } 254 }; 255 $("#delivery_delivery_option input").change(function(){ 256 toggleDeliveryInfo(); 257 }); 258 $("#delivery_delivery_new_address_option input").change(function(){ 259 toggleAddNewAddress(); 260 togglePreviousAddressInfo(); 261 }); 262 $("#delivery_delivery_address_option input").change(function(){ 263 toggleAddNewAddress(); 264 toggleDifferentDeliveryInfo(); 265 }); 266 toggleAddNewAddress(); 267 toggleDifferentDeliveryInfo(); 268 togglePreviousAddressInfo(); 269 toggleDeliveryInfo(); 270 271 /* Recommendations */ 272 273 if($('#next-recommendations').length || $("#previous-recommendations").length){ 274 var slider = $("#unit-recommended-productions-slider"); 275 var width = 0; 276 var height = 0; 277 slider.children().each(function(){ 278 width+= $(this).width() + parseFloat($(this).css("margin-left")) + parseFloat($(this).css("margin-right")); 279 if($(this).height() > height){ 280 height = $(this).height(); 281 } 282 }); 283 slider.css("width", width); 284 slider.css("height", height); 285 } 286 287 $('#redeem-gift-certificate-link').click(function(){ 288 $('#unit-gift-certificate-dropdown').slideUp(); 289 $('#unit-apply-gift-certificate').slideDown(); 290 }); 291 292 var appliedGiftCertificate = false 293 $('.area-gift-certificate, .pre-payment-group').on('click', '#apply-gift-certificate', function(event) { 294 295 event.preventDefault(); 296 297 var t = $(this); 298 var applyUrl = $(this).data('apply-url'), 299 reloadPage = $(this).data('reload-page'), 300 cartUrl = $(this).data('cart-url'), 301 applySpinner = $('.gift-certificate-spinner'); 302 303 $(this).attr("disabled", "disabled"); 304 $(this).val("Applying"); 305 306 openColorbox('applying-gift-certificate'); 307 308 $.post(applyUrl, { gift_certificate_code: $('#gift-certificate-code').val() }, function(data) { 309 // Replace Gift Certificate HTML with the response 310 $('.area-gift-certificate').html(data); 311 // Close the colorbox 312 $('#applying-gift-certificate').colorbox.close(); 313 // Was it a success? 314 if($(data).find('.success').length) { 315 // Reload to update basket contents 316 window.location.reload(); 317 } 318 }); 319 320 }); 321 322 try{ 323 // Polyfill placeholders for older browsers. 324 $('input, textarea').placeholder(); 325 }catch(e){} 326 327 try { 328 var performance_switcher_form = $('#performance-switcher-form') 329 performance_switcher_form.find(".button-submit").hide(); 330 performance_switcher_form.find("#performance-switcher").change(function () { 331 performance_switcher_form.submit(); 332 }); 333 } catch(e) {} 334 335 var submittedPaymentForm = false; 336 $("#payment-form, #registration-form, #recover-account-form").submit(function(e){ 337 if(submittedPaymentForm){ 338 e.preventDefault(); 339 }else{ 340 submittedPaymentForm = true; 341 } 342 }); 343 344 var openColorbox = function(dialogId, onCompleteCallback){ 345 $.colorbox({ 346 html: $("#" + dialogId).html(), 347 overlayClose: false, 348 escKey: false, 349 onComplete: onCompleteCallback 350 }); 351 $("#cboxClose").css("display", "none"); 352 }; 353 354 $("#mute-live-protector").click(function(e){ 355 e.preventDefault(); 356 var $flashBox = $(this).parents('.flash-message');
357 var cookieName = $flashBox.data("cookiename"); 358 $flashBox.fadeOut(); 359 $.cookie(cookieName, '0', {expires: 0.0208, path: '/'}); 360 }); 361});
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.