social_cheesecake 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license SocialCheesecake JavaScript Library v0.1.0
2
+ * @license SocialCheesecake JavaScript Library v0.2.0
3
3
  * https://github.com/adiezbal/SocialCheesecake
4
4
  * Developed by Alicia Díez (https://github.com/adiezbal)
5
5
  * Copyright 2011, Technical University of Madrid (Universidad Politécnica de Madrid)
@@ -11,10 +11,12 @@ var socialCheesecake = socialCheesecake || {};
11
11
  }
12
12
  }
13
13
  this.id = settings.id;
14
+ this.name = settings.name;
14
15
  this.opacity = 1;
15
16
  this._focused = false;
16
17
  this._selected = false;
17
18
  this._hidden = false;
19
+ this._filtered = false;
18
20
  this.fading = "none";
19
21
  this.parents = [];
20
22
  if(settings.parent) this.parents.push(settings.parent);
@@ -26,8 +28,9 @@ var socialCheesecake = socialCheesecake || {};
26
28
  actor.focus();
27
29
  for (var subsector in actor.parents){
28
30
  sector = actor.parents[subsector].parent;
29
- sector.eventHandler("mouseover");
30
- actor.parents[subsector].eventHandler("mouseover");
31
+ sector.focus();
32
+ sector.changeColor(sector.mouseover.color);
33
+ actor.parents[subsector].changeColor(actor.parents[subsector].mouseover.color);
31
34
  }
32
35
  }
33
36
  var mouseoutCallback = function(){
@@ -35,8 +38,9 @@ var socialCheesecake = socialCheesecake || {};
35
38
  actor.unfocus();
36
39
  for (var subsector in actor.parents){
37
40
  sector = actor.parents[subsector].parent;
38
- sector.eventHandler("mouseout");
39
- actor.parents[subsector].eventHandler("mouseout");
41
+ sector.unfocus();
42
+ sector.changeColor(sector.mouseout.color);
43
+ actor.parents[subsector].changeColor(sector.mouseout.color);
40
44
  }
41
45
  }
42
46
  actor_div.addEventListener("mouseover", mouseoverCallback, false);
@@ -46,11 +50,13 @@ var socialCheesecake = socialCheesecake || {};
46
50
  if( actor.isSelected()){
47
51
  // Deactivate actor
48
52
  actor._selected = false;
53
+ actor.unfocus();
49
54
  actor_div.addEventListener("mouseover", mouseoverCallback, false);
50
55
  actor_div.addEventListener("mouseout", mouseoutCallback, false);
51
56
  }else{
52
57
  //Activate actor
53
58
  actor._selected = true;
59
+ actor.focus();
54
60
  actor_div.removeEventListener("mouseover", mouseoverCallback, false);
55
61
  actor_div.removeEventListener("mouseout", mouseoutCallback, false);
56
62
  }
@@ -108,6 +114,7 @@ var socialCheesecake = socialCheesecake || {};
108
114
  }
109
115
 
