Skip to content

Commit

Permalink
se agrego el modulo de torneos
Browse files Browse the repository at this point in the history
  • Loading branch information
manduks committed Nov 20, 2012
1 parent a121f8a commit ef18470
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 80 deletions.
50 changes: 48 additions & 2 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,55 @@ Template.container.matches = function() {
Template.container.prices = function() {
return Prices.find({}, {sort: {score: -1, name: 1}});
};
Template.container.tournaments = function() {
return Tournaments.find({}, {sort: {score: -1, name: 1}});
};
Template.comboTournaments.tournaments = function() {
return Tournaments.find({}, {sort: {score: -1, name: 1}});
};

Template.clubForm.events({
'click button' :function() {
'click button' :function(e) {
e.preventDefault();
var obj = u.getFormValues('clubForm');
Clubs.insert({nombre:obj.nombre,torneo:obj.torneo,logo:this.links.large_thumbnail});

},
'click #logobtn' :function(e) {
$('#logoFile').click();
},
'change #logoFile' :function(e) {
var input = $('#logoFile');
var callback = function(links) {
console.log('cargado!!!');
this.links = links;
};
u.upload(input[0].files[0],callback);
}
});
Template.tournamentForm.events({
'click button' :function(e) {
e.preventDefault();
var obj = u.getFormValues('tournamentForm');
Tournaments.insert({nombre:obj.nombre,descripcion:obj.descripcion,logo:this.links.large_thumbnail});
},
'click #t-logobtn' :function(e) {
$('#t-logoFile').click();
},
'change #t-logoFile' :function(e) {
var input = $('#t-logoFile');
var callback = function(links) {
console.log('cargado!!!');
this.links = links;
};
u.upload(input[0].files[0],callback);
}
});
});

//eliminar equipo
Template.club.events({
'click button' :function() {
Clubs.remove( { _id : this._id });
}
});

65 changes: 12 additions & 53 deletions client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,59 +45,18 @@
.navbar .btn-navbar {
margin-top: 10px;
}



/* CUSTOMIZE THE NAVBAR
-------------------------------------------------- */

/* Carousel base class */
.carousel {
margin-bottom: 60px;
}

.carousel .container {
position: absolute;
right: 0;
bottom: 0;
left: 0;
}

.carousel-control {
background-color: transparent;
border: 0;
font-size: 120px;
margin-top: 0;
text-shadow: 0 1px 1px rgba(0,0,0,.4);
}

.carousel .item {
height: 500px;
}
.carousel img {
min-width: 100%;
height: 500px;
}

