forked from songliuchen/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
958 lines (925 loc) · 33 KB
/
index.html
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Cesium Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="https://cesiumjs.org/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="https://cesiumjs.org/favicon.ico" type="image/x-icon"/>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<style>
html,body
{
padding:0;
margin:0;
height: 100%;
width: 100%;
overflow: hidden;
min-width: 1000px;
}
a{
text-decoration: none;
color:white;
}
ul
{
margin:0px;
padding:0px;
}
li
{
list-style-type:none;
}
.nav
{
position:fixed;
top:0;
left:0;
width:100%;
z-index:999;
background-color:#3c8dbc;
padding-left: 17px;
height:60px;
}
.nav .logo
{
width:35px;
height:35px;
vertical-align: middle;
display: inline-block;
}
.nav .title
{
color:white;
font-size:24px;
line-height: 60px;
vertical-align: middle;
margin-left:10px;
display: inline-block;
}
.nav .menu
{
color:white;
text-align: center;
vertical-align: middle;
float:right;
}
.nav .menu .item
{
margin-right:30px;
padding-left:10px;
padding-right: 10px;
border-top:4px solid transparent;
line-height: 56px;
cursor:pointer;
}
.nav .menu .item:hover
{
background-color:#487EA5;
border-top:4px solid #d69e36;
line-height: 56px;
}
.nav .menu .item .fa-sort-down
{
vertical-align: text-top;
}
.nav .menu .sub_menu
{
display: none;
position: absolute;
top:0;
left:0;
text-align: center;
min-width:200px;
}
.nav .menu .sub_menu li
{
height: 44px;
background-color: #3375A1;
line-height: 44px;
padding-left: 15px;
padding-right: 15px;
cursor:pointer;
}
.nav .menu .sub_menu li:hover
{
background-color:#385990
}
.nav .menu .sub_menu li a
{
display: inline-block;
width:100%;
}
.side
{
position:fixed;
top:60px;
left:0px;
width:230px;
height:100%;
display: inline-block;
background-color:#3c8dbc;
transition:width 0.2s;
-moz-transition:width 0.2s;
-webkit-transition:width 0.2s;
-o-transition:width 0.2s;
}
.side .expend
{
background-color:#2e658a;
color:white;
cursor: pointer;
text-align: center;
vertical-align: middle;
line-height: 36px;
height:36px;
}
.side .menu .root_menu
{
background-color:#3c8dbc;
color:white;
font-weight: 400;
font-size: 14px;
overflow: hidden;
cursor: pointer;
}
.side .menu .root_menu .menu_item
{
background-color:#3c8dbc;
line-height: 44px;
padding-left:17px;
padding-right:17px;
overflow: hidden;
white-space: nowrap;
height: 44px;
border-left:4px solid transparent;
}
.side .menu .root_menu .menu_item:hover
{
background-color:#43759d;
border-left:4px solid #3C6A8E;
}
.side .menu .root_menu .menu_item a
{
width:100%;
display: inline-block;
}
.side .menu .root_menu .icon
{
margin-right:12px;
width:16px;
}
.side .menu .root_menu .pull-right
{
float:right;
line-height: 44px;
}
.side .menu .sub_container
{
height:0px;
overflow: hidden;
transition:height 0.5s;
-moz-transition:height 0.5s;
-webkit-transition:height 0.5s;
-o-transition:height 0.5s;
}
.side .menu .sub_menu
{
line-height: 35px;
height: 35px;
overflow: hidden;
white-space: nowrap;
}
.side .menu .sub_menu:hover
{
background-color:#487ea5;
border-left:4px solid #335875;
}
.side .menu .sub_menu a
{
line-height: 35px;
width:100%;
display: inline-block;
}
.side .menu .sub_menu a span
{
padding-left:50px;
}
.side .menu .sub_menu span
{
line-height: 35px;
height: 35px;
}
.right
{
position: fixed;
top:60px;
left:230px;
width: calc(100% - 230px);
transition:width 0.2s;
-moz-transition:width 0.2s;
-webkit-transition:width 0.2s;
-o-transition:width 0.2s;
overflow-y: scroll;
height: calc(100% - 60px);
}
#web_loader
{
width:100%;
height:100%;
margin-top:0;
min-width: 600px;
border:0;
display: none;
}
#list_loader
{
padding-left:40px;
}
#list_loader .title
{
margin-bottom: 0;
height:40px;
line-height: 40px;
font-weight: 400;
margin-right: 20px;
border-bottom: 1px solid #3c8dbc;
color:#666666;
font-size: 22px;
}
#list_loader .content
{
margin-top:15px;
}
#list_loader .content .sub_title
{
font-size:18px;
color:#666666;
}
#list_loader .content .cart
{
width:200px;
height:200px;
border-radius: 2px;
box-shadow: 0 0 3px rgba(150, 150, 150, 0.5);
-webkit-box-shadow: 0 0 3px rgba(150, 150, 150, 0.5);
display: inline-block;
margin-top:20px;
margin-left:10px;
margin-right:50px;
text-align: center;
cursor:pointer;
transition: all 0.6s;
}
#list_loader .content .cart:hover
{
transform: scale(1.1,1.1);
}
#list_loader .content .cart .des
{
text-align: center;
color:#666666;
line-height: 40px;
height:40px;
font-size:14px;
}
#list_loader .content .cart .img
{
width:200px;
height:160px;
}
</style>
</head>
<body onhashchange="hashChanged(event)" onmouseup="mouseDownEvent(event)">
<div class="nav">
<a href = "./index.html">
<img class="logo" src="https://cesiumjs.org/favicon.ico" />
<div class="title">
Cesium Demo
</div>
</a>
<!-- <div class ="menu">
<a href='https://github.com/songliuchen/cesium' target="_blank"><div class="item">下载</div></a>
</div> -->
<div class ="menu">
<div class="item" onclick="showSubMenu(event)"><span>展示方式 </span><span class="fa fa-sort-down"></span></div>
<ul class="sub_menu nav_sub_menu">
<li>
<a href = "./index.html">图文模式</a>
</li>
<li>
<a href = "#base-load_cesium?show_type=1">列表模式</a>
</li>
</ul>
</div>
<div class ="menu">
<a href='./index.html'><div class="item">首页</div></a>
</div>
</div>
<div class="side">
<div class ="expend" onclick="toggle()">
<div class="fa fa-bars fold" id = "expendMenu"></div>
</div>
<ul class ="menu">
<li class="root_menu">
<div class="menu_item" onclick="toggoleSildMenu(event)">
<a href= "#base">
<span class="fa fa-building icon"></span>
<span>基础</span>
<span class="fa fa-angle-down pull-right"></span>
</a>
</div>
<ul class="sub_container">
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#base-load_cesium" class ="route"><span>Hello Cesium</span></a>
</li>
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#base-load_cesium2" class ="route"><span>去除所有控件</span></a>
</li>
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#base-load_cesium3" class ="route"><span>动态显示隐藏控件</span></a>
</li>
</ul>
</li>
<li class="root_menu">
<div class="menu_item" onclick="toggoleSildMenu(event)">
<a href= "#model">
<span class="fa fa-plane icon"></span>
<span>模型</span>
<span class="fa fa-angle-down pull-right"></span>
</a>
</div>
<ul class="sub_container">
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#model-show" class ="route"><span>模型属性修改</span></a>
</li>
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#model-show_underline" class ="route"><span>地下模型</span></a>
</li>
</ul>
</li>
<li class="root_menu">
<div class="menu_item" onclick="toggoleSildMenu(event)">
<a href= "#datasource">
<span class="fa fa-database icon"></span>
<span>数据源</span>
<span class="fa fa-angle-down pull-right"></span>
</a>
</div>
<ul class="sub_container">
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#datasource-geojson" class ="route"><span>GeoJSON</span></a>
</li>
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#datasource-topojson" class ="route"><span>TopoJSON</span></a>
</li>
</ul>
</li>
<li class="root_menu">
<div class="menu_item" onclick="toggoleSildMenu(event)">
<a href= "#fly">
<span class="fa fa-paper-plane icon"></span>
<span>路线</span>
<span class="fa fa-angle-down pull-right"></span>
</a>
</div>
<ul class="sub_container">
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#fly-fly" class ="route"><span>飞行</span></a>
</li>
</ul>
</li>
<li class="root_menu">
<div class="menu_item" onclick="toggoleSildMenu(event)">
<a href= "#3dtiles">
<span class="fa fa-delicious icon"></span>
<span>3DTiles</span>
<span class="fa fa-angle-down pull-right"></span>
</a>
</div>
<ul class="sub_container">
<li class="sub_menu"onclick="sildMenuItemClick(event)" >
<a href="#3dtiles-load_3dtiles" class ="route"><span>加载黄浦江数据</span></a>
</li>
<li class="sub_menu"onclick="sildMenuItemClick(event)" >
<a href="#3dtiles-load_3dtiles2" class ="route"><span>加载工厂数据</span></a>
</li>
<li class="sub_menu"onclick="sildMenuItemClick(event)" >
<a href="#3dtiles-load_official" class ="route"><span>加载小区数据</span></a>
</li>
<li class="sub_menu"onclick="sildMenuItemClick(event)" >
<a href="#3dtiles-load_point_cloud" class ="route"><span>加载点云数据</span></a>
</li>
</ul>
</li>
<li class="root_menu">
<div class="menu_item" onclick="toggoleSildMenu(event)">
<a href= "#tools">
<span class="fa fa-briefcase icon"></span>
<span>工具</span>
<span class="fa fa-angle-down pull-right"></span>
</a>
</div>
<ul class="sub_container">
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#tools-3dtiles_download" class ="route"><span>爬取网络3DTiles数据</span></a>
</li>
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#tools-transb3dm_to_gltf" class ="route"><span>b3dm中提取gltf模型</span></a>
</li>
</ul>
</li>
<li class="root_menu">
<div class="menu_item" onclick="toggoleSildMenu(event)">
<a href= "#plugins">
<span class="fa fa-plug icon"></span>
<span>插件</span>
<span class="fa fa-angle-down pull-right"></span>
</a>
</div>
<ul class="sub_container">
<li class="sub_menu" onclick="sildMenuItemClick(event)">
<a href="#plugins-cesium_zh" class ="route"><span>汉化插件</span></a>
</li>
</ul>
</li>
</ul>
</div>
<div class="right">
<iframe id ="web_loader" src=""></iframe>
<ul id = "list_loader">
<li>
<a name="base"> </a>
<h3 class="title"><i class="fa fa-building"></i> 基础</h3>
<div class ="content">
<div class="sub_title">Hello World</div>
<a name="base-load_cesium"> </a>
<div class="cart">
<a href ="./index.html#base-load_cesium?type=1" target="_blank">
<span class="des">Hello Cesium</span>
<img class="img" src="./assets/thumb/hello_world.jpg" >
</a>
</div>
<a name="base-load_cesium2"> </a>
<div class="cart">
<a href ="./index.html#base-load_cesium2?type=1" target="_blank">
<span class="des">去除所有控件</span>
<img class="img" src="./assets/thumb/no_controller.png" >
</a>
</div>
<a name="base-load_cesium3"> </a>
<div class="cart">
<a href ="./index.html#base-load_cesium3?type=1" target="_blank">
<span class="des">动态显示隐藏控件</span>
<img class="img" src="./assets/thumb/dynamic_controller.png" >
</a>
</div>
</div>
</li>
<li>
<a name="model"> </a>
<h3 class="title"><i class="fa fa-plane"></i> 模型</h3>
<div class ="content">
<div class="sub_title">模型基础操作</div>
<a name="model-show"> </a>
<div class="cart">
<a href ="./index.html#model-show?type=1" target="_blank">
<span class="des">模型属性修改</span>
<img class="img" src="./assets/thumb/model_show.png" >
</a>
</div>
<a name="model-show_underline"> </a>
<div class="cart">
<a href ="./index.html#model-show_underline?type=1" target="_blank">
<span class="des">地下模型</span>
<img class="img" src="./assets/thumb/model_show_underline.png" >
</a>
</div>
</div>
</li>
<li>
<a name="datasource"> </a>
<h3 class="title"><i class="fa fa-database"></i> 数据源</h3>
<div class ="content">
<div class="sub_title">JSON数据源</div>
<a name="datasource-geojson"> </a>
<div class="cart">
<a href ="./index.html#datasource-geojson?type=1"target="_blank">
<span class="des">Geo JSON</span>
<img class="img" src="./assets/thumb/datasource_geojson.png" >
</a>
</div>
<a name="datasource-topojson"> </a>
<div class="cart">
<a href ="./index.html#datasource-topojson?type=1" target="_blank">
<span class="des">Topo JSON</span>
<img class="img" src="./assets/thumb/datasource_topojson.png" >
</a>
</div>
</div>
</li>
<li>
<a name="fly"> </a>
<h3 class="title"><i class="fa fa-paper-plane"></i> 路线</h3>
<div class ="content">
<div class="sub_title">飞行</div>
<a name="fly-fly"> </a>
<div class="cart" >
<a href ="./index.html#fly-fly?type=1" target="_blank">
<span class="des">飞行</span>
<img class="img" src="./assets/thumb/fly_fly.png" >
</a>
</div>
</div>
</li>
<li>
<a name="3dtiles"> </a>
<h3 class="title"><i class="fa fa-delicious"></i> 3DTiles</h3>
<div class ="content">
<div class="sub_title">局部数据加载</div>
<a name="3dtiles-load_3dtiles"> </a>
<div class="cart">
<a href ="./index.html#3dtiles-load_3dtiles?type=1"target="_blank">
<span class="des">加载黄浦江数据</span>
<img class="img" src="./assets/thumb/3dtiles-load_3dtiles.png" >
</a>
</div>
<a name="3dtiles-load_3dtiles2"> </a>
<div class="cart">
<a href ="./index.html#3dtiles-load_3dtiles2?type=1" target="_blank">
<span class="des">加载工厂数据</span>
<img class="img" src="./assets/thumb/3dtiles-load_3dtiles2.png" >
</a>
</div>
<a name="3dtiles-load_official"> </a>
<div class="cart">
<a href ="./index.html#3dtiles-load_official?type=1" target="_blank">
<span class="des">加载小区数据</span>
<img class="img" src="./assets/thumb/3dtiles-load_official.png" >
</a>
</div>
<a name="3dtiles-load_point_cloud"> </a>
<div class="cart">
<a href ="./index.html#3dtiles-load_point_cloud?type=1" target="_blank">
<span class="des">加载点云数据</span>
<img class="img" src="./assets/thumb/3dtiles-load_point_cloud.png" >
</a>
</div>
</div>
</li>
<li>
<a name="tools"> </a>
<h3 class="title"><i class="fa fa-briefcase"></i> 工具</h3>
<div class ="content">
<div class="sub_title">爬虫</div>
<a name="tools-3dtiles_download"> </a>
<div class="cart" >
<a href ="./tools/3dtiles_download.py" target="_blank">
<span class="des">爬取网络3DTiles数据</span>
<img class="img" src="./assets/thumb/tools-3dtiles_download.png" >
</a>
</div>
<a name="tools-transb3dm_to_gltf"> </a>
<div class="cart" >
<a href ="./tools/transb3dm_to_gltf.py" target="_blank">
<span class="des">b3dm中提取gltf模型</span>
<img class="img" src="./assets/thumb/tools-transb3dm_to_gltf.png" >
</a>
</div>
</div>
</li>
<li>
<a name="plugins"> </a>
<h3 class="title"><i class="fa fa-plug"></i> 插件</h3>
<div class ="content">
<div class="sub_title">插件</div>
<a name="plugins-cesium_zh"> </a>
<div class="cart" >
<a href ="./index.html#plugins-cesium_zh?type=1" target="_blank">
<span class="des">汉化插件</span>
<img class="img" src="./assets/thumb/pulgins-cesium_zh.png" >
</a>
</div>
</div>
</li>
</ul>
</div>
</body>
<script>
//初始化
init();
/**
* 初始化
*/
function init()
{
//加载当前选择demo
loadFrame();
//默认展开左侧菜单
initSideMenuStatus();
}
/**
* 加载页面展示方式,是展示iframe 还是 list
* 动态设置iframe src
* 动态修改标题
*/
function loadFrame()
{
//判断是列表模式还是演示模式,列表模式隐藏iframe,演示模式隐藏列表容器
var type = getUrlParams("type");
var showType = getUrlParams("show_type");
window.showType = showType;
window.type = type;
var listElement = document.getElementById("list_loader");
var webElement = document.getElementById("web_loader");
if(!type && !showType)
{
listElement.style.display ="block";
webElement.style.display="none";
}
else
{
listElement.style.display ="none";
webElement.style.display="block";
}
if(type)
{
//右侧展示示例内容
setIframeSrc(window.location.hash);
//动态修改左侧所有菜单,添加链接为预览模式
var routes = document.getElementsByClassName("route");
for(var i = 0;i<routes.length;i++)
{
if(!routes[i].getAttribute('href').endsWith("?type=1"))
routes[i].setAttribute("href",routes[i].getAttribute('href')+"?type=1");
}
}
else if(showType)
{
setIframeSrc("index_list");
}
//设置标题
dynamicChangeTitle(window.location.hash);
}
/**
* 获取url参数
*/
function getUrlParams(paramsName)
{
var name,value;
var str=location.href; //取得整个地址栏
var num=str.indexOf("?")
str=str.substr(num+1);
var arr=str.split("&"); //各个参数放到数组里
console.log(arr)
for(var i=0;i < arr.length;i++)
{
num=arr[i].indexOf("=");
if(num>0)
{
name=arr[i].substring(0,num);
value=arr[i].substr(num+1);
if(name == paramsName)
return value;
}
}
return "";
}
/**
* 修改面板宽度
*/
function toggle()
{
var panel = document.getElementsByClassName("side");
panel = panel[0];
var width = panel.clientWidth;
var expendMenu = document.getElementById("expendMenu");
var right = document.getElementsByClassName("right");
right = right[0];
var rotate = "";
if(width == 230)
{
width = 50;
//控制图标旋转
rotate = "rotate(90deg)";
}
else
{
width = 230;
rotate = "rotate(0deg)";
}
//关闭所有已经展开的菜单
if(width ==50)
{
var subContainers = document.getElementsByClassName("sub_container");
for(var i = 0;i<subContainers.length;i++)
{
if(subContainers[i].clientHeight>0)
{
toggoleSildMenu({currentTarget:subContainers[i].parentElement.children[0]});
}
}
}
//设置左侧面板高度
panel.style.width = width+"px";
right.style.left=width+"px";
right.style.width="calc( 100% - "+width+"px )";
debugger;
//设置菜单按钮
expendMenu.style.transform = rotate;
expendMenu.style["transition-duration"] = "0.5s";
}
/**
* 折叠展开左侧菜单
*/
function toggoleSildMenu(event)
{
var panel = document.getElementsByClassName("side");
panel = panel[0];
var width = panel.clientWidth;
//折叠情况不让展开
if(width ==50)
return;
var rootMenu = event.currentTarget;
var subContainer = rootMenu.parentElement.children[1];
var height = subContainer.clientHeight;
if(height>0)
{
subContainer.style.height = 0+"px";
rootMenu.style.backgroundColor="";
rootMenu.style.borderLeft="";
rootMenu.children[0].children[2].style.transform = "rotate(0deg)";
rootMenu.children[0].children[2].style.transitionDuration = "0.2s";
}
else
{
var leftMenuItems = document.getElementsByClassName("menu_item");
for(var i = 0;i<leftMenuItems.length;i++)
{
if(leftMenuItems[i] != event.rootMenu)
{
var subContainerTemp = leftMenuItems[i].parentElement.children[1];
var heightTemp = subContainerTemp.clientHeight;
if(heightTemp>0)
{
//去除背景颜色,左边框颜色,展开效果
subContainerTemp.style.height = 0+"px";
leftMenuItems[i].style.backgroundColor="";
leftMenuItems[i].style.borderLeft="";
leftMenuItems[i].children[0].children[2].style.transform = "rotate(0deg)";
leftMenuItems[i].children[0].children[2].style.transitionDuration = "0.2s";
//判断 子项是否有选中,有选择则取消选中
var subContainerLis = subContainerTemp.getElementsByTagName("li");
for(var j = 0;j<subContainerLis.length;j++)
{
if(subContainerLis[j].style.backgroundColor)
{
subContainerLis[j].style.backgroundColor = "";
subContainerLis[j].style.borderLeft="";
break;
}
}
break;
}
}
}
subContainer.style.height = subContainer.children.length*35+"px";
rootMenu.style.backgroundColor="#43759d";
rootMenu.style.borderLeft="4px solid #3C6A8E";
rootMenu.children[0].children[2].style.transform = "rotate(180deg)";
rootMenu.children[0].children[2].style.transitionDuration = "0.2s";
}
}
/**
* 左侧子菜单点击效果
*/
function sildMenuItemClick(event)
{
var menuItem = event.currentTarget;
var items = menuItem.parentElement.children;
for(var i = 0;i<items.length;i++)
{
if(items[i] !=menuItem)
{
items[i].style.backgroundColor="";
items[i].style.borderLeft="";
}
}
menuItem.style.backgroundColor="#487ea5";
menuItem.style.borderLeft="4px solid #335875";
}
/**
* 监控路由变化
*/
function hashChanged(event)
{
loadFrame();
if(type)
{
setIframeSrc(event.newURL.split("#")[1]);
}
}
/**
* 设置iframe 地址
*/
function setIframeSrc(url)
{
url = url.replace("#","");
url = url.split("?")[0];
if(url.split("-").length>1)
url = "./"+url.split('-')[0]+"/"+url.split('-')[1]+".html";
else
url = "./"+url+".html";
var webElement = document.getElementById("web_loader");
webElement.src = url;
}
/**
* 显示下拉菜单
*/
function showSubMenu(event)
{
var element = event.currentTarget;
element.style.backgroundColor = "#487EA5";
element.style.borderTop= "4px solid #d69e36";
var parentElement = element.parentElement;
var subMenu = parentElement.children[1];
subMenu.style.position = "absolute";
subMenu.style.top = 60+"px";
subMenu.style.left = (element.offsetLeft-200+element.clientWidth)+"px";
subMenu.style.zIndex = 9999;
subMenu.style.display="block";
}
/**
* 全局鼠标事件监听
*/
function mouseDownEvent()
{
var navSubMenus = document.getElementsByClassName("nav_sub_menu");
for(var i = 0;i<navSubMenus.length;i++)
{
navSubMenus[i].style.display="none";
}
var nav = document.getElementsByClassName("nav");
var menus = nav[0].getElementsByClassName("item");
for(var i = 0;i<menus.length;i++)
{
menus[i].style.backgroundColor = "";
menus[i].style.borderTop = "";
}
}
/**
* 动态修改标题
*/
function dynamicChangeTitle(url)
{
if(url.indexOf("?")>0)
url = url.split("?")[0];
if(!url.startsWith("#"))
url = "#"+url;
var routes = document.getElementsByClassName("route");
for(var i = 0;i<routes.length;i++)
{
//判断当前路由和菜单路由相同,则设置该文本为title
if(routes[i].hash.split("?")[0]==url)
{
document.title= routes[i].innerText;
}
}
}
/**
* 根据当前路由,初始化展开左侧菜单
*/
function initSideMenuStatus()
{
var selectMenu = window.location.hash;
selectMenu = selectMenu.split("?")[0];
var selectMenus = selectMenu.split("-");
var leftMenuItems = document.getElementsByClassName("menu_item");
for(var i = 0;i<leftMenuItems.length;i++)
{
//判断路由是否等于当前路由
if(leftMenuItems[i].children[0].hash ==selectMenus[0])
{
//展开一级菜单
toggoleSildMenu({currentTarget:leftMenuItems[i]});
if(selectMenus.length>1)
{
var subContainerTemp = leftMenuItems[i].parentElement.children[1];
var subContainerLis = subContainerTemp.getElementsByTagName("li");
for(var j = 0;j<subContainerLis.length;j++)
{
if(subContainerLis[j].children[0].hash.split("?")[0] ==selectMenu)
{
//展开子项
sildMenuItemClick({currentTarget:subContainerLis[j]});
break;
}
}
}
break;
}
}
}
</script>
</html>