110
116
  socialCheesecake.Actor.prototype.show = function() {
117
+ if(this.isFiltered()) return;
111
118
  var actor_div = this.getDiv();
112
119
  this._hidden = false;
113
120
  if (actor_div.getAttribute("style")){
@@ -120,6 +127,23 @@ var socialCheesecake = socialCheesecake || {};
120
127
  return this._hidden;
121
128
  }
122
129
 
130
+ socialCheesecake.Actor.prototype.isFiltered = function() {
131
+ return this._filtered;
132
+ }
133
+
134
+ socialCheesecake.Actor.prototype.isVisible = function() {
135
+ return !(this.isHidden() || this.isFiltered());
136
+ }
137
+
138
+ socialCheesecake.Actor.prototype.filter = function() {
139
+ this._filtered = true;
140
+ this.fadeOut(100, true);
141
+ }
142
+
143
+ socialCheesecake.Actor.prototype.unfilter = function() {
144
+ this._filtered = false;
145
+ }
146
+
123
147
  socialCheesecake.Actor.prototype.setDivOpacity = function(opacity) {
124
148
  opacity = (opacity > 1) ? 1 : opacity;
125
149
  opacity = (opacity < 0) ? 0 : opacity;
@@ -141,7 +165,6 @@ var socialCheesecake = socialCheesecake || {};
141
165
  var deltaOpacity = 1000.0/ (60.0 *time);
142
166
  var grow = 0;
143
167
 
144
- var x = actor.opacity;
145
168
  //console.log(">Fade actor "+ actor.id+" now with opacity "+ x);
146
169
  //console.log(" >Fading value "+ this.fading);
147
170
 
@@ -154,11 +177,11 @@ var socialCheesecake = socialCheesecake || {};
154
177
  var opacity = this.opacity + grow * deltaOpacity;
155
178
  opacity = Math.round(opacity*1000)/1000;
156
179
  actor.setDivOpacity(opacity);
180
+ var x = actor.opacity;
157
181
 
158
182
  if (((this.fading == "out") && (opacity >= 0))||
159
183
  ((this.fading == "in") && (opacity <= 1))){
160
184
  requestAnimFrame(function() {
161
-
162
185
  actor.fade(time, modifyDisplay);
163
186
  });
164
187
  }else{
@@ -175,6 +198,7 @@ var socialCheesecake = socialCheesecake || {};
175
198
  }
176
199
 
177
200
  socialCheesecake.Actor.prototype.fadeIn = function(time, modifyDisplay) {
201
+ if(this.isFiltered()) return;
178
202
  this.fading = "in";
179
203
  this.fade(time, modifyDisplay);
180
204
  }
@@ -1,5 +1,24 @@
1
1
  var socialCheesecake = socialCheesecake || {};
2
2
  (function() {
3
+ //General variable settings (with dafault values)
4
+ /* Normal */
5
+ var sectorFillColor = "#eeffee"; //normal, mouseout, mouseup states
6
+ var sectorFocusColor = "#77ff77"; //mousedown state
7
+ var sectorHoverColor = "#aaffaa"; //mouseover state
8
+ var sectorTextAndStrokeColor = "#1F4A75"; //text and border color
9
+
10
+ /* Extra */
11
+ var extraSectorFillColor = "#D4E4EA"; //normal, mouseout, mouseup states for extra sectors
12
+ var extraFocusColor = "#1FA0F7"; //mousedown state for extra sectors
13
+ var extraHoverColor = "#1FA0F7"; //mouseover state for extra sectors
14
+ var extraTextAndStrokeColor = "#1F4A75"; //text and border color for extra sectors
15
+
16
+ /* Grey */
17
+ var greySectorFillColor = "#f5f5f5"; //normal, mouseout, mouseup states for grey auxiliar sectors
18
+ var greyFocusColor = "#f5f5f5"; //mousedown state for grey auxiliar sectors
19
+ var greyHoverColor = "#f5f5f5"; //mouseover state for grey auxiliar sectors
20
+ var greyTextAndStrokeColor = "#666"; //text and border color for grey auxilar sectors
21
+
3
22
  socialCheesecake.Cheesecake = function(cheesecakeData) {
4
23
  var jsonSectors = cheesecakeData.sectors;
5
24
  var cheesecake = this;
@@ -10,6 +29,8 @@ var socialCheesecake = socialCheesecake || {};
10
29
  };
11
30
  cheesecake.rMax = cheesecakeData.rMax;
12
31
  cheesecake.sectors = [];
32
+ cheesecake.highlightedSector = null;
33
+ cheesecake.highlightedSectorCallback = cheesecakeData.highlightedSectorCallback || undefined;
13
34
  cheesecake.auxiliarSectors = [];
14
35
  cheesecake.stage = new Kinetic.Stage(cheesecakeData.container.id,
15
36
  cheesecakeData.container.width, cheesecakeData.container.height);
@@ -18,64 +39,104 @@ var socialCheesecake = socialCheesecake || {};
18
39
  grid_id : cheesecakeData.grid.id,
19
40
  divIdPrefix : cheesecakeData.grid.divIdPrefix || "actor_"
20
41
  });
21
-
22
- var phi = 0;
23
- var delta = 2 * Math.PI / jsonSectors.length;
24
- var actors = [];
25
- for(var i = 0; i < jsonSectors.length; i++) {
26
- var settings = {
42
+ cheesecake.searchEngine = new socialCheesecake.SearchEngine({
43
+ parent : this
44
+ });
45
+ cheesecake.matchActorsNumber = cheesecakeData.match || true;
46
+ cheesecake.changes = {};
47
+
48
+ var extraSector = new socialCheesecake.Sector({
27
49
  parent : cheesecake,
28
50
  center : {
29
51
  x : cheesecakeData.center.x,
30
52
  y : cheesecakeData.center.y
31
53
  },
32
- label : jsonSectors[i].name,
33
- phi : phi,
34
- delta : delta,
54
+ label: "+",
35
55
  rOut : cheesecakeData.rMax,
36
- subsectors : jsonSectors[i].subsectors,
56
+ color : socialCheesecake.Cheesecake.getExtraSectorFillColor(),
37
57
  mouseover : {
38
- color : "#aaffaa",
58
+ color : socialCheesecake.Cheesecake.getExtraSectorHoverColor(),
39
59
  callback : function(sector) {
40
- /* FIX FOR EXECUTING MOUSEOUT BEFORE MOUSEOVER */
41
- for(var i in cheesecake.sectors){
42
- cheesecake.sectors[i].getRegion().addEventListener("mouseout", undefined);
43
- if(cheesecake.sectors[i]!= sector){
44
- cheesecake.sectors[i].unfocus();
45
- cheesecake.sectors[i].changeColor(cheesecake.sectors[i].mouseout.color);
46
- }
47
- }
48
- sector.getRegion().addEventListener("mouseout", function() {
49
- sector.eventHandler('mouseout');
50
- });
51
-
52
- document.body.style.cursor = "pointer";
53
- cheesecake.grid.hideAll();
54
- cheesecake.grid.fadeIn(sector.actors, 300, true);
55
- sector.focus();
60
+ sector.focus();
56
61
  }
57
62
  },
58
63
  mouseout : {
59
- color : "#eeffee",
64
+ color : socialCheesecake.Cheesecake.getExtraSectorFillColor(),
60
65
  callback : function(sector) {
61
- document.body.style.cursor = "default";
62
- cheesecake.grid.fadeInAll(300, true);
63
66
  sector.unfocus();
64
67
  }
65
68
  },
66
- mousedown : {
67
- color : "#77ff77",
68
- callback : function(sector) {
69
- cheesecake.focusAndBlurCheesecake(sector);
70
- cheesecake.grid.hideAll();
71
- cheesecake.grid.fadeIn(sector.actors,300, true);
72
- }
73
- },
74
- mouseup : { color : "#aaffaa" }
75
- };
76
- cheesecake.sectors[i] = new socialCheesecake.Sector(settings);
77
- cheesecake.stage.add(cheesecake.sectors[i].getRegion());
78
- phi += delta;
69
+ mouseup : {color : socialCheesecake.Cheesecake.getExtraSectorFillColor()},
70
+ mousedown : {color : socialCheesecake.Cheesecake.getExtraSectorFocusColor()},
71
+ auxiliar : true,
72
+ textAndStrokeColor : socialCheesecake.Cheesecake.getExtraSectorTextAndStrokeColor()
73
+ });
74
+ cheesecake.sectors[jsonSectors.length] = extraSector;
75
+
76
+ for(var i = 0; i < jsonSectors.length; i++) {
77
+ var settings = {
78
+ parent : cheesecake,
79
+ center : {
80
+ x : cheesecakeData.center.x,
81
+ y : cheesecakeData.center.y
82
+ },
83
+ label : jsonSectors[i].name,
84
+ rOut : cheesecakeData.rMax,
85
+ subsectors : jsonSectors[i].subsectors,
86
+ mouseover : {
87
+ color : socialCheesecake.Cheesecake.getSectorHoverColor(),
88
+ callback : function(sector) {
89
+ /* FIX FOR EXECUTING MOUSEOUT BEFORE MOUSEOVER */
90
+ for(var i in cheesecake.sectors){
91
+ cheesecake.sectors[i].getRegion().removeEventListener("mouseout");
92
+ if(cheesecake.sectors[i]!= sector){
93
+ cheesecake.sectors[i].unfocus();
94
+ cheesecake.sectors[i].changeColor(cheesecake.sectors[i].mouseout.color);
95
+ }
96
+ }
97
+ sector.getRegion().addEventListener("mouseout", function() {
98
+ sector.eventHandler('mouseout');
99
+ });
100
+ /* END of FIX */
101
+ document.body.style.cursor = "pointer";
102
+ cheesecake.grid.hideAll();
103
+ cheesecake.grid.fadeIn(sector.actors, 300, true);
104
+ sector.focus();
105
+ sector.getCheesecake().setHighlightedSector(sector);
106
+ //sector.getCheesecake().fanInSector(sector, true);
107
+ }
108
+ },
109
+ mouseout : {
110
+ color : socialCheesecake.Cheesecake.getSectorFillColor(),
111
+ callback : function(sector) {
112
+ document.body.style.cursor = "default";
113
+ cheesecake.grid.fadeInAll(300, true);
114
+ sector.unfocus();
115
+ sector.getCheesecake().setHighlightedSector(null);
116
+ //sector.getCheesecake().fanInSector(sector, false);
117
+ }
118
+ },
119
+ mousedown : {
120
+ color : socialCheesecake.Cheesecake.getSectorFocusColor(),
121
+ callback : function(sector) {
122
+ cheesecake.focusAndBlurCheesecake(sector);
123
+ cheesecake.grid.hideAll();
124
+ cheesecake.grid.fadeIn(sector.actors,300, true);
125
+ }
126
+ },
127
+ mouseup : { color : socialCheesecake.Cheesecake.getSectorFillColor() },
128
+ textAndStrokeColor : socialCheesecake.Cheesecake.getSectorTextAndStrokeColor()
129
+ };
130
+ cheesecake.sectors[i] = new socialCheesecake.Sector(settings);
131
+ }
132
+ cheesecake.calculatePortions();
133
+ cheesecake.draw();
134
+ }
135
+
136
+ socialCheesecake.Cheesecake.prototype.draw = function(){
137
+ var sectors = this.sectors;
138
+ for (var sector in sectors){
139
+ this.stage.add(sectors[sector].getRegion());
79
140
  }
80
141
  }
81
142
 
@@ -93,9 +154,7 @@ var socialCheesecake = socialCheesecake || {};
93
154
  cheesecake.stage.remove(regions[i]);
94
155
  }
95
156
  }
