1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
'use strict';
modulum('GbcImageWidget', ['ImageWidget', 'WidgetFactory'],
function(context, cls) {
cls.GbcImageWidget = context.oo.Class(cls.ImageWidget, function($super) {
return {
__name: 'GbcImageWidget',
__templateName: "ImageWidget",
_updateImage: function() {
if (!this._element) {
return;
}
if (this._hasContent) {
this._element.empty();
this._hasContent = false;
}
if (this._img) {
this._img.off('error.ImageWidget');
this._img.off('load.ImageWidget');
this._img = null;
}
var backgroundImage = null;
var backgroundSize = null;
var backgroundRepeat = null;
var backgroundPosition = null;
var width = null;
if (this._src) {
this._img = document.createElement('i');
this._img.on('error.ImageWidget', this._onError.bind(this));
this._img.setAttribute('class', "zmdi " + this._src);
this._img.on('load.ImageWidget', this._onLoad.bind(this));
this._element.appendChild(this._img);
this._element.toggleClass('gbc_autoScale', this._autoScale);
}
if (this._standalone) {
if (!this._border) {
this._border = document.createElement('div');
this._border.addClass('gbc_ImageWidget_border');
}
this._element.appendChild(this._border);
}
this.setStyle({
'background-image': backgroundImage,
'background-size': backgroundSize,
'background-repeat': backgroundRepeat,
'background-position': backgroundPosition,
'width': width
});
if (this.__charMeasurer) {
this._element.appendChild(this.__charMeasurer);
}
},
};
});
cls.WidgetFactory.registerBuilder('GbcImage', cls.GbcImageWidget);
});