-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscenes.js
92 lines (73 loc) · 2.01 KB
/
scenes.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
SB(function () {
$$nav.on();
});
window.App = new (TabsHead.extend({
el: 'body',
scenesIndexes: {},
constructor: function () {
var self = this;
Backbone.View.prototype.constructor.apply(self, arguments)
//ViewModel.prototype._constructor.apply();
self.heads = [];
self.bodies = [];
self.views = [];
self.$el.bind('nav_key:return', function (e) {
if (self.currentScene)
self.currentScene.back(e);
});
},
currentScene: undefined,
setScenesContainer: function (bodiesContainer) {
this.bodiesContainer = $(bodiesContainer);
},
setHeader: function ($header, headsSelector) {
var $header = $($header);
this.heads = _.map($header.children(), function (el) {
return $(el);
});
$header.on('click', headsSelector, _.bind(this.onClick, this))
},
addScene: function (prototype) {
var self = this;
SB(function () {
self.scenesIndexes[prototype.name] = self.views.length;
var scene = new (Scene.extend(prototype))();
self.add(null, scene.$el);
if (prototype.isDefault) {
self.setScene(prototype.name);
}
});
},
setScene: function (name) {
this.show(this.scenesIndexes[name]);
},
show: function (index) {
TabsHead.prototype.show.apply(this, arguments);
this.currentScene = this.views[index];
}
}))();
window.Scene = TabContent.extend({
isDefault: false,
/**
* Название сцены
* @type {String}
*/
name: '',
backScene: false,
lazyParseBinds: true,
back: function (e) {
if (!this.backScene) {
if (ExitPopup) {
ExitPopup.show();
} else {
SB.sendReturn();
}
}
else {
App.setScene(this.backScene);
}
if (e) {
e.stopPropagation();
}
}
});