Commit 0d58ddda authored by Yong Liu's avatar Yong Liu

fix #10281 #10280

parent 7a2fed21
......@@ -126,6 +126,9 @@
if (config.options.isKommune) {
_.each(hierarchy.levels, function (level) {
level.members = _.sortBy(level.members, 'label');
if (level.label === "Fylker") {
templateData.fylker = level.members;
}
});
}
templateData.hierarchy = hierarchy;
......@@ -134,6 +137,9 @@
$(container).html(html);
if (templateData.isKommune) {
if ($(".alphabet a").length > 0) {
$($(".alphabet a")[0]).addClass('current');
}
$('.alphabet .current').trigger("click");
}
});
......@@ -350,36 +356,61 @@
onLevelChanged(form, levelID, dimensionID);
})
.on('click', '.spiderwidget .alphabet a', function (event) {
var letter = $(event.currentTarget).text().trim();
var letter = $(event.currentTarget).attr('value').trim();
$("ul.visible>li").each(function () {
var label = $(this).find("label").text().trim();
if (label.substring(0, 1).toLowerCase() !== letter.toLowerCase()) {
var label = $(this).find("input").attr('value').trim();
if (label.length % 2 !== letter.length % 2 || label.substring(0, letter.length).toLowerCase() !== letter.toLowerCase()) {
$(this).removeClass("visible").addClass("hidden");
} else {
$(this).removeClass("hidden").addClass("visible");
}
});
$('.includeFylkCheckbox').prop('checked', $("#Fylker input[value=" + letter + "]").prop('checked'));
$('.alphabet .current').removeClass('current');
$(this).addClass('current');
})
.on('change', '.spiderwidget .levellists input[type="checkbox"]', function (event) {
var element = event.currentTarget,
form = $(element).parents('form');
form = $(element).parents('form'),
all = true;
$("li.visible").each(function () {
if ($(this).find("input").prop("checked") !== true) {
all = false;
}
});
$(".includeHeleFylkerCheckbox").prop('checked', all);
Messagebus.sendMessage('member-toggle', event);
onControlDimensionChanged(form, dimensionID);
})
.on('change', '.includeFylkCheckbox', function (event) {
var element = event.currentTarget,
form = $(element).parents('form');
.on('click', '.includeHeleFylkerCheckbox', function (event) {
var letter = $('.alphabet .current').attr('value'),
element = event.currentTarget;
if (element.checked !== true) {
$(form).find("#Fylker input:checkbox:checked").each(function () {
$(this).prop('checked', false);
$("#Kommuner li").each(function () {
var label = $(this).find("input").attr('value').trim();
if (label.length % 2 === letter.length % 2 && label.substring(0, letter.length).toLowerCase() === letter.toLowerCase()) {
$(this).find("input").prop('checked', false);
}
});
} else {
$(form).find("#Kommuner input:checkbox:checked").each(function () {
setCheckedFylker(form, $(this).val(), true);
$("#Kommuner li").each(function () {
var label = $(this).find("input").attr('value');
if (label.length % 2 === letter.length % 2 && label.substring(0, letter.length).toLowerCase() === letter.toLowerCase()) {
$(this).find("input").prop('checked', true);
}
});
}
onControlDimensionChanged(('form.spiderwidget'), dimensionID);
})
.on('change', '.includeFylkCheckbox', function (event) {
var letter = $('.alphabet .current').attr('value'),
element = event.currentTarget,
form = $(element).parents('form');
if (element.checked !== true) {
$("#Fylker input[value=" + letter + "]").prop('checked', false);
} else {
$("#Fylker input[value=" + letter + "]").prop('checked', true);
}
onControlDimensionChanged(form, dimensionID);
});
......
......@@ -63,18 +63,19 @@
.alphabet a
{
width: 24px;
float: left;
color: #333;
color: #057c9a;
cursor: pointer;
height: 25px;
border: 1px solid #CCC;
display: block;
font-size: 18px;
text-align: center;
font-size: 14px;
text-align: left;
text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
text-decoration: none;
background-color: #F1F1F1;
width: 140px;
margin: 2px 2px 2px 2px;
}
.alphabet a.first {
......
......@@ -3,44 +3,10 @@
<div>
<h2>Kommuner</h2>
<div class="alphabet">
<a class="first current">A</a>
<a>B</a>
<a>C</a>
<a>D</a>
<a>E</a>
<a>F</a>
<a>G</a>
<a>H</a>
<a>I</a>
<a>J</a>
<a>K</a>
<a>L</a>
<a>M</a>
<a>N</a>
<a>O</a>
<a>P</a>
<a>Q</a>
<a>R</a>
<a>S</a>
<a>T</a>
<a>U</a>
<a>V</a>
<a>W</a>
<a>X</a>
<a>Y</a>
<a>Z</a>
<a>&#198;</a>
<a>&#216;</a>
<a class="last">&#xC5;</a>
{{#each fylker}}
<a id="fylker-{{id}}" value="{{id}}" title="{{label}}">{{label}}</a>
{{/each}}
</div>
<div><ul><li class="search-filter-item checkbox-item clearfix">
<input type="checkbox" id="inlkuderFylkestallCB" class="includeFylkCheckbox">
<label for="inlkuderFylkestallCB">
Vis fylkestall for kommunene du har valgt
<span class="icon-check search-filter-checked-label" aria-hidden="true"></span>
<span class="search-filter-unchecked-label"></span>
</label>
</ul></li></div>
</div>
{{/if}}
{{#if useReferenceList}}
......@@ -58,9 +24,18 @@
{{#unless isKommune}}
<h2>Fylker</h2>
{{/unless}}
<h2>{{title}}</h2>
<div class="levellists">
{{#if isKommune}}
<div><ul><li class="search-filter-item checkbox-item clearfix">
<input type="checkbox" id="inlkuderFylkestallCB" class="includeFylkCheckbox">
<label for="inlkuderFylkestallCB">
Hele fylket
<span class="icon-check search-filter-checked-label" aria-hidden="true"></span>
<span class="search-filter-unchecked-label"></span>
</label>
</ul></li></div>
{{/if}}
<div class="levellists">
{{> levellists hierarchy}}
</div>
</form>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment