blossom
Version:
Modern, Cross-Platform Application Framework
37 lines (29 loc) • 1.08 kB
JavaScript
// ==========================================================================
// Project: Blossom - Modern, Cross-Platform Application Framework
// Copyright: ©2012 Fohr Motion Picture Studios. All rights reserved.
// License: Licensed under the GPLv3 license (see BLOSSOM-LICENSE).
// ==========================================================================
SC.Image = SC.Object.extend({
isImage: true, // Walk like a duck.
source: null,
_sc_sourceDidChange: function() {
var source = this.get('source');
if (source !== this._sc_source) {
this._sc_source = source;
this.__sc_element__ = null; // clear any existing image
if (source) {
var img = new Image(), that = this;
img.onload = function() {
// console.log('img.onload');
that.__sc_element__ = img;
if (that.imageDidLoad) that.imageDidLoad();
};
img.src = source;
}
}
}.observes('source'),
init: function() {
arguments.callee.base.apply(this, arguments);
this._sc_sourceDidChange();
}
});