-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathStaticImage.js
More file actions
59 lines (47 loc) · 1.78 KB
/
StaticImage.js
File metadata and controls
59 lines (47 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
define([
"dojo/_base/declare",
"mxui/widget/_WidgetBase",
"dijit/_TemplatedMixin",
"dojo/_base/lang",
"dojo/text!DynamicImage/widget/template/StaticImage.html"
], function (declare, _WidgetBase, _TemplatedMixin, lang, widgetTemplate) {
"use strict";
return declare("DynamicImage.widget.StaticImage", [_WidgetBase, _TemplatedMixin], {
templateString: widgetTemplate,
_contextObj: null,
update: function (obj, callback) {
logger.debug(this.id + ".update");
this._contextObj = obj;
this._resetSubscriptions();
this._updateRendering(callback);
},
_updateRendering: function (callback) {
logger.debug(this.id + "._updateRendering");
if (this.imageurl !== "") {
this.imageNode.src = this.imageurl;
} else {
this.imageNode.src = this.defaultImage;
}
this._executeCallback(callback, "_updateRendering");
},
_resetSubscriptions: function () {
logger.debug(this.id + "._resetSubscriptions");
this.unsubscribeAll();
if (this._contextObj) {
this.subscribe({
guid: this._contextObj.getGuid(),
callback: lang.hitch(this, function (guid) {
this._updateRendering();
})
});
}
},
_executeCallback: function (cb, from) {
logger.debug(this.id + "._executeCallback" + (from ? " from " + from : ""));
if (cb && typeof cb === "function") {
cb();
}
}
});
});
require(["DynamicImage/widget/StaticImage"]);