function Banner()

in static/js/com/banners-rotator.js [21:47]


function Banner(params) {
  if (!params.id || !params.type)
    throw new Error('Banner `id` and `type` sould be provided');

  if (!(params.type in Banner.TYPE))
    throw new Error('Unsupported banner type `' + params.type + '`');

  var mountNode = ('mountNode' in params) ? params.mountNode : Banner.defaults[params.type].mountNode;
  if (!mountNode) throw new Error('You must provide mount node for `' + params.id + '` banner');
  mountNode = (typeof mountNode === 'string') ? document.getElementById(mountNode) : mountNode;
  if (!mountNode) throw new Error('Mount node for `' + params.id + '` doesnt exist');
  this.mountNode = mountNode;

  this.id = params.id;
  this.type = params.type;
  this.url = 'url' in params ? params.url : null;
  this.imageUrl = 'imageUrl' in params ? params.imageUrl : null;
  this.width = 'width' in params ? params.width : Banner.defaults[params.type].width;
  this.height = 'height' in params ? params.height : Banner.defaults[params.type].height;
  this.template = 'template' in params ? params.template : null;
  this.target = 'target' in params ? params.target : '_self';
  this.linkCss = 'linkCss' in params ? params.linkCss : null;
  this.closeButtonCss = 'closeButtonCss' in params ? params.closeButtonCss : null;

  this.onCreate = ('onCreate' in params && typeof params.onCreate === 'function') ? params.onCreate : null;
  this.onClick = ('onClick' in params && typeof params.onClick === 'function') ? params.onClick : null;
}