1(function ($, Drupal) { 2 'use strict'; 3 4 /** 5 * Behavior description. 6 */ 7 8 Drupal.behaviors.ts_pricing = { 9 attach: (context, settings) => {} 10 }; 11 12 $(document).ajaxComplete((event, xhr, settings) => { 13 const form = $('.ui-dialog .webform-submission-contact-sales-form'); 14 const comment = form.find('[name="field_lead_commentary"]'); 15 if(comment.length && !comment.val()) { 16 const ts_pricing = localStorage.ts_pricing; 17 if(typeof ts_pricing !== 'undefined') { 18 let text = ''; 19 const data = JSON.parse(ts_pricing); 20 if(data.items.length && data.items[0].id === 'unlimited') { 21 text = `${data.items[0].title} platform`; 22 } else { 23 text = 'Order:' + "\n"; 24 for(const [key, item] of Object.entries(data.items)) { 25 text += item.title + ': ' + item.formula + ' = ' + data.currency_sign + item.costTotal + ";\n"; 26 if(typeof item.contacts !== 'undefined' && item.contacts) { 27 text += item.contacts.title + ': ' + item.contacts.users + ' contacts = ' + data.currency_sign + item.contacts.costTotal + ";\n"; 28 } 29 if(typeof item.emails !== 'undefined' && item.emails) { 30 text += item.emails.title + ': ' + item.emails.users + ' emails = ' + data.currency_sign + item.emails.costTotal + ";\n"; 31 } 32 } 33 text += data.total.support.title + ': ' + data.total.support.pct + '% = ' + data.currency_sign + data.total.support.cost + ";\n"; 34 text += 'Total per month: ' + data.currency_sign + data.total.total + ";\n"; 35 text += 'Total per year: ' + data.currency_sign + data.total.totalYear; 36 } 37 38 comment.val(text); 39 40 const ajax_settings = { 41 url: '/ajax/pricing/data', 42 submit: { 43 data: data 44 } 45 }; 46 47 const ajaxObject = Drupal.ajax(ajax_settings); 48 ajaxObject.options.type = 'POST'; 49 ajaxObject.options.complete = () => {}; 50 ajaxObject.execute(); 51 } 52 } 53 54 if(form.find('.webform-confirmation').length && typeof localStorage.ts_pricing !== 'undefined') { 55 localStorage.removeItem('ts_pricing'); 56 } 57 }); 58 59} (jQuery, Drupal));
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.