Browse files

team selection

  • Loading branch information...
1 parent 6e0f088 commit ddfa585d17d75cec898105a9edf1d1f11bc86f89 @wooki committed Dec 12, 2012
Showing with 11 additions and 1 deletion.
  1. +1 −1 application/views/missions/selection.php
  2. +10 −0 js/application.js
View
2 application/views/missions/selection.php
@@ -17,7 +17,7 @@
<?= form_open('missions/selection/'.$game->slug, array('class' => 'set-team')) ?>
<?= form_hidden('team', ''); ?>
- <p>Discuss and select your team of <span class="label label-info"><?= $team_size ?></span></p>
+ <p>Discuss and select your team of <span class="label label-info" data-team-size="<?= $team_size ?>"><?= $team_size ?></span></p>
<?php foreach ($game->players as $p) { ?>
<button style="margin-bottom: 0.5em;" type="button" class="btn btn-large" data-toggle="button"><i class="icon-user"></i> <?= $p->name ?></button>
View
10 js/application.js
@@ -27,6 +27,16 @@ var covertmission = function() {
$.backstretch("/img/bg.jpg");
}
+ // set team - require team leader to set correct number of players
+ // and keeps the hidden field updated
+ $('form.set-team').submit(function(event) {
+ var selected_count = $('button[data-toggle].active').length;
+ if (selected_count != $('button[data-toggle].active').attr('data-team-size')) {
+ event.preventDefault();
+ alert("Please select the correct number of players for your team");
+ }
+ });
+
// lobby - refresh status every n seconds and update players
if ($('.game_state').length) {
// <p data-game-state="joining" class="alert alert-info game_state">Waiting to start</p>

0 comments on commit ddfa585

Please sign in to comment.