Skip to content

Commit

Permalink
Improve interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 24, 2010
1 parent c3f6437 commit fc26495
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 32 deletions.
6 changes: 4 additions & 2 deletions data/dm/i18n/en_fr.yml
Expand Up @@ -3,7 +3,6 @@
"Draw": "Egalité"
"Start a new game": "Commencer une nouvelle partie"
"To invite someone to play, give this url:": "Pour inviter quelqu'un à jouer, donnez cette url:"
"Or challenge the Artificial Intelligence": "Ou défiez l'intelligence artificielle"
"Your turn": "A vous de jouer"
"Waiting for opponent": "Attente de l'adversaire"
"You just added the chess/game widget. Please reload the page to activate it, and this message will never appear again.": "Vous venez d'ajouter le widget chess/game. Veuillez recharger la page pour l'activer, et ce message n'apparaîtra plus jamais."
Expand All @@ -13,4 +12,7 @@
"Resign this game": "Abandonner cette partie"
"To continue later, use this url:": "Pour reprendre la partie plus tard, utilisez cette url:"
"Your browser does not support JavaScript.": "Votre navigateur ne supporte pas JavaScript."
"Creating a new game...": "Création d'une nouvelle partie..."
"Creating a new game...": "Création d'une nouvelle partie..."
"Play with a friend": "Jouer avec un ami"
"Play with the machine": "Jouer avec la machine"
"Save": "Enregistrer"
23 changes: 15 additions & 8 deletions modules/dmChessGame/templates/_table.php
Expand Up @@ -21,15 +21,22 @@
)
).

_tag('div.dm_chess_separator').

_tag('div.dm_chess_permalink',
__('To continue later, use this url:').
_link($sf_request->getUri())->text($sf_request->getUri())->set('mt10')
_tag('div.dm_chess_table_controls.clearfix',

_tag('a.dm_chess_permalink_toggle',
__('Save')
).

_link('+/dmChessGame/resign')
->param('player', $player->code)
->text(__('Resign'))
->title(__('Resign this game'))
->set('.dm_chess_give_up')
).

_tag('div.dm_chess_give_up',
_link('+/dmChessGame/resign')->param('player', $player->code)->text(__('Resign'))->title(__('Resign this game'))

_tag('div.dm_chess_permalink.none',
__('To continue later, use this url:').
_tag('span', $sf_request->getUri())
)

);
14 changes: 8 additions & 6 deletions modules/dmChessGame/templates/_tableNotStarted.php
Expand Up @@ -2,16 +2,18 @@

echo _tag('div.dm_chess_table.dm_chess_table_not_started',

__('To invite someone to play, give this url:').
_tag('a.button.toggle_join_url', 'Play with a friend').

_tag('div.dm_chess_join_url',
_link($dm_page)->param('g', $player->Game->code)->getAbsoluteHref()
_tag('div.dm_chess_join_url.none',
_tag('p', __('To invite someone to play, give this url:')).
_tag('span', _link($dm_page)->param('g', $player->Game->code)->getAbsoluteHref())
).

_tag('div.dm_chess_separator').

_tag('div.dm_chess_join_ai',
_link('+/dmChessGame/inviteAi')->param('player', $player->code)->text(__('Or challenge the Artificial Intelligence'))
_link('+/dmChessGame/inviteAi')
->param('player', $player->code)
->text(__('Play with the machine'))
->set('.button')
)

);
15 changes: 10 additions & 5 deletions web/css/table.css
Expand Up @@ -18,7 +18,6 @@ div.dm_chess_join_url {
border: 1px solid #D4D4D4;
margin: 24px 0;
padding: 10px;
font-size: 11px;
}

div.dm_chess_separator {
Expand All @@ -31,14 +30,20 @@ div.dm_chess_permalink a.link {
display: block;
}

div.dm_chess_give_up {
div.dm_chess_table_controls {
margin-top: 20px;
text-align: right;
}
div.dm_chess_give_up a.link {
color: #888;
font-size: 90%;
}
div.dm_chess_table_controls a.dm_chess_permalink_toggle {
float: left;
}
div.dm_chess_table_controls a.dm_chess_give_up {
float: right;
}
div.dm_chess_table_controls div.dm_chess_permalink {
margin-top: 1em;
}

div.dm_chess_current_player {
height: 64px;
Expand Down
30 changes: 20 additions & 10 deletions web/js/ctrl.js
Expand Up @@ -4,18 +4,28 @@ $(function()
{
var options = dm_configuration.dm_chess_game;

options.opponent
? $game.game(options)
: setTimeout(waitForOpponent = function()
if(options.opponent)
{
$.ajax({
url: $.dm.ctrl.getHref('+/dmChessGame/getNbPlayers')+'?game='+options.game.code,
success: function(response)
{
response == 2 ? location.reload() : setTimeout(waitForOpponent, options.beat.delay);
}
$game.game(options);
}
else
{
$('a.toggle_join_url').click(function()
{
$('div.dm_chess_join_url').toggle(100);
});
}, options.beat.delay);

setTimeout(waitForOpponent = function()
{
$.ajax({
url: $.dm.ctrl.getHref('+/dmChessGame/getNbPlayers')+'?game='+options.game.code,
success: function(response)
{
response == 2 ? location.reload() : setTimeout(waitForOpponent, options.beat.delay);
}
});
}, options.beat.delay);
}
}
else if($waiting = $('div.dm_chess_not_created').orNot())
{
Expand Down
8 changes: 7 additions & 1 deletion web/js/game.js
Expand Up @@ -4,6 +4,7 @@

_init: function()
{

var self = this;
self.title_timeout = null;
self.pieceMoving = false
Expand Down Expand Up @@ -91,7 +92,7 @@

self.restartBeat();

self.$table.find("div.dm_chess_give_up a").click(function()
self.$table.find("a.dm_chess_give_up").click(function()
{
if (confirm($(this).attr('title')+' ?'))
{
Expand All @@ -108,6 +109,11 @@
return false;
});

self.$table.find("a.dm_chess_permalink_toggle").click(function()
{
self.$table.find('div.dm_chess_permalink').toggle(100);
});

self.$table.find("select#dm_chess_level_select").change(function()
{
$.ajax({
Expand Down

0 comments on commit fc26495

Please sign in to comment.