.carousel-caption {
background-color: transparent;
position: static;
max-width: 550px;
padding: 0 20px;
margin-bottom: 100px;
}
.carousel-caption h1,
.carousel-caption .lead {
margin: 0;
line-height: 1.25;
color: #fff;
text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.carousel-caption .btn {
margin-top: 10px;
}

/* -------------CONTAINER ------------- */
/* -------------CONTAINER ------------- */
.container {
margin-bottom: 0px;
}
.attachments {
padding: 18px;
position: relative;
white-space: nowrap;
font-size: 13px;
line-height: 17px;
border: 3px dashed #DDD;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
39 changes: 34 additions & 5 deletions client/utils.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@

/**
* Este es el objeto utiliario de la appp
* @type {Object}
*/
var utils ={
log:function(obj) {
if (typeof console !== 'undefined'){
var utils = {
log: function(obj) {
if(typeof console !== 'undefined') {
console.log(obj);
}
},
getFormValues: function(id) {
// get all the inputs into an array.
var $inputs = $('#' + id + ' :input'),
values = {};
$inputs.each(function() {
values[this.name] = $(this).val();
});
return values;
},
upload: function(file,callback) {
// file is from a <input> tag or from Drag'n Drop
// Is the file an image?
if(!file || !file.type.match(/image.*/)) return;

// It is!
// Let's build a FormData object
var fd = new FormData();
fd.append("image", file); // Append the file
fd.append("key", "a4c3b38ee3fd904669addc69b21a39c2"); // Get your own key: http://api.imgur.com/
// Create the XHR (Cross-Domain XHR FTW!!!)
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://api.imgur.com/2/upload.json"); // Boooom!
xhr.onload = function() {
callback(JSON.parse(xhr.responseText).upload.links);
};

// Ok, I don't handle the errors. An exercice for the reader.
// And now, we send the formdata
xhr.send(fd);
}
};

var global = this;
var u = utils;
116 changes: 97 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
<div class="nav-collapse collapse">
<p class="navbar-text pull-right">{{loginButtons align="right"}}</p>
<ul class="nav">
<li class="active"><a href="#users-list" data-toggle="tab">Users</a></li>
<li ><a href="#clubs-list" data-toggle="tab" >Clubs</a></li>
<li ><a href="#matches-list" data-toggle="tab">Matches</a></li>
<li ><a href="#prices-list" data-toggle="tab">Prices</a></li>
<li class="active"><a href="#users-list" data-toggle="tab">Usuarios</a></li>
<li ><a href="#clubs-list" data-toggle="tab" >Equipos</a></li>
<li ><a href="#matches-list" data-toggle="tab">Partidos</a></li>
<li ><a href="#prices-list" data-toggle="tab">Premios</a></li>
<li ><a href="#tournament-list" data-toggle="tab">Torneos</a></li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
Expand All @@ -45,20 +46,31 @@
<template name="container">
<div class="container">
<div class="tab-content">
<div class="tab-pane fade " id="users-list">
<div class="tab-pane fade active in" id="users-list">
{{#each users}}
{{> user}}
{{/each}}
</div>
<div class="tab-pane fade active in" id="clubs-list">
<div class="tab-pane fade" id="clubs-list">
<div class ="row">
<div class="span4">
{{> clubForm}}
</div>
<div class="span8">
{{#each clubs}}
{{> club}}
{{/each}}
<table class="table table-hover">
<thead>
<tr>
<th>Logo</th>
<th>Nombre</th>
<th>Torneo</th>
</tr>
</thead>
<tbody>
{{#each clubs}}
{{> club}}
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
Expand All @@ -71,6 +83,29 @@
{{#each prices}}
{{> price}}
{{/each}}
</div>
<div class="tab-pane fade" id="tournament-list">
<div class ="row">
<div class="span4">
{{> tournamentForm}}
</div>
<div class="span8">
<table class="table table-hover">
<thead>
<tr>
<th>Logo</th>
<th>Nombre</th>
<th>Descripción</th>
</tr>
</thead>
<tbody>
{{#each tournaments}}
{{> tournament}}
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div> <!-- /container -->
Expand All @@ -84,9 +119,12 @@
</template>
<!-- ====================== CLUBS ============================ -->
<template name="club">
<div class="item {{selected}}">
<span class="name">{{name}}</span>
</div>
<tr>
<td><img src="{{logo}}" class="img-polaroid"></td>
<td>{{nombre}}</td>
<td>{{torneo}}</td>
<td><button type="button" class="btn btn-danger">Eliminar</button></td>
</tr>
</template>
<!-- ====================== MATCHES ============================ -->
<template name="match">
Expand All @@ -100,6 +138,14 @@
<span class="name">{{name}} ${{price}}</span>
</div>
</template>
<!-- ====================== TOURNAMENTS ============================ -->
<template name="tournament">
<tr>
<td><img src="{{logo}}" class="img-polaroid"></td>
<td>{{nombre}}</td>
<td>{{descripcion}}</td>
</tr>
</template>

<!-- ====================== FORM USERS ========================= -->
<template name="userForm">
Expand All @@ -110,19 +156,22 @@
</template>
<!-- ====================== FORM CLUBS ========================= -->
<template name="clubForm">
<h4>Clubs</h4>
<form class="form-horizontal">
<h4>Equipos</h4>
<form class="form-horizontal" id="clubForm">
<div class="control-group">
<input type="text" class="input-large" placeholder="Nombre">
<input type="text" class="input-large" name="nombre" placeholder="Nombre">
</div>
<div class="control-group">
<input type="text" class="input-large" placeholder="Liga">
{{>comboTournaments}}
</div>
<div class="control-group">
<input type="text" class="input-large" placeholder="Logo">
<div class="control-group well" style="max-width: 180px;">
<div class="attachments" id="logobtn">
Click para subir logo!
<input style="visibility: collapse; width: 0px;" type="file" id="logoFile">
</div>
</div>
<div class="control-group">
<button type="submit" class="btn btn-primary">Add Club</button>
<button type="submit" class="btn btn-primary btn-large">Agregar Equipo</button>
</div>
</form>
</template>
Expand All @@ -140,4 +189,33 @@ <h4>Clubs</h4>
<button type="submit" class="btn btn-primary">Add Framework</button>
</form>
</template>
<!-- ====================== FORM TOURNAMENTS ========================= -->
<template name="tournamentForm">
<h4>Torneos</h4>
<form class="form-horizontal" id="tournamentForm">
<div class="control-group">
<input type="text" class="input-large" name="nombre" placeholder="Nombre">
</div>
<div class="control-group">
<textarea rows="3" class="input-large" name="descripcion" placeholder="Descripción"></textarea>
</div>
<div class="control-group well" style="max-width: 180px;">
<div class="attachments" id="t-logobtn">
Click para subir logo!
<input style="visibility: collapse; width: 0px;" type="file" id="t-logoFile">
</div>
</div>
<div class="control-group">
<button type="submit" class="btn btn-primary btn-large">Agregar Torneo</button>
</div>
</form>
</template>
<!-- ====================== COMBO TOURNAMENTS ========================= -->
<template name="comboTournaments">
<select class="input-large" name="torneo" placeholder="Torneo">
{{#each tournaments}}
<option>{{nombre}}</option>
{{/each}}
</select>
</template>

2 changes: 1 addition & 1 deletion model.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
var Clubs = new Meteor.Collection("clubs");
var Matches = new Meteor.Collection("matches");
var Prices = new Meteor.Collection("Prices");
var Torneo = new Meteor.Collection("tournament");
var Tournaments = new Meteor.Collection("tournament");

0 comments on commit ef18470

Please sign in to comment.