Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow board resizing

  • Loading branch information...
commit 431f0e76d6d1a14b17773b1d0ca3abac82739669 1 parent efb28ac
Ali Asaria authored
Showing with 68 additions and 1 deletion.
  1. +32 −1 client/script.js
  2. +11 −0 lib/data/redis.js
  3. +25 −0 server.js
View
33 client/script.js
@@ -119,6 +119,10 @@ function getMessage( m )
addSticker( message.data.cardId, message.data.stickerId );
break;
+ case 'setBoardSize':
+ resizeBoard( message.data );
+ break;
+
default:
//unknown message
alert('unknown action: ' + JSON.stringify(message));
@@ -533,6 +537,23 @@ function updateName ( sid, 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
11 lib/data/redis.js
@@ -146,6 +146,17 @@ db.prototype = {
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;
View
25 server.js
@@ -287,6 +287,19 @@ function scrub( text ) {
broadcastToRoom( client, { action: 'addSticker', data: { cardId: cardId, stickerId: stickerId }});
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:
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 = [];
Please sign in to comment.
Something went wrong with that request. Please try again.