-
Notifications
You must be signed in to change notification settings - Fork 0
/
couplelogcollection.js
76 lines (66 loc) · 1.85 KB
/
couplelogcollection.js
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
function CoupleLogCollection(logs){
this.logs = logs;
this.couplelogs = {};
};
CoupleLogCollection.prototype.setCurrentUser = function(currentUser){
this.currentUser = currentUser;
};
CoupleLogCollection.prototype.eachIf = function(whatToDo){
$.each(this.logs, function(id, value){
if(id != 'counter') {
whatToDo(id);
}
});
}
CoupleLogCollection.prototype.create = function(){
this.addLog = new AddLog(this, this.currentUser);
var _this = this;
this.eachIf(function(id){
_this.couplelogs[id] = new CoupleLog(_this, _this.logs[id], _this.currentUser);
});
};
CoupleLogCollection.prototype.destroy = function(){
var _this = this;
this.eachIf(function(id){
if (_this.couplelogs[id] != undefined) {
_this.couplelogs[id].destroy();
_this.addLog.destroy();
}
});
};
CoupleLogCollection.prototype.makeCurrent = function(idn){
var _this = this;
//перерисовка баров при изменении размеров окна
$(window).resize(function(){
_this.couplelogs[idn].sync();
forceOperaRepaint();
// Forcing Opera full page reflow/repaint to fix page draw bugs
function forceOperaRepaint() {
if (window.opera) {
var bs = document.body.style;
bs.position = 'relative';
setTimeout(function() {
bs.position = 'static';
}, 1);
}
}
});
$.cookie('currentId', null, { expires: 1 })
function currentToggle(id){
_this.couplelogs[id].slide.slideToggle("fast", function(){
// _this.couplelogs[id].sync();
});
_this.couplelogs[id].title.toggleClass("active");
};
this.eachIf(function(id){
if (_this.couplelogs[id].data.id == idn) {
currentToggle(id);
} else if (_this.couplelogs[id].title.attr("class") == "active"){
currentToggle(id);
}
if (_this.couplelogs[id].title.attr("class") == "active") {
$.cookie('currentId', idn, { expires: 1 })
}
_this.couplelogs[id].sync();
});
};