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.
@@ -1,7 +1,8 @@
1
1
  var socialCheesecake = socialCheesecake || {};
2
2
  (function() {
3
3
  socialCheesecake.Subsector = function(settings) {
4
- this.id = settings.id || null;
4
+ this.id = null;
5
+ if(settings.id != undefined ) this.id = settings.id;
5
6
  if(settings.parent != null) this.parent = settings.parent;
6
7
  this.label = "";
7
8
  if(settings.label != null) this.label = settings.label;
@@ -15,7 +16,7 @@ var socialCheesecake = socialCheesecake || {};
15
16
  this.auxiliar = (settings.auxiliar) ? settings.auxiliar : false;
16
17
  this.type = (settings.type) ? settings.type : "normalSubsector";
17
18
  if(settings.simulate != null) this.simulate = settings.simulate;
18
- if(settings.color) this.color = settings.color;
19
+ this.color = settings.color || socialCheesecake.colors.normalSubsector.background;
19
20
  if(settings.fontColor) this.fontColor = settings.fontColor;
20
21
  if(settings.borderColor) this.borderColor = settings.borderColor;
21
22
  if(settings.click != null) this.click = settings.click;
@@ -78,6 +79,19 @@ var socialCheesecake = socialCheesecake || {};
78
79
  return subsector.parent.parent;
79
80
  }
80
81
 
82
+ /*
83
+ * Returns the subsector's index IN SOCIALCHEESECAKE
84
+ */
85
+ socialCheesecake.Subsector.prototype.getIndex = function(){
86
+ var subsector = this;
87
+ var sector = subsector.parent;
88
+ var index = null;
89
+ for(var i in sector.subsectors){
90
+ if(sector.subsectors[i] === subsector ) index = i;
91
+ }
92
+ return index;
93
+ }
94
+
81
95
  socialCheesecake.Subsector.prototype.removeActor = function(actor){
82
96
  var actors = this.actors;
83
97
  var actorParents;
@@ -59,6 +59,19 @@ var socialCheesecake = socialCheesecake || {};
59
59
  },
60
60
  writeCenterText : function(text, context, centerX, centerY) {
61
61
  context.fillText(text, centerX - context.measureText(text).width / 2, centerY);
62
+ },
63
+ getTextHeight : function(text, style){
64
+ var style = style || socialCheesecake.text.style;
65
+ var div = document.createElement('div');
66
+ var height = 0;
67
+ div.setAttribute('id','getTextHeight');
68
+ div.setAttribute('display','none');
69
+ div.setAttribute('style', 'font: '+style);
70
+ div.innerHTML = text;
71
+ document.body.appendChild(div);
72
+ height = parseInt(window.getComputedStyle(div).fontSize);
73
+ document.body.removeChild(div);
74
+ return height;
62
75
  }
63
76
  }
64
77
  })();
@@ -1,3 +1,3 @@
1
1
  module SocialCheesecake
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -3,7 +3,6 @@ window.requestAnimFrame = (function(callback) {
3
3
  function(callback) {
4
4
  window.setTimeout(callback, 1000 / 60);
5
5
  };
6
-
7
6
  })();
8
7
  var sectorsCounter = 0;
9
8
  var subsectorsCounter = [0];
@@ -19,8 +18,33 @@ var cheesecakeData = {
19
18
  id : "grid",
20
19
  divIdPrefix : "actor_"
21
20
  },
22
- onChange : function() {
23
- console.log("Cambio detectado");
21
+ callbacks : {
22
+ onChange : function() {
23
+ console.log("Cambio detectado");
24
+ },
25
+ onSubsectorAddedBegin : function(subsector){
26
+ console.log("New subsector is going to be added.");
27
+ console.log(subsector);
28
+ },
29
+ onSubsectorAddedEnd : function(subsector){
30
+ console.log("New subsector "+ subsector.getIndex() +" added in sector "+subsector.parent.getIndex());
31
+ console.log(subsector.getCheesecake());
32
+ },
33
+ onSectorHighlight : function(){
34
+ console.log("sector HIGHLIGHTED");
35
+ },
36
+ onSectorFocusBegin : function(){
37
+ console.log("going to FOCUS sector ");
38
+ },
39
+ onSectorFocusEnd : function(){
40
+ console.log("sector FOCUSED");
41
+ },
42
+ onSectorUnfocusBegin : function(){
43
+ console.log("going to UNFOCUS sector");
44
+ },
45
+ onSectorUnfocusEnd : function(sector){
46
+ console.log("sector UNFOCUSED");
47
+ }
24
48
  },
25
49
  text : {
26
50
  newStyle : "bold italic 14px sans-serif"
@@ -123,7 +147,8 @@ function createCheese() {
123
147
  }
124
148
  var sector = {
125
149
  name : $("#label_s" + i).val(),
126
- subsectors : subsectors
150
+ subsectors : subsectors,
151
+ id : i
127
152
  };
128
153
  sectors.push(sector);
129
154
  }
@@ -137,12 +162,19 @@ function createCheese() {
137
162
  if(cheese)
138
163
  deleteCheese();
139
164
  cheese = new socialCheesecake.Cheesecake(cheesecakeData);
165
+ $('.actor').css('display','none');
166
+ cheese.grid.showAll();
140
167
  }
141
168
 
142
169
  function deleteCheese() {
143
170
  $('canvas').detach();
144
171
  cheese.grid.hideAll();
145
172
  cheese = 0;
173
+ var clone = $("#cheesecake").clone();
174
+ clone.attr("id","cheesecake2");
175
+ $("#cheesecake").after(clone);
176
+ $("#cheesecake").remove();
177
+ clone.attr("id","cheesecake");
146
178
  }
147
179
 
148
180
  function randomName() {
@@ -116,6 +116,15 @@ canvas {
116
116
  margin: 1px;
117
117
  opacity: 1;
118
118
  }
119
+ #grid .actor.selected {
120
+ border: 2px solid #8E846B;
121
+ background-color: #ffe481;
122
+ margin: 1px;
123
+ opacity: 1;
124
+ }
125
+ #grid .actor.orphan {
126
+ border: 2px solid #BD1823 !important;
127
+ }
119
128
  #grid .actor img {
120
129
  width: 64px;
121
130
  height: 64px;
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_cheesecake
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Alicia D\xC3\xADez"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-27 00:00:00 Z
18
+ date: 2012-05-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: railties