-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdesktop.js
More file actions
74 lines (65 loc) · 1.97 KB
/
Copy pathdesktop.js
File metadata and controls
74 lines (65 loc) · 1.97 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
var Desktop = {
options: {
windowArea: ".window-area",
windowAreaClass: "",
taskBar: ".task-bar > .tasks",
taskBarClass: ""
},
wins: {},
setup: function(options){
this.options = $.extend( {}, this.options, options );
return this;
},
addToTaskBar: function(wnd){
var icon = wnd.getIcon();
var wID = wnd.win.attr("id");
var item = $("<span>").addClass("task-bar-item started").html(icon);
item.data("wID", wID);
item.appendTo($(this.options.taskBar));
},
removeFromTaskBar: function(wnd){
console.log(wnd);
var wID = wnd.attr("id");
var items = $(".task-bar-item");
var that = this;
$.each(items, function(){
var item = $(this);
if (item.data("wID") === wID) {
delete that.wins[wID];
item.remove();
}
})
},
createWindow: function(o){
var that = this;
o.onDragStart = function(pos, el){
win = $(el);
$(".window").css("z-index", 1);
if (!win.hasClass("modal"))
win.css("z-index", 3);
};
o.onDragStop = function(pos, el){
win = $(el);
if (!win.hasClass("modal"))
win.css("z-index", 2);
};
o.onWindowDestroy = function(win){
console.log(win);
that.removeFromTaskBar(win);
};
var w = $("<div>").appendTo($(this.options.windowArea));
var wnd = w.window(o).data("window");
var win = wnd.win;
var shift = Metro.utils.objectLength(this.wins) * 16;
if (wnd.options.place === "auto" && wnd.options.top === "auto" && wnd.options.left === "auto") {
win.css({
top: shift,
left: shift
});
}
this.wins[win.attr("id")] = wnd;
this.addToTaskBar(wnd);
w.remove();
}
};
Desktop.setup();