social_cheesecake 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/kinetic.js +1710 -1081
- data/app/assets/javascripts/socialcheesecake/_header.js +2 -3
- data/app/assets/javascripts/socialcheesecake/actor.js +30 -20
- data/app/assets/javascripts/socialcheesecake/cheesecake.js +118 -72
- data/app/assets/javascripts/socialcheesecake/eventCallbackHandlers.js +14 -5
- data/app/assets/javascripts/socialcheesecake/grid.js +35 -10
- data/app/assets/javascripts/socialcheesecake/search.js +12 -20
- data/app/assets/javascripts/socialcheesecake/sector.js +93 -71
- data/app/assets/javascripts/socialcheesecake/subsector.js +16 -2
- data/app/assets/javascripts/socialcheesecake/text.js +13 -0
- data/lib/social_cheesecake/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/main.js +36 -4
- data/test/dummy/app/assets/stylesheets/style.css +9 -0
- metadata +4 -4
@@ -1,12 +1,11 @@
|
|
1
1
|
/**
|
2
|
-
* @license SocialCheesecake JavaScript Library v0.
|
2
|
+
* @license SocialCheesecake JavaScript Library v0.5.0
|
3
3
|
* https://github.com/adiezbal/SocialCheesecake
|
4
4
|
* Developed by Alicia Diez (https://github.com/adiezbal)
|
5
5
|
* Copyright 2011, Technical University of Madrid (Universidad Politecnica de Madrid)
|
6
6
|
* Licensed under the MIT or GPL Version 2 licenses.
|
7
|
-
* Date: Dec 22 2011
|
8
7
|
*
|
9
|
-
* Copyright (C)
|
8
|
+
* Copyright (C) 2012 by Technical University of Madrid (Universidad Politécnica de Madrid)
|
10
9
|
*
|
11
10
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
12
11
|
* of this software and associated documentation files (the "Software"), to deal
|
@@ -2,14 +2,13 @@ var socialCheesecake = socialCheesecake || {};
|
|
2
2
|
(function() {
|
3
3
|
socialCheesecake.Actor = function(settings) {
|
4
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"
|
5
|
+
throw "No arguments passed to the function";
|
8
6
|
|
9
7
|
this.id = settings.id;
|
10
8
|
this.name = settings.name;
|
9
|
+
this.grid = settings.grid;
|
11
10
|
this.extraInfo = (settings.extraInfo) ? settings.extraInfo : undefined;
|
12
|
-
this.opacity =
|
11
|
+
this.opacity = this.grid.maxOpacity || 1;
|
13
12
|
this._focused = false;
|
14
13
|
this._selected = false;
|
15
14
|
this._hidden = true;
|
@@ -25,21 +24,25 @@ var socialCheesecake = socialCheesecake || {};
|
|
25
24
|
actor_div.addEventListener("mouseover", function() {
|
26
25
|
var sector;
|
27
26
|
actor.focus();
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
if(!actor.isOrphan()){
|
28
|
+
for(var subsector in actor.parents) {
|
29
|
+
sector = actor.parents[subsector].parent;
|
30
|
+
sector.focus();
|
31
|
+
sector.colorHandler("mouseover");
|
32
|
+
actor.parents[subsector].colorHandler("mouseover");
|
33
|
+
}
|
33
34
|
}
|
34
35
|
}, false);
|
35
36
|
actor_div.addEventListener("mouseout", function() {
|
36
37
|
var sector;
|
37
38
|
actor.unfocus();
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
if(!actor.isOrphan()){
|
40
|
+
for(var subsector in actor.parents) {
|
41
|
+
sector = actor.parents[subsector].parent;
|
42
|
+
sector.unfocus();
|
43
|
+
sector.colorHandler("mouseout");
|
44
|
+
actor.parents[subsector].colorHandler("mouseout");
|
45
|
+
}
|
43
46
|
}
|
44
47
|
}, false);
|
45
48
|
actor_div.addEventListener("click", function() {
|
@@ -124,6 +127,13 @@ var socialCheesecake = socialCheesecake || {};
|
|
124
127
|
var gridIdPrefix = this.getCheesecake().grid.divIdPrefix;
|
125
128
|
return this._focused;
|
126
129
|
}
|
130
|
+
|
131
|
+
socialCheesecake.Actor.prototype.isOrphan = function (){
|
132
|
+
var actor = this;
|
133
|
+
var orphan = false;
|
134
|
+
if( actor.parents.length <1) orphan = true;
|
135
|
+
return orphan;
|
136
|
+
}
|
127
137
|
|
128
138
|
socialCheesecake.Actor.prototype.hide = function() {
|
129
139
|
var actor_div = this.getDiv();
|
@@ -198,8 +208,8 @@ var socialCheesecake = socialCheesecake || {};
|
|
198
208
|
socialCheesecake.Actor.prototype.fade = function(time, modifyDisplay) {
|
199
209
|
var actor = this;
|
200
210
|
var time = (time) ? time : 300;
|
201
|
-
var minOpacity =
|
202
|
-
var maxOpacity =
|
211
|
+
var minOpacity = this.grid.minOpacity;
|
212
|
+
var maxOpacity = this.grid.maxOpacity;
|
203
213
|
var deltaOpacity = ((maxOpacity - minOpacity)* 1000.0) / (60.0 * time);
|
204
214
|
var grow = 0;
|
205
215
|
|
@@ -227,7 +237,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
227
237
|
}
|
228
238
|
|
229
239
|
socialCheesecake.Actor.prototype.fadeOut = function(time, modifyDisplay) {
|
230
|
-
var maxOpacity =
|
240
|
+
var maxOpacity = this.grid.maxOpacity;
|
231
241
|
this.fading = "out";
|
232
242
|
this.setDivOpacity(maxOpacity);
|
233
243
|
this.fade(time, modifyDisplay);
|
@@ -235,7 +245,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
235
245
|
|
236
246
|
socialCheesecake.Actor.prototype.fadeIn = function(time, modifyDisplay) {
|
237
247
|
var actor = this;
|
238
|
-
var minOpacity =
|
248
|
+
var minOpacity = this.grid.minOpacity;
|
239
249
|
|
240
250
|
if(actor.isFiltered())
|
241
251
|
return;
|
@@ -247,11 +257,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
247
257
|
}
|
248
258
|
|
249
259
|
socialCheesecake.Actor.prototype.getCheesecake = function() {
|
250
|
-
return this.
|
260
|
+
return this.grid.parent;
|
251
261
|
}
|
252
262
|
|
253
263
|
socialCheesecake.Actor.prototype.getDiv = function() {
|
254
|
-
var gridIdPrefix = this.
|
264
|
+
var gridIdPrefix = this.grid.divIdPrefix;
|
255
265
|
var actor_id = this.id;
|
256
266
|
var actor_div = document.getElementById(gridIdPrefix + actor_id);
|
257
267
|
return actor_div;
|
@@ -11,16 +11,9 @@ var socialCheesecake = socialCheesecake || {};
|
|
11
11
|
cheesecake.rMax = cheesecakeData.rMax;
|
12
12
|
cheesecake.sectors = [];
|
13
13
|
cheesecake.highlightedSector = null;
|
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;
|
20
14
|
cheesecake.auxiliarSectors = [];
|
21
15
|
cheesecake.stage = new Kinetic.Stage(cheesecakeData.container.id, cheesecakeData.container.width, cheesecakeData.container.height);
|
22
|
-
cheesecake.stage.add(new Kinetic.Layer());
|
23
|
-
cheesecake.stage.mainLayer = cheesecake.stage.layers[0];
|
16
|
+
cheesecake.stage.add(new Kinetic.Layer({name: "main"}));
|
24
17
|
cheesecake.grid = new socialCheesecake.Grid({
|
25
18
|
parent : this,
|
26
19
|
grid_id : cheesecakeData.grid.id,
|
@@ -28,18 +21,10 @@ var socialCheesecake = socialCheesecake || {};
|
|
28
21
|
maxOpacity : cheesecakeData.grid.maxOpacity || 1,
|
29
22
|
minOpacity : cheesecakeData.grid.minOpacity || 0
|
30
23
|
});
|
31
|
-
cheesecake.searchEngine = new socialCheesecake.SearchEngine({
|
32
|
-
parent : this
|
33
|
-
});
|
34
24
|
cheesecake.matchActorsNumber = cheesecakeData.match;
|
35
|
-
if(cheesecake.matchActorsNumber == null)
|
36
|
-
cheesecake.matchActorsNumber = true;
|
25
|
+
if(cheesecake.matchActorsNumber == null) cheesecake.matchActorsNumber = true;
|
37
26
|
cheesecake._initialState = {};
|
38
27
|
cheesecake._changes = {};
|
39
|
-
cheesecake.onChange = function(cheesecake) {
|
40
|
-
};
|
41
|
-
if(cheesecakeData.onChange)
|
42
|
-
cheesecake.onChange = cheesecakeData.onChange;
|
43
28
|
//Text settings
|
44
29
|
if(cheesecakeData.text) {
|
45
30
|
for(var style in cheesecakeData.text) {
|
@@ -54,6 +39,13 @@ var socialCheesecake = socialCheesecake || {};
|
|
54
39
|
}
|
55
40
|
}
|
56
41
|
}
|
42
|
+
//Callback settings
|
43
|
+
if(cheesecakeData.callbacks){
|
44
|
+
for(var type in cheesecakeData.callbacks) {
|
45
|
+
socialCheesecake.eventCallbackHandlers[type] = cheesecakeData.callbacks[type];
|
46
|
+
}
|
47
|
+
}
|
48
|
+
cheesecake.syncSectorFocusCallbacks = cheesecake.syncSectorFocusCallbacks || false;
|
57
49
|
//Extra sector if necessary
|
58
50
|
if(jsonSectors.length < 16) {
|
59
51
|
var extraSector = new socialCheesecake.Sector({
|
@@ -95,14 +87,14 @@ var socialCheesecake = socialCheesecake || {};
|
|
95
87
|
}
|
96
88
|
|
97
89
|
socialCheesecake.Cheesecake.prototype.disable = function() {
|
98
|
-
var layers = this.stage.
|
90
|
+
var layers = this.stage.getChildren();
|
99
91
|
for(var layer in layers) {
|
100
92
|
layers[layer].listen(false);
|
101
93
|
}
|
102
94
|
}
|
103
95
|
|
104
96
|
socialCheesecake.Cheesecake.prototype.enable = function() {
|
105
|
-
var layers = this.stage.
|
97
|
+
var layers = this.stage.getChildren();
|
106
98
|
for(var layer in layers) {
|
107
99
|
layers[layer].listen(true);
|
108
100
|
}
|
@@ -111,6 +103,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
111
103
|
socialCheesecake.Cheesecake.prototype.focusAndBlurCheesecake = function(sector) {
|
112
104
|
var cheesecake = this;
|
113
105
|
var sectorIndex;
|
106
|
+
var onSectorFocusBegin = socialCheesecake.eventCallbackHandlers.onSectorFocusBegin;
|
114
107
|
for(var i in cheesecake.sectors) {
|
115
108
|
if(cheesecake.sectors[i] === sector)
|
116
109
|
sectorIndex = i;
|
@@ -119,6 +112,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
119
112
|
throw "sector doesn't belong to this cheesecake"
|
120
113
|
cheesecake.clearLayer();
|
121
114
|
cheesecake.setHighlightedSector(sector);
|
115
|
+
cheesecake.disable();
|
122
116
|
|
123
117
|
//Add auxiliar sectors
|
124
118
|
var greySettings = {
|
@@ -138,15 +132,9 @@ var socialCheesecake = socialCheesecake || {};
|
|
138
132
|
cheesecake.addToLayer(greySector);
|
139
133
|
cheesecake.addToLayer(dummySector);
|
140
134
|
//Animations
|
141
|
-
var greyClickCallback = function() {
|
142
|
-
greySector.label = "";
|
143
|
-
cheesecake.unfocusAndUnblurCheesecake();
|
144
|
-
};
|
145
135
|
var greyResizeCallback = function() {
|
146
|
-
greySector.
|
147
|
-
|
148
|
-
}
|
149
|
-
greySector.label = "GO BACK";
|
136
|
+
greySector.changeProperty("label", "GO BACK");
|
137
|
+
cheesecake.enable();
|
150
138
|
};
|
151
139
|
var greyRotateToCallback = function() {
|
152
140
|
greySector.resizeDelta({
|
@@ -168,11 +156,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
168
156
|
callback : dummyResizeCallback
|
169
157
|
});
|
170
158
|
}
|
171
|
-
if(
|
159
|
+
if(onSectorFocusBegin) {
|
172
160
|
if(cheesecake.syncSectorFocusCallbacks) {
|
173
|
-
|
161
|
+
onSectorFocusBegin(cheesecake, callback);
|
174
162
|
} else {
|
175
|
-
|
163
|
+
onSectorFocusBegin(cheesecake);
|
176
164
|
callback();
|
177
165
|
}
|
178
166
|
} else {
|
@@ -194,8 +182,8 @@ var socialCheesecake = socialCheesecake || {};
|
|
194
182
|
socialCheesecake.Cheesecake.prototype.recoverCheesecake = function() {
|
195
183
|
var cheesecake = this;
|
196
184
|
var lastSector = this.highlightedSector;
|
197
|
-
var mainLayer = this.stage.
|
198
|
-
var regions = mainLayer.
|
185
|
+
var mainLayer = this.stage.getChild("main");
|
186
|
+
var regions = mainLayer.getChildren();
|
199
187
|
|
200
188
|
//Delete the auxiliar sectors
|
201
189
|
cheesecake.removeFromLayer(cheesecake.auxiliarSectors);
|
@@ -214,6 +202,8 @@ var socialCheesecake = socialCheesecake || {};
|
|
214
202
|
socialCheesecake.Cheesecake.prototype.unfocusAndUnblurCheesecake = function() {
|
215
203
|
var cheesecake = this;
|
216
204
|
var auxiliarSectors = this.auxiliarSectors;
|
205
|
+
var onSectorUnfocusEnd = socialCheesecake.eventCallbackHandlers.onSectorUnfocusEnd;
|
206
|
+
var onSectorUnfocusBegin = socialCheesecake.eventCallbackHandlers.onSectorUnfocusBegin;
|
217
207
|
var dummySector;
|
218
208
|
var sectorNewDelta;
|
219
209
|
var sectorNewPhi;
|
@@ -241,8 +231,8 @@ var socialCheesecake = socialCheesecake || {};
|
|
241
231
|
anchor : "M",
|
242
232
|
delta : dummyNewDelta,
|
243
233
|
callback : function() {
|
244
|
-
if(
|
245
|
-
|
234
|
+
if(onSectorUnfocusEnd) {
|
235
|
+
onSectorUnfocusEnd(cheesecake);
|
246
236
|
}
|
247
237
|
cheesecake.grid.showAll();
|
248
238
|
dummySector.rotateTo({
|
@@ -263,11 +253,11 @@ var socialCheesecake = socialCheesecake || {};
|
|
263
253
|
}
|
264
254
|
});
|
265
255
|
}
|
266
|
-
if(
|
256
|
+
if(onSectorUnfocusBegin) {
|
267
257
|
if(cheesecake.syncSectorFocusCallbacks) {
|
268
|
-
|
258
|
+
onSectorUnfocusBegin(cheesecake, actions);
|
269
259
|
} else {
|
270
|
-
|
260
|
+
onSectorUnfocusBegin(cheesecake);
|
271
261
|
actions();
|
272
262
|
}
|
273
263
|
} else {
|
@@ -277,12 +267,14 @@ var socialCheesecake = socialCheesecake || {};
|
|
277
267
|
|
278
268
|
socialCheesecake.Cheesecake.prototype.addNewSector = function() {
|
279
269
|
var cheesecake = this;
|
280
|
-
var sectors = this.sectors;
|
270
|
+
var sectors = this.sectors;
|
271
|
+
var id = this.getInitialState().sectors.length;
|
272
|
+
console.log(id);
|
281
273
|
var newSector;
|
282
274
|
var settings = {
|
283
275
|
parent : cheesecake,
|
284
276
|
center : cheesecake.center,
|
285
|
-
|
277
|
+
id : id,
|
286
278
|
label : "New Sector",
|
287
279
|
rOut : cheesecake.rMax,
|
288
280
|
subsectors : [{name : "New Subsector 1"}]
|
@@ -294,40 +286,43 @@ var socialCheesecake = socialCheesecake || {};
|
|
294
286
|
cheesecake.calculatePortions();
|
295
287
|
}
|
296
288
|
|
289
|
+
/*
|
290
|
+
* Add new Subsector to the Focused Sector
|
291
|
+
*/
|
292
|
+
socialCheesecake.Cheesecake.prototype.addNewSubsector = function(subsectorIndex){
|
293
|
+
var cheesecake = this;
|
294
|
+
var sector = this.getFocusedSector();
|
295
|
+
if(sector == null) return;
|
296
|
+
if(subsectorIndex > sector.subsectors.length ){
|
297
|
+
console.log("Cannot add new subsector in position "+ subsectorIndex+".This sector only has "+sector.subsectors.length+" subsectors");
|
298
|
+
return;
|
299
|
+
}
|
300
|
+
sector.turnExtraIntoNewSubsector(subsectorIndex);
|
301
|
+
}
|
302
|
+
|
297
303
|
/**
|
298
304
|
* actorId - actor which changes one of its parents
|
299
305
|
*/
|
300
306
|
socialCheesecake.Cheesecake.prototype.updateActorMembership = function(actor) {
|
301
307
|
var changes = this._changes;
|
302
308
|
var grid = this.grid;
|
303
|
-
|
309
|
+
changes.actors = changes.actors || [];
|
310
|
+
var changesInActors = changes.actors;
|
304
311
|
var alreadyChanged = false;
|
305
312
|
var actorId = actor.id;
|
306
313
|
var actorParents = actor.getParentsIds();
|
307
314
|
var actorName = actor.name;
|
308
315
|
var actorExtraInfo = actor.extraInfo;
|
309
|
-
var onChange =
|
316
|
+
var onChange = socialCheesecake.eventCallbackHandlers.onChange;
|
310
317
|
|
311
|
-
|
312
|
-
changesInActors
|
313
|
-
|
314
|
-
|
315
|
-
alreadyChanged = true;
|
316
|
-
changesInActors[a].subsectors = actorParents;
|
317
|
-
}
|
318
|
+
for(var a in changesInActors) {
|
319
|
+
if(changesInActors[a].id == actorId) {
|
320
|
+
alreadyChanged = true;
|
321
|
+
changesInActors[a].subsectors = actorParents;
|
318
322
|
}
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
subsectors : actorParents,
|
323
|
-
name : actorName,
|
324
|
-
extraInfo : actorExtraInfo,
|
325
|
-
justAdded : false
|
326
|
-
});
|
327
|
-
}
|
328
|
-
} else {
|
329
|
-
changes.actors = [];
|
330
|
-
changes.actors.push({
|
323
|
+
}
|
324
|
+
if(!alreadyChanged) {
|
325
|
+
changesInActors.push({
|
331
326
|
id : actorId,
|
332
327
|
subsectors : actorParents,
|
333
328
|
name : actorName,
|
@@ -336,7 +331,30 @@ var socialCheesecake = socialCheesecake || {};
|
|
336
331
|
});
|
337
332
|
}
|
338
333
|
//Execute onChange Callback
|
339
|
-
onChange(this);
|
334
|
+
if(onChange) onChange(this);
|
335
|
+
}
|
336
|
+
|
337
|
+
/*
|
338
|
+
* Executes when a sector is removed / added and/or subsectors are added or removed from them
|
339
|
+
*/
|
340
|
+
socialCheesecake.Cheesecake.prototype.updateSectorChanges = function(sector){
|
341
|
+
var changes = this._changes;
|
342
|
+
changes.sectors = changes.sectors || [];
|
343
|
+
var changesInSectors = changes.sectors;
|
344
|
+
var alreadyChanged = false;
|
345
|
+
for(var s in changesInSectors){
|
346
|
+
if(changesInSectors[s].id == sector.id){
|
347
|
+
alreadyChanged = true;
|
348
|
+
changesInSectors[s].subsectors = sector.getSubsectorsIds();
|
349
|
+
changesInSectors[s].name = sector.label;
|
350
|
+
}
|
351
|
+
}if(!alreadyChanged){
|
352
|
+
changesInSectors.push({
|
353
|
+
id : sector.id,
|
354
|
+
subsectors : sector.getSubsectorsIds(),
|
355
|
+
name : sector.label
|
356
|
+
});
|
357
|
+
}
|
340
358
|
}
|
341
359
|
|
342
360
|
socialCheesecake.Cheesecake.prototype.calculatePortions = function() {
|
@@ -389,7 +407,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
389
407
|
}
|
390
408
|
|
391
409
|
socialCheesecake.Cheesecake.prototype.addToLayer = function(sectors, layer){
|
392
|
-
var layer = layer || this.stage.
|
410
|
+
var layer = layer || this.stage.getChild("main");
|
393
411
|
if(sectors instanceof Array){
|
394
412
|
for(var sector in sectors){
|
395
413
|
layer.add(sectors[sector].getRegion());
|
@@ -400,7 +418,7 @@ var socialCheesecake = socialCheesecake || {};
|
|
400
418
|
}
|
401
419
|
|
402
420
|
socialCheesecake.Cheesecake.prototype.removeFromLayer = function(sectors, layer){
|
403
|
-
var layer = layer || this.stage.
|
421
|
+
var layer = layer || this.stage.getChild("main");
|
404
422
|
if(sectors instanceof Array){
|
405
423
|
for(var sector in sectors) {
|
406
424
|
try{
|
@@ -413,14 +431,20 @@ var socialCheesecake = socialCheesecake || {};
|
|
413
431
|
}
|
414
432
|
}
|
415
433
|
|
416
|
-
socialCheesecake.Cheesecake.prototype.drawLayer = function(layer){
|
417
|
-
var layer = layer || this.stage.
|
434
|
+
socialCheesecake.Cheesecake.prototype.drawLayer = function(layer, initialContextState){
|
435
|
+
var layer = layer || this.stage.getChild("main");
|
436
|
+
initialContextState = (initialContextState != null)? initialContextState : true;
|
437
|
+
if(initialContextState){
|
438
|
+
var context = layer.getContext();
|
439
|
+
context.restore();
|
440
|
+
context.save();
|
441
|
+
}
|
418
442
|
layer.draw();
|
419
443
|
}
|
420
444
|
|
421
445
|
socialCheesecake.Cheesecake.prototype.clearLayer = function(layer){
|
422
|
-
var layer = layer || this.stage.
|
423
|
-
var regions = layer.
|
446
|
+
var layer = layer || this.stage.getChild("main");
|
447
|
+
var regions = layer.getChildren();
|
424
448
|
for(var i = (regions.length - 1); i >= 0; i--) {
|
425
449
|
layer.remove(regions[i]);
|
426
450
|
}
|
@@ -428,11 +452,10 @@ var socialCheesecake = socialCheesecake || {};
|
|
428
452
|
}
|
429
453
|
|
430
454
|
socialCheesecake.Cheesecake.prototype.setHighlightedSector = function(sector) {
|
455
|
+
var onSectorHighlight = socialCheesecake.eventCallbackHandlers.onSectorHighlight;
|
431
456
|
if(this.highlightedSector != sector) {
|
432
457
|
this.highlightedSector = sector;
|
433
|
-
if(
|
434
|
-
this.onSectorHighlight(this);
|
435
|
-
}
|
458
|
+
if(onSectorHighlight) onSectorHighlight(this);
|
436
459
|
}
|
437
460
|
}
|
438
461
|
|
@@ -523,19 +546,42 @@ var socialCheesecake = socialCheesecake || {};
|
|
523
546
|
socialCheesecake.Cheesecake.prototype.getInitialState = function() {
|
524
547
|
return this._initialState;
|
525
548
|
}
|
549
|
+
|
550
|
+
socialCheesecake.Cheesecake.prototype.filter = function(pattern) {
|
551
|
+
console.log("search")
|
552
|
+
var grid = this.grid;
|
553
|
+
var highlightedSector = this.highlightedSector;
|
554
|
+
socialCheesecake.SearchEngine.filter(pattern, grid.actors);
|
555
|
+
if(highlightedSector) {
|
556
|
+
grid.fadeIn(highlightedSector.actors, 100, true);
|
557
|
+
} else {
|
558
|
+
grid.fadeIn(grid.actors, 100, true);
|
559
|
+
}
|
560
|
+
}
|
526
561
|
|
527
562
|
socialCheesecake.Cheesecake.prototype._setInitialState = function() {
|
528
563
|
var state = this._initialState;
|
529
564
|
var actors = this.grid.actors;
|
565
|
+
var sectors = this.sectors;
|
530
566
|
|
531
567
|
state.actors = [];
|
532
|
-
for(var actor in actors
|
568
|
+
for(var actor in actors){
|
533
569
|
state.actors.push({
|
534
570
|
id : actors[actor].id,
|
535
571
|
subsectors : actors[actor].getParentsIds(),
|
536
572
|
name : actors[actor].name,
|
537
573
|
extraInfo : actors[actor].extraInfo
|
538
|
-
})
|
574
|
+
});
|
575
|
+
}
|
576
|
+
state.sectors = [];
|
577
|
+
for(var sector in sectors){
|
578
|
+
if(sectors[sector].type == "normalSector"){
|
579
|
+
state.sectors.push({
|
580
|
+
id : sectors[sector].id,
|
581
|
+
name : sectors[sector].label,
|
582
|
+
subsectors : sectors[sector].getSubsectorsIds()
|
583
|
+
});
|
584
|
+
}
|
539
585
|
}
|
540
586
|
}
|
541
587
|
})();
|