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.
@@ -30,16 +30,24 @@ var socialCheesecake = socialCheesecake || {};
30
30
  }
31
31
  // If the actor was not in the array, create it and add it to the array
32
32
  if(!actorAlreadyDeclared){
33
- actor = new socialCheesecake.Actor({
34
- id : actor_info.id,
35
- parent: subsector
36
- });
33
+ actor_info.parent = subsector;
34
+ actor = new socialCheesecake.Actor(actor_info);
37
35
  actors.push(actor);
38
36
  }
39
37
  return actor;
40
38
  }
41
39
 
40
+ socialCheesecake.Grid.prototype.removeActor = function(actor){
41
+ var actors = this.actors;
42
+ for(var actorIndex in actors){
43
+ if((actors[actorIndex].id==actor.id)&&(actor.parents.length <= 0 )){
44
+ actors.splice(actorIndex,1);
45
+ }
46
+ }
47
+ }
48
+
42
49
  socialCheesecake.Grid.prototype.getActor = function (id) {
50
+ var actors = this.actors;
43
51
  for (var i in actors){
44
52
  if (this.actors[i].id == id){
45
53
  return this.actors[i];
@@ -48,6 +56,24 @@ var socialCheesecake = socialCheesecake || {};
48
56
  return null
49
57
  }
50
58
 
59
+ socialCheesecake.Grid.prototype.getSelectedActors = function(){
60
+ var actors = this.actors;
61
+ var selectedActors = [];
62
+ for (var i in actors){
63
+ if(actors[i].isSelected()) selectedActors.push(actors[i]);
64
+ }
65
+ return selectedActors;
66
+ }
67
+
68
+ socialCheesecake.Grid.prototype.getShownActors = function(){
69
+ var actors = this.actors;
70
+ var shownActors = [];
71
+ for (var i in actors){
72
+ if((!actors[i].isHidden())&&(!actors[i].isFiltered())) shownActors.push(actors[i]);
73
+ }
74
+ return shownActors;
75
+ }
76
+
51
77
  socialCheesecake.Grid.prototype.focus = function (actor_ids) {
52
78
  if (actor_ids instanceof Array) {
53
79
  for(var i in actor_ids){
@@ -71,22 +97,23 @@ var socialCheesecake = socialCheesecake || {};
71
97
  this.focus(this.actors);
72
98
  }
73
99
 
74
- socialCheesecake.Grid.prototype.hide = function (actor_ids) {
100
+ socialCheesecake.Grid.prototype.hide = function (actor_ids, ignoreSelected) {
101
+ var actor;
75
102
  if (actor_ids instanceof Array) {
76
103
  for(var i in actor_ids){
77
- var actor = actor_ids[i];
78
- if(actor instanceof socialCheesecake.Actor){
79
- actor.hide();
80
- }else{
81
- this.getActor(actor).hide();
82
- }
104
+ actor = actor_ids[i];
105
+ if (!(actor instanceof socialCheesecake.Actor)){
106
+ actor = this.getActor(actor);
107
+ }
108
+ if((!actor.isSelected())||(ignoreSelected)) actor.hide();
83
109
  }
84
110
  } else {
85
111
  if(actor_ids instanceof socialCheesecake.Actor){
86
- actor_ids.hide();
112
+ actor = actor_ids;
87
113
  }else{
88
- this.getActor(actor_ids).hide();
89
- }
114
+ actor = this.getActor(actor_ids);
115
+ }
116
+ actor.hide();
90
117
  }
91
118
  }
92
119
 
@@ -140,22 +167,23 @@ var socialCheesecake = socialCheesecake || {};
140
167
  this.unfocus(this.actors);
141
168
  }
142
169
 
143
- socialCheesecake.Grid.prototype.fadeOut = function (actor_ids, time, modifyDisplay) {
170
+ socialCheesecake.Grid.prototype.fadeOut = function (actor_ids, time, modifyDisplay, ignoreSelected) {
171
+ var actor;
144
172
  if (actor_ids instanceof Array) {
145
173
  for(var i in actor_ids){
146
- var actor = actor_ids[i];
147
- if(actor instanceof socialCheesecake.Actor){
148
- actor.fadeOut(time, modifyDisplay);
149
- }else{
150
- this.getActor(actor).fadeOut(time, modifyDisplay);
151
- }
174
+ actor = actor_ids[i];
175
+ if (!(actor instanceof socialCheesecake.Actor)){
176
+ actor = this.getActor(actor);
177
+ }
178
+ if((!actor.isSelected())||(ignoreSelected)) actor.fadeOut(time, modifyDisplay);
152
179
  }
153
180
  } else {
154
181
  if(actor_ids instanceof socialCheesecake.Actor){
155
- actor_ids.fadeOut(time, modifyDisplay);
182
+ actor = actor_ids;
156
183
  }else{
157
- this.getActor(actor_ids).fadeOut(time, modifyDisplay);
158
- }
184
+ actor = this.getActor(actor_ids);
185
+ }
186
+ if((!actor.isSelected())||(ignoreSelected)) actor.fadeOut(time, modifyDisplay);
159
187
  }
160
188
  }
161
189
 
@@ -163,22 +191,23 @@ var socialCheesecake = socialCheesecake || {};
163
191
  this.fadeOut(this.actors, time, modifyDisplay);
164
192
  }
165
193
 
166
- socialCheesecake.Grid.prototype.fadeIn = function (actor_ids, time, modifyDisplay) {
194
+ socialCheesecake.Grid.prototype.fadeIn = function (actor_ids, time, modifyDisplay, ignoreSelected) {
195
+ var actor;
167
196
  if (actor_ids instanceof Array) {
168
197
  for(var i in actor_ids){
169
- var actor = actor_ids[i];
170
- if(actor instanceof socialCheesecake.Actor){
171
- actor.fadeIn(time, modifyDisplay);
172
- }else{
173
- this.getActor(actor).fadeIn(time, modifyDisplay);
174
- }
198
+ actor = actor_ids[i];
199
+ if (!(actor instanceof socialCheesecake.Actor)){
200
+ actor = this.getActor(actor);
201
+ }
202
+ if((!actor.isSelected())||(ignoreSelected)) actor.fadeIn(time, modifyDisplay);
175
203
  }
176
204
  } else {
177
205
  if(actor_ids instanceof socialCheesecake.Actor){
178
- actor_ids.fadeIn(time, modifyDisplay);
206
+ actor = actor_ids;
179
207
  }else{
180
- this.getActor(actor_ids).fadeIn(time, modifyDisplay);
181
- }
208
+ actor = this.getActor(actor_ids);
209
+ }
210
+ if((!actor.isSelected())||(ignoreSelected)) actor.fadeIn(time, modifyDisplay);
182
211
  }
183
212
  }
184
213
 
@@ -0,0 +1,26 @@
1
+ var socialCheesecake = socialCheesecake || {};
2
+ (function() {
3
+ socialCheesecake.SearchEngine = function(settings){
4
+ this.parent = settings.parent;
5
+ }
6
+
7
+ socialCheesecake.SearchEngine.prototype.filter = function(pattern){
8
+ var actors = this.parent.grid.actors;
9
+ var patt = new RegExp(pattern.toLowerCase());
10
+
11
+ for (var i in actors){
12
+ var actor = actors[i];
13
+ if(actor.name.toLowerCase().match(patt)){
14
+ actor.unfilter();
15
+ }else{
16
+ actor.filter();
17
+ }
18
+ }
19
+
20
+ if(this.parent.highlightedSector){
21
+ this.parent.grid.fadeIn(this.parent.highlightedSector.actors, 100, true);
22
+ }else{
23
+ this.parent.grid.fadeIn(this.parent.grid.actors, 100, true);
24
+ }
25
+ }
26
+ })();