96
-
97
- //Unfocus all actors
98
- cheesecake.grid.unfocusAll();
157
+ this.setHighlightedSector(sector);
99
158
 
100
159
  //Add auxiliar sectors
101
160
  var greySettings = {
@@ -108,20 +167,21 @@ var socialCheesecake = socialCheesecake || {};
108
167
  delta : 2 * Math.PI - sector.delta,
109
168
  rOut : cheesecake.rMax,
110
169
  mouseout : {
111
- color : "#f5f5f5",
170
+ color : socialCheesecake.Cheesecake.getGreySectorFillColor(),
112
171
  callback : function() {
113
172
  document.body.style.cursor = "default";
114
173
  }
115
174
  },
116
- mousedown : { color : "#f5f5f5" },
117
- mouseup : { color : "#f5f5f5" },
175
+ mousedown : { color : socialCheesecake.Cheesecake.getGreySectorFocusColor() },
176
+ mouseup : { color : socialCheesecake.Cheesecake.getGreySectorFillColor() },
118
177
  mouseover : {
119
- color : "#f5f5f5",
178
+ color : socialCheesecake.Cheesecake.getGreySectorHoverColor(),
120
179
  callback : function() {
121
180
  document.body.style.cursor = "pointer";
122
181
  }
123
182
  },
124
- color : "#f5f5f5",
183
+ color : socialCheesecake.Cheesecake.getGreySectorFillColor(),
184
+ textAndStrokeColor : socialCheesecake.Cheesecake.getGreySectorTextAndStrokeColor(),
125
185
  auxiliar : true
126
186
  };
