allow board resizing

This commit is contained in:
Ali Asaria 2011-05-27 01:08:25 -04:00
parent efb28ac4f1
commit 431f0e76d6
3 changed files with 68 additions and 1 deletions

View file

@ -119,6 +119,10 @@ function getMessage( m )
addSticker( message.data.cardId, message.data.stickerId ); addSticker( message.data.cardId, message.data.stickerId );
break; break;
case 'setBoardSize':
resizeBoard( message.data );
break;
default: default:
//unknown message //unknown message
alert('unknown action: ' + JSON.stringify(message)); alert('unknown action: ' + JSON.stringify(message));
@ -533,6 +537,23 @@ function updateName ( sid, name )
$('#names-ul').children(id).text( name ); $('#names-ul').children(id).text( name );
} }
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
function boardResizeHappened(event, ui)
{
var newsize = ui.size
sendAction( 'setBoardSize', newsize);
}
function resizeBoard (size) {
$( ".board-outline" ).animate( {
height: size.height,
width: size.width
} );
}
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
@ -661,7 +682,17 @@ $( ".sticker" ).draggable({
}); });
$( ".board-outline" ).resizable( { ghost: false, minWidth: 700, minHeight: 400 , maxWidth: 3200, maxHeight: 1800} ); $( ".board-outline" ).resizable( {
ghost: false,
minWidth: 700,
minHeight: 400 ,
maxWidth: 3200,
maxHeight: 1800,
stop: function(event, ui) {
boardResizeHappened(event, ui);
}
} );
}); });

View file

@ -146,6 +146,17 @@ db.prototype = {
redisClient.hset(REDIS_PREFIX + '-room:' + room + '-cards', cardId, JSON.stringify(card)); redisClient.hset(REDIS_PREFIX + '-room:' + room + '-cards', cardId, JSON.stringify(card));
} }
}); });
},
setBoardSize: function(room, size) {
redisClient.set(REDIS_PREFIX + '-room:' + room + '-size', JSON.stringify(size));
},
getBoardSize: function(room, callback) {
redisClient.get(REDIS_PREFIX + '-room:' + room + '-size', function (err, res) {
callback(JSON.parse(res));
});
} }
}; };
exports.db = db; exports.db = db;

View file

@ -287,6 +287,19 @@ function scrub( text ) {
broadcastToRoom( client, { action: 'addSticker', data: { cardId: cardId, stickerId: stickerId }}); broadcastToRoom( client, { action: 'addSticker', data: { cardId: cardId, stickerId: stickerId }});
break; break;
case 'setBoardSize':
var size = {};
size.width = scrub(message.data.width);;
size.height = scrub(message.data.height);
getRoom(client, function(room) {
db.setBoardSize( room, size );
});
broadcastToRoom( client, { action: 'setBoardSize', data: size } );
break;
default: default:
console.log('unknown action'); console.log('unknown action');
@ -346,6 +359,18 @@ function initClient ( client )
} }
); );
}); });
db.getBoardSize( room, function(size) {
if (size != null) {
client.send(
{
action: 'setBoardSize',
data: size
}
);
}
});
roommates_clients = rooms.room_clients(room); roommates_clients = rooms.room_clients(room);
roommates = []; roommates = [];