Mise à jour des descriptions des relations avec les mots saisis.

This commit is contained in:
Yoann 2011-04-27 14:33:52 +02:00
parent ca04fbfe81
commit 69fe0cdd1e
3 changed files with 35 additions and 13 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
code.zip
vp.log
*~

View File

@ -130,20 +130,20 @@ if(!isset($_SESSION['userId']))
<label for="word-"></label>
</td>
<td>
<input type="text" id="word-"/>
<input class="word" type="text" id="word-"/>
<span class="status"></span>
</td>
<td>
<input type="checkbox" id="r1-"/><label class="r1" for="r1-">Blabla</label>
<input type="checkbox" id="r1-"/><label class="r1 relationLabel" for="r1-">Blabla</label>
</td>
<td>
<input type="checkbox" id="r2-"/><label class="r2" for="r2-">Blabla</label>
<input type="checkbox" id="r2-"/><label class="r2 relationLabel" for="r2-">Blabla</label>
</td>
<td>
<input type="checkbox" id="r3-"/><label class="r3" for="r3-">Blabla</label>
<input type="checkbox" id="r3-"/><label class="r3 relationLabel" for="r3-">Blabla</label>
</td>
<td>
<input type="checkbox" id="r4-"/><label class="r4" for="r4-">Blabla</label>
<input type="checkbox" id="r4-"/><label class="r4 relationLabel" for="r4-">Blabla</label>
</td>
</tr>
</tbody>

View File

@ -27,8 +27,6 @@ $(function() {
.clone()
.changeId(i)
.addClass(i%2==0 ? "lightLine" : "")
// .find("label").attr("for", "word"+i).text(i).end()
// .find("input").attr("id", "word"+i).end()
.appendTo(".wordLinesTable tbody");
(function (i) {
@ -44,19 +42,40 @@ $(function() {
// $(truc.children("option").get(2 /* ou 1 */))
};
var displayRelations = function() {
$(".r1").text(relations[$("#relation1").val()]);
$(".r2").text(relations[$("#relation2").val()]);
$(".r3").text(relations[0]);
$(".r4").text(relations[-1]);
var updateRelationLabels = function() {
$('#relations option').each(function(i,e) {
$(e).text(applyFormat($(e).data("format"), $('#centralWord').val() || 'mot central', '…'));
});
$('.relationLabel').each(function(i,e) {
$(e).text(applyFormat(
$(e).data("format"),
$('#centralWord').val() || 'mot central',
$(e).closest('.wordLine').find('.word').val() || '…'));
});
}
var displayRelations = function() {
$(".r1").data("format", relations[$("#relation1").val()]);
$(".r2").data("format", relations[$("#relation2").val()]);
$(".r3").data("format", relations[0]);
$(".r4").data("format", relations[-1]);
updateRelationLabels();
}
var applyFormat = function(str, mc, mn) {
return str.replace(/%mc/g, mc).replace(/%mn/g, mn);
};
var displayCentralWordAndRelations = function() {
$("#centralWord").focusout(checkWord);
$.each(relations, function(i, value) {
if(i != 0 && i != -1)
$('<option/>').val(i).text(value).appendTo("#relations select");
$('<option/>')
.val(i)
.data("format", value)
.appendTo("#relations select");
});
$("#relation1, #relation2").change(function() {
if ($("#relation1").val() == $("#relation2").val())
@ -66,6 +85,7 @@ $(function() {
displayRelations();
});
displayRelations();
};
var displayButtons = function () {
@ -77,6 +97,7 @@ $(function() {
};
var checkWord = function () {
updateRelationLabels();
var input = $(this);
var word = input.val();