127
187
  var dummySettings = {
@@ -144,7 +204,8 @@ var socialCheesecake = socialCheesecake || {};
144
204
  callback : function() {
145
205
  document.body.style.cursor = "pointer";
146
206
  }
147
- }
207
+ },
208
+ auxiliar : true
148
209
  };
149
210
  var greySector = new socialCheesecake.Sector(greySettings);
150
211
  cheesecake.auxiliarSectors.push(greySector);
@@ -156,14 +217,16 @@ var socialCheesecake = socialCheesecake || {};
156
217
 
157
218
  //Animations
158
219
  var greyMousedownCallback = function() {
220
+ greySector.label = "";
159
221
  cheesecake.unfocusAndUnblurCheesecake();
160
222
  cheesecake.grid.showAll();
161
223
  }
162
224
  var greyResizeCallback = function() {
163
225
  greySector.mousedown.callback = greyMousedownCallback;
226
+ greySector.label = "GO BACK";
164
227
  }
165
228
  var greyRotateToCallback = function() {
166
- greySector.resize({
229
+ greySector.resizeDelta({
167
230
  delta : 3 * Math.PI / 2,
168
231
  anchor : "M",
169
232
  callback : greyResizeCallback
@@ -173,7 +236,7 @@ var socialCheesecake = socialCheesecake || {};
173
236
  dummySector.splitUp();
174
237
  }
175
238
  var dummyRotateToCallback = function() {
176
- dummySector.resize({
239
+ dummySector.resizeDelta({
177
240
  anchor : "M",
178
241
  callback : dummyResizeCallback
179
242
  });
@@ -203,15 +266,16 @@ var socialCheesecake = socialCheesecake || {};
203
266
  }
204
267
  cheesecake.auxiliarSectors.pop();
205
268
 
206
- // Add the former sectors
207
- for(var i in cheesecake.sectors) {
208
- cheesecake.stage.add(cheesecake.sectors[i].getRegion());
209
- }
269
+ // Add the former sectors and actors
270
+ cheesecake.draw();
271
+ cheesecake.grid.fadeInAll(300, true);
210
272
  }
211
273
  socialCheesecake.Cheesecake.prototype.unfocusAndUnblurCheesecake = function() {
212
274
  var cheesecake = this;
213
275
  var auxiliarSectors = this.auxiliarSectors;
214
276
  var sector;
277
+ var sectorNewDelta;
278
+ var sectorNewPhi;
215
279
  var greySector;
216
280
 
217
281
  //Localize the dummy and grey sectors
@@ -224,22 +288,25 @@ var socialCheesecake = socialCheesecake || {};
224
288
  }
225
289
 
226
290
  //Animate and go back to the general view
291
+ sectorNewDelta = cheesecake.sectors[sector.simulate].delta;
292
+ sectorNewPhi = cheesecake.sectors[sector.simulate].phi;
293
+ this.setHighlightedSector(null);
227
294
  sector.putTogether();
228
- sector.resize({
295
+ sector.resizeDelta({
229
296
  anchor : "M",
230
- delta : sector.originalAttr.delta,
297
+ delta : sectorNewDelta,
231
298
  callback : function() {
232
299
  sector.rotateTo({
233
- destination : sector.originalAttr.phi
300
+ destination : sectorNewPhi
234
301
  });
235
302
  }
236
303
  });
237
- greySector.resize({
304
+ greySector.resizeDelta({
238
305
  anchor : "M",
239
- delta : greySector.originalAttr.delta,
306
+ delta : (2*Math.PI) - sectorNewDelta,
240
307
  callback : function() {
241
308
  greySector.rotateTo({
242
- destination : greySector.originalAttr.phi,
309
+ destination : sectorNewPhi + sectorNewDelta,
243
310
  callback : function() {
244
311
  cheesecake.recoverCheesecake();
245
312
  }
@@ -247,5 +314,262 @@ var socialCheesecake = socialCheesecake || {};
247
314
  }
248
315
  });
249
316
  }
317
+
318
+ /**
319
+ * actorId - actor which changes one of its parents
320
+ */
321
+ socialCheesecake.Cheesecake.prototype.updateActorMembership = function (actorId){
322
+ var changes = this.changes;
323
+ var grid = this.grid;
324
+ var changesInActors;
325
+ var alreadyChanged = false;
326
+ var actorParents = grid.getActor(actorId).parents;
327
+ var actorSubsectors = [];
328
+
329
+ for(var parent in actorParents){
330
+ actorSubsectors.push(actorParents[parent].id);
331
+ }
332
+
333
+ if(changes.actors != undefined){
334
+ changesInActors = changes.actors
335
+ for( var actor in changesInActors){
336
+ if(changesInActors[actor].id == actorId){
337
+ alreadyChanged = true;
338
+ changesInActors[actor].subsectors = actorSubsectors;
339
+ }
340
+ }
341
+ if(!alreadyChanged){
342
+ changesInActors.push({
343
+ id : actorId,
344
+ subsectors : actorSubsectors
345
+ });
346
+ }
347
+ }else{
348
+ changes.actors = [];
349
+ changes.actors.push({
350
+ id : actorId,
351
+ subsectors : actorSubsectors
352
+ });
353
+ }
354
+ }
355
+
356
+ socialCheesecake.Cheesecake.prototype.calculatePortions = function (){
357
+ var sectors = this.sectors;
358
+ var match = this.matchActorsNumber;
359
+ var deltaExtra = Math.PI / 8;
360
+ var deltaSector;
361
+ var minDeltaSector = Math.PI / 6;
362
+ var phi = ((5 * Math.PI) / 4) - (deltaExtra / 2);
363
+ var sectorActors;
364
+ var totalActors = 0;
365
+ var consideredActors = 0;
366
+ var littleSectors = 0;
367
+ var isLittle = [];
368
+
369
+ sectors[sectors.length-1].phi = phi;
370
+ sectors[sectors.length-1].delta = deltaExtra;
371
+ sectors[sectors.length-1].originalAttr.phi = sectors[sectors.length-1].phi;
372
+ sectors[sectors.length-1].originalAttr.delta = sectors[sectors.length-1].delta;
373
+ phi += deltaExtra;
374
+
375
+ if(this.grid.actors.length == 0) match =false;
376
+ if(match){
377
+ //Calculate total number of actors
378
+ for (var i = 0; i < sectors.length -1; i++){
379
+ totalActors += (sectors[i].actors.length);
380
+ }
381
+ consideredActors = totalActors;
382
+ //Calculate percentage of actors of each sector
383
+ for (var i = 0; i < sectors.length -1; i++){
384
+ sectorActors = sectors[i].actors.length;
385
+ if( sectorActors / totalActors <= 0.1){
386
+ isLittle[i] = true;
387
+ littleSectors++;
388
+ consideredActors -= sectors[i].actors.length;
389
+ }
390
+ }
391
+ //Assign width
392
+ for (var i = 0; i < sectors.length -1; i++){
393
+ if(isLittle[i]){
394
+ deltaSector = minDeltaSector;
395
+ }else{
396
+ deltaSector = (sectors[i].actors.length / consideredActors)*
397
+ (2*Math.PI - deltaExtra - littleSectors*minDeltaSector);
398
+ }
399
+ sectors[i].phi = phi;
400
+ sectors[i].delta = deltaSector;
401
+ sectors[i].originalAttr.phi = sectors[i].phi;
402
+ sectors[i].originalAttr.delta = sectors[i].delta;
403
+ phi += deltaSector;
404
+ }
405
+ }else{
406
+ deltaSector = (2 * Math.PI - deltaExtra) / (sectors.length-1);
407
+ for (var i = 0; i < sectors.length -1; i++){
408
+ sectors[i].phi = phi;
409
+ sectors[i].delta = deltaSector;
410
+ sectors[i].originalAttr.phi = sectors[i].phi;
411
+ sectors[i].originalAttr.delta = sectors[i].delta;
412
+ phi += deltaSector;
413
+ }
414
+ }
415
+ }
416
+
417
+ socialCheesecake.Cheesecake.prototype.setHighlightedSector = function(sector){
418
+ if(this.highlightedSector != sector){
419
+ this.highlightedSector = sector;
420
+ if(this.highlightedSectorCallback){
421
+ this.highlightedSectorCallback(this);
422
+ }
423
+ }
424
+ }
425
+
426
+ socialCheesecake.Cheesecake.prototype.getChanges = function (){
427
+ return this.changes;
428
+ }
429
+
430
+ /**
431
+ * sector - sector to open or to close
432
+ * open - true: expand sector
433
+ * - false: shrink sector
434
+ */
435
+ socialCheesecake.Cheesecake.prototype.fanInSector = function (sector, open){
436
+ var sectors = this.sectors;
437
+ var minDelta = Math.PI/5;
438
+ var prevSectorIndex = 0;
439
+ var laterSectorIndex = 0;
440
+ var deltaToChange = 0;
441
+
442
+ if(open && (sector.delta >= minDelta)) return;
443
+
444
+ //Find the sector's neighbours
445
+ for(var i= 0; i<sectors.length; i++){
446
+ if(sectors[i]=== sector){
447
+ prevSectorIndex = i-1;
448
+ laterSectorIndex = (i+1);
449
+ //console.log("current "+i)
450
+ }
451
+ }
452
+ if(prevSectorIndex < 0) prevSectorIndex = sectors.length -1;
453
+ if(laterSectorIndex >= sectors.length) laterSectorIndex = 0;
454
+
455
+ //Animate the three sectors
456
+ if(open){
457
+ deltaToChange = (minDelta - sector.delta)/2;
458
+ sector.resizeDelta({
459
+ anchor: "m",
460
+ delta: minDelta
461
+ });
462
+ console.log("delta to change "+ deltaToChange);
463
+ console.log("delta of prev "+ sectors[prevSectorIndex].delta);
464
+ console.log("delta of later "+ sectors[laterSectorIndex].delta);
465
+ sectors[prevSectorIndex].resizeDelta({
466
+ anchor: "b",
467
+ delta : (sectors[prevSectorIndex].delta - deltaToChange)
468
+ });
469
+ sectors[laterSectorIndex].resizeDelta({
470
+ anchor: "e",
471
+ delta : (sectors[laterSectorIndex].delta - deltaToChange)
472
+ });
473
+ }else{
474
+ sector.resizeDelta({
475
+ anchor: "m",
476
+ delta: sector.originalAttr.delta
477
+ });
478
+ sectors[prevSectorIndex].resizeDelta({
479
+ anchor: "b",
480
+ delta : sectors[prevSectorIndex].originalAttr.delta
481
+ });
482
+ sectors[laterSectorIndex].resizeDelta({
483
+ anchor: "e",
484
+ delta : sectors[laterSectorIndex].originalAttr.delta
485
+ });
486
+ }
487
+ }
488
+ //Colors and text style settings
489
+ /** Sector Normal Fill Color (also mouseout and mouseup) */
490
+ socialCheesecake.Cheesecake.getSectorFillColor = function (){
491
+ return sectorFillColor;
492
+ }
493
+ socialCheesecake.Cheesecake.setSectorFillColor = function (newColor){
494
+ if(typeof newColor === "string") sectorFillColor = newColor;
495
+ }
496
+ /** Extra Sectors Normal Fill Color (also mouseout and mouseup) */
497
+ socialCheesecake.Cheesecake.getExtraSectorFillColor = function (){
498
+ return extraSectorFillColor;
499
+ }
500
+ socialCheesecake.Cheesecake.setExtraSectorFillColor = function (newColor){
501
+ if(typeof newColor === "string") extraSectorFillColor = newColor;
502
+ }
503
+ /** Grey Sectors Normal Fill Color (also mouseout and mouseup) */
504
+ socialCheesecake.Cheesecake.getGreySectorFillColor = function (){
505
+ return greySectorFillColor;
506
+ }
507
+ socialCheesecake.Cheesecake.setGreySectorFillColor = function (newColor){
508
+ if(typeof newColor === "string") greySectorFillColor = newColor;
509
+ }
510
+ /** Sector Focus Fill Color (mousedown) */
511
+ socialCheesecake.Cheesecake.getSectorFocusColor = function (){
512
+ return sectorFocusColor;
513
+ }
514
+ socialCheesecake.Cheesecake.setSectorFocusColor = function (newColor){
515
+ if(typeof newColor === "string") sectorFocusColor = newColor;
516
+ }
517
+ /** Extra Sectors Focus Fill Color (mousedown) */
518
+ socialCheesecake.Cheesecake.getExtraSectorFocusColor = function (){
519
+ return extraFocusColor;
520
+ }
521
+ socialCheesecake.Cheesecake.setExtraSectorFocusColor = function (newColor){
522
+ if(typeof newColor === "string") extraFocusColor = newColor;
523
+ }
524
+ /** Grey Sectors Focus Fill Color (mousedown) */
525
+ socialCheesecake.Cheesecake.getGreySectorFocusColor = function (){
526
+ return greyFocusColor;
527
+ }
528
+ socialCheesecake.Cheesecake.setGreySectorFocusColor = function (newColor){
529
+ if(typeof newColor === "string") greyFocusColor = newColor;
530
+ }
531
+ /** Sector Hover Fill Color (mouseover) */
532
+ socialCheesecake.Cheesecake.getSectorHoverColor = function (){
533
+ return sectorHoverColor;
534
+ }
535
+ socialCheesecake.Cheesecake.setSectorHoverColor = function (newColor){
536
+ if(typeof newColor === "string") sectorHoverColor = newColor;
537
+ }
538
+ /** Extra Sectors Hover Fill Color (mouseover) */
539
+ socialCheesecake.Cheesecake.getExtraSectorHoverColor = function (){
540
+ return extraHoverColor;
541
+ }
542
+ socialCheesecake.Cheesecake.setExtraSectorHoverColor = function (newColor){
543
+ if(typeof newColor === "string") extraHoverColor = newColor;
544
+ }
545
+ /** Grey Sectors Hover Fill Color (mouseover) */
546
+ socialCheesecake.Cheesecake.getGreySectorHoverColor = function (){
547
+ return greyHoverColor;
548
+ }
549
+ socialCheesecake.Cheesecake.setGreySectorHoverColor = function (newColor){
550
+ if(typeof newColor === "string") greyHoverColor = newColor;
551
+ }
552
+ /** Sector Text and Stroke Color */
553
+ socialCheesecake.Cheesecake.getSectorTextAndStrokeColor = function (){
554
+ return sectorTextAndStrokeColor;
555
+ }
556
+ socialCheesecake.Cheesecake.setSectorTextAndStrokeColor = function (newColor){
557
+ if(typeof newColor === "string") sectorTextAndStrokeColor = newColor;
558
+ }
559
+ /** Extra Sectors Hover Fill Color (mouseover) */
560
+ socialCheesecake.Cheesecake.getExtraSectorTextAndStrokeColor = function (){
561
+ return extraTextAndStrokeColor;
562
+ }
563
+ socialCheesecake.Cheesecake.setExtraSectorTextAndStrokeColor = function (newColor){
564
+ if(typeof newColor === "string") extraTextAndStrokeColor = newColor;
565
+ }
566
+ /** Grey Sectors Hover Fill Color (mouseover) */
567
+ socialCheesecake.Cheesecake.getGreySectorTextAndStrokeColor = function (){
568
+ return greyTextAndStrokeColor;
569
+ }
570
+ socialCheesecake.Cheesecake.setGreySectorTextAndStrokeColor = function (newColor){
571
+ if(typeof newColor === "string") greyTextAndStrokeColor = newColor;
572
+ }
573
+
250
574
  })();
251
575