#PHRAS-610 #time 2h

WIP
This commit is contained in:
Jean-Yves Gaulier
2015-07-29 19:05:11 +02:00
parent 41758fe341
commit 4090164896
2 changed files with 20 additions and 44 deletions

View File

@@ -3,15 +3,16 @@
{% for base in search_datas['bases'] %} {% for base in search_datas['bases'] %}
{% set sbas_id = base['sbas_id'] %} {% set sbas_id = base['sbas_id'] %}
<div class="sbas_list sbas_{{sbas_id}}" style="margin-bottom: 10px;"> <div class="sbas_list sbas_{{sbas_id}}" style="margin-bottom: 10px;">
<input type="checkbox" name="reference" value="{{sbas_id}}"/> <input type="hidden" name="reference" value="{{sbas_id}}"/>
<div class="clksbas"> <div class="clksbas">
<span onclick="deploy(this, '.sbascont_{{sbas_id}}' );return false;" class="deployer_opened" ></span> <span onclick="deploy(this, '.sbascont_{{sbas_id}}' );" class="deployer_opened" ></span>
<label style="display: inline" class="checkbox" for="sbasChkr_{{sbas_id}}_{{unique_id}}" onclick="clksbas({{sbas_id}}, $('#sbasChkr_{{sbas_id}}_{{unique_id}}')); return false;"> <input type="checkbox" checked xstyle="display: none;" id="sbasChkr_{{sbas_id}}_{{unique_id}}" class="sbasChkr_{{sbas_id}}"
onchange="clksbas(this, {{sbas_id}});" />
<label style="display: inline" class="checkbox" for="sbasChkr_{{sbas_id}}_{{unique_id}}">
<span>{{sbas_id|sbas_labels(app)}}</span> <span>{{sbas_id|sbas_labels(app)}}</span>
<span class="infos_sbas_{{sbas_id}}"> <span class="infos_sbas_{{sbas_id}}">
{{base["collections"]|length}}/{{base['collections']|length}} {{base["collections"]|length}}/{{base['collections']|length}}
</span> </span>
<input type="checkbox" checked style="display: none;" id="sbasChkr_{{sbas_id}}_{{unique_id}}" class="sbasChkr_{{sbas_id}}" />
</label> </label>
</div> </div>
<div class="sbascont sbascont_{{sbas_id}}" style="-moz-column-width:150px; -webkit-column-width: 150px; -moz-column-gap: 20px; -webkit-column-gap: 20px;"> <div class="sbascont sbascont_{{sbas_id}}" style="-moz-column-width:150px; -webkit-column-width: 150px; -moz-column-gap: 20px; -webkit-column-gap: 20px;">
@@ -23,13 +24,12 @@
<tr> <tr>
<td> <td>
<input class="ck_{{collection["base_id"]}} checkbas" style="*margin-top:-18px;" <input class="ck_{{collection["base_id"]}} checkbas" style="*margin-top:-18px;"
onclick="cancelEvent(event);return false;" onchange="infoSbas(this, {{sbas_id}});checkFilters(true);"
onmousedown="infoSbas(this, {{sbas_id}}, false, event); return false;"
id="ck_{{collection["base_id"]}}_{{unique_id}}" type="checkbox" id="ck_{{collection["base_id"]}}_{{unique_id}}" type="checkbox"
name="bases[]" value="{{collection["base_id"]}}" {% if collection["selected"] %}checked="checked"{% endif %} /> name="bases[]" value="{{collection["base_id"]}}" {% if collection["selected"] %}checked="checked"{% endif %} />
</td> </td>
<td> <td>
<label style="line-height: 18px;" onclick="infoSbas($('#ck_{{base_id}}_{{unique_id}}'),{{sbas_id}}, false, event); return false;" <label style="line-height: 18px;"
for="ck_{{base_id}}_{{unique_id}}" class="ck_{{base_id}} {% if collection["selected"] %}selected{% endif %} checkbox inline"> for="ck_{{base_id}}_{{unique_id}}" class="ck_{{base_id}} {% if collection["selected"] %}selected{% endif %} checkbox inline">
{{base_id|get_collection_logo(app)|raw}} {{base_id|bas_labels(app)}} {{base_id|get_collection_logo(app)|raw}} {{base_id|bas_labels(app)}}
</label> </label>

View File

@@ -156,12 +156,12 @@ function is_shift_key(event) {
function checkBases(bool) { function checkBases(bool) {
$('form.phrasea_query .sbas_list').each(function () { $('form.phrasea_query .sbas_list').each(function () {
var id = $(this).find('input[name=reference]:first').val(); var sbas_id = $(this).find('input[name=reference]:first').val();
if (bool) if (bool)
$(this).find(':checkbox').attr('checked', 'checked'); $(this).find(':checkbox').attr('checked', 'checked');
else else
$(this).find(':checkbox').removeAttr('checked'); $(this).find(':checkbox').removeAttr('checked');
infoSbas(false, id, true, false); infoSbas(null, sbas_id);
}); });
if (bool) { if (bool) {
@@ -2750,58 +2750,34 @@ function deploy(deployer, todeploy_selector)
} }
} }
function clksbas(num, el) { function clksbas(el, sbas_id) {
var bool = true; var bool = $(el).attr('checked');
if (el.attr('checked')) { $.each($('.sbascont_' + sbas_id + ' :checkbox'), function () {
bool = false;
$('.sbasChkr_' + num).removeAttr('checked');
}
else {
$('.sbasChkr_' + num).attr('checked', 'checked');
}
$.each($('.sbascont_' + num + ' :checkbox'), function () {
this.checked = bool; this.checked = bool;
}); });
if (bool) { if (bool) {
$('.sbascont_' + num + ' label').addClass('selected'); $('.sbascont_' + sbas_id + ' label').addClass('selected');
} }
else { else {
$('.sbascont_' + num + ' label').removeClass('selected'); $('.sbascont_' + sbas_id + ' label').removeClass('selected');
} }
infoSbas(false, num, false, false); infoSbas(null, sbas_id);
} checkFilters(true);
function cancelEvent(event) {
if (event.stopPropagation)
event.stopPropagation();
if (event.preventDefault)
event.preventDefault();
event.cancelBubble = true;
return false;
} }
function infoSbas(el, num, donotfilter, event) { function infoSbas(el, sbas_id) {
if (event)
cancelEvent(event);
if (el) { if (el) {
var item = $('input.ck_' + $(el).val());
var label = $('label.ck_' + $(el).val()); var label = $('label.ck_' + $(el).val());
if ($(el).attr('checked')) { if ($(el).attr('checked')) {
label.removeClass('selected'); label.addClass('selected');
item.removeAttr('checked');
} }
else { else {
label.addClass('selected'); label.removeClass('selected');
item.attr('checked', 'checked');
} }
} }
$('.infos_sbas_' + num).empty().append($('.basChild_' + num + ':first .checkbas:checked').length + '/' + $('.basChild_' + num + ':first .checkbas').length); $('.infos_sbas_' + sbas_id).empty().append($('.basChild_' + sbas_id + ':first .checkbas:checked').length + '/' + $('.basChild_' + sbas_id + ':first .checkbas').length);
if (donotfilter !== true)
checkFilters(true);
} }
function advSearch(event) { function advSearch(event) {