Skip to content

Overriding default config object

Maciek Jurczyk edited this page Feb 17, 2016 · 5 revisions

Overriding default config object

For using the same configuration on multiple widgets one can pass default configuration object as third argument to pathfora.initializeWidgets() function. This way all specified fields inside passed object will be overriden and widgets will use this settings as default ones. Full configuration object:

var config = {
  generic: {
    className: 'pathfora',
    header: 'Welcome!',
    theme: 'custom',
    colors: {
      background: '#000',
      header: '#fff',
      text: '#fff',
      close: '#888',
      actionText: '#000',
      actionBackground: '#fff',
      cancelText: '#000',
      cancelBackground: '#fff'
    },
    displayConditions: {
      showOnInit: true,
      showDelay: 0,
      hideAfter: 20,
      displayWhenElementVisible: '',
      scrollPercentageToDisplay: 0
    }
  },
  message: {
    layout: 'modal', // [ bar, slideout, button, inline ]
    variant: 'A'
  },
  subscription: {
    layout: 'slideout', // [ bar, slideout, button, inline ]
    variant: 'A'
  },
  form: {
    layout: 'folding', // [ bar, slideout, button, inline ]
    variant: 'A',
    position: 'left',
    nameField: true,
    titleField: false,
    placeholders: {
      name: 'Your Name',
      title: 'Your Title',
      email: 'Your Email',
      message: 'Your Message'
    }
  }
};

Example usage:

var message1 = new pathfora.Message({
   msg: 'Example widget',
});

var message2 = new pathfora.Subscription({
   msg: 'Example widget',
});

var message3 = new pathfora.Form({
   msg: 'Example widget',
});

var lyticsId = 1234;

pathfora.initializeWidgets([ message1, message2, message3 ], lyticsId, config);