Skip to content

Instantly share code, notes, and snippets.

@fraszczakszymon
Last active February 19, 2016 10:18
Show Gist options
  • Save fraszczakszymon/5330782db874bb17aaac to your computer and use it in GitHub Desktop.
Save fraszczakszymon/5330782db874bb17aaac to your computer and use it in GitHub Desktop.
Flite component: Wikia skin
Object({
name: 'Wikia skin',
rectangle: null,
api: null,
spinner: null,
config: null,
assetUrl: null,
flite: {
initialize: function (resources) {
this.api = resources.api;
this.config = resources.config;
this.loadCustomAd = this.api.window && this.api.window.top && this.api.window.top.loadCustomAd;
// Component parameters
this.destinationUrl = this.config.getValue('destination_url');
this.skinImage = this.config.getValue('skin_image');
this.backgroundColor = (this.config.getValue('background_color') || '').replace('#', '');
this.middleColor = (this.config.getValue('middle_color') || '').replace('#', '');
// Preload image
var image = new Image();
image.src = this.skinImage;
image.onload = function () {
var div = this.api.dom.getElement('div');
div.css('backgroundImage', 'url("' + this.skinImage + '")');
div.width(0);
div.height(0);
this.addChild(div);
}.bind(this);
},
show: function () {
this.loadCustomAd && this.loadCustomAd({
type: 'skin',
destUrl: this.destinationUrl,
skinImage: this.skinImage,
backgroundColor: this.backgroundColor,
middleColor: this.middleColor,
ten64: true
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment