Skip to content

JavaScript Objects

Marie-Louise edited this page Aug 20, 2018 · 8 revisions

Objects are similar to variables, but instead they can contain many values. Each value is written as a pair separated by a semicolon i.e name:value . These pairs are referred to as properties .

var car = {type:"Fiat", model:"500", color:"white"};

In the Drupal codebase (footer.tpl.config.js) it's necessary to edit the following object :

module.exports = {
  name: 'Footer',
  status: 'ready',
  preview: '@preview_fullwidth.tpl',
  context: {
    back_to_top: '',
    search: '',
    navigation: '',
    social: [
      {
        url: 'https://twitter.com/wellcometrust',
        title: 'Twitter',
        class_modifier: 'twitter'
      },
      {
        url: 'https://www.facebook.com/WellcomeTrust/',
        title: 'Facebook',
        class_modifier: 'facebook'
      },
      {
        url: 'https://www.youtube.com/user/wellcometrust',
        title: 'YouTube',
        class_modifier: 'youtube'
       },
      {
        url: 'https://www.linkedin.com/company/wellcome-trust',
        title: 'LinkedIn',
        class_modifier: 'linkedin'
      }
    ],
    footer_navigation: [
      {
        title: 'Footer item',
        url: '/',
      },
      {
        title: 'External site',
        url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
      },
      {
        title: 'More navigation',
    url: '/',
      },
      {
        title: 'A slightly longer nav item',
        url: '/',
      }
    ]
  }
};

Clone this wiki locally