Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New grid added and new callback at the beginning

  • Loading branch information...
commit 766b8f72e3e7acfbdc80a902c969471e5142e3af 1 parent 3901a85
@adiezbal adiezbal authored
View
15 rails/app/assets/javascripts/socialcheesecake/actor.js
@@ -9,7 +9,8 @@ var socialCheesecake = socialCheesecake || {};
this.id = settings.id;
this.name = settings.name;
this.extraInfo = (settings.extraInfo) ? settings.extraInfo : undefined;
- this.opacity = socialCheesecake.Grid.maxOpacity;
+ this.grid = settings.grid;
+ this.opacity = this.grid.maxOpacity || null;
this._focused = false;
this._selected = false;
this._hidden = true;
@@ -121,7 +122,7 @@ var socialCheesecake = socialCheesecake || {};
socialCheesecake.Actor.prototype.isFocused = function() {
var actor = this;
- var gridIdPrefix = this.getCheesecake().grid.divIdPrefix;
+ var gridIdPrefix = this.getCheesecake().mainGrid.divIdPrefix;
return this._focused;
}
@@ -198,8 +199,8 @@ var socialCheesecake = socialCheesecake || {};
socialCheesecake.Actor.prototype.fade = function(time, modifyDisplay) {
var actor = this;
var time = (time) ? time : 300;
- var minOpacity = socialCheesecake.Grid.minOpacity;
- var maxOpacity = socialCheesecake.Grid.maxOpacity;
+ var minOpacity = this.grid.minOpacity;
+ var maxOpacity = this.grid.maxOpacity;
var deltaOpacity = ((maxOpacity - minOpacity)* 1000.0) / (60.0 * time);
var grow = 0;
@@ -227,7 +228,7 @@ var socialCheesecake = socialCheesecake || {};
}
socialCheesecake.Actor.prototype.fadeOut = function(time, modifyDisplay) {
- var maxOpacity = socialCheesecake.Grid.maxOpacity;
+ var maxOpacity = this.grid.maxOpacity;
this.fading = "out";
this.setDivOpacity(maxOpacity);
this.fade(time, modifyDisplay);
@@ -235,7 +236,7 @@ var socialCheesecake = socialCheesecake || {};
socialCheesecake.Actor.prototype.fadeIn = function(time, modifyDisplay) {
var actor = this;
- var minOpacity = socialCheesecake.Grid.minOpacity;
+ var minOpacity = this.grid.minOpacity;
if(actor.isFiltered())
return;
@@ -251,7 +252,7 @@ var socialCheesecake = socialCheesecake || {};
}
socialCheesecake.Actor.prototype.getDiv = function() {
- var gridIdPrefix = this.getCheesecake().grid.divIdPrefix;
+ var gridIdPrefix = this.getCheesecake().mainGrid.divIdPrefix;
var actor_id = this.id;
var actor_div = document.getElementById(gridIdPrefix + actor_id);
return actor_div;
View
17 rails/app/assets/javascripts/socialcheesecake/cheesecake.js
@@ -12,7 +12,8 @@ var socialCheesecake = socialCheesecake || {};
cheesecake.sectors = [];
cheesecake.highlightedSector = null;
cheesecake.onSectorHighlight = cheesecakeData.onSectorHighlight || null;
- cheesecake.onSubsectorAdded = cheesecakeData.onSubsectorAdded || null;
+ cheesecake.onSubsectorAddedBegin = cheesecakeData.onSubsectorAddedBegin || null;
+ cheesecake.onSubsectorAddedEnd = cheesecakeData.onSubsectorAddedEnd || null;
cheesecake.onSectorFocusBegin = cheesecakeData.onSectorFocusBegin || null;
cheesecake.onSectorFocusEnd = cheesecakeData.onSectorFocusEnd || null;
cheesecake.onSectorUnfocusBegin = cheesecakeData.onSectorUnfocusBegin || null;
@@ -21,13 +22,14 @@ var socialCheesecake = socialCheesecake || {};
cheesecake.auxiliarSectors = [];
cheesecake.stage = new Kinetic.Stage(cheesecakeData.container.id, cheesecakeData.container.width, cheesecakeData.container.height);
cheesecake.stage.add(new Kinetic.Layer({name: "main"}));
- cheesecake.grid = new socialCheesecake.Grid({
+ cheesecake.mainGrid = new socialCheesecake.Grid({
parent : this,
grid_id : cheesecakeData.grid.id,
divIdPrefix : cheesecakeData.grid.divIdPrefix || "actor_",
maxOpacity : cheesecakeData.grid.maxOpacity || 1,
minOpacity : cheesecakeData.grid.minOpacity || 0
});
+ cheesecake.limboGrid = new socialCheesecake.Grid({ parent : this });
cheesecake.matchActorsNumber = cheesecakeData.match;
if(cheesecake.matchActorsNumber == null)
cheesecake.matchActorsNumber = true;
@@ -153,7 +155,7 @@ var socialCheesecake = socialCheesecake || {};
});
};
var dummyResizeCallback = function() {
- var grid = cheesecake.grid;
+ var grid = cheesecake.mainGrid;
grid.hideAll();
grid.show(cheesecake.sectors[sectorIndex].actors);
dummySector.splitUp();
@@ -241,7 +243,7 @@ var socialCheesecake = socialCheesecake || {};
if(cheesecake.onSectorUnfocusEnd) {
cheesecake.onSectorUnfocusEnd(cheesecake);
}
- cheesecake.grid.showAll();
+ cheesecake.mainGrid.showAll();
dummySector.rotateTo({
destination : dummyNewPhi
});
@@ -310,7 +312,7 @@ var socialCheesecake = socialCheesecake || {};
*/
socialCheesecake.Cheesecake.prototype.updateActorMembership = function(actor) {
var changes = this._changes;
- var grid = this.grid;
+ var grid = this.mainGrid;
var changesInActors;
var alreadyChanged = false;
var actorId = actor.id;
@@ -542,7 +544,8 @@ var socialCheesecake = socialCheesecake || {};
}
socialCheesecake.Cheesecake.prototype.filter = function(pattern) {
- var grid = this.grid;
+ console.log("search")
+ var grid = this.mainGrid;
var highlightedSector = this.highlightedSector;
socialCheesecake.SearchEngine.filter(pattern, grid.actors);
if(highlightedSector) {
@@ -554,7 +557,7 @@ var socialCheesecake = socialCheesecake || {};
socialCheesecake.Cheesecake.prototype._setInitialState = function() {
var state = this._initialState;
- var actors = this.grid.actors;
+ var actors = this.mainGrid.actors;
state.actors = [];
for(var actor in actors ) {
View
12 rails/app/assets/javascripts/socialcheesecake/eventCallbackHandlers.js
@@ -6,7 +6,7 @@ var socialCheesecake = socialCheesecake || {};
var cheesecake = sector.getCheesecake();
document.body.style.cursor = "pointer";
- cheesecake.grid.focus(sector.actors);
+ cheesecake.mainGrid.focus(sector.actors);
sector.focus();
if(cheesecake.highlightedSector != null) {
cheesecake.highlightedSector.fan(false, function() {
@@ -21,7 +21,7 @@ var socialCheesecake = socialCheesecake || {};
var cheesecake = sector.getCheesecake();
document.body.style.cursor = "default";
- cheesecake.grid.unfocusAll();
+ cheesecake.mainGrid.unfocusAll();
sector.unfocus();
cheesecake.setHighlightedSector(null);
sector.fan(false);
@@ -29,7 +29,7 @@ var socialCheesecake = socialCheesecake || {};
click : function(sector) {
var cheesecake = sector.getCheesecake();
cheesecake.focusAndBlurCheesecake(sector);
- cheesecake.grid.unfocus(sector.actors);
+ cheesecake.mainGrid.unfocus(sector.actors);
}
},
extraSector : {
@@ -70,18 +70,18 @@ var socialCheesecake = socialCheesecake || {};
mouseover : function(subsector) {
var cheesecake = subsector.getCheesecake();
document.body.style.cursor = "pointer";
- if(subsector.parent.subsectors.length < 1) cheesecake.grid.focus(subsector.actors);
+ if(subsector.parent.subsectors.length < 1) cheesecake.mainGrid.focus(subsector.actors);
cheesecake.setHighlightedSector(subsector);
},
mouseout : function(subsector) {
var cheesecake = subsector.getCheesecake();
document.body.style.cursor = "default";
- if(subsector.parent.subsectors.length < 1) cheesecake.grid.unfocus(subsector.actors);
+ if(subsector.parent.subsectors.length < 1) cheesecake.mainGrid.unfocus(subsector.actors);
cheesecake.setHighlightedSector(subsector.parent);
},
click : function(subsector) {
var cheesecake = subsector.getCheesecake();
- var selectedActors = cheesecake.grid.getSelectedActors();
+ var selectedActors = cheesecake.mainGrid.getSelectedActors();
if(selectedActors.length > 0)
subsector.changeMembership(selectedActors);
},
View
5 rails/app/assets/javascripts/socialcheesecake/grid.js
@@ -10,8 +10,8 @@ var socialCheesecake = socialCheesecake || {};
this.parent = settings.parent;
this.id = settings.grid_id;
this.divIdPrefix = settings.divIdPrefix;
- socialCheesecake.Grid.maxOpacity = settings.maxOpacity;
- socialCheesecake.Grid.minOpacity = settings.minOpacity;
+ this.maxOpacity = settings.maxOpacity;
+ this.minOpacity = settings.minOpacity;
}
socialCheesecake.Grid.prototype.addActor = function(actor_info, subsector) {
@@ -37,6 +37,7 @@ var socialCheesecake = socialCheesecake || {};
// If the actor was not in the array, create it and add it to the array
if(!actorAlreadyDeclared) {
actor_info.parent = subsector;
+ actor_info.grid = this;
actor = new socialCheesecake.Actor(actor_info);
actors.push(actor);
}
View
6 rails/app/assets/javascripts/socialcheesecake/sector.js
@@ -220,6 +220,8 @@ var socialCheesecake = socialCheesecake || {};
console.log("Reached subsectors limit. No new subsectors will be added");
return;
}
+ //Initial callback
+ if(cheesecake.onSubsectorAddedBegin != null) cheesecake.onSubsectorAddedBegin(sector.subsectors[subsectorIndex]);
//Create dummies for the animation
for(var i in allSubsectors){
var settings = {
@@ -339,7 +341,7 @@ var socialCheesecake = socialCheesecake || {};
cheesecake.addToLayer(normalSubsectors);
if(extraSubsectors) cheesecake.addToLayer(extraSubsectors);
cheesecake.drawLayer();
- if(cheesecake.onSubsectorAdded != null) cheesecake.onSubsectorAdded(sector.subsectors[subsectorIndex]);
+ if(cheesecake.onSubsectorAddedEnd != null) cheesecake.onSubsectorAddedEnd(sector.subsectors[subsectorIndex]);
};
for (var i = 0; i< dummyNormal.length; i++){
dummyNormal[i].resizeWidth({
@@ -791,7 +793,7 @@ var socialCheesecake = socialCheesecake || {};
if (this == subsector){
actor = this.parent.addActor(actorInfo, subsector);
}else{
- actor = this.parent.grid.addActor(actorInfo, subsector);
+ actor = this.parent.mainGrid.addActor(actorInfo, subsector);
}
actors.push(actor);
}
View
2  rails/app/assets/javascripts/socialcheesecake/subsector.js
@@ -23,7 +23,7 @@ var socialCheesecake = socialCheesecake || {};
if(settings.mouseover != null) this.mouseover = settings.mouseover;
if(settings.mouseout != null) this.mouseout = settings.mouseout;
- var grid = this.getCheesecake().grid;
+ var grid = this.getCheesecake().mainGrid;
if (settings.actors){
for(var actor in settings.actors){
var actor_info = {
View
5 rails/test/dummy/app/assets/javascripts/main.js
@@ -22,7 +22,10 @@ var cheesecakeData = {
onChange : function() {
console.log("Cambio detectado");
},
- onSubsectorAdded : function(subsector){
+ onSubsectorAddedBegin : function(subsector){
+ console.log("New subsector "+ subsector.getIndex() +" BEGIN IN "+subsector.parent.getIndex());
+ },
+ onSubsectorAddedEnd : function(subsector){
console.log("New subsector "+ subsector.getIndex() +" added in sector "+subsector.parent.getIndex());
console.log(subsector.getCheesecake());
},
Please sign in to comment.
Something went wrong with that request. Please try again.