social_cheesecake 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/javascripts/socialcheesecake/_header.js +3 -3
- data/app/assets/javascripts/socialcheesecake/actor.js +139 -123
- data/app/assets/javascripts/socialcheesecake/cheesecake.js +293 -304
- data/app/assets/javascripts/socialcheesecake/colors.js +36 -0
- data/app/assets/javascripts/socialcheesecake/eventCallbackHandlers.js +116 -0
- data/app/assets/javascripts/socialcheesecake/grid.js +144 -181
- data/app/assets/javascripts/socialcheesecake/search.js +13 -13
- data/app/assets/javascripts/socialcheesecake/sector.js +363 -290
- data/app/assets/javascripts/socialcheesecake/subsector.js +122 -0
- data/app/assets/javascripts/socialcheesecake/text.js +16 -19
- data/lib/social_cheesecake/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/main.js +0 -16
- data/test/dummy/app/assets/stylesheets/style.css +0 -1
- metadata +7 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license SocialCheesecake JavaScript Library v0.
|
|
2
|
+
* @license SocialCheesecake JavaScript Library v0.4.0
|
|
3
3
|
* https://github.com/adiezbal/SocialCheesecake
|
|
4
|
-
* Developed by Alicia
|
|
5
|
-
* Copyright 2011, Technical University of Madrid (Universidad
|
|
4
|
+
* Developed by Alicia Diez (https://github.com/adiezbal)
|
|
5
|
+
* Copyright 2011, Technical University of Madrid (Universidad Politecnica de Madrid)
|
|
6
6
|
* Licensed under the MIT or GPL Version 2 licenses.
|
|
7
7
|
* Date: Dec 22 2011
|
|
8
8
|
*
|
|
@@ -1,243 +1,259 @@
|
|
|
1
|
-
var socialCheesecake = socialCheesecake || {};
|
|
1
|
+
var socialCheesecake = socialCheesecake || {};
|
|
2
2
|
(function() {
|
|
3
3
|
socialCheesecake.Actor = function(settings) {
|
|
4
|
-
if(!settings)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if(!( property in settings)) {
|
|
10
|
-
settings[property] = defaultSettings[property];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
4
|
+
if(!settings)
|
|
5
|
+
throw "No arguments passed to the function"
|
|
6
|
+
if(!settings.parent)
|
|
7
|
+
throw "Actor must be associated to at least a subsector"
|
|
8
|
+
|
|
13
9
|
this.id = settings.id;
|
|
14
10
|
this.name = settings.name;
|
|
15
11
|
this.extraInfo = (settings.extraInfo) ? settings.extraInfo : undefined;
|
|
16
|
-
this.opacity =
|
|
12
|
+
this.opacity = socialCheesecake.Grid.maxOpacity;
|
|
17
13
|
this._focused = false;
|
|
18
14
|
this._selected = false;
|
|
19
15
|
this._hidden = true;
|
|
20
16
|
this._filtered = false;
|
|
21
17
|
this.fading = "none";
|
|
22
18
|
this.parents = [];
|
|
23
|
-
if(settings.parent)
|
|
24
|
-
|
|
19
|
+
if(settings.parent)
|
|
20
|
+
this.parents.push(settings.parent);
|
|
21
|
+
|
|
25
22
|
var actor = this;
|
|
26
23
|
var actor_div = actor.getDiv();
|
|
27
|
-
|
|
28
|
-
actor_div.addEventListener("mouseover", function(){
|
|
24
|
+
|
|
25
|
+
actor_div.addEventListener("mouseover", function() {
|
|
29
26
|
var sector;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
for (var subsector in actor.parents){
|
|
27
|
+
actor.focus();
|
|
28
|
+
for(var subsector in actor.parents) {
|
|
34
29
|
sector = actor.parents[subsector].parent;
|
|
35
30
|
sector.focus();
|
|
36
|
-
sector.
|
|
37
|
-
actor.parents[subsector].
|
|
31
|
+
sector.colorHandler("mouseover");
|
|
32
|
+
actor.parents[subsector].colorHandler("mouseover");
|
|
38
33
|
}
|
|
39
34
|
}, false);
|
|
40
|
-
actor_div.addEventListener("mouseout", function(){
|
|
35
|
+
actor_div.addEventListener("mouseout", function() {
|
|
41
36
|
var sector;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
for (var subsector in actor.parents){
|
|
37
|
+
actor.unfocus();
|
|
38
|
+
for(var subsector in actor.parents) {
|
|
46
39
|
sector = actor.parents[subsector].parent;
|
|
47
40
|
sector.unfocus();
|
|
48
|
-
sector.
|
|
49
|
-
actor.parents[subsector].
|
|
41
|
+
sector.colorHandler("mouseout");
|
|
42
|
+
actor.parents[subsector].colorHandler("mouseout");
|
|
50
43
|
}
|
|
51
44
|
}, false);
|
|
52
|
-
actor_div.addEventListener("
|
|
45
|
+
actor_div.addEventListener("click", function() {
|
|
53
46
|
var sector;
|
|
54
|
-
if(
|
|
55
|
-
// Deactivate actor
|
|
47
|
+
if(actor.isSelected()) {
|
|
56
48
|
actor.unselect();
|
|
57
|
-
}else{
|
|
58
|
-
//Activate actor
|
|
49
|
+
} else {
|
|
59
50
|
actor.select();
|
|
51
|
+
actor.unfocus();
|
|
60
52
|
}
|
|
61
53
|
}, false);
|
|
62
54
|
}
|
|
63
|
-
|
|
55
|
+
|
|
64
56
|
socialCheesecake.Actor.prototype.getParentsIds = function() {
|
|
65
57
|
var parents = this.parents;
|
|
66
58
|
var parentsIds = [];
|
|
67
|
-
|
|
68
|
-
for(var i in parents){
|
|
59
|
+
|
|
60
|
+
for(var i in parents) {
|
|
69
61
|
parentsIds.push(parents[i].id);
|
|
70
62
|
}
|
|
71
63
|
return parentsIds;
|
|
72
64
|
}
|
|
73
|
-
|
|
65
|
+
|
|
66
|
+
socialCheesecake.Actor.prototype.addClass = function(cssClass) {
|
|
67
|
+
var actor_div = this.getDiv();
|
|
68
|
+
var newClass = "";
|
|
69
|
+
var classRegExp = new RegExp("(^|\\s)" + cssClass + "($|\\s)");
|
|
70
|
+
|
|
71
|
+
if(actor_div.getAttribute("class")) {
|
|
72
|
+
newClass = actor_div.getAttribute("class");
|
|
73
|
+
if(!(newClass.match(classRegExp)) ) {
|
|
74
|
+
newClass = newClass.concat(" " + cssClass);
|
|
75
|
+
actor_div.setAttribute("class", newClass);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
newClass = cssClass;
|
|
79
|
+
actor_div.setAttribute("class", newClass);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
socialCheesecake.Actor.prototype.removeClass = function(cssClass) {
|
|
84
|
+
var actor_div = this.getDiv();
|
|
85
|
+
var newClass = "";
|
|
86
|
+
var classRegExp = new RegExp("(^|\\s)" + cssClass + "($|\\s)");
|
|
87
|
+
|
|
88
|
+
if(actor_div.getAttribute("class")) {
|
|
89
|
+
newClass = actor_div.getAttribute("class");
|
|
90
|
+
if (newClass.match(classRegExp)){
|
|
91
|
+
classRegExp = new RegExp("(^|\\s)" + cssClass);
|
|
92
|
+
newClass = actor_div.getAttribute("class").replace(classRegExp, "");
|
|
93
|
+
actor_div.setAttribute("class", newClass);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
74
98
|
socialCheesecake.Actor.prototype.isSelected = function() {
|
|
75
99
|
return this._selected;
|
|
76
100
|
}
|
|
77
|
-
|
|
101
|
+
|
|
78
102
|
socialCheesecake.Actor.prototype.select = function() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
actor.focus();
|
|
103
|
+
this._selected = true;
|
|
104
|
+
this.addClass("selected");
|
|
82
105
|
}
|
|
83
|
-
|
|
106
|
+
|
|
84
107
|
socialCheesecake.Actor.prototype.unselect = function() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
actor.unfocus();
|
|
108
|
+
this._selected = false;
|
|
109
|
+
this.removeClass("selected");
|
|
88
110
|
}
|
|
89
|
-
|
|
111
|
+
|
|
90
112
|
socialCheesecake.Actor.prototype.focus = function() {
|
|
91
|
-
var actor_div = this.getDiv();
|
|
92
|
-
var newClass="";
|
|
93
113
|
this._focused = true;
|
|
94
|
-
|
|
95
|
-
if (!(actor_div.getAttribute("class").match(/\sfocused/) )){
|
|
96
|
-
newClass = actor_div.getAttribute("class").concat(" focused");
|
|
97
|
-
actor_div.setAttribute("class", newClass);
|
|
98
|
-
}
|
|
99
|
-
}else{
|
|
100
|
-
newClass = "focused";
|
|
101
|
-
actor_div.setAttribute("class", newClass);
|
|
102
|
-
}
|
|
114
|
+
this.addClass("focused");
|
|
103
115
|
}
|
|
104
|
-
|
|
116
|
+
|
|
105
117
|
socialCheesecake.Actor.prototype.unfocus = function() {
|
|
106
|
-
var actor_div = this.getDiv();
|
|
107
|
-
var newClass="";
|
|
108
118
|
this._focused = false;
|
|
109
|
-
|
|
110
|
-
newClass = actor_div.getAttribute("class").replace(/(^|\s)focused($|\s)/, "");
|
|
111
|
-
actor_div.setAttribute("class", newClass);
|
|
112
|
-
}
|
|
119
|
+
this.removeClass("focused");
|
|
113
120
|
}
|
|
114
|
-
|
|
115
|
-
socialCheesecake.Actor.prototype.isFocused = function() {
|
|
121
|
+
|
|
122
|
+
socialCheesecake.Actor.prototype.isFocused = function() {
|
|
123
|
+
var actor = this;
|
|
116
124
|
var gridIdPrefix = this.getCheesecake().grid.divIdPrefix;
|
|
117
125
|
return this._focused;
|
|
118
126
|
}
|
|
119
|
-
|
|
127
|
+
|
|
120
128
|
socialCheesecake.Actor.prototype.hide = function() {
|
|
121
129
|
var actor_div = this.getDiv();
|
|
122
|
-
var newStyle=" display: none;";
|
|
130
|
+
var newStyle = " display: none;";
|
|
123
131
|
this._hidden = true;
|
|
124
|
-
if
|
|
125
|
-
if
|
|
126
|
-
newStyle = actor_div.getAttribute("style").replace(/display\s*:\s*[a-z]*;/, "display: none;");
|
|
127
|
-
}else{
|
|
132
|
+
if(actor_div.getAttribute("style")) {
|
|
133
|
+
if(actor_div.getAttribute("style").match(/display\s*:\s*[a-z]*;/)) {
|
|
134
|
+
newStyle = actor_div.getAttribute("style").replace(/display\s*:\s*[a-z]*;/, "display: none;");
|
|
135
|
+
} else {
|
|
128
136
|
newStyle = actor_div.getAttribute("style").concat("display: none;");
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
139
|
actor_div.setAttribute("style", newStyle);
|
|
132
|
-
this.fading= "none";
|
|
140
|
+
this.fading = "none";
|
|
133
141
|
}
|
|
134
142
|
|
|
135
143
|
socialCheesecake.Actor.prototype.show = function() {
|
|
136
144
|
var actor_div = this.getDiv();
|
|
137
|
-
var newStyle=" display: inline;";
|
|
138
|
-
|
|
139
|
-
if(this.isFiltered())
|
|
140
|
-
|
|
145
|
+
var newStyle = " display: inline;";
|
|
146
|
+
|
|
147
|
+
if(this.isFiltered())
|
|
148
|
+
return;
|
|
149
|
+
|
|
141
150
|
this._hidden = false;
|
|
142
|
-
if
|
|
143
|
-
if
|
|
144
|
-
newStyle = actor_div.getAttribute("style").replace(/display\s*:\s*[a-z]*;/, "display: inline;");
|
|
145
|
-
}else{
|
|
151
|
+
if(actor_div.getAttribute("style")) {
|
|
152
|
+
if(actor_div.getAttribute("style").match(/display\s*:\s*[a-z]*;/)) {
|
|
153
|
+
newStyle = actor_div.getAttribute("style").replace(/display\s*:\s*[a-z]*;/, "display: inline;");
|
|
154
|
+
} else {
|
|
146
155
|
newStyle = actor_div.getAttribute("style").concat("display: inline;");
|
|
147
|
-
}
|
|
156
|
+
}
|
|
148
157
|
}
|
|
149
158
|
actor_div.setAttribute("style", newStyle);
|
|
150
159
|
}
|
|
151
|
-
|
|
160
|
+
|
|
152
161
|
socialCheesecake.Actor.prototype.isHidden = function() {
|
|
153
162
|
return this._hidden;
|
|
154
163
|
}
|
|
155
|
-
|
|
164
|
+
|
|
156
165
|
socialCheesecake.Actor.prototype.isFiltered = function() {
|
|
157
166
|
return this._filtered;
|
|
158
167
|
}
|
|
159
|
-
|
|
168
|
+
|
|
160
169
|
socialCheesecake.Actor.prototype.isVisible = function() {
|
|
161
170
|
return !(this.isHidden() || this.isFiltered());
|
|
162
171
|
}
|
|
163
|
-
|
|
172
|
+
|
|
164
173
|
socialCheesecake.Actor.prototype.filter = function() {
|
|
165
174
|
this._filtered = true;
|
|
166
175
|
this.fadeOut(100, true);
|
|
167
176
|
}
|
|
168
|
-
|
|
177
|
+
|
|
169
178
|
socialCheesecake.Actor.prototype.unfilter = function() {
|
|
170
179
|
this._filtered = false;
|
|
171
180
|
}
|
|
172
|
-
|
|
181
|
+
|
|
173
182
|
socialCheesecake.Actor.prototype.setDivOpacity = function(opacity) {
|
|
174
183
|
opacity = (opacity > 1) ? 1 : opacity;
|
|
175
184
|
opacity = (opacity < 0) ? 0 : opacity;
|
|
176
185
|
var actor = this;
|
|
177
186
|
var actor_div = this.getDiv();
|
|
178
|
-
|
|
187
|
+
|
|
179
188
|
this.opacity = opacity;
|
|
180
|
-
var newStyle="opacity: "+this.opacity + ";";
|
|
181
|
-
|
|
182
|
-
if
|
|
189
|
+
var newStyle = "opacity: " + this.opacity + ";";
|
|
190
|
+
|
|
191
|
+
if(actor_div.getAttribute("style")) {
|
|
183
192
|
newStyle = actor_div.getAttribute("style").replace(/opacity\s*:\s*[a-zA-Z0-9.]*;/g, "");
|
|
184
|
-
newStyle = newStyle.concat("opacity: "+this.opacity + ";");
|
|
193
|
+
newStyle = newStyle.concat("opacity: " + this.opacity + ";");
|
|
185
194
|
}
|
|
186
195
|
actor_div.setAttribute("style", newStyle);
|
|
187
196
|
}
|
|
188
|
-
|
|
197
|
+
|
|
189
198
|
socialCheesecake.Actor.prototype.fade = function(time, modifyDisplay) {
|
|
190
|
-
var actor = this;
|
|
199
|
+
var actor = this;
|
|
191
200
|
var time = (time) ? time : 300;
|
|
192
|
-
var
|
|
201
|
+
var minOpacity = socialCheesecake.Grid.minOpacity;
|
|
202
|
+
var maxOpacity = socialCheesecake.Grid.maxOpacity;
|
|
203
|
+
var deltaOpacity = ((maxOpacity - minOpacity)* 1000.0) / (60.0 * time);
|
|
193
204
|
var grow = 0;
|
|
194
205
|
|
|
195
|
-
if
|
|
206
|
+
if(this.fading == "out") {
|
|
196
207
|
grow = -1;
|
|
197
|
-
|
|
208
|
+
if(deltaOpacity > (this.opacity - minOpacity)) deltaOpacity = this.opacity - minOpacity;
|
|
209
|
+
} else if(this.fading == "in") {
|
|
198
210
|
grow = 1;
|
|
211
|
+
if(deltaOpacity > (maxOpacity - this.opacity)) deltaOpacity = maxOpacity - this.opacity;
|
|
199
212
|
}
|
|
213
|
+
|
|
200
214
|
var opacity = this.opacity + grow * deltaOpacity;
|
|
201
|
-
opacity = Math.round(opacity*1000)/1000;
|
|
215
|
+
opacity = Math.round(opacity * 1000) / 1000;
|
|
202
216
|
actor.setDivOpacity(opacity);
|
|
203
|
-
|
|
204
|
-
if
|
|
205
|
-
|
|
206
|
-
requestAnimFrame(function() {
|
|
217
|
+
|
|
218
|
+
if(((this.fading == "out") && (opacity > minOpacity)) || ((this.fading == "in") && (opacity < maxOpacity))) {
|
|
219
|
+
requestAnimFrame(function() {
|
|
207
220
|
actor.fade(time, modifyDisplay);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
this.fading = "none";
|
|
224
|
+
if((modifyDisplay) && (opacity <= minOpacity))
|
|
225
|
+
actor.hide();
|
|
226
|
+
}
|
|
213
227
|
}
|
|
214
|
-
|
|
228
|
+
|
|
215
229
|
socialCheesecake.Actor.prototype.fadeOut = function(time, modifyDisplay) {
|
|
230
|
+
var maxOpacity = socialCheesecake.Grid.maxOpacity;
|
|
216
231
|
this.fading = "out";
|
|
217
|
-
this.setDivOpacity(
|
|
232
|
+
this.setDivOpacity(maxOpacity);
|
|
218
233
|
this.fade(time, modifyDisplay);
|
|
219
234
|
}
|
|
220
|
-
|
|
235
|
+
|
|
221
236
|
socialCheesecake.Actor.prototype.fadeIn = function(time, modifyDisplay) {
|
|
222
237
|
var actor = this;
|
|
223
|
-
|
|
224
|
-
|
|
238
|
+
var minOpacity = socialCheesecake.Grid.minOpacity;
|
|
239
|
+
|
|
240
|
+
if(actor.isFiltered())
|
|
241
|
+
return;
|
|
225
242
|
actor.fading = "in";
|
|
226
|
-
actor.setDivOpacity(
|
|
227
|
-
if
|
|
243
|
+
actor.setDivOpacity(minOpacity);
|
|
244
|
+
if(modifyDisplay)
|
|
245
|
+
actor.show();
|
|
228
246
|
actor.fade(time, modifyDisplay);
|
|
229
247
|
}
|
|
230
|
-
|
|
231
|
-
socialCheesecake.Actor.prototype.getCheesecake = function
|
|
248
|
+
|
|
249
|
+
socialCheesecake.Actor.prototype.getCheesecake = function() {
|
|
232
250
|
return this.parents[0].parent.parent;
|
|
233
251
|
}
|
|
234
|
-
|
|
235
|
-
socialCheesecake.Actor.prototype.getDiv = function
|
|
252
|
+
|
|
253
|
+
socialCheesecake.Actor.prototype.getDiv = function() {
|
|
236
254
|
var gridIdPrefix = this.getCheesecake().grid.divIdPrefix;
|
|
237
255
|
var actor_id = this.id;
|
|
238
|
-
var actor_div = document.getElementById(gridIdPrefix+actor_id);
|
|
256
|
+
var actor_div = document.getElementById(gridIdPrefix + actor_id);
|
|
239
257
|
return actor_div;
|
|
240
258
|
}
|
|
241
|
-
|
|
242
|
-
})();
|
|
243
|
-
|
|
259
|
+
})();
|
|
@@ -1,34 +1,5 @@
|
|
|
1
1
|
var socialCheesecake = socialCheesecake || {};
|
|
2
2
|
(function() {
|
|
3
|
-
|
|
4
|
-
//General variable settings (with default values)
|
|
5
|
-
socialCheesecake.colors = {
|
|
6
|
-
normalSector : {
|
|
7
|
-
background : "#eeffee", //normal, mouseout, mouseup states
|
|
8
|
-
highlight : "#77ff77", //mousedown state
|
|
9
|
-
hover : "#aaffaa", //mouseover state
|
|
10
|
-
font : "#1F4A75", //text
|
|
11
|
-
border : "#1F4A75" //stroke
|
|
12
|
-
},
|
|
13
|
-
extraSector : {
|
|
14
|
-
background : "#e5e5e5",
|
|
15
|
-
highlight : "#1FA0F7",
|
|
16
|
-
hover : "#D4E4EA",
|
|
17
|
-
font : "#1F4A75",
|
|
18
|
-
border : "#1F4A75"
|
|
19
|
-
},
|
|
20
|
-
greySector : {
|
|
21
|
-
background : "#f5f5f5",
|
|
22
|
-
highlight : "#f5f5f5",
|
|
23
|
-
hover : "#f5f5f5",
|
|
24
|
-
font : "#666",
|
|
25
|
-
border : "#666"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Number of actors to animate */
|
|
30
|
-
var maxVisibleActors = 30;
|
|
31
|
-
|
|
32
3
|
socialCheesecake.Cheesecake = function(cheesecakeData) {
|
|
33
4
|
var jsonSectors = cheesecakeData.sectors;
|
|
34
5
|
var cheesecake = this;
|
|
@@ -40,137 +11,75 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
40
11
|
cheesecake.rMax = cheesecakeData.rMax;
|
|
41
12
|
cheesecake.sectors = [];
|
|
42
13
|
cheesecake.highlightedSector = null;
|
|
43
|
-
cheesecake.
|
|
14
|
+
cheesecake.onSectorHighlight = cheesecakeData.onSectorHighlight || null;
|
|
15
|
+
cheesecake.onSectorFocusBegin = cheesecakeData.onSectorFocusBegin || null;
|
|
16
|
+
cheesecake.onSectorFocusEnd = cheesecakeData.onSectorFocusEnd || null;
|
|
17
|
+
cheesecake.onSectorUnfocusBegin = cheesecakeData.onSectorUnfocusBegin || null;
|
|
18
|
+
cheesecake.onSectorUnfocusEnd = cheesecakeData.onSectorUnfocusEnd || null;
|
|
19
|
+
cheesecake.syncSectorFocusCallbacks = cheesecake.syncSectorFocusCallbacks || false;
|
|
44
20
|
cheesecake.auxiliarSectors = [];
|
|
45
|
-
cheesecake.stage = new Kinetic.Stage(cheesecakeData.container.id,
|
|
46
|
-
cheesecakeData.container.width, cheesecakeData.container.height);
|
|
21
|
+
cheesecake.stage = new Kinetic.Stage(cheesecakeData.container.id, cheesecakeData.container.width, cheesecakeData.container.height);
|
|
47
22
|
cheesecake.stage.add(new Kinetic.Layer());
|
|
48
23
|
cheesecake.stage.mainLayer = cheesecake.stage.layers[0];
|
|
49
24
|
cheesecake.grid = new socialCheesecake.Grid({
|
|
50
25
|
parent : this,
|
|
51
26
|
grid_id : cheesecakeData.grid.id,
|
|
52
|
-
divIdPrefix : cheesecakeData.grid.divIdPrefix || "actor_"
|
|
27
|
+
divIdPrefix : cheesecakeData.grid.divIdPrefix || "actor_",
|
|
28
|
+
maxOpacity : cheesecakeData.grid.maxOpacity || 1,
|
|
29
|
+
minOpacity : cheesecakeData.grid.minOpacity || 0
|
|
53
30
|
});
|
|
54
31
|
cheesecake.searchEngine = new socialCheesecake.SearchEngine({
|
|
55
32
|
parent : this
|
|
56
33
|
});
|
|
57
34
|
cheesecake.matchActorsNumber = cheesecakeData.match;
|
|
58
|
-
if(cheesecake.matchActorsNumber==null)
|
|
35
|
+
if(cheesecake.matchActorsNumber == null)
|
|
36
|
+
cheesecake.matchActorsNumber = true;
|
|
59
37
|
cheesecake._initialState = {};
|
|
60
38
|
cheesecake._changes = {};
|
|
61
|
-
cheesecake.onChange = function(cheesecake){
|
|
62
|
-
|
|
63
|
-
socialCheesecake.Cheesecake.setMaxVisibleActors(cheesecakeData.maxVisibleActors);
|
|
39
|
+
cheesecake.onChange = function(cheesecake) {
|
|
40
|
+
};
|
|
64
41
|
if(cheesecakeData.onChange)
|
|
65
42
|
cheesecake.onChange = cheesecakeData.onChange;
|
|
66
43
|
//Text settings
|
|
67
|
-
if(cheesecakeData.text){
|
|
68
|
-
for(
|
|
69
|
-
socialCheesecake.text[style]= cheesecakeData.text[style];
|
|
44
|
+
if(cheesecakeData.text) {
|
|
45
|
+
for(var style in cheesecakeData.text) {
|
|
46
|
+
socialCheesecake.text[style] = cheesecakeData.text[style];
|
|
70
47
|
}
|
|
71
48
|
}
|
|
72
49
|
//Color settings
|
|
73
|
-
if(cheesecakeData.colors){
|
|
74
|
-
for(
|
|
75
|
-
for
|
|
76
|
-
socialCheesecake.colors[type][color]= cheesecakeData.colors[type][color];
|
|
50
|
+
if(cheesecakeData.colors) {
|
|
51
|
+
for(var type in cheesecakeData.colors) {
|
|
52
|
+
for(var color in cheesecakeData.colors[type]) {
|
|
53
|
+
socialCheesecake.colors[type][color] = cheesecakeData.colors[type][color];
|
|
77
54
|
}
|
|
78
55
|
}
|
|
79
56
|
}
|
|
80
|
-
|
|
81
|
-
if(jsonSectors.length < 16){
|
|
57
|
+
//Extra sector if necessary
|
|
58
|
+
if(jsonSectors.length < 16) {
|
|
82
59
|
var extraSector = new socialCheesecake.Sector({
|
|
83
60
|
parent : cheesecake,
|
|
84
|
-
center :
|
|
85
|
-
|
|
86
|
-
y : cheesecakeData.center.y
|
|
87
|
-
},
|
|
88
|
-
label: "+",
|
|
61
|
+
center : cheesecake.center,
|
|
62
|
+
label : "+",
|
|
89
63
|
rOut : cheesecakeData.rMax,
|
|
90
64
|
color : socialCheesecake.colors.extraSector.background,
|
|
91
|
-
mouseover : {
|
|
92
|
-
color : socialCheesecake.colors.extraSector.hover,
|
|
93
|
-
callback : function(sector) {
|
|
94
|
-
sector.focus();
|
|
95
|
-
cheesecake.grid.hideAll();
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
mouseout : {
|
|
99
|
-
color : socialCheesecake.colors.extraSector.background,
|
|
100
|
-
callback : function(sector) {
|
|
101
|
-
sector.unfocus();
|
|
102
|
-
cheesecake.grid.fadeInAll(300, true);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
mouseup : {color : socialCheesecake.colors.extraSector.background},
|
|
106
|
-
mousedown : {
|
|
107
|
-
color : socialCheesecake.colors.extraSector.highlight
|
|
108
|
-
/*callback : function(sector){
|
|
109
|
-
cheesecake.focusAndBlurCheesecake(sector);
|
|
110
|
-
}*/
|
|
111
|
-
},
|
|
112
65
|
subsectors : [{
|
|
113
66
|
name : "New Subsector 1"
|
|
114
67
|
}],
|
|
115
68
|
auxiliar : true,
|
|
116
|
-
|
|
117
|
-
borderColor : socialCheesecake.colors.extraSector.border
|
|
69
|
+
type : "extraSector"
|
|
118
70
|
});
|
|
119
71
|
cheesecake.sectors[jsonSectors.length] = extraSector;
|
|
120
72
|
}
|
|
121
73
|
var minNumSectors = Math.min(jsonSectors.length, 16);
|
|
122
|
-
for(var i = 0; i < minNumSectors; i++) {
|
|
74
|
+
for(var i = 0; i < minNumSectors; i++) {
|
|
123
75
|
var settings = {
|
|
124
76
|
parent : cheesecake,
|
|
125
|
-
center :
|
|
126
|
-
x : cheesecakeData.center.x,
|
|
127
|
-
y : cheesecakeData.center.y
|
|
128
|
-
},
|
|
77
|
+
center : cheesecake.center,
|
|
129
78
|
id : jsonSectors[i].id,
|
|
130
79
|
label : jsonSectors[i].name,
|
|
131
80
|
rOut : cheesecakeData.rMax,
|
|
132
81
|
subsectors : jsonSectors[i].subsectors,
|
|
133
|
-
|
|
134
|
-
color : socialCheesecake.colors.normalSector.hover,
|
|
135
|
-
callback : function(sector) {
|
|
136
|
-
document.body.style.cursor = "pointer";
|
|
137
|
-
cheesecake.grid.hideAll();
|
|
138
|
-
cheesecake.grid.fadeIn(sector.actors, 300, true);
|
|
139
|
-
sector.focus();
|
|
140
|
-
if(cheesecake.highlightedSector != null){
|
|
141
|
-
cheesecake.highlightedSector.fan(false,
|
|
142
|
-
function(){
|
|
143
|
-
sector.fan(true);
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
}else{
|
|
147
|
-
sector.fan(true);
|
|
148
|
-
}
|
|
149
|
-
sector.getCheesecake().setHighlightedSector(sector);
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
mouseout : {
|
|
153
|
-
color : socialCheesecake.colors.normalSector.background,
|
|
154
|
-
callback : function(sector) {
|
|
155
|
-
document.body.style.cursor = "default";
|
|
156
|
-
cheesecake.grid.hide(sector.actors);
|
|
157
|
-
cheesecake.grid.fadeInAll(300, true);
|
|
158
|
-
sector.unfocus();
|
|
159
|
-
sector.getCheesecake().setHighlightedSector(null);
|
|
160
|
-
sector.fan(false);
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
mousedown : {
|
|
164
|
-
color : socialCheesecake.colors.normalSector.highlight,
|
|
165
|
-
callback : function(sector) {
|
|
166
|
-
cheesecake.focusAndBlurCheesecake(sector);
|
|
167
|
-
cheesecake.grid.hideAll();
|
|
168
|
-
cheesecake.grid.fadeIn(sector.actors,300, true);
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
mouseup : { color : socialCheesecake.colors.normalSector.background },
|
|
172
|
-
fontColor : socialCheesecake.colors.normalSector.font,
|
|
173
|
-
borderColor : socialCheesecake.colors.normalSector.border
|
|
82
|
+
type : "normalSector"
|
|
174
83
|
};
|
|
175
84
|
cheesecake.sectors[i] = new socialCheesecake.Sector(settings);
|
|
176
85
|
}
|
|
@@ -178,142 +87,106 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
178
87
|
cheesecake._setInitialState();
|
|
179
88
|
cheesecake.draw();
|
|
180
89
|
}
|
|
181
|
-
|
|
182
|
-
socialCheesecake.Cheesecake.prototype.draw = function(){
|
|
90
|
+
|
|
91
|
+
socialCheesecake.Cheesecake.prototype.draw = function() {
|
|
183
92
|
var sectors = this.sectors;
|
|
184
|
-
|
|
185
|
-
for (var sector in sectors){
|
|
186
|
-
mainLayer.add(sectors[sector].getRegion());
|
|
187
|
-
}
|
|
93
|
+
this.addToLayer(sectors);
|
|
188
94
|
this.stage.draw();
|
|
189
95
|
}
|
|
190
|
-
|
|
191
|
-
socialCheesecake.Cheesecake.prototype.disable = function(){
|
|
96
|
+
|
|
97
|
+
socialCheesecake.Cheesecake.prototype.disable = function() {
|
|
192
98
|
var layers = this.stage.layers;
|
|
193
|
-
for(var layer in layers){
|
|
99
|
+
for(var layer in layers) {
|
|
194
100
|
layers[layer].listen(false);
|
|
195
101
|
}
|
|
196
102
|
}
|
|
197
|
-
|
|
198
|
-
socialCheesecake.Cheesecake.prototype.enable = function(){
|
|
103
|
+
|
|
104
|
+
socialCheesecake.Cheesecake.prototype.enable = function() {
|
|
199
105
|
var layers = this.stage.layers;
|
|
200
|
-
for(var layer in layers){
|
|
106
|
+
for(var layer in layers) {
|
|
201
107
|
layers[layer].listen(true);
|
|
202
108
|
}
|
|
203
109
|
}
|
|
204
|
-
|
|
110
|
+
|
|
205
111
|
socialCheesecake.Cheesecake.prototype.focusAndBlurCheesecake = function(sector) {
|
|
206
112
|
var cheesecake = this;
|
|
207
|
-
var mainLayer = this.stage.mainLayer;
|
|
208
|
-
var regions = mainLayer.getShapes();
|
|
209
113
|
var sectorIndex;
|
|
210
114
|
for(var i in cheesecake.sectors) {
|
|
211
|
-
if(cheesecake.sectors[i] === sector)
|
|
115
|
+
if(cheesecake.sectors[i] === sector)
|
|
116
|
+
sectorIndex = i;
|
|
212
117
|
}
|
|
213
118
|
if(sectorIndex == null)
|
|
214
119
|
throw "sector doesn't belong to this cheesecake"
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
mainLayer.clear();
|
|
221
|
-
this.setHighlightedSector(sector);
|
|
222
|
-
|
|
120
|
+
cheesecake.clearLayer();
|
|
121
|
+
cheesecake.setHighlightedSector(sector);
|
|
122
|
+
|
|
223
123
|
//Add auxiliar sectors
|
|
224
124
|
var greySettings = {
|
|
225
125
|
parent : cheesecake,
|
|
226
|
-
center :
|
|
227
|
-
x : cheesecake.center.x,
|
|
228
|
-
y : cheesecake.center.y
|
|
229
|
-
},
|
|
126
|
+
center : cheesecake.center,
|
|
230
127
|
phi : sector.phi + sector.delta,
|
|
231
128
|
delta : 2 * Math.PI - sector.delta,
|
|
232
129
|
rOut : cheesecake.rMax,
|
|
233
|
-
mouseout : {
|
|
234
|
-
color : socialCheesecake.colors.greySector.background,
|
|
235
|
-
callback : function() {
|
|
236
|
-
document.body.style.cursor = "default";
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
mousedown : { color : socialCheesecake.colors.greySector.highlight },
|
|
240
|
-
mouseup : { color : socialCheesecake.colors.greySector.background },
|
|
241
|
-
mouseover : {
|
|
242
|
-
color : socialCheesecake.colors.greySector.hover,
|
|
243
|
-
callback : function() {
|
|
244
|
-
document.body.style.cursor = "pointer";
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
130
|
color : socialCheesecake.colors.greySector.background,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
auxiliar : true
|
|
251
|
-
};
|
|
252
|
-
var dummySettings = {
|
|
253
|
-
parent : cheesecake,
|
|
254
|
-
center : {
|
|
255
|
-
x : cheesecake.center.x,
|
|
256
|
-
y : cheesecake.center.y
|
|
257
|
-
},
|
|
258
|
-
phi : sector.phi,
|
|
259
|
-
delta : sector.delta,
|
|
260
|
-
rOut : sector.rOut,
|
|
261
|
-
label : sector.label,
|
|
262
|
-
simulate : sectorIndex,
|
|
263
|
-
mouseout : {
|
|
264
|
-
callback : function() {
|
|
265
|
-
document.body.style.cursor = "default";
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
mouseover : {
|
|
269
|
-
callback : function() {
|
|
270
|
-
document.body.style.cursor = "pointer";
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
auxiliar : true
|
|
131
|
+
auxiliar : true,
|
|
132
|
+
type : "greySector"
|
|
274
133
|
};
|
|
275
134
|
var greySector = new socialCheesecake.Sector(greySettings);
|
|
276
135
|
cheesecake.auxiliarSectors.push(greySector);
|
|
277
|
-
var dummySector =
|
|
278
|
-
cheesecake.auxiliarSectors.push(dummySector);
|
|
279
|
-
|
|
280
|
-
mainLayer.add(greySector.getRegion());
|
|
281
|
-
mainLayer.add(dummySector.getRegion());
|
|
136
|
+
var dummySector = this.getAuxiliarClone(sectorIndex);
|
|
282
137
|
|
|
138
|
+
cheesecake.addToLayer(greySector);
|
|
139
|
+
cheesecake.addToLayer(dummySector);
|
|
283
140
|
//Animations
|
|
284
|
-
var
|
|
141
|
+
var greyClickCallback = function() {
|
|
285
142
|
greySector.label = "";
|
|
286
143
|
cheesecake.unfocusAndUnblurCheesecake();
|
|
287
|
-
}
|
|
144
|
+
};
|
|
288
145
|
var greyResizeCallback = function() {
|
|
289
|
-
greySector.
|
|
146
|
+
greySector.click = {
|
|
147
|
+
callback : greyClickCallback
|
|
148
|
+
}
|
|
290
149
|
greySector.label = "GO BACK";
|
|
291
|
-
}
|
|
150
|
+
};
|
|
292
151
|
var greyRotateToCallback = function() {
|
|
293
152
|
greySector.resizeDelta({
|
|
294
153
|
delta : 3 * Math.PI / 2,
|
|
295
154
|
anchor : "M",
|
|
296
155
|
callback : greyResizeCallback
|
|
297
156
|
});
|
|
298
|
-
}
|
|
157
|
+
};
|
|
299
158
|
var dummyResizeCallback = function() {
|
|
159
|
+
var grid = cheesecake.grid;
|
|
160
|
+
grid.hideAll();
|
|
161
|
+
grid.show(cheesecake.sectors[sectorIndex].actors);
|
|
300
162
|
dummySector.splitUp();
|
|
301
|
-
}
|
|
163
|
+
};
|
|
302
164
|
var dummyRotateToCallback = function() {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
165
|
+
var callback = function() {
|
|
166
|
+
dummySector.resizeDelta({
|
|
167
|
+
anchor : "M",
|
|
168
|
+
callback : dummyResizeCallback
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if(cheesecake.onSectorFocusBegin) {
|
|
172
|
+
if(cheesecake.syncSectorFocusCallbacks) {
|
|
173
|
+
cheesecake.onSectorFocusBegin(cheesecake, callback);
|
|
174
|
+
} else {
|
|
175
|
+
cheesecake.onSectorFocusBegin(cheesecake);
|
|
176
|
+
callback();
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
callback();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
309
182
|
greySector.rotateTo({
|
|
310
|
-
destination : 5*Math.PI / 4,
|
|
183
|
+
destination : 5 * Math.PI / 4,
|
|
311
184
|
callback : greyRotateToCallback,
|
|
312
185
|
anchor : "M"
|
|
313
186
|
});
|
|
314
187
|
|
|
315
188
|
dummySector.rotateTo({
|
|
316
|
-
destination : Math.PI / 4
|
|
189
|
+
destination : Math.PI / 4,
|
|
317
190
|
callback : dummyRotateToCallback,
|
|
318
191
|
anchor : "M"
|
|
319
192
|
});
|
|
@@ -325,72 +198,106 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
325
198
|
var regions = mainLayer.getShapes();
|
|
326
199
|
|
|
327
200
|
//Delete the auxiliar sectors
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
mainLayer.remove(regions[i]);
|
|
331
|
-
cheesecake.auxiliarSectors.pop();
|
|
332
|
-
}
|
|
333
|
-
}
|
|
201
|
+
cheesecake.removeFromLayer(cheesecake.auxiliarSectors);
|
|
202
|
+
cheesecake.auxiliarSectors = [];
|
|
334
203
|
mainLayer.clear();
|
|
335
|
-
|
|
204
|
+
|
|
336
205
|
// Add the former sectors and actors
|
|
337
206
|
cheesecake.draw();
|
|
338
|
-
if(lastSector){
|
|
207
|
+
if(lastSector) {
|
|
339
208
|
lastSector.color = lastSector.originalAttr.color;
|
|
340
209
|
lastSector.fan(false);
|
|
341
210
|
lastSector.unfocus();
|
|
342
211
|
this.setHighlightedSector(null);
|
|
343
212
|
}
|
|
344
|
-
cheesecake.grid.fadeInAll(300, true);
|
|
345
213
|
}
|
|
346
214
|
socialCheesecake.Cheesecake.prototype.unfocusAndUnblurCheesecake = function() {
|
|
347
215
|
var cheesecake = this;
|
|
348
216
|
var auxiliarSectors = this.auxiliarSectors;
|
|
349
|
-
var
|
|
217
|
+
var dummySector;
|
|
350
218
|
var sectorNewDelta;
|
|
351
219
|
var sectorNewPhi;
|
|
352
220
|
var greySector;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
221
|
+
var actions = function() {
|
|
222
|
+
//Localize the dummy and grey sectors
|
|
223
|
+
for(var i in auxiliarSectors) {
|
|
224
|
+
if(auxiliarSectors[i].simulate != null) {
|
|
225
|
+
var options = {
|
|
226
|
+
phi : auxiliarSectors[i].phi,
|
|
227
|
+
delta : auxiliarSectors[i].delta,
|
|
228
|
+
rOut : auxiliarSectors[i].rOut
|
|
229
|
+
};
|
|
230
|
+
dummySector = cheesecake.getAuxiliarClone(auxiliarSectors[i].simulate, options);
|
|
231
|
+
} else {
|
|
232
|
+
greySector = auxiliarSectors[i];
|
|
233
|
+
}
|
|
360
234
|
}
|
|
361
|
-
}
|
|
362
235
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
greySector.resizeDelta({
|
|
377
|
-
anchor : "M",
|
|
378
|
-
delta : (2*Math.PI) - sectorNewDelta,
|
|
379
|
-
callback : function() {
|
|
380
|
-
greySector.rotateTo({
|
|
381
|
-
destination : sectorNewPhi + sectorNewDelta,
|
|
382
|
-
callback : function() {
|
|
383
|
-
cheesecake.recoverCheesecake();
|
|
236
|
+
//Animate and go back to the general view
|
|
237
|
+
dummyNewDelta = cheesecake.sectors[dummySector.simulate].delta;
|
|
238
|
+
dummyNewPhi = cheesecake.sectors[dummySector.simulate].phi;
|
|
239
|
+
dummySector.putTogether();
|
|
240
|
+
dummySector.resizeDelta({
|
|
241
|
+
anchor : "M",
|
|
242
|
+
delta : dummyNewDelta,
|
|
243
|
+
callback : function() {
|
|
244
|
+
if(cheesecake.onSectorUnfocusEnd) {
|
|
245
|
+
cheesecake.onSectorUnfocusEnd(cheesecake);
|
|
384
246
|
}
|
|
385
|
-
|
|
247
|
+
cheesecake.grid.showAll();
|
|
248
|
+
dummySector.rotateTo({
|
|
249
|
+
destination : dummyNewPhi
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
greySector.resizeDelta({
|
|
254
|
+
anchor : "M",
|
|
255
|
+
delta : (2 * Math.PI) - dummyNewDelta,
|
|
256
|
+
callback : function() {
|
|
257
|
+
greySector.rotateTo({
|
|
258
|
+
destination : dummyNewPhi + dummyNewDelta,
|
|
259
|
+
callback : function() {
|
|
260
|
+
cheesecake.recoverCheesecake();
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
if(cheesecake.onSectorUnfocusBegin) {
|
|
267
|
+
if(cheesecake.syncSectorFocusCallbacks) {
|
|
268
|
+
cheesecake.onSectorUnfocusBegin(cheesecake, actions);
|
|
269
|
+
} else {
|
|
270
|
+
cheesecake.onSectorUnfocusBegin(cheesecake);
|
|
271
|
+
actions();
|
|
386
272
|
}
|
|
387
|
-
}
|
|
273
|
+
} else {
|
|
274
|
+
actions();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
socialCheesecake.Cheesecake.prototype.addNewSector = function() {
|
|
279
|
+
var cheesecake = this;
|
|
280
|
+
var sectors = this.sectors;
|
|
281
|
+
var newSector;
|
|
282
|
+
var settings = {
|
|
283
|
+
parent : cheesecake,
|
|
284
|
+
center : cheesecake.center,
|
|
285
|
+
/*id : jsonSectors[i].id,*/
|
|
286
|
+
label : "New Sector",
|
|
287
|
+
rOut : cheesecake.rMax,
|
|
288
|
+
subsectors : [{name : "New Subsector 1"}]
|
|
289
|
+
};
|
|
290
|
+
//move the extra sector to its new position, create new sector.
|
|
291
|
+
sectors.push(sectors[sectors.length-1]);
|
|
292
|
+
newSector = new socialCheesecake.Sector(settings);
|
|
293
|
+
cheesecake.sectors[sectors.length-2] = newSector;
|
|
294
|
+
cheesecake.calculatePortions();
|
|
388
295
|
}
|
|
389
296
|
|
|
390
297
|
/**
|
|
391
298
|
* actorId - actor which changes one of its parents
|
|
392
299
|
*/
|
|
393
|
-
socialCheesecake.Cheesecake.prototype.updateActorMembership = function
|
|
300
|
+
socialCheesecake.Cheesecake.prototype.updateActorMembership = function(actor) {
|
|
394
301
|
var changes = this._changes;
|
|
395
302
|
var grid = this.grid;
|
|
396
303
|
var changesInActors;
|
|
@@ -400,16 +307,16 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
400
307
|
var actorName = actor.name;
|
|
401
308
|
var actorExtraInfo = actor.extraInfo;
|
|
402
309
|
var onChange = this.onChange;
|
|
403
|
-
|
|
404
|
-
if(changes.actors != undefined){
|
|
310
|
+
|
|
311
|
+
if(changes.actors != undefined) {
|
|
405
312
|
changesInActors = changes.actors
|
|
406
|
-
for(
|
|
407
|
-
if(changesInActors[a].id == actorId){
|
|
313
|
+
for(var a in changesInActors) {
|
|
314
|
+
if(changesInActors[a].id == actorId) {
|
|
408
315
|
alreadyChanged = true;
|
|
409
316
|
changesInActors[a].subsectors = actorParents;
|
|
410
317
|
}
|
|
411
318
|
}
|
|
412
|
-
if(!alreadyChanged){
|
|
319
|
+
if(!alreadyChanged) {
|
|
413
320
|
changesInActors.push({
|
|
414
321
|
id : actorId,
|
|
415
322
|
subsectors : actorParents,
|
|
@@ -418,7 +325,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
418
325
|
justAdded : false
|
|
419
326
|
});
|
|
420
327
|
}
|
|
421
|
-
}else{
|
|
328
|
+
} else {
|
|
422
329
|
changes.actors = [];
|
|
423
330
|
changes.actors.push({
|
|
424
331
|
id : actorId,
|
|
@@ -431,8 +338,8 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
431
338
|
//Execute onChange Callback
|
|
432
339
|
onChange(this);
|
|
433
340
|
}
|
|
434
|
-
|
|
435
|
-
socialCheesecake.Cheesecake.prototype.calculatePortions = function
|
|
341
|
+
|
|
342
|
+
socialCheesecake.Cheesecake.prototype.calculatePortions = function() {
|
|
436
343
|
var sectors = this.sectors;
|
|
437
344
|
var match = this.matchActorsNumber;
|
|
438
345
|
var deltaExtra = Math.PI / 8;
|
|
@@ -442,34 +349,35 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
442
349
|
var sectorPortions = [];
|
|
443
350
|
var totalSectors = sectors.length;
|
|
444
351
|
var totalActors = 0;
|
|
445
|
-
var totalAngle = 2*Math.PI;
|
|
352
|
+
var totalAngle = 2 * Math.PI;
|
|
446
353
|
var unusedAngle;
|
|
447
|
-
|
|
354
|
+
|
|
448
355
|
//Begin with the extra Sector, if it exists
|
|
449
|
-
if
|
|
450
|
-
sectors[sectors.length-1].phi = phi;
|
|
451
|
-
sectors[sectors.length-1].delta = deltaExtra;
|
|
452
|
-
sectors[sectors.length-1].originalAttr.phi = sectors[sectors.length-1].phi;
|
|
453
|
-
sectors[sectors.length-1].originalAttr.delta = sectors[sectors.length-1].delta;
|
|
356
|
+
if(sectors[sectors.length - 1].auxiliar) {
|
|
357
|
+
sectors[sectors.length - 1].phi = phi;
|
|
358
|
+
sectors[sectors.length - 1].delta = deltaExtra;
|
|
359
|
+
sectors[sectors.length - 1].originalAttr.phi = sectors[sectors.length - 1].phi;
|
|
360
|
+
sectors[sectors.length - 1].originalAttr.delta = sectors[sectors.length - 1].delta;
|
|
454
361
|
phi += deltaExtra;
|
|
455
|
-
totalSectors = sectors.length -1;
|
|
362
|
+
totalSectors = sectors.length - 1;
|
|
456
363
|
totalAngle -= deltaExtra;
|
|
457
364
|
}
|
|
458
|
-
if(!match){
|
|
365
|
+
if(!match) {
|
|
459
366
|
unusedAngle = 0;
|
|
460
|
-
}else{
|
|
367
|
+
} else {
|
|
461
368
|
unusedAngle = totalAngle - totalSectors * minDeltaSector
|
|
462
369
|
}
|
|
463
370
|
for(var i = 0; i < totalSectors; i++) {
|
|
464
371
|
sectorActors[i] = sectors[i].actors.length;
|
|
465
372
|
totalActors += sectorActors[i];
|
|
466
373
|
sectorPortions[i] = minDeltaSector;
|
|
467
|
-
if(!match)
|
|
374
|
+
if(!match)
|
|
375
|
+
sectorPortions[i] = totalAngle / totalSectors;
|
|
468
376
|
}
|
|
469
377
|
for(var i = 0; i < totalSectors; i++) {
|
|
470
|
-
if(totalActors!=0){
|
|
471
|
-
sectorPortions[i] += (sectorActors[i] / totalActors) * unusedAngle;
|
|
472
|
-
}else{
|
|
378
|
+
if(totalActors != 0) {
|
|
379
|
+
sectorPortions[i] += (sectorActors[i] / totalActors) * unusedAngle;
|
|
380
|
+
} else {
|
|
473
381
|
sectorPortions[i] = totalAngle / totalSectors;
|
|
474
382
|
}
|
|
475
383
|
sectors[i].phi = phi;
|
|
@@ -480,35 +388,126 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
480
388
|
}
|
|
481
389
|
}
|
|
482
390
|
|
|
483
|
-
socialCheesecake.Cheesecake.prototype.
|
|
484
|
-
|
|
391
|
+
socialCheesecake.Cheesecake.prototype.addToLayer = function(sectors, layer){
|
|
392
|
+
var layer = layer || this.stage.mainLayer;
|
|
393
|
+
if(sectors instanceof Array){
|
|
394
|
+
for(var sector in sectors){
|
|
395
|
+
layer.add(sectors[sector].getRegion());
|
|
396
|
+
}
|
|
397
|
+
}else{
|
|
398
|
+
layer.add(sectors.getRegion());
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
socialCheesecake.Cheesecake.prototype.removeFromLayer = function(sectors, layer){
|
|
403
|
+
var layer = layer || this.stage.mainLayer;
|
|
404
|
+
if(sectors instanceof Array){
|
|
405
|
+
for(var sector in sectors) {
|
|
406
|
+
try{
|
|
407
|
+
layer.remove(sectors[sector].getRegion());
|
|
408
|
+
}catch(e){
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}else{
|
|
412
|
+
layer.remove(sectors.getRegion());
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
socialCheesecake.Cheesecake.prototype.drawLayer = function(layer){
|
|
417
|
+
var layer = layer || this.stage.mainLayer;
|
|
418
|
+
layer.draw();
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
socialCheesecake.Cheesecake.prototype.clearLayer = function(layer){
|
|
422
|
+
var layer = layer || this.stage.mainLayer;
|
|
423
|
+
var regions = layer.getShapes();
|
|
424
|
+
for(var i = (regions.length - 1); i >= 0; i--) {
|
|
425
|
+
layer.remove(regions[i]);
|
|
426
|
+
}
|
|
427
|
+
layer.clear();
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
socialCheesecake.Cheesecake.prototype.setHighlightedSector = function(sector) {
|
|
431
|
+
if(this.highlightedSector != sector) {
|
|
485
432
|
this.highlightedSector = sector;
|
|
486
|
-
if(this.
|
|
487
|
-
this.
|
|
433
|
+
if(this.onSectorHighlight) {
|
|
434
|
+
this.onSectorHighlight(this);
|
|
488
435
|
}
|
|
489
436
|
}
|
|
490
437
|
}
|
|
491
438
|
|
|
492
|
-
socialCheesecake.Cheesecake.prototype.
|
|
439
|
+
socialCheesecake.Cheesecake.prototype.getAuxiliarClone = function(sectorIndex, options){
|
|
440
|
+
var dummy = null;
|
|
441
|
+
var cheesecake = this;
|
|
442
|
+
var sector = null;
|
|
443
|
+
var auxiliarSectors = cheesecake.auxiliarSectors;
|
|
444
|
+
var settings = {};
|
|
445
|
+
var options = options || {};
|
|
446
|
+
//Localize the dummy sector
|
|
447
|
+
for(var i in auxiliarSectors) {
|
|
448
|
+
if(auxiliarSectors[i].simulate != null) {
|
|
449
|
+
dummy = auxiliarSectors[i];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if( sectorIndex != null){
|
|
453
|
+
sector = cheesecake.sectors[sectorIndex];
|
|
454
|
+
settings = {
|
|
455
|
+
phi : options.phi || sector.phi,
|
|
456
|
+
delta : options.delta || sector.delta,
|
|
457
|
+
rOut : options.rOut || sector.rOut,
|
|
458
|
+
label : options.label || sector.label,
|
|
459
|
+
borderColor : options.borderColor || socialCheesecake.colors[sector.type]["border"],
|
|
460
|
+
color : options.color || sector.color,
|
|
461
|
+
fontColor : options.fontColor || socialCheesecake.colors[sector.type]["font"],
|
|
462
|
+
simulate : sectorIndex,
|
|
463
|
+
auxiliar : true,
|
|
464
|
+
type: "dummySector"
|
|
465
|
+
}
|
|
466
|
+
//if dummy doesnt exist, create a new one
|
|
467
|
+
if(!dummy){
|
|
468
|
+
dummy = new socialCheesecake.Sector({
|
|
469
|
+
center : cheesecake.center,
|
|
470
|
+
parent : cheesecake
|
|
471
|
+
});
|
|
472
|
+
this.auxiliarSectors.push(dummy);
|
|
473
|
+
}
|
|
474
|
+
for(var property in settings){
|
|
475
|
+
dummy[property] = settings[property];
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return dummy;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
socialCheesecake.Cheesecake.prototype.getFocusedSector = function(){
|
|
482
|
+
var dummy = this.getAuxiliarClone();
|
|
483
|
+
var sectors = this.sectors;
|
|
484
|
+
var sector = null;
|
|
485
|
+
if(dummy){
|
|
486
|
+
sector = sectors[dummy.simulate];
|
|
487
|
+
}
|
|
488
|
+
return sector;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
socialCheesecake.Cheesecake.prototype.getSectorById = function(id) {
|
|
493
492
|
var sectors = this.sectors;
|
|
494
493
|
var sector;
|
|
495
|
-
for
|
|
496
|
-
if
|
|
494
|
+
for(var i in sectors) {
|
|
495
|
+
if(sectors[i].id == id) {
|
|
497
496
|
sector = sectors[i];
|
|
498
497
|
break;
|
|
499
498
|
}
|
|
500
499
|
}
|
|
501
500
|
return sector;
|
|
502
501
|
}
|
|
503
|
-
|
|
504
|
-
socialCheesecake.Cheesecake.prototype.getSubsectorById = function(id){
|
|
502
|
+
|
|
503
|
+
socialCheesecake.Cheesecake.prototype.getSubsectorById = function(id) {
|
|
505
504
|
var sectors = this.sectors;
|
|
506
505
|
var subsectors;
|
|
507
506
|
var subsector;
|
|
508
|
-
for
|
|
507
|
+
for(var i in sectors) {
|
|
509
508
|
subsectors = sectors[i].subsectors;
|
|
510
|
-
for
|
|
511
|
-
if
|
|
509
|
+
for(var j in subsectors) {
|
|
510
|
+
if(subsectors[j].id == id) {
|
|
512
511
|
subsector = subsectors[j];
|
|
513
512
|
break;
|
|
514
513
|
}
|
|
@@ -516,37 +515,27 @@ var socialCheesecake = socialCheesecake || {};
|
|
|
516
515
|
}
|
|
517
516
|
return subsector;
|
|
518
517
|
}
|
|
519
|
-
|
|
520
|
-
socialCheesecake.Cheesecake.prototype.getChanges = function
|
|
518
|
+
|
|
519
|
+
socialCheesecake.Cheesecake.prototype.getChanges = function() {
|
|
521
520
|
return this._changes;
|
|
522
521
|
}
|
|
523
|
-
|
|
524
|
-
socialCheesecake.Cheesecake.prototype.getInitialState = function
|
|
522
|
+
|
|
523
|
+
socialCheesecake.Cheesecake.prototype.getInitialState = function() {
|
|
525
524
|
return this._initialState;
|
|
526
525
|
}
|
|
527
|
-
|
|
528
|
-
socialCheesecake.Cheesecake.prototype._setInitialState = function
|
|
526
|
+
|
|
527
|
+
socialCheesecake.Cheesecake.prototype._setInitialState = function() {
|
|
529
528
|
var state = this._initialState;
|
|
530
529
|
var actors = this.grid.actors;
|
|
531
|
-
|
|
530
|
+
|
|
532
531
|
state.actors = [];
|
|
533
|
-
for(
|
|
534
|
-
state.actors.push({
|
|
535
|
-
id: actors[actor].id
|
|
532
|
+
for(var actor in actors ) {
|
|
533
|
+
state.actors.push({
|
|
534
|
+
id : actors[actor].id,
|
|
536
535
|
subsectors : actors[actor].getParentsIds(),
|
|
537
536
|
name : actors[actor].name,
|
|
538
537
|
extraInfo : actors[actor].extraInfo
|
|
539
538
|
})
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/** Number of actors to animate */
|
|
544
|
-
socialCheesecake.Cheesecake.getMaxVisibleActors = function(){
|
|
545
|
-
return maxVisibleActors;
|
|
546
|
-
}
|
|
547
|
-
socialCheesecake.Cheesecake.setMaxVisibleActors = function(number){
|
|
548
|
-
if(typeof number === "number") maxVisibleActors = number;
|
|
539
|
+
}
|
|
549
540
|
}
|
|
550
|
-
|
|
551
541
|
})();
|
|
552
|
-
|