/
hype_view.js
97 lines (73 loc) · 3.49 KB
/
hype_view.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Generated by CoffeeScript 1.3.3
(function() {
var HypeView,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
window.HypeView = HypeView = (function(_super) {
__extends(HypeView, _super);
function HypeView() {
this._animationComplete = __bind(this._animationComplete, this);
this._animationSceneLoad = __bind(this._animationSceneLoad, this);
this.showSceneNamed = __bind(this.showSceneNamed, this);
this.render = __bind(this.render, this);
this._documentLoaded = __bind(this._documentLoaded, this);
this.load = __bind(this.load, this);
return HypeView.__super__.constructor.apply(this, arguments);
}
HypeView._views = {};
HypeView.prototype.initialize = function() {
this.basename = this.options['basename'];
this.width = this.options['width'];
this.height = this.options['height'];
this.sounds = {};
return HypeView._views[this.basename] = this;
};
HypeView.prototype.load = function(documentLoadedCallback) {
this.documentLoadedCallback = documentLoadedCallback;
return this.render();
};
HypeView.prototype._documentLoaded = function() {
console.log("hype view loaded", this.basename);
return this.documentLoadedCallback();
};
HypeView.prototype.render = function() {
var new_el;
new_el = $("<div id='" + this.basename + "_hype_container' class='hype-container' style='position:relative;overflow:hidden;width:" + this.options['width'] + "px;height:" + this.options['height'] + "px;background-color:transparent;'>\n <script type='text/javascript' charset='utf-8' src='" + this.basename + "_Resources/" + this.basename + "_hype_generated_script.js?71143'></script>\n</div>");
this.$el.replaceWith(new_el);
this.setElement(new_el);
return this;
};
HypeView.prototype.showSceneNamed = function(scene_name, data, animationCompleteCallback) {
this.animationCompleteCallback = animationCompleteCallback;
this.hypeDocument.templateData = data;
return this.hypeDocument.showSceneNamed(scene_name);
};
HypeView.byDocumentName = function(document_name) {
return this._views[document_name];
};
HypeView.prototype._animationSceneLoad = function() {
var alts,
_this = this;
alts = this.$el.find("[alt]");
return alts.each(function(i, el) {
return $(el).html(_.template($(el).attr("alt"), _this.hypeDocument.templateData));
});
};
HypeView.prototype._animationComplete = function() {
return this.animationCompleteCallback();
};
HypeView.documentLoaded = function(hypeDocument) {
this._views[hypeDocument.documentName()].hypeDocument = hypeDocument;
return this._views[hypeDocument.documentName()]._documentLoaded();
};
HypeView.animationSceneLoad = function(hypeDocument) {
return this._views[hypeDocument.documentName()]._animationSceneLoad();
};
HypeView.animationComplete = function(hypeDocument) {
return this._views[hypeDocument.documentName()]._animationComplete();
};
return HypeView;
})(Backbone.View);
module.exports = window.HypeView;
}).call(this);