make new cards start at more sane starting point
This commit is contained in:
parent
1c83ca056c
commit
9844cd3d84
1 changed files with 198 additions and 202 deletions
400
client/script.js
400
client/script.js
|
@ -12,31 +12,31 @@ var socket = io.connect();
|
||||||
function sendAction(a, d)
|
function sendAction(a, d)
|
||||||
{
|
{
|
||||||
//console.log('--> ' + a);
|
//console.log('--> ' + a);
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
action: a,
|
action: a,
|
||||||
data: d
|
data: d
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.json.send ( message );
|
socket.json.send ( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('connect', function(){
|
socket.on('connect', function(){
|
||||||
//console.log('successful socket.io connect');
|
//console.log('successful socket.io connect');
|
||||||
|
|
||||||
//let the path be the room name
|
//let the path be the room name
|
||||||
var path = location.pathname;
|
var path = location.pathname;
|
||||||
|
|
||||||
//imediately join the room which will trigger the initializations
|
//imediately join the room which will trigger the initializations
|
||||||
sendAction('joinRoom', path);
|
sendAction('joinRoom', path);
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('disconnect', function(){
|
socket.on('disconnect', function(){
|
||||||
blockUI("Server disconnected. Refresh page to try and reconnect...");
|
blockUI("Server disconnected. Refresh page to try and reconnect...");
|
||||||
//$('.blockOverlay').click($.unblockUI);
|
//$('.blockOverlay').click($.unblockUI);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('message', function(data){
|
socket.on('message', function(data){
|
||||||
getMessage(data);
|
getMessage(data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -48,21 +48,21 @@ function unblockUI()
|
||||||
function blockUI(message)
|
function blockUI(message)
|
||||||
{
|
{
|
||||||
message = message || 'Waiting...';
|
message = message || 'Waiting...';
|
||||||
|
|
||||||
$.blockUI({
|
$.blockUI({
|
||||||
message: message,
|
message: message,
|
||||||
|
|
||||||
css: {
|
css: {
|
||||||
border: 'none',
|
border: 'none',
|
||||||
padding: '15px',
|
padding: '15px',
|
||||||
backgroundColor: '#000',
|
backgroundColor: '#000',
|
||||||
'-webkit-border-radius': '10px',
|
'-webkit-border-radius': '10px',
|
||||||
'-moz-border-radius': '10px',
|
'-moz-border-radius': '10px',
|
||||||
opacity: .5,
|
opacity: .5,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
fontSize: '20px'
|
fontSize: '20px'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//respond to an action event
|
//respond to an action event
|
||||||
|
@ -71,9 +71,9 @@ function getMessage( m )
|
||||||
var message = m; //JSON.parse(m);
|
var message = m; //JSON.parse(m);
|
||||||
var action = message.action;
|
var action = message.action;
|
||||||
var data = message.data;
|
var data = message.data;
|
||||||
|
|
||||||
//console.log('<-- ' + action);
|
//console.log('<-- ' + action);
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case 'roomAccept':
|
case 'roomAccept':
|
||||||
|
@ -81,76 +81,76 @@ function getMessage( m )
|
||||||
//(this is a bit of unnessary back and forth but that's okay for now)
|
//(this is a bit of unnessary back and forth but that's okay for now)
|
||||||
sendAction('initializeMe', null);
|
sendAction('initializeMe', null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'roomDeny':
|
case 'roomDeny':
|
||||||
//this doesn't happen yet
|
//this doesn't happen yet
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'moveCard':
|
case 'moveCard':
|
||||||
moveCard($("#" + data.id), data.position);
|
moveCard($("#" + data.id), data.position);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'initCards':
|
case 'initCards':
|
||||||
initCards(data);
|
initCards(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'createCard':
|
case 'createCard':
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
drawNewCard(data.id, data.text, data.x, data.y, data.rot, data.colour, null);
|
drawNewCard(data.id, data.text, data.x, data.y, data.rot, data.colour, null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'deleteCard':
|
case 'deleteCard':
|
||||||
$("#" + data.id).fadeOut(500,
|
$("#" + data.id).fadeOut(500,
|
||||||
function() {$(this).remove();}
|
function() {$(this).remove();}
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'editCard':
|
case 'editCard':
|
||||||
$("#" + data.id).children('.content:first').text(data.value);
|
$("#" + data.id).children('.content:first').text(data.value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'initColumns':
|
case 'initColumns':
|
||||||
initColumns(data);
|
initColumns(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'updateColumns':
|
case 'updateColumns':
|
||||||
initColumns(data);
|
initColumns(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'changeTheme':
|
case 'changeTheme':
|
||||||
changeThemeTo(data);
|
changeThemeTo(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'join-announce':
|
case 'join-announce':
|
||||||
displayUserJoined(data.sid, data.user_name);
|
displayUserJoined(data.sid, data.user_name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'leave-announce':
|
case 'leave-announce':
|
||||||
displayUserLeft(data.sid);
|
displayUserLeft(data.sid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'initialUsers':
|
case 'initialUsers':
|
||||||
displayInitialUsers(data);
|
displayInitialUsers(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'nameChangeAnnounce':
|
case 'nameChangeAnnounce':
|
||||||
updateName( message.data.sid, message.data.user_name );
|
updateName( message.data.sid, message.data.user_name );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'addSticker':
|
case 'addSticker':
|
||||||
addSticker( message.data.cardId, message.data.stickerId );
|
addSticker( message.data.cardId, message.data.stickerId );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'setBoardSize':
|
case 'setBoardSize':
|
||||||
resizeBoard( message.data );
|
resizeBoard( message.data );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//unknown message
|
//unknown message
|
||||||
alert('unknown action: ' + JSON.stringify(message));
|
alert('unknown action: ' + JSON.stringify(message));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,16 +161,19 @@ $(document).bind('keyup', function(event) {
|
||||||
function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
{
|
{
|
||||||
//cards[id] = {id: id, text: text, x: x, y: y, rot: rot, colour: colour};
|
//cards[id] = {id: id, text: text, x: x, y: y, rot: rot, colour: colour};
|
||||||
|
|
||||||
var h = '<div id="' + id + '" class="card ' + colour + ' draggable" style="-webkit-transform:rotate(' + rot + 'deg);">\
|
var h = '<div id="' + id + '" class="card ' + colour +
|
||||||
|
' draggable" style="-webkit-transform:rotate(' + rot + 'deg);\
|
||||||
|
">\
|
||||||
<img src="/images/icons/token/Xion.png" class="card-icon delete-card-icon" />\
|
<img src="/images/icons/token/Xion.png" class="card-icon delete-card-icon" />\
|
||||||
<img class="card-image" src="/images/' + colour + '-card.png">\
|
<img class="card-image" src="/images/' + colour + '-card.png">\
|
||||||
<div id="content:' + id + '" class="content stickertarget droppable">' + text + '</div>\
|
<div id="content:' + id + '" class="content stickertarget droppable">' +
|
||||||
|
text + '</div>\
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
var card = $(h);
|
var card = $(h);
|
||||||
card.appendTo('#board');
|
card.appendTo('#board');
|
||||||
|
|
||||||
//@TODO
|
//@TODO
|
||||||
//Draggable has a bug which prevents blur event
|
//Draggable has a bug which prevents blur event
|
||||||
//http://bugs.jqueryui.com/ticket/4261
|
//http://bugs.jqueryui.com/ticket/4261
|
||||||
|
@ -178,12 +181,12 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
//we click on a card
|
//we click on a card
|
||||||
//The following doesn't work so we will do the bug
|
//The following doesn't work so we will do the bug
|
||||||
//fix recommended in the above bug report
|
//fix recommended in the above bug report
|
||||||
// card.click( function() {
|
// card.click( function() {
|
||||||
// $(this).focus();
|
// $(this).focus();
|
||||||
// } );
|
// } );
|
||||||
|
|
||||||
card.draggable(
|
card.draggable(
|
||||||
{
|
{
|
||||||
snap: false,
|
snap: false,
|
||||||
snapTolerance: 5,
|
snapTolerance: 5,
|
||||||
containment: [0,0,2000,2000],
|
containment: [0,0,2000,2000],
|
||||||
|
@ -197,7 +200,7 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
//After a drag:
|
//After a drag:
|
||||||
|
@ -212,41 +215,45 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
position: ui.position,
|
position: ui.position,
|
||||||
oldposition: ui.originalPosition,
|
oldposition: ui.originalPosition,
|
||||||
};
|
};
|
||||||
|
|
||||||
sendAction('moveCard', data);
|
sendAction('moveCard', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
card.children(".droppable").droppable(
|
card.children(".droppable").droppable(
|
||||||
{
|
{
|
||||||
accept: '.sticker',
|
accept: '.sticker',
|
||||||
drop: function( event, ui ) {
|
drop: function( event, ui ) {
|
||||||
var stickerId = ui.draggable.attr("id");
|
var stickerId = ui.draggable.attr("id");
|
||||||
var cardId = $(this).parent().attr('id');
|
var cardId = $(this).parent().attr('id');
|
||||||
|
|
||||||
addSticker( cardId, stickerId );
|
addSticker( cardId, stickerId );
|
||||||
|
|
||||||
var data = { cardId: cardId, stickerId: stickerId };
|
var data = { cardId: cardId, stickerId: stickerId };
|
||||||
sendAction('addSticker', data);
|
sendAction('addSticker', data);
|
||||||
|
|
||||||
//remove hover state to everything on the board to prevent
|
//remove hover state to everything on the board to prevent
|
||||||
//a jquery bug where it gets left around
|
//a jquery bug where it gets left around
|
||||||
$('.card-hover-draggable').removeClass('card-hover-draggable');
|
$('.card-hover-draggable').removeClass('card-hover-draggable');
|
||||||
},
|
},
|
||||||
hoverClass: 'card-hover-draggable'
|
hoverClass: 'card-hover-draggable'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var speed = Math.floor(Math.random() * 1000);
|
var speed = Math.floor(Math.random() * 1000);
|
||||||
if (typeof(animationspeed) != 'undefined') speed = animationspeed;
|
if (typeof(animationspeed) != 'undefined') speed = animationspeed;
|
||||||
|
|
||||||
|
var startPosition = $("#create-card").position();
|
||||||
|
|
||||||
|
card.css( 'top' , startPosition.top - card.height()*.5 );
|
||||||
|
card.css('left', startPosition.left - card.width() *.5 );
|
||||||
|
|
||||||
card.animate({
|
card.animate({
|
||||||
left: x + "px",
|
left: x + "px",
|
||||||
top: y + "px"
|
top: y + "px"
|
||||||
}, speed);
|
}, speed);
|
||||||
|
|
||||||
card.hover(
|
card.hover(
|
||||||
function(){
|
function(){
|
||||||
$(this).addClass('hover');
|
$(this).addClass('hover');
|
||||||
$(this).children('.card-icon').fadeIn(10);
|
$(this).children('.card-icon').fadeIn(10);
|
||||||
},
|
},
|
||||||
|
@ -255,7 +262,7 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
$(this).children('.card-icon').fadeOut(150);
|
$(this).children('.card-icon').fadeOut(150);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
card.children('.card-icon').hover(
|
card.children('.card-icon').hover(
|
||||||
function(){
|
function(){
|
||||||
$(this).addClass('card-icon-hover');
|
$(this).addClass('card-icon-hover');
|
||||||
|
@ -264,7 +271,7 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
$(this).removeClass('card-icon-hover');
|
$(this).removeClass('card-icon-hover');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
card.children('.delete-card-icon').click(
|
card.children('.delete-card-icon').click(
|
||||||
function(){
|
function(){
|
||||||
$("#" + id).remove();
|
$("#" + id).remove();
|
||||||
|
@ -273,12 +280,12 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
card.children('.content').editable(function(value, settings) {
|
card.children('.content').editable(function(value, settings) {
|
||||||
onCardChange( id, value );
|
onCardChange( id, value );
|
||||||
return(value);
|
return(value);
|
||||||
}, {
|
}, {
|
||||||
type : 'textarea',
|
type : 'textarea',
|
||||||
submit : 'OK',
|
submit : 'OK',
|
||||||
style : 'inherit',
|
style : 'inherit',
|
||||||
cssclass : 'card-edit-form',
|
cssclass : 'card-edit-form',
|
||||||
type : 'textarea',
|
type : 'textarea',
|
||||||
|
@ -286,7 +293,7 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
onblur: 'submit',
|
onblur: 'submit',
|
||||||
event: 'dblclick', //event: 'mouseover'
|
event: 'dblclick', //event: 'mouseover'
|
||||||
});
|
});
|
||||||
|
|
||||||
//add applicable sticker
|
//add applicable sticker
|
||||||
if (sticker != null)
|
if (sticker != null)
|
||||||
$("#" + id).children('.content').addClass( sticker );
|
$("#" + id).children('.content').addClass( sticker );
|
||||||
|
@ -294,22 +301,22 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
|
||||||
|
|
||||||
|
|
||||||
function onCardChange( id, text )
|
function onCardChange( id, text )
|
||||||
{
|
{
|
||||||
sendAction('editCard', { id: id, value: text });
|
sendAction('editCard', { id: id, value: text });
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveCard(card, position) {
|
function moveCard(card, position) {
|
||||||
card.animate({
|
card.animate({
|
||||||
left: position.left+"px",
|
left: position.left+"px",
|
||||||
top: position.top+"px"
|
top: position.top+"px"
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSticker ( cardId , stickerId )
|
function addSticker ( cardId , stickerId )
|
||||||
{
|
{
|
||||||
|
|
||||||
cardContent = $('#' + cardId).children('.content');
|
cardContent = $('#' + cardId).children('.content');
|
||||||
|
|
||||||
cardContent.removeClass("sticker-red");
|
cardContent.removeClass("sticker-red");
|
||||||
cardContent.removeClass("sticker-blue");
|
cardContent.removeClass("sticker-blue");
|
||||||
cardContent.removeClass("sticker-green");
|
cardContent.removeClass("sticker-green");
|
||||||
|
@ -333,9 +340,9 @@ function addSticker ( cardId , stickerId )
|
||||||
function createCard( id, text, x, y, rot, colour )
|
function createCard( id, text, x, y, rot, colour )
|
||||||
{
|
{
|
||||||
drawNewCard(id, text, x, y, rot, colour, null);
|
drawNewCard(id, text, x, y, rot, colour, null);
|
||||||
|
|
||||||
var action = "createCard";
|
var action = "createCard";
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
id: id,
|
id: id,
|
||||||
text: text,
|
text: text,
|
||||||
|
@ -344,17 +351,17 @@ function createCard( id, text, x, y, rot, colour )
|
||||||
rot: rot,
|
rot: rot,
|
||||||
colour: colour
|
colour: colour
|
||||||
};
|
};
|
||||||
|
|
||||||
sendAction(action, data);
|
sendAction(action, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomCardColour()
|
function randomCardColour()
|
||||||
{
|
{
|
||||||
var colours = ['yellow', 'green', 'blue', 'white'];
|
var colours = ['yellow', 'green', 'blue', 'white'];
|
||||||
|
|
||||||
var i = Math.floor(Math.random() * colours.length);
|
var i = Math.floor(Math.random() * colours.length);
|
||||||
|
|
||||||
return colours[i];
|
return colours[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,13 +370,13 @@ function initCards( cardArray )
|
||||||
{
|
{
|
||||||
//first delete any cards that exist
|
//first delete any cards that exist
|
||||||
$('.card').remove();
|
$('.card').remove();
|
||||||
|
|
||||||
cards = cardArray;
|
cards = cardArray;
|
||||||
|
|
||||||
for (i in cardArray)
|
for (i in cardArray)
|
||||||
{
|
{
|
||||||
card = cardArray[i];
|
card = cardArray[i];
|
||||||
|
|
||||||
drawNewCard(
|
drawNewCard(
|
||||||
card.id,
|
card.id,
|
||||||
card.text,
|
card.text,
|
||||||
|
@ -391,19 +398,19 @@ function initCards( cardArray )
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
|
|
||||||
function drawNewColumn (columnName)
|
function drawNewColumn (columnName)
|
||||||
{
|
{
|
||||||
var cls = "col";
|
var cls = "col";
|
||||||
if (totalcolumns == 0)
|
if (totalcolumns == 0)
|
||||||
{
|
{
|
||||||
cls = "col first";
|
cls = "col first";
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#icon-col').before('<td class="' + cls + '" width="10%" style="display:none"><h2 id="col-' + (totalcolumns+1) + '" class="editable">' + columnName + '</h2></td>');
|
$('#icon-col').before('<td class="' + cls + '" width="10%" style="display:none"><h2 id="col-' + (totalcolumns+1) + '" class="editable">' + columnName + '</h2></td>');
|
||||||
|
|
||||||
$('.editable').editable(function(value, settings) {
|
$('.editable').editable(function(value, settings) {
|
||||||
onColumnChange( this.id, value );
|
onColumnChange( this.id, value );
|
||||||
return(value);
|
return(value);
|
||||||
}, {
|
}, {
|
||||||
style : 'inherit',
|
style : 'inherit',
|
||||||
cssclass : 'card-edit-form',
|
cssclass : 'card-edit-form',
|
||||||
type : 'textarea',
|
type : 'textarea',
|
||||||
|
@ -414,9 +421,9 @@ function drawNewColumn (columnName)
|
||||||
xindicator: '<img src="/images/ajax-loader.gif">',
|
xindicator: '<img src="/images/ajax-loader.gif">',
|
||||||
event: 'dblclick', //event: 'mouseover'
|
event: 'dblclick', //event: 'mouseover'
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.col:last').fadeIn(1500);
|
$('.col:last').fadeIn(1500);
|
||||||
|
|
||||||
totalcolumns ++;
|
totalcolumns ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,63 +445,63 @@ function onColumnChange( id, text )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
names.push( $(this).text() );
|
names.push( $(this).text() );
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
updateColumns(names);
|
updateColumns(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayRemoveColumn()
|
function displayRemoveColumn()
|
||||||
{
|
{
|
||||||
if (totalcolumns <= 0) return false;
|
if (totalcolumns <= 0) return false;
|
||||||
|
|
||||||
$('.col:last').fadeOut( 150,
|
$('.col:last').fadeOut( 150,
|
||||||
function() {
|
function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
totalcolumns --;
|
totalcolumns --;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createColumn( name )
|
function createColumn( name )
|
||||||
{
|
{
|
||||||
if (totalcolumns >= 8) return false;
|
if (totalcolumns >= 8) return false;
|
||||||
|
|
||||||
drawNewColumn( name );
|
drawNewColumn( name );
|
||||||
columns.push(name);
|
columns.push(name);
|
||||||
|
|
||||||
var action = "updateColumns";
|
var action = "updateColumns";
|
||||||
|
|
||||||
var data = columns;
|
var data = columns;
|
||||||
|
|
||||||
sendAction(action, data);
|
sendAction(action, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteColumn()
|
function deleteColumn()
|
||||||
{
|
{
|
||||||
if (totalcolumns <= 0) return false;
|
if (totalcolumns <= 0) return false;
|
||||||
|
|
||||||
displayRemoveColumn();
|
displayRemoveColumn();
|
||||||
columns.pop();
|
columns.pop();
|
||||||
|
|
||||||
var action = "updateColumns";
|
var action = "updateColumns";
|
||||||
|
|
||||||
var data = columns;
|
var data = columns;
|
||||||
|
|
||||||
sendAction(action, data);
|
sendAction(action, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateColumns( c )
|
function updateColumns( c )
|
||||||
{
|
{
|
||||||
columns = c;
|
columns = c;
|
||||||
|
|
||||||
var action = "updateColumns";
|
var action = "updateColumns";
|
||||||
|
|
||||||
var data = columns;
|
var data = columns;
|
||||||
|
|
||||||
sendAction(action, data);
|
sendAction(action, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,9 +515,9 @@ function initColumns( columnArray )
|
||||||
{
|
{
|
||||||
totalcolumns = 0;
|
totalcolumns = 0;
|
||||||
columns = columnArray;
|
columns = columnArray;
|
||||||
|
|
||||||
$('.col').remove();
|
$('.col').remove();
|
||||||
|
|
||||||
for (i in columnArray)
|
for (i in columnArray)
|
||||||
{
|
{
|
||||||
column = columnArray[i];
|
column = columnArray[i];
|
||||||
|
@ -552,9 +559,9 @@ for (i=0;i<ARRcookies.length;i++)
|
||||||
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
|
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
|
||||||
x=x.replace(/^\s+|\s+$/g,"");
|
x=x.replace(/^\s+|\s+$/g,"");
|
||||||
if (x==c_name)
|
if (x==c_name)
|
||||||
{
|
{
|
||||||
return unescape(y);
|
return unescape(y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +569,7 @@ for (i=0;i<ARRcookies.length;i++)
|
||||||
function setName( name )
|
function setName( name )
|
||||||
{
|
{
|
||||||
sendAction( 'setUserName', name );
|
sendAction( 'setUserName', name );
|
||||||
|
|
||||||
setCookie('scrumscrum-username', name, 365);
|
setCookie('scrumscrum-username', name, 365);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,8 +589,8 @@ function displayUserJoined ( sid, user_name )
|
||||||
name = user_name;
|
name = user_name;
|
||||||
else
|
else
|
||||||
name = sid.substring(0,5);
|
name = sid.substring(0,5);
|
||||||
|
|
||||||
|
|
||||||
$('#names-ul').append('<li id="user-' + sid + '">' + name + '</li>')
|
$('#names-ul').append('<li id="user-' + sid + '">' + name + '</li>')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,9 +601,9 @@ function displayUserLeft ( sid )
|
||||||
name = user_name;
|
name = user_name;
|
||||||
else
|
else
|
||||||
name = sid;
|
name = sid;
|
||||||
|
|
||||||
var id = '#user-' + sid.toString();
|
var id = '#user-' + sid.toString();
|
||||||
|
|
||||||
$('#names-ul').children(id).fadeOut( 1000 , function() {
|
$('#names-ul').children(id).fadeOut( 1000 , function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
|
@ -606,7 +613,7 @@ function displayUserLeft ( sid )
|
||||||
function updateName ( sid, name )
|
function updateName ( sid, name )
|
||||||
{
|
{
|
||||||
var id = '#user-' + sid.toString();
|
var id = '#user-' + sid.toString();
|
||||||
|
|
||||||
$('#names-ul').children(id).text( name );
|
$('#names-ul').children(id).text( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,13 +622,13 @@ function updateName ( sid, name )
|
||||||
|
|
||||||
function boardResizeHappened(event, ui)
|
function boardResizeHappened(event, ui)
|
||||||
{
|
{
|
||||||
var newsize = ui.size
|
var newsize = ui.size
|
||||||
|
|
||||||
sendAction( 'setBoardSize', newsize);
|
sendAction( 'setBoardSize', newsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resizeBoard (size) {
|
function resizeBoard (size) {
|
||||||
$( ".board-outline" ).animate( {
|
$( ".board-outline" ).animate( {
|
||||||
height: size.height,
|
height: size.height,
|
||||||
width: size.width
|
width: size.width
|
||||||
} );
|
} );
|
||||||
|
@ -630,21 +637,21 @@ function resizeBoard (size) {
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function calcCardOffset() {
|
function calcCardOffset() {
|
||||||
var offsets = {};
|
var offsets = {};
|
||||||
$(".card").each(function() {
|
$(".card").each(function() {
|
||||||
var card = $(this);
|
var card = $(this);
|
||||||
$(".col").each(function(i) {
|
$(".col").each(function(i) {
|
||||||
var col = $(this);
|
var col = $(this);
|
||||||
if(col.offset().left + col.outerWidth() > card.offset().left + card.outerWidth() || i === $(".col").size() - 1) {
|
if(col.offset().left + col.outerWidth() > card.offset().left + card.outerWidth() || i === $(".col").size() - 1) {
|
||||||
offsets[card.attr('id')] = {
|
offsets[card.attr('id')] = {
|
||||||
col: col,
|
col: col,
|
||||||
x: ( (card.offset().left - col.offset().left) / col.outerWidth() )
|
x: ( (card.offset().left - col.offset().left) / col.outerWidth() )
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return offsets;
|
return offsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -652,7 +659,7 @@ function calcCardOffset() {
|
||||||
//doSync is false if you don't want to synchronize
|
//doSync is false if you don't want to synchronize
|
||||||
//with all the other users who are in this room
|
//with all the other users who are in this room
|
||||||
function adjustCard(offsets, doSync) {
|
function adjustCard(offsets, doSync) {
|
||||||
$(".card").each(function() {
|
$(".card").each(function() {
|
||||||
var card = $(this);
|
var card = $(this);
|
||||||
var offset = offsets[this.id];
|
var offset = offsets[this.id];
|
||||||
if(offset) {
|
if(offset) {
|
||||||
|
@ -690,11 +697,11 @@ function adjustCard(offsets, doSync) {
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
if (boardInitialized == false)
|
if (boardInitialized == false)
|
||||||
blockUI('<img src="/images/ajax-loader.gif" width=43 height=11/>');
|
blockUI('<img src="/images/ajax-loader.gif" width=43 height=11/>');
|
||||||
|
|
||||||
//setTimeout($.unblockUI, 2000);
|
//setTimeout($.unblockUI, 2000);
|
||||||
|
|
||||||
|
|
||||||
$( "#create-card" )
|
$( "#create-card" )
|
||||||
|
@ -702,17 +709,17 @@ $(function() {
|
||||||
var rotation = Math.random() * 10 - 5; //add a bit of random rotation (+/- 10deg)
|
var rotation = Math.random() * 10 - 5; //add a bit of random rotation (+/- 10deg)
|
||||||
uniqueID = Math.round(Math.random()*99999999); //is this big enough to assure uniqueness?
|
uniqueID = Math.round(Math.random()*99999999); //is this big enough to assure uniqueness?
|
||||||
//alert(uniqueID);
|
//alert(uniqueID);
|
||||||
createCard(
|
createCard(
|
||||||
'card' + uniqueID,
|
'card' + uniqueID,
|
||||||
'',
|
'',
|
||||||
58, $('div.board-outline').height(),// hack - not a great way to get the new card coordinates, but most consistant ATM
|
58, $('div.board-outline').height(),// hack - not a great way to get the new card coordinates, but most consistant ATM
|
||||||
rotation,
|
rotation,
|
||||||
randomCardColour());
|
randomCardColour());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Style changer
|
// Style changer
|
||||||
$("#smallify").click(function(){
|
$("#smallify").click(function(){
|
||||||
if (currentTheme == "bigcards")
|
if (currentTheme == "bigcards")
|
||||||
|
@ -727,16 +734,16 @@ $(function() {
|
||||||
{
|
{
|
||||||
currentTheme = "bigcards";
|
currentTheme = "bigcards";
|
||||||
$("link[title=cardsize]").attr("href", "css/bigcards.css");
|
$("link[title=cardsize]").attr("href", "css/bigcards.css");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
sendAction('changeTheme', currentTheme);
|
sendAction('changeTheme', currentTheme);
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#icon-col').hover(
|
$('#icon-col').hover(
|
||||||
function() {
|
function() {
|
||||||
$('.col-icon').fadeIn(10);
|
$('.col-icon').fadeIn(10);
|
||||||
|
@ -745,58 +752,58 @@ $(function() {
|
||||||
$('.col-icon').fadeOut(150);
|
$('.col-icon').fadeOut(150);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$('#add-col').click(
|
$('#add-col').click(
|
||||||
function(){
|
function(){
|
||||||
createColumn('New');
|
createColumn('New');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$('#delete-col').click(
|
$('#delete-col').click(
|
||||||
function(){
|
function(){
|
||||||
deleteColumn();
|
deleteColumn();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// $('#cog-button').click( function(){
|
// $('#cog-button').click( function(){
|
||||||
// $('#config-dropdown').fadeToggle();
|
// $('#config-dropdown').fadeToggle();
|
||||||
// } );
|
// } );
|
||||||
|
|
||||||
// $('#config-dropdown').hover(
|
// $('#config-dropdown').hover(
|
||||||
// function(){ /*$('#config-dropdown').fadeIn()*/ },
|
// function(){ /*$('#config-dropdown').fadeIn()*/ },
|
||||||
// function(){ $('#config-dropdown').fadeOut() }
|
// function(){ $('#config-dropdown').fadeOut() }
|
||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
|
|
||||||
var user_name = getCookie('scrumscrum-username');
|
var user_name = getCookie('scrumscrum-username');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("#yourname-input").focus(function()
|
$("#yourname-input").focus(function()
|
||||||
{
|
{
|
||||||
if ($(this).val() == 'unknown')
|
if ($(this).val() == 'unknown')
|
||||||
{
|
{
|
||||||
$(this).val("");
|
$(this).val("");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).addClass('focused');
|
$(this).addClass('focused');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#yourname-input").blur(function()
|
$("#yourname-input").blur(function()
|
||||||
{
|
{
|
||||||
if ($(this).val() == "")
|
if ($(this).val() == "")
|
||||||
{
|
{
|
||||||
$(this).val('unknown');
|
$(this).val('unknown');
|
||||||
}
|
}
|
||||||
$(this).removeClass('focused');
|
$(this).removeClass('focused');
|
||||||
|
|
||||||
setName($(this).val());
|
setName($(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#yourname-input").val(user_name);
|
$("#yourname-input").val(user_name);
|
||||||
$("#yourname-input").blur();
|
$("#yourname-input").blur();
|
||||||
|
|
||||||
|
@ -804,22 +811,22 @@ $(function() {
|
||||||
|
|
||||||
$("#yourname-input").keypress(function(e)
|
$("#yourname-input").keypress(function(e)
|
||||||
{
|
{
|
||||||
code= (e.keyCode ? e.keyCode : e.which);
|
code= (e.keyCode ? e.keyCode : e.which);
|
||||||
if (code == 10 || code == 13)
|
if (code == 10 || code == 13)
|
||||||
{
|
{
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$( ".sticker" ).draggable({
|
$( ".sticker" ).draggable({
|
||||||
revert: true,
|
revert: true,
|
||||||
zIndex: 1000
|
zIndex: 1000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$( ".board-outline" ).resizable( {
|
$( ".board-outline" ).resizable( {
|
||||||
ghost: false,
|
ghost: false,
|
||||||
minWidth: 700,
|
minWidth: 700,
|
||||||
minHeight: 400 ,
|
minHeight: 400 ,
|
||||||
|
@ -829,18 +836,18 @@ $( ".board-outline" ).resizable( {
|
||||||
|
|
||||||
//A new scope for precalculating
|
//A new scope for precalculating
|
||||||
(function() {
|
(function() {
|
||||||
var offsets;
|
var offsets;
|
||||||
|
|
||||||
$(".board-outline").bind("resizestart", function() {
|
$(".board-outline").bind("resizestart", function() {
|
||||||
offsets = calcCardOffset();
|
offsets = calcCardOffset();
|
||||||
});
|
});
|
||||||
$(".board-outline").bind("resize", function(event, ui) {
|
$(".board-outline").bind("resize", function(event, ui) {
|
||||||
adjustCard(offsets, false);
|
adjustCard(offsets, false);
|
||||||
});
|
});
|
||||||
$(".board-outline").bind("resizestop", function(event, ui) {
|
$(".board-outline").bind("resizestop", function(event, ui) {
|
||||||
boardResizeHappened(event, ui);
|
boardResizeHappened(event, ui);
|
||||||
adjustCard(offsets, true);
|
adjustCard(offsets, true);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
@ -860,18 +867,7 @@ $('#eraser').draggable(
|
||||||
);
|
);
|
||||||
|
|
||||||
//disable image dragging
|
//disable image dragging
|
||||||
window.ondragstart = function() { return false; }
|
window.ondragstart = function() { return false; }
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue