Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/HexGL/libs/Editor_files/ModuleList.js
4627 views
1
var pgli = pgli || {};
2
pgli.ui = pgli.ui || {};
3
4
pgli.ui.ModuleList = gamecore.Base.extend('ModuleList',
5
{ // static
6
tplModuleItem: "<li data-path='$path'>$name</li>",
7
tplModuleList: "<ul data-path='$path'>$list</ul>"
8
},
9
{ // instance
10
11
project: null,
12
container: null,
13
14
init: function(domContainer)
15
{
16
this.container = $('#'+domContainer);
17
this.container.on("click", "li", {object: this}, this.onModuleClick);
18
},
19
20
bindProject: function(project)
21
{
22
this.project = project;
23
},
24
25
draw: function()
26
{
27
var static = pgli.ui.ModuleList;
28
var modules = "";
29
var module = null;
30
if(!this.project.isEmpty()) for(var i = 0, len = this.project.getModulesCount(); i < len; ++i)
31
{
32
key = this.project.getModuleKey(i);
33
module = this.project.getModule(key);
34
modules += static.tplModuleItem.replace("$path", key).replace("$name", key);
35
}
36
this.container.html(static.tplModuleList.replace("$list", modules));
37
},
38
39
onModuleClick: function(event)
40
{
41
event.data.object.project.rememberActiveFile();
42
event.data.object.project.getAppInstance().showInEditor($(this).attr("data-path"));
43
event.data.object.container.find('li').removeClass('active');
44
$(this).addClass('active');
45
}
46
47
});
48