Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions js/jquery.mapael.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,15 @@
var i = 0
, id = 0
, animDuration = 0
, elemOptions = {},
showlegendElems = true;
, elemOptions = {}
, showlegendElems = true;

// Set showlegendElems variable
// If not defined, or badly defined, revert to TRUE
// Keep default (true) if opt.setLegendElemsState not defined, or badly defined
if (typeof opt != "undefined" && typeof opt.setLegendElemsState === "string") {
showlegendElems = (opt.setLegendElemsState === "hide") ? false : true;
}

// Hide/Show all elements based on showlegendElems
// Toggle (i.e. click) only if:
// - slice legend is shown AND we want to hide
// - slice legend is hidden AND we want to show
$("[data-type='elem']", $(this)).each(function() {
if (($(this).attr('data-hidden') === "0" && showlegendElems === false) ||
($(this).attr('data-hidden') === "1" && showlegendElems === true)) {
// Toggle state of element by clicking
$(this).trigger('click', false);
}
});

if (typeof opt != "undefined") {
(opt.resetAreas) && (options.areas = {});
(opt.resetPlots) && (options.plots = {});
Expand Down Expand Up @@ -392,13 +380,27 @@
}

// Update legends
Mapael.createLegends($self, options, "area", areas, 1);
if (options.map.width) {
Mapael.createLegends($self, options, "plot", plots, (options.map.width / mapConf.width));
} else {
Mapael.createLegends($self, options, "plot", plots, ($container.width() / mapConf.width));
if (typeof updatedOptions != "undefined" && typeof updatedOptions.legend === "object") {
Mapael.createLegends($self, options, "area", areas, 1);
if (options.map.width) {
Mapael.createLegends($self, options, "plot", plots, (options.map.width / mapConf.width));
} else {
Mapael.createLegends($self, options, "plot", plots, ($container.width() / mapConf.width));
}
}

// Hide/Show all elements based on showlegendElems
// Toggle (i.e. click) only if:
// - slice legend is shown AND we want to hide
// - slice legend is hidden AND we want to show
$("[data-type='elem']", $(this)).each(function() {
if (($(this).attr('data-hidden') === "0" && showlegendElems === false) ||
($(this).attr('data-hidden') === "1" && showlegendElems === true)) {
// Toggle state of element by clicking
$(this).trigger('click', false);
}
});

if(typeof opt != "undefined")
opt.afterUpdate && opt.afterUpdate($self, paper, areas, plots, options);
});
Expand Down