-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJAXApp.js
More file actions
160 lines (137 loc) · 3.5 KB
/
JAXApp.js
File metadata and controls
160 lines (137 loc) · 3.5 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import {JAXEnv} from './JAXEnv.js';
import {JAXHudLayer} from './JAXHudLayer.js'
import {jaxHudState} from "./JAXHudState.js";
import {JAXDataObj} from "./JAXDataObj.js";
var JAXApp,__Proto;
JAXApp=function(jaxEnv,appDiv){
if(!jaxEnv)
return;
JAXDataObj.call(this,jaxEnv,null,null);
this.appPath=document.location.pathname;
this.appDir=JAXEnv.getPathDir(this.appPath);
this.jaxClassFunc=JAXApp;
this.jaxEnv=jaxEnv;
this.appDiv=appDiv;
this.clientW=this.w=appDiv.offsetWidth;
this.clientH=this.h=appDiv.offsetHeight;
this.layers_=[];
this.uiEvent=1;
Object.defineProperty(this,'layers',{
set:function(list){
let layerCSS,layer;
for(layerCSS of list){
layer=new JAXHudLayer(this,appDiv);
layer.owner_=this;
layer.applyCSS(layerCSS);
this.layers_.push(layer);
}
}
});
//可能会用到的回调函数:
//this.OnCreate=null;
//this.OnFree=null;
//this.AfCreate=null;
};
JAXApp.jaxPptSet=new Set(["layers"]);
__Proto=JAXApp.prototype={};
//---------------------------------------------------------------------------
//根据CSS创建App
__Proto.startByDef=function(cssObj)
{
this.jaxEnv.pushObjHasher(this);
JAXEnv.applyCSS(this,cssObj,JAXApp.jgxPptSet);
if(this.OnCreate){
this.OnCreate();
}
if(this.AfCreate){
this.jaxEnv.callAfter(this.AfCreate.bind(this));
}
this.jaxEnv.popObjHasher(this);
};
//---------------------------------------------------------------------------
//根据CSS创建App
__Proto.update=function()
{
let list,layer;
list=this.layers_;
for(layer of list){
layer.update();
}
//TODO: Code this:
};
//---------------------------------------------------------------------------
//网页窗口尺寸发生变化:
__Proto.OnResize=function(w,h){
var style=this.appDiv.style;
var list,i,n;
this.w=w;
this.h=h;
style.width=""+w+"px";
style.height=""+h+"px";
this.w=w;
this.h=h;
this.clientW=w;
this.clientH=h;
list=this.layers_;
n=list.length;
for(i=0;i<n;i++){
list[i]._doLayout();
}
};
//---------------------------------------------------------------
//ApplyCSS合并属性之前
__Proto.preApplyCSS = function (cssObj){
var stateObj=cssObj.appState;
if(stateObj){
if(!stateObj.isJAXHudState) {
stateObj = jaxHudState(this.jaxEnv, stateObj);
}
this.jaxEnv.pushHudState(stateObj);
this.stateObj=stateObj;
this.stateObj_=stateObj;
stateObj.setupState();
}
};
//---------------------------------------------------------------
//ApplyCSS的最后:
__Proto.postApplyCSS = function (cssObj) {
let stateObj=this.stateObj_;
if(stateObj){
this.jaxEnv.popHudState(stateObj);
}
};
//***************************************************************************
//有关启动App的函数:
//***************************************************************************
{
__Proto=JAXEnv.prototype;
//---------------------------------------------------------------------------
//创建App
__Proto.createApp=function()
{
if(this.app){
throw "Error: JAXEnv already has a App!";
}
this.app=new JAXApp(this,this.jaxDiv);
return this.app;
};
//---------------------------------------------------------------------------
//初始化App
__Proto.initApp=function(appDef)
{
if(!this.app){
throw "Error: JAXEnv has no App!";
}
this.app.startByDef(appDef);
return this.app;
};
//---------------------------------------------------------------------------
//创建且初始化App
__Proto.startApp=function(appDef)
{
this.app=new JAXApp(this,this.jaxDiv);
this.app.startByDef(appDef);
return this.app;
};
}
export {JAXApp};