forked from hooray/hoorayos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhros.taskBar.js
More file actions
172 lines (172 loc) · 5.22 KB
/
Copy pathhros.taskBar.js
File metadata and controls
172 lines (172 loc) · 5.22 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
/*
** 任务栏
*/
HROS.taskBar = (function(){
return {
/*
** 初始化
*/
init: function(){
//当浏览器窗口改变大小时,任务栏的显示也需进行刷新
$(window).on('resize', function(){
HROS.taskBar.resize();
});
//绑定任务栏拖动事件
HROS.taskBar.move();
//绑定任务栏前进后退按钮事件
HROS.taskBar.pageClick();
//绑定任务栏右键事件
$('#task-content-inner').on('contextmenu', '.task-item', function(e){
$('.popup-menu').hide();
$('.quick_view_container').remove();
HROS.popupMenu.task(e, $(this));
return false;
});
},
pageClick: function(){
$('#task-next-btn').on('click', function(){
if($(this).hasClass('disable') == false){
var taskW = $('#task-content-inner .task-item').width();
var marginL = parseInt($('#task-content-inner').css('margin-left')) - taskW;
var overW = $('#task-bar').width() - $('#task-next').outerWidth(true) - $('#task-prev').outerWidth(true) - $('#task-content-inner .task-item').length * taskW;
if(marginL <= overW){
marginL = overW;
$('#task-next a').addClass('disable');
}
$('#task-prev a').removeClass('disable');
$('#task-content-inner').animate({
marginLeft: marginL
}, 200);
}
});
$('#task-prev-btn').on('click', function(){
if($(this).hasClass('disable') == false){
var taskW = $('#task-content-inner .task-item').width();
var marginL = parseInt($('#task-content-inner').css('margin-left')) + taskW;
if(marginL >= 0){
marginL = 0;
$('#task-prev a').addClass('disable');
}
$('#task-next a').removeClass('disable');
$('#task-content-inner').animate({
marginLeft: marginL
}, 200);
}
});
},
resize: function(){
if(HROS.CONFIG.dockPos == 'left'){
$('#task-bar').css({
left: $('#dock-bar').width(),
right: 0
});
}else if(HROS.CONFIG.dockPos == 'right'){
$('#task-bar').css({
left: 0,
right: $('#dock-bar').width()
});
}else{
$('#task-bar').css({
left: 0,
right: 0
});
}
var realW = $('#task-content-inner .task-item').length * $('#task-content-inner .task-item').width();
var showW = $('#task-bar').width() - $('#task-next').outerWidth(true) - $('#task-prev').outerWidth(true);
if(realW >= showW){
$('#task-next, #task-prev').show();
$('#task-content').css('width', showW);
$('#task-content-inner').stop(true, false).animate({
marginLeft: 0
}, 200);
$('#task-next a').removeClass('disable');
$('#task-prev a').addClass('disable');
}else{
$('#task-next, #task-prev').hide();
$('#task-content').css('width','100%');
$('#task-content-inner').css({
marginLeft: 0
});
}
},
move: function(){
$('#task-content-inner').on('mousedown touchstart', '.task-item', function(e){
e.preventDefault();
e.stopPropagation();
if(e.which == 0 || e.which == 1){
var self = $(this);
var task_left = self.offset().left;
var task_width = self.width();
var drag = self.clone().addClass('task-dragging').css({
left: task_left
});
var current_animate_id;
var dx = e.type == 'mousedown' ? e.clientX : e.originalEvent.targetTouches[0].clientX;
var cx = e.type == 'mousedown' ? e.clientX : e.originalEvent.targetTouches[0].clientX;
var lay = HROS.maskBox.desk();
$(document).on('mousemove touchmove', function(e){
$('body').append(drag);
self.css('opacity', 0);
lay.show();
cx = e.type == 'mousemove' ? e.clientX : e.originalEvent.targetTouches[0].clientX;
var left = cx - dx + task_left;
drag.css('left', left);
$('#task-content-inner').find('.task-item').each(function(i){
var this_left = $(this).offset().left;
if(left > this_left && left < this_left + task_width / 2){
if(self.attr('id') != $(this).attr('id')){
swapTab($(this).attr('id'), 'b');
}
}else if(left < this_left && left > this_left - task_width / 2){
if(self.attr('id') != $(this).attr('id')){
swapTab($(this).attr('id'), 'a');
}
}
});
}).on('mouseup touchend', function(e){
$(document).off('mousemove touchmove mouseup touchend');
lay.hide();
drag.animate({
left: self.offset().left
}, 200, function(){
$(this).remove();
self.css('opacity', 1);
});
if(dx == cx){
if(self.hasClass('task-item-current')){
HROS.window.hide(self.attr('appid'));
}else{
HROS.window.show2top(self.attr('appid'));
}
}
});
var swapTab = function(id, boa){
if(!(self.is(':animated') && current_animate_id == id)){
current_animate_id = id;
self.stop(true, true);
$('#task-content-inner').find('.task-temp').remove();
var temp = self.clone().insertAfter(self).addClass('task-temp');
if(boa == 'b'){
$('#' + id).before(self.css({
width: 0
}));
}else{
$('#' + id).after(self.css({
width: 0
}));
}
self.animate({
width: task_width
}, 100);
temp.animate({
width: 0
}, 100, function(){
$(this).remove();
});
}
};
}
});
}
}
})();