Ajout prototype et structure projet

- ajout du prototype datant de Février 2013
- ajout d'un template d'arborescence de fichiers
This commit is contained in:
JonRiv 2013-09-19 17:22:49 +02:00
parent 827af5ef45
commit 98ead701c3
14 changed files with 617 additions and 0 deletions

View File

@ -0,0 +1,131 @@
@font-face {
font-family: 'Aller';
src: url('../fonts/Aller/Aller_Lt.ttf');
font-weight:400;
}
html, body {width:100%;height:100%;margin:0;padding:0;border:none;font-family:'Aller';font-size:14px;line-height:1.4;}
header, footer {height:10px;}
input, textarea {font-family:'Aller';font-size:14px;font-weight:bold;color:#2a2a37;resize: none; }
.field textarea ~ p{border:1px solid red;}
h1.framaTitle {position:absolute;top:-10px;font-size:24px;}
[role="Main"] {
width:650px;
height:350px;
margin:auto;
margin-top:5%;
padding:10px;
border:3px solid #CCC;
border-radius:8px;
position:relative;
overflow:hidden;
}
[role="Main"] p {display:block;margin:2px;padding:2px;}
[role="Main"] div.field p {display:inline-block;width:200px;}
[role="Main"] div.check p {display:inline-block;width:600px;}
[role="Main"] input {display:inline;}
[role="Main"] textarea {max-width:50%;max-height:40%;}
#entry_form {position:absolute;display:inline;margin:10px;padding:4px;margin-top:40px;}
#entry_form form {margin-top:20px;}
#entry_form form input[type="submit"]{float:right;}
#entry_form form .check {margin-top:0px;}
#entry_form form .check:not(:last-of-type) {margin-top:20px;}
#choices {position:absolute;display:inline;margin:10px;padding:4px;padding-bottom:10px;margin-top:40px;}
#action {position:absolute;display:inline;margin:10px;padding:4px;margin-top: 20px;}
#action p {display:block;margin:2px;padding:2px;width:630px;}
.trans {
-webkit-transition:0.5s all ease;
-moz-transition:0.5s all ease;
-ms-transition:0.5s all ease;
-o-transition:0.5s all ease;
transition:0.5s all ease;
}
.fastTrans {
-webkit-transition:0.2s all ease;
-moz-transition:0.2s all ease;
-ms-transition:0.2s all ease;
-o-transition:0.2s all ease;
transition:0.2s all ease;
}
.wait {
-webkit-transition:0s all ease;
-moz-transition:0s all ease;
-ms-transition:0s all ease;
-o-transition:0s all ease;
transition:0s all ease;
}
.active {left:0px;opacity:1;}
.inactive {left:1000px;opacity:0;}
label {clear:both;display:block;width:300px;}
label input {margin-left:10px;}
.add_entries {width:400px;float:left;}
.add_entries p {display:inline;}
#choices .continue {float:left;}
#choices label p {float:left;width:70px;}
#choices .presentation {width:640px;}
.choice_line.active {}
.choice_line.chosen td input[type="checkbox"]:checked {background:black;}
.choice_line.chosen td:not(.ok):not(:first-of-type):not(:last-of-type) {background:#d96f6f;}
.choice_line.chosen td.ok {background:#00bee9;}
.choice_line.active input[type="checkbox"]{width:100%;height:100%;}
.choice_line.chosen input[type="checkbox"]{display:none;}
button[type="print"] {float:right;margin-right:20px;}
#action table {
display: inline-block;
position: relative;
overflow: auto;
width: 640px;
}
/*_ Donne du style aux champs de renseignement _*/
.field > input, input.choice, input[name="active_name"], textarea {
display: inline;
border-style: solid;
border-width: 1px;
border-color: #dedede;
padding-left:4px;
width: auto;
height: auto;
color: #008bc1;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset;
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset;
transition: border 0.15s linear 0s, box-shadow 0.15s linear 0s, color 0.15s linear 0s;
-webkit-transition: border 0.15s linear 0s, box-shadow 0.15s linear 0s, color 0.15s linear 0s;
-moz-transition: border 0.15s linear 0s, box-shadow 0.15s linear 0s, color 0.15s linear 0s;
-o-transition: border 0.15s linear 0s, box-shadow 0.15s linear 0s, color 0.15s linear 0s;
}
input[name="active_name"]:focus, input.choice:focus, .field > input:focus, textarea:focus {
color: #333;
border-color: rgba(0, 139, 93, 0.4);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset, 0 0 8px rgba(0, 139, 93, 0.6);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset, 0 0 8px rgba(40, 90, 160, 0.6);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset, 0 0 8px rgba(40, 90, 160, 0.6);
outline: 0 none;
}

View File

@ -0,0 +1,92 @@
This Dalton Maag Ltd Free Licence Agreement becomes a binding contract between the Licensee and Dalton Maag Ltd when the Licensee commences a Font Software download, or if the Licensee is acquiring Font Software on a permanent medium, when the Licensee opens the package in which the software is contained. If the Licensee does not wish to be bound by the Agreements, the Licensee cannot access, use or download the Font Software. Please read all of the Agreement before agreeing to be bound by its terms and conditions.
This Free Licence Agreement supplements, and should be read in conjunction with, the standard Dalton Maag End User Licence Agreement version 1.2.
1 You, the Licensee, are granted the right by Dalton Maag to Use the Aller Font Family, Standard Edition under the terms set out in the EULA. This free licence has a Licensed Unit size of 25 Users.
2 Use by more than 25 Users, or equivalent Website Visitors, is a breach of this Free Licence Agreement, and instead requires a commercial licence.
Fontsquirrel Note: 1000 website visitors is the equivalent of 1 user - http://www.daltonmaag.com/about/web_embedding_faq.html
3 Editions other than the Standard Edition of the Aller Font Family are not covered by this Free Licence Agreement, and require a commercial licence.
4 Dalton Maag will provide no technical support under this Free Licence Agreement.
5 The Licensee may redistribute the Aller Font Family only as a verbatim copy of the .zip file supplied, ensuring that the acquirers attention is drawn to this Free Licence Agreement and the End User Licence Agreement.
You can contact us by email at info@daltonmaag.com or by post:
Dalton Maag Ltd Unit 107 245A Coldharbour Lane
London SW9 8RR United Kingdom
You can find out more about the Aller Font Family at our website: http://www.daltonmaag.com/aller
-------
Dalton Maag Ltd End User Licence Agreement (EULA)
We recommend that the Licensee prints this End User Licence Agreement for further reference.
This Dalton Maag Ltd End User Licence Agreement (“EULA”) becomes a binding contract between the Licensee and Dalton Maag Ltd when the Licensee commences a Font Software download, or if the Licensee is acquiring Font Software on a permanent medium, when the Licensee opens the package in which the software is contained.
If the Licensee does not wish to be bound by the EULA, the Licensee cannot access, use or download the Font Software. Please read all of the EULA before agreeing to be bound by its terms and conditions.
The Licensee hereby agrees to the following:
1 The Licensee is bound by the EULA and acknowledges that all Use (as defined herein) of the Font Software (as defined herein) supplied by Dalton Maag is governed by the EULA.
2 “Dalton Maag” shall mean Dalton Maag Ltd, its successors and assignees, its parent and affiliated corporations, its authorized distributors, and any third party which has licensed to Dalton Maag any or all of the components of the Font Software supplied to the Licensee.
3 “Licensee” shall mean the individual, company, corporation, or other organization subject to this End User Licence Agreement due to their access or Use of Dalton Maag Font Software.
4 “Font Software” shall mean the software provided by Dalton Maag which, when used on an appropriate Device or Devices, generates typeface and typographic designs and ornaments. Font Software shall include all bitmap representations of typeface and typographic designs and ornaments created by or derived from the Font Software. Font Software includes upgrades, updates, related files, permitted copies, permitted conversions, and related documentation.
5 “Device” shall mean a hardware, software, or firmware component to which an individual is able to give commands (whether by keyboard or otherwise), regardless of the locations of the individual, the Device, or the Font Software.
6 “Use” of the Font Software shall be deemed to occur when an individual is able to give commands (whether by keyboard or otherwise) to a Device on which the Font Software is installed, regardless of the locations of the individual, the Device, or the Font Software.
7 “User” shall mean an individual giving commands (whether by keyboard or otherwise) to a Device on which the Font Software is installed, regardless of the locations of the individual, the Device, or the Font Software. Users do not need to be members of the Licensees organization or household, and may be members of the public.
8 “Licensed Unit” shall mean the number of simultaneous Users permitted by the Licence. If the Licensee intends that Devices on which the Font Software is installed should be simultaneously used by more Users than permitted by the Licensed Unit, the Licensee should purchase an additional Licensed Unit of the correct size to cover the shortfall.
9 “Derivative Work” shall mean data based upon or derived from the Font Software, or any portion of the Font Software, in any form in which such data may be recast, transformed, or adapted,
including, but not limited to, data in any format into which Font Software may be converted.
10 “Digital Product” shall mean an electronic document or data file created by Use of the Font Software which is offered for distribution outside of the Licensees organization or household. By way of illustration and not by way of limitation, an electronic book, electronic magazine, or computer game shall all be considered Digital Products. A separate OEM/ISV licence is required to use Dalton Maag Font Software in Digital Products. A document distributed in connection with a commercial transaction in which the consideration is unrelated to such document, for example, a business letter, a ticket for an event, an invoice, or a receipt shall not be considered a Digital Product.
11 “Licensees Website” shall mean the publicly or privately accessible collection of linked webpages, and other files, under the legal control of the Licensee.
12 “Website Visitor” shall mean a unique individual who accesses any webpage, file, or data hosted on or provided by the Licensees Website.
13 The Licensee is hereby granted a non-exclusive, non-assignable, non-transferable (except as expressly permitted in section 21) licence to Use the Font Software subject to all of the terms and conditions of the EULA. The Licensee has no rights to the Font Software other than as expressly set forth in the EULA. The Licensee agrees that Dalton Maag owns all right, title and interest in and to the Font Software, its structure, organization, code, and related files, including all property rights therein such as copyright, design and trademark rights. The Licensee agrees that the Font Software, its structure, organization, code, and related files are valuable property of Dalton Maag and that any intentional Use of the Font Software not expressly permitted by the EULA constitutes infringement of copyright. All rights not expressly granted in the EULA are expressly reserved to Dalton Maag. The Licensee may not use the Font Software to electronically distribute a Digital Product without a separate licence from Dalton Maag authorizing the Licensee to do so.
14 The Licensee shall not install, access or Use the Font Software until it has paid the applicable licence fee in full, or received an invoice for the licence fee and that invoice has not yet reached its due date, or been given written authorization to Use the Font Software by Dalton Maag. The Licensee shall pay all applicable invoices in full within 30 days of each invoices issue date. If the Licensee fails to pay any invoice when it is due, then, in addition to any other rights and remedies available, Dalton Maag may charge the Licensee interest at a rate of 6% above Bank of England base rate from the due date to the date on which the Licensee pays in full including any interest and/or cancel the Licence, or suspend the Licence and charge the Licensee for all additional costs resulting from such suspension and any subsequent resumption.
15 The Licensee may install the Font Software on any number of Devices which are all under the ownership or exclusive control of the Licensee, or of the Licensees direct employees. The Licensee shall ensure that the number of simultaneous Users of Devices on which the Font Software is installed does not exceed the Licensed Unit. The Licensee must take all reasonable steps to ensure that it retains exclusive custody and control over all copies of the Font Software. The Licensee must not transfer the ownership of Devices on which the Font Software is installed. Upon termination
of the EULA, the Licensee must destroy all copies of the Font Software.
16 The Licensee may convert the Font Software to EOT format (or other format which Dalton Maag may from time-to-time make it known that it allows under specific terms) for installation on the Licensees Website. Website Visitors are included in the Licensed Unit at the equivalence of 1,000 (one thousand) Website Visitors per day being equal to 1 (one) User of the Font Software. For the purpose of Licensed Unit assessment, the Licensee may disregard the Licensees Websites busiest day in a seven-day period. Should the number of Website Visitors cause the number of Users to exceed the Licensed Unit, the Licensee must immediately purchase an additional Licensed Unit of the correct size to cover the shortfall.
17 The Licensee may electronically distribute Font Software embedded in a personal or business document (that is, a document other than a “Digital Product” as defined herein) only when the Font Software embedded in such document is in a static bitmap image or an embedded electronic document, and is distributed in a secure format that permits only the viewing and printing (and not the editing, altering, enhancing, or modifying) of such static graphic image or embedded document. The Licensee may not embed Font Software in an electronic document or data file for any reason other than the Licensees own personal or business Use.
18 The Licensee may not alter Font Software for the purpose of adding any functionality which such Font Software did not have when delivered to the Licensee by Dalton Maag. If the Font Software contains embedding bits that limit the capabilities of the Font Software, the Licensee may not change or alter the embedding bits. Font Software may not be used to create or distribute any electronic document in which the Font Software, or any part thereof, is embedded in a format that permits editing, alterations, enhancements, or modifications by the recipient of such document. If the Licensee has reason to believe that a recipient of an electronic document possesses the capability to edit, alter, enhance, or modify such electronic document even though the Licensee has distributed it in a format which does not permit such editing, alteration, enhancement, or modification, the Licensee shall not transmit such document to such a person.
19 The Licensee may take one (1) copy of the Font Software used for a particular document, or Font Software embedded in an electronic document, to a commercial printer or service bureau solely for the purpose of printing such document. The commercial printer or service bureau shall not be permitted to Use the Font Software to make changes or amendments to the document. The Licensee shall ensure that the commercial printer or service bureau destroys all copies of the Font Software upon final delivery of the printed document.
20 The Licensee acknowledges that the typeface design and Font Software are protected by the copyright, design, and other intellectual property laws of England and Wales, by the copyright and design laws of other nations, and by international treaties. The Licensee agrees to treat the Font Software as the Licensee would any other copyrighted material, such as a book. The Licensee may not copy the Font Software, except as expressly provided herein. Any copies that the Licensee is expressly permitted to make pursuant to the EULA must contain the same copyright, trademark, and other proprietary notices that appear on or in the Font Software. The Licensee shall not produce Derivative Works of this Font Software except for document embedding and permitted conversions as expressly set out in this Agreement. The Licensee is permitted to reverse engineer the Font Software in order to produce any compatible software product, provided that such a product is not a Derivative Work of the Font Software. The Licensee agrees to use trademarks associated with the Font Software according to accepted trademark practice, including identification of the trademark owners name. Trademarks can only be used to identify printed output produced by the Font Software. The use of any trademark as herein authorized does not give the Licensee any rights of ownership in that trademark and all use of any trademark shall inure to the sole benefit of Dalton Maag. The Licensee may not change any trademark or trade name designation for the Font Software.
21 The Licensee may not rent, lease, sublicense, give, lend, or further distribute the Font Software, or any copy thereof, except as expressly provided herein. The Licensee may transfer all the Licensees rights to use the Font Software to another person or legal entity provided that the transferee accepts and agrees to be bound by all the terms and conditions of the EULA and the Licensee destroy all copies of the Font Software, including all copies stored in the memory of a hardware device, and provided the entirety of the Licensed Unit is transferred.
22 Dalton Maag makes no warranty, express or implied, that this Font Software is suitable for any specific purpose. Dalton Maag will provide the Licensee with basic technical support on the correct installation and exploitation of the Font Software in common software packages and operating systems. Once Font Software has been downloaded online or security seals broken on physical packaging, the software cannot be returned. Otherwise, the Licensee has a right to cancel within fourteen (14) days of completion of the contract of sale.
23 Dalton Maag, or its appointed auditor, is entitled to inspect and have access to any premises, and to any Devices, owned or operated by Licensee, at or on which this Font Software is kept or Used, for the purposes of ensuring that the Licensee is complying with the terms of this Licence. The Licensees business information shall remain strictly confidential by Dalton Maag and their auditor, who shall be granted access to all the necessary documents to verify compliance with this and any other agreement with Dalton Maag. The inspection shall take place within the Licensees usual business hours and after reasonable written notice. Dalton Maag shall bear the costs of the inspection. However, if, in the course of the inspection, deviations to the detriment of Dalton Maag are discovered, the Licensee shall bear the costs of the audit.
24 This EULA will be governed by the laws of England and Wales. For the purposes of the Sale of Goods Act 1979, Supply of Goods and Services Act 1982, and the Consumer Protection (Distance Selling) Regulations 2000, Font Software is classified as computer software.
25 The EULA shall automatically terminate upon failure by the Licensee (or any authorized person or member of the Licensees immediate household to whom the Licensee has given permission to Use the Font Software) to comply with its terms. The termination of the EULA shall not preclude Dalton Maag from suing the Licensee for damages of any breach of the EULA. The EULA may only be modified in writing signed by an authorized officer of Dalton Maag.
26 The Licensee has the rights expressly set forth in the EULA and no other. All rights in and to the Font Software, including unpublished rights, are reserved under the copyright laws of England and Wales and other jurisdictions. All rights reserved. The EULA may be enforced by Dalton Maag or by an authorized dealer acting on behalf of Dalton Maag.
Version 1.2. For licences issued from 22 August 2010.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,119 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Framadate || Prototype Ajax</title>
<script src="js/jquery-1.9.0.min.js" type="text/javascript" charset="utf-8" ></script>
<script src="js/script.js" type="text/javascript" charset="utf-8" ></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header id="header" class=""></header><!-- /header -->
<div role="Main" class="fastTrans wait">
<h1 class="framaTitle trans wait">FramaDate <small>prototype</small></h1>
<div id="entry_form" class="trans active wait">
<div class="presentation">
<p>Vous avez choisi de créer un nouveau sondage !</p>
<p>Merci de remplir les champs obligatoires, marqués d'une *.</p>
</div>
<form id="user_infos" action="truc.php" method="post" accept-charset="utf-8">
<div class="field">
<p>Titre du sondage * :</p>
<input type="text" name="titre" value="Sondage" placeholder="Titre du sondage * :" maxlength="80" pattern="^[a-zA-Z][a-zA-Z0-9-_\.]{1,80}$" required>
</div>
<div class="field">
<p>Commentaires :</p>
<textarea name="commentaire" placeholder="Commentaires :"></textarea>
</div>
<div class="field">
<p>Votre nom * :</p>
<input type="text" name="nom" value="Jonathan" placeholder="Votre nom *" maxlength="40" pattern="^[a-zA-Z]{1,40}$" required>
</div>
<div class="field">
<p>Votre adresse e-mail * :</p>
<input type="email" name="mail" value="Jonathan@mail.com" placeholder="Votre adresse e-mail * :" maxlength="64" required>
</div>
<div class="check">
<input name="modif" type="checkbox"></input>
<p> Vous souhaitez que les sondés puissent modifier toutes les lignes du sondage eux-mêmes.</p>
</div>
<div class="check">
<input name="receive_mail" type="checkbox"></input>
<p> Vous souhaitez recevoir un mail à chaque participation d'un sondé.</p>
</div>
<input type="submit" id="submission" name="" value="Continue">
<!--<button class="continue" value="Continue">Continue</button>-->
</form>
</div>
<div id="choices" class="trans inactive wait">
<div class="presentation">
<p>Vous avez créé un sondage pour déterminer un choix entre plusieurs choses.</p>
<p>Entrez les différents choix à proposer au vote :</p>
</div>
<label for="choix_1"><p>Choix 1 :</p></label>
<input id="choix_1" class="choice" type="text" name="Choix_1" value="Travailler">
<label for="choix_2"><p>Choix 2 :</p></label>
<input id="choix_2" class="choice" type="text" name="Choix_2" value="Manger">
<label for="choix_3"><p>Choix 3 :</p></label>
<input id="choix_3" class="choice" type="text" name="Choix_3" value="Boire">
<label for="choix_4"><p>Choix 4 :</p></label>
<input id="choix_4" class="choice" type="text" name="Choix_4" value="Dormir">
<label for="choix_5"><p>Choix 5 :</p></label>
<input id="choix_5" class="choice" type="text" name="Choix_5" value="Se réveiller">
<div class="add_entries"><p>Ajouter un champ supplémentaire</p><button>+</button></div>
<button class="continue" type="">Continue</button>
</div>
<div id="action" class="trans inactive wait">
<div class="recap">
<p class="date_title"></p>
<p class="date_author"></p>
<p class="date_url"></p>
</div>
<div class="howto">
<p>Pour participer à ce sondage, veuillez entrer votre nom, choisir toutes les valeurs qui vous conviennent
(sans tenir compte des disponibilités des autres sondés) et valider votre choix avec le bouton en bout de ligne.</p>
</div>
<div class="tableR">
<table>
<thead>
<tr>
<th>header</th>
<th>header</th>
<th>header</th>
<th>header</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
<td>data</td>
<td>data</td>
<td>data</td>
</tr>
</tbody>
</table>
<button type="print">Print Json</button>
</div>
<div class="commentary">
</div>
</div>
<div id="printJSON" class="trans inactive wait">
<pre>
<code></code>
</pre>
</div>
</div>
<footer></footer><!-- /footer -->
</body>
</html>

File diff suppressed because one or more lines are too long

271
Archives/prototype/js/script.js vendored Normal file
View File

@ -0,0 +1,271 @@
$(document).ready(function(){
FramaClassic = {
//initialise les méthodes
init : function(){
FramaClassic.vars();
FramaClassic.loggin();
FramaClassic.catchForm();
FramaClassic.anim();
FramaClassic.adjustHeight();
},
//garde un modele de l'objet json
vars : function(){
FramaClassic.HtmlForm = $('#user_infos');
FramaClassic.JsonObject =
{
infos : {
titre : "",
commentaire : "",
nom : "",
mail : "",
option_modif : "",//renvoie false/true
option_mail : "",//renvoie false/true
option_date_fin : "",
//entries : {[I1,I2,I3,...]},
//entries : {[]},
entries : []
},
/*
users : {
Prenom1 : {[o,n,o,...]},
Prenom2 : {[n,n,n,...]}
},
*/
users : {},
/*
commentaires : {
prenom : "",
prenomBis : ""
}
*/
commentaires : {}
}
},
anim : function(){
setTimeout(function(){
$('.wait').removeClass('wait');
},10)
},
loggin : function(){
//console.log(FramaClassic.HtmlForm);
//console.log(FramaClassic.submitBut);
//console.log(FramaClassic.JsonObject);
},
catchForm : function(){
//lors de l'envoi du formulaire :
FramaClassic.HtmlForm.submit(function(e){
//retrait du comportement par défaut
e.preventDefault();
//mise à jour du cache du formulaire
FramaClassic.HtmlForm = $('#user_infos');
//alimentation de l'objet Json
FramaClassic.jsonForm(FramaClassic.HtmlForm);
//jeu d'ajout/retrait de classes, menant à l'étape suivante
$('div#entry_form').removeClass('active').addClass('inactive');
$('div#choices').removeClass('inactive').addClass('active');
//mise à jour & initialisation des méthodes liées
FramaClassic.adjustHeight();
FramaClassic.moreChoices();
FramaClassic.getEntries();
})
},
jsonForm : function(data){
FramaClassic.JsonObject =
{
infos : {
titre : data.find('input[name="titre"]').val(),
commentaire : data.find('textarea[name="commentaire"]').text(),
nom : data.find('input[name="nom"]').val(),
mail : data.find('input[name="mail"]').val(),
option_modif : data.find('input[name="modif"]').is(':checked'),
option_mail : data.find('input[name="receive_mail"]').is(':checked'),
option_date_fin : "",
//entries : {[I1,I2,I3,...]},
//entries : {[]},
entries : []
},
/*
users : {
Prenom1 : [o,n,o,...],
Prenom2 : [n,n,n,...]
},
*/
users : {},
/*
commentaires : {
prenom : "",
prenomBis : ""
}
*/
commentaires : {}
};
},
//ajustement de la taille de la div contenante à son contenu
adjustHeight : function(){
$('div[role="Main"]').height($('.active').outerHeight()+30);
},
//ajout de choix (par 1 ou par 5)
moreChoices : function(){
var button = $('.add_entries').find('button');
var entries_length = $('#choices').find('label').length;
button.on('click',function(){
//Ajout de 5 choix supplémentaires
//for (var i = 0; i <= 4; i++) {
// entries_length += 1;
// var list_model = '<label for="choix_'+entries_length+'"><p>Choix '+entries_length+' :</p></label><input id="choix_'+entries_length+'" class="choice" type="text" name="Choix_'+entries_length+'" value="">';
// $('#choices').find('label:last').append(list_model);
//};
//Ajout d'un choix supplementaire
entries_length += 1;
var list_model = '<label for="choix_'+entries_length+'"><p>Choix '+entries_length+' :</p></label><input id="choix_'+entries_length+'" class="choice" type="text" name="Choix_'+entries_length+'" value="">';
$('#choices').find('input:last').after(list_model);
FramaClassic.adjustHeight();
})
},
//alimente l'objet JSON avec les entrées
getEntries : function(){
$('#choices .continue').on('click',function(){
//FramaClassic.JsonObject.infos.entries = [];
$('#choices').find('label ~ input.choice').each(function(){
if ($(this).val() !== ''){
FramaClassic.JsonObject.infos.entries.push($(this).val());
console.log($(this).val());
}
else {}
})
if (FramaClassic.JsonObject.infos.entries[0] == undefined){
alert('Vous devez renseigner au moins un choix');
}
else {
$('#choices').removeClass('active').addClass('inactive');
$('#action').removeClass('inactive').addClass('active');
FramaClassic.actionTable();
FramaClassic.adjustHeight();
}
})
},
//génére le tableau de choix des entrées
actionTable : function(){
var headContent, bodyContent;
var tableTemplate = "<table><thead><tr>"+headContent+"</tr></thead><tbody>"+bodyContent+"</tbody></table>";
var headEntries = FramaClassic.JsonObject.infos.entries;
var ok = '<button class="ok">ok</button>';
var headTh = '<th></th>';
var bodyTd = '<td><input type="text" name="active_name" value="'+FramaClassic.JsonObject.infos.nom+'" placeholder=""></td>';
for (var i = 0; i <= headEntries.length-1; i++) {
headTh += '<th class="head_entry">'+headEntries[i]+'</th>';
bodyTd += '<td><input name="modif" type="checkbox"></input></td>';
};
headTh += '<th class="ok_field"></th>';
bodyTd += '<td class="ok_field">'+ok+'</td>';
var tableTemplate = "<table><thead><tr>"+headTh+"</tr></thead><tbody><tr class='choice_line active'>"+bodyTd+"</tr></tbody></table>";
$('table').replaceWith(tableTemplate);
//identifie la plus grande largeur et l'applique aux td de thead
//!necessité d'inserer le template dans le dom pour faire ce controle
var THeadz = $('table').find('thead').find('.head_entry');
var width_counter = 0;
THeadz.each(function(){
var tempwidth = parseInt($(this).css('width'));
if (tempwidth >= width_counter){width_counter = tempwidth};
});
width_counter = width_counter+(width_counter*0.1);
THeadz.each(function(){
$(this).css('width',width_counter);
});
FramaClassic.addLine();
FramaClassic.printJSON();
},
//ajoute un nouvel utilisateur
addLine : function(){
//attachement dynamique
$(document).on('click','button.ok',function(){
var name = $(this).parent().parent().find('td input[name="active_name"]').val();
//si le nom est vide, alerte
if (name == ''){
return alert('Indiquez un nom svp');
}
$(this).parent().parent().find('td input[name="active_name"]').replaceWith(name);
var colNum = $(this).parent().parent().find('td').length;
var name_entry_template = '<td><input type="text" name="active_name" value="" placeholder=""></td>';
var ok = '<button class="ok">ok</button>';
for (var i = 0; i <= colNum-3; i++) {
name_entry_template += '<td><input name="modif" type="checkbox"></input></td>';
};
//ajouter une condition pour ne pas rajouter +d'1 ligne à la fois
var activeLines = $('tr.active');
var activeOk = activeLines.find('button.ok');
activeOk.remove();
//var selected = activeLines.find('[type="checkbox"]:checked');
//selected.parent().addClass('ok');
var flag = '',
choice_sequence = [];
activeLines.find('input[name="modif"]').each(function(){
if ($(this).is(':checked')){
$(this).parent().addClass('ok');
flag = "o";
}
else {
flag = "n";
}
choice_sequence.push(flag);
})
FramaClassic.JsonObject.users[name] = choice_sequence;
activeLines.removeClass('active').addClass('chosen');
var newLine = '<tr class="choice_line active">'+name_entry_template+'<td>'+ok+'</td></tr>';
$('table tbody').append(newLine);
FramaClassic.adjustHeight();
})
},
printJSON : function(){
$('button[type="print"]').click(function(){
if(confirm('Voulez-vous visualiser le fichier JSON ?'))
{
$('#printJSON').find('code').html(JSON.stringify(FramaClassic.JsonObject, null, 4));
var newHeight = parseInt($('#printJSON').find('code').css('height'));
newHeight = newHeight + 40;
$('#action').removeClass('active').addClass('inactive');
$('#printJSON').removeClass('inactive').addClass('active');
$('div[role="Main"]').css('height',newHeight);
var JSONheader = $('<div class="json_title">Contenu du fichier JSON :</div>');
$('div[role="Main"]').prepend(JSONheader);
$('h1').css('left','500px');
}
})
}
};
FramaClassic.init();
})