Our Office

Level 39, One Canada Square
London, England, E14 5AB
United Kingdom

 
 

Contact Us

The following is placeholder text known as “lorem ipsum,” which is scrambled Latin used by designers to mimic real copy. Mauris id fermentum nulla. Nullam sit amet nisi condimentum erat iaculis auctor.

Name *
Name

Y.namespace('Template').Salesforce = Class.create({

/ baseUrl oid sqsFormSubmit / initialize: function (config) { this.config = config; },

submit: function () { var formData = this.getFormData(this.config.sqsFormSubmit); var phoneNumber = '';

if (formData['phone'] && formData['phone'].length >= 4) {
  phoneNumber = formData['phone'].join('-');
}
var description = '';

for (key in formData) {
  var value = formData[key];

  if (Array.isArray(value)) {
    value = value.join(' ');
  }

  description += key + ': ' + value + '\n';
}

var params = {
  first_name: formData['name'][0],
  last_name: formData['name'][1],
  email: formData['email_address'],
  phone: phoneNumber,
  company: formData['company'],
  lead_source: formData['sqf_lead_source'] || 'web',
  description: description,
  oid: this.config.oid
};

$.ajax({
  url: this.config.baseUrl,
  data: params,
  type: 'GET',
  dataType: 'jsonp',
  jsonp: false,
  complete: function(data) {
    debugger;
    console.log('done');
  }
});

},

getFormData: function (formSubmit) { var data = {};

formSubmit.get("formNode").all(".form-item").each(function(item) {
  var key = null;

  if (item.get('nodeName') == 'FIELDSET') {
    key = item.get('id').split('-')[0];
  } else {
    var inputNode = item.one('.title');

    if (inputNode) {
      var text = inputNode.get('innerText');
      key = text.replace(' *', '').replace(' ', "_").toLowerCase();
    } else {
      key = item._node.name.toLowerCase();
    }
  }

  if (key) {
    data[key] = formSubmit._getFieldData(item);
  }
});

return data;

}

});