forked from hooray/hoorayos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhros.dock.js
More file actions
217 lines (217 loc) · 6.38 KB
/
hros.dock.js
File metadata and controls
217 lines (217 loc) · 6.38 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
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
/*
** 应用码头
*/
HROS.dock = (function(){
return {
/*
** 初始化
*/
init: function(){
HROS.dock.setPos();
//绑定应用码头拖动事件
HROS.dock.move();
var dockShowtopFunc;
$('#dock-container').on('mouseenter', function(){
dockShowtopFunc = setTimeout(function(){
$('#dock-container').addClass('showtop');
}, 300);
}).on('mouseleave', function(){
clearInterval(dockShowtopFunc);
$(this).removeClass('showtop');
});
$('body').on('contextmenu', '#dock-container', function(e){
HROS.popupMenu.hide();
HROS.folderView.hide();
HROS.searchBar.hide();
HROS.startMenu.hide();
HROS.popupMenu.dock(e);
return false;
});
//绑定应用码头上各个按钮的点击事件
$('#dock-bar .dock-tool-setting').on('mousedown', function(){
return false;
}).on('click',function(){
if(HROS.base.checkLogin()){
HROS.window.createTemp({
appid: 'hoorayos-zmsz',
title: '桌面设置',
url: 'sysapp/desksetting/index.php',
width: 800,
height: 450,
isflash: false
});
}else{
HROS.base.login();
}
});
$('#dock-bar .dock-tool-style').on('mousedown', function(){
return false;
}).on('click', function(){
if(HROS.base.checkLogin()){
HROS.window.createTemp({
appid: 'hoorayos-ztsz',
title: '主题设置',
url: 'sysapp/wallpaper/index.php',
width: 580,
height: 550,
isflash: false
});
}else{
HROS.base.login();
}
});
$('#dock-bar .dock-tool-appmanage').on('mousedown', function(){
return false;
}).on('click',function(){
HROS.appmanage.set();
});
$('#dock-bar .dock-tool-search').on('mousedown', function(e){
return false;
}).on('click',function(e){
e.stopPropagation();
HROS.searchBar.get();
});
$('#dock-bar .pagination').on('mousedown', function(){
return false;
}).on('click',function(){
HROS.dock.switchDesk($(this).attr('index'));
});
$('#dock-bar .dock-tool-start').on('mousedown', function(){
return false;
}).on('click', function(){
HROS.startMenu.show();
return false;
});
},
setPos: function(){
HROS.dock.switchDesk(HROS.CONFIG.desk);
var desktop = $('#desk-' + HROS.CONFIG.desk), desktops = $('#desk .desktop-container');
var desk_w = desktop.css('width', '100%').width(), desk_h = desktop.css('height', '100%').height();
//清除dock位置样式
$('#dock-container').removeClass('dock-top dock-left dock-right');
$('#dock-bar').removeClass('top-bar left-bar right-bar').hide();
if(HROS.CONFIG.dockPos == 'top'){
$('#dock-bar').addClass('top-bar').children('#dock-container').addClass('dock-top');
desktops.css({
width: desk_w,
height: desk_h - $('#task-bar').height() - $('#dock-bar').height(),
left: desk_w,
top: $('#dock-bar').height()
});
desktop.css({
left: 0
});
$('#dock-bar').show();
}else if(HROS.CONFIG.dockPos == 'left'){
$('#dock-bar').addClass('left-bar').children('#dock-container').addClass('dock-left');
desktops.css({
width: desk_w - $('#dock-bar').width(),
height: desk_h - $('#task-bar').height(),
left: desk_w + $('#dock-bar').width(),
top: 0
});
desktop.css({
left: $('#dock-bar').width()
});
$('#dock-bar').show();
}else if(HROS.CONFIG.dockPos == 'right'){
$('#dock-bar').addClass('right-bar').children('#dock-container').addClass('dock-right');
desktops.css({
width: desk_w - $('#dock-bar').width(),
height: desk_h - $('#task-bar').height(),
left: desk_w,
top: 0
});
desktop.css({
left: 0
});
$('#dock-bar').show();
}else if(HROS.CONFIG.dockPos == 'none'){
desktops.css({
width: desk_w,
height: desk_h - $('#task-bar').height(),
left: desk_w,
top: 0
});
desktop.css({
left: 0
});
}
HROS.taskBar.resize();
HROS.folderView.setPos();
},
updatePos: function(pos){
if(pos != HROS.CONFIG.dockPos && typeof(pos) != 'undefined'){
HROS.CONFIG.dockPos = pos;
if(pos == 'none'){
HROS.app.dataAllDockToDesk(HROS.CONFIG.desk);
}
//更新码头位置
HROS.dock.setPos();
//更新桌面应用
HROS.app.set();
if(HROS.base.checkLogin()){
$.ajax({
data: {
ac: 'setDockPos',
dock: pos,
desk: HROS.CONFIG.desk
}
});
}
}
},
move: function(){
$('#dock-container').on('mousedown touchstart',function(e){
if(e.which == 0 || e.which == 1){
var lay = HROS.maskBox.dock(), location;
$(document).on('mousemove touchmove', function(e){
var cx = e.type == 'mousemove' ? e.clientX : e.originalEvent.targetTouches[0].clientX;
var cy = e.type == 'mousemove' ? e.clientY : e.originalEvent.targetTouches[0].clientY;
lay.show();
if(cy < lay.height() * 0.2){
location = 'top';
}else if(cx < lay.width() * 0.5){
location = 'left';
}else{
location = 'right';
}
$('.dock_drap_effect').removeClass('hover');
$('.dock_drap_effect_' + location).addClass('hover');
}).on('mouseup touchend', function(){
$(document).off('mousemove touchmove mouseup touchend');
lay.hide();
HROS.dock.updatePos(location);
});
}
});
},
/*
** 切换桌面
*/
switchDesk: function(deskNumber){
//验证传入的桌面号是否为1-5的正整数
deskNumber = /^\+?[1-5]*$/.test(deskNumber) ? deskNumber: 1;
var pagination = $('#dock-bar .dock-pagination'), currindex = HROS.CONFIG.desk, switchindex = deskNumber,
currleft = $('#desk-' + currindex).offset().left, switchleft = $('#desk-' + switchindex).offset().left;
if(currindex != switchindex){
if(!$('#desk-' + switchindex).hasClass('animated') && !$('#desk-' + currindex).hasClass('animated')){
$('#desk-' + currindex).addClass('animated').animate({
left: switchleft
}, 500, 'easeInOutCirc', function(){
$(this).removeClass('animated');
});
$('#desk-'+switchindex).addClass('animated').animate({
left: currleft
}, 500, 'easeInOutCirc', function(){
$(this).removeClass('animated');
pagination.removeClass('current-pagination-' + currindex).addClass('current-pagination-' + switchindex);
HROS.CONFIG.desk = switchindex;
});
}
}else{
pagination.removeClass('current-pagination-' + currindex).addClass('current-pagination-' + switchindex);
}
}
}
})();