");
} else {
$('#queryResults').empty();
$('#export_buttons').addClass("hide");
$('#mapButtons').addClass("hide");
$('.stateContent').empty();
$('.stateHeading').append(' | No law');
$(".timeline-tab").addClass("hide");
}
}
});
}
function populateQueryResults(dataset, stateQueryResult, getAnswers) {
$.ajax({
url: monocle_host + 'questions/' + dataset,
method: 'GET',
data: JSON.stringify(queryJson),
success: function (result) {
questions = JSON.parse(result);
getAnswers(questions, stateQueryResult);
}
});
}
function populateStateClicksTab(){
if(!map){
profile_loaded = true;
map = new Datamap({
element: document.getElementById('container'),
scope: 'usa',
responsive: true,
fills: {
defaultFill: '#FFFFFF' //any hex, color name or rgb/rgba value
},
geographyConfig: {
popupOnHover: false,
highlightFillColor: '#D1E0E0',
highlightBorderColor: '#000000',
borderColor: '#000000',
},
done: function (datamap) {
}
});
window.addEventListener('resize', function() {
map.resize();
});
map.addPlugin('clickLabels', function (layer, options) {
var options = options;
function stateClick(d, self) {
self.svg.selectAll('.datamaps-subunit').attr('data-click', 0)
self.svg.selectAll('path.datamaps-subunit')
.style('fill', '#FFFFFF')
.style('stroke', '#000000')
.attr('data-click', 0);
var $this = self.svg.select('path.datamaps-subunit.' + d.id);
$this.style('fill', options.clickedColor || '#00FF00'); // clicked fill color
$this.attr('data-click', 1);
options.click(d) || null;
};
var self = this;
options = options || {};
var labelStartCoodinates = this.projection([-67.707617, 42.722131]);
self.svg.selectAll('.datamaps-subunit').attr('data-click', 0);
self.svg.selectAll('.datamaps-subunit')
.on(clickEvent, function (geography) {
stateClick(geography, self);
})
.on(mouseOutEvent, function (geography) {
var $this = self.svg.select('path.datamaps-subunit.' + geography.id);
var previousAttributes = JSON.parse($this.attr('data-previousAttributes'));
for (var attr in previousAttributes) {
$this.style(attr, previousAttributes[attr]);
}
if ($this.attr('data-click') == 1) {
$this.style('fill', options.clickedColor || '#00FF00')
.style("stroke-width", 1)
}
});
self.svg.selectAll(".datamaps-subunit")
.attr("data-foo", function (d) {
var center = self.path.centroid(d);
var xOffset = 7.5,
yOffset = 5;
if (["FL", "KY", "MI"].indexOf(d.id) > -1) xOffset = -2.5;
if (d.id === "NY") xOffset = -1;
if (d.id === "MI") yOffset = 18;
if (d.id === "LA") xOffset = 13;
var x, y;
x = center[0] - xOffset;
y = center[1] + yOffset;
var smallStateIndex = ["VT", "NH", "MA", "RI", "CT", "NJ", "DE", "MD", "DC"].indexOf(d.id);
if (smallStateIndex > -1) {
var yStart = labelStartCoodinates[1];
x = labelStartCoodinates[0];
y = yStart + (smallStateIndex * (2 + (options.fontSize || 12)));
layer.append("line")
.attr("x1", x - 3)
.attr("y1", y - 5)
.attr("x2", center[0])
.attr("y2", center[1])
.style("stroke", options.labelColor || "#000")
.style("stroke-width", options.lineWidth || 1)
}
layer.append("text")
.attr("x", x)
.attr("y", y)
.style("font-size", options.fontSize || 10)
.style("font-family", options.fontFamily || "Verdana")
.style("fill", options.labelColor || "#000")
.text(d.id).on("mouseover", function () {
var $this = self.svg.select('path.datamaps-subunit.' + d.id); // select the path for this current hover over state label
var previousAttributes = {
'fill': $this.style('fill'),
'stroke': $this.style('stroke'),
'stroke-width': $this.style('stroke-width'),
'fill-opacity': $this.style('fill-opacity')
};
$this
.style('fill', self.options.geographyConfig.highlightFillColor)
.style('stroke', self.options.geographyConfig.highlightBorderColor)
.attr('data-previousAttributes', JSON.stringify(previousAttributes))
.attr('data-click', 0);
})
.on(clickEvent, function () {
stateClick(d, self);
})
.on(mouseOutEvent, function () {
var $this = self.svg.select('path.datamaps-subunit.' + d.id); // select the path for this current hover over state label
if ($this.attr('data-click') != 1) {
var previousAttributes = JSON.parse($this.attr('data-previousAttributes'));
for (var attr in previousAttributes) {
$this.style(attr, previousAttributes[attr]);
}
}
$this.on('mousemove', null);
})
.on(mouseMoveEvent, function () {
d3.select("body").style("cursor", "default");
var element = self.svg.select('path.datamaps-subunit.' + d.id);
var options = self.options.geographyConfig;
var position = d3.mouse(this);
var svg = self.svg;
})
});
});
map.clickLabels({
clickedColor: '#A3C2C2',
click: mapClick
});
} else {
if(map_current_select !== undefined){
var currentsState = [map_current_select];
}
}
}
function populateQuestionAnswersTab(use_lawatlas){
if(map2_current_selects !== undefined){
highlightStates(map2_current_selects, map2);
}
if(typeof questions_loaded === 'undefined'){
questions_loaded = false;
}
if(!questions_loaded){
questions_loaded = true;
if(use_lawatlas){
qurl = '/query_form?dataset=' + dataset_name + '&display_id=' + $("#form_id").val() + '&use_lawatlas=true';
} else {
qurl = '/query_form?dataset=' + dataset_name + '&display_id=' + $("#form_id").val();
}
$("#query_form").load(qurl, function() {
$("#query_form").find(".collapse").show(); //removeClass("collapse");
$(".filter-parent").change(function() {
try {
parentObj = $(this).parentsUntil(".parent-question").parent();
openMyFormChildren($(this), $(parentObj), ".child-question");
} catch(err)
{
alert(err);
}
});
$(".filter-child").change(function() {
try {
parentObj = $(this).parentsUntil(".child-question").parent();
openMyFormChildren($(this), $(parentObj), ".grandchild-question");
} catch(err)
{
alert(err);
}
});
function openMyFormChildren(changeWhatObject, right_parent, child_class, toggle)
{
try
{
if(toggle)
{
if($(right_parent).find(child_class).is(":visible"))
{
$(right_parent).find(child_class).slideUp();
}
else
{
$(right_parent).find(child_class).slideDown();
}
}
else
{
if($(changeWhatObject).val()=="Yes")
{
$(right_parent).find(child_class).slideDown();
}
else if($(changeWhatObject).val()=="No")
{
$(right_parent).find(child_class).slideUp();
}
else if($(changeWhatObject).val()=="true")
{
$(right_parent).find(child_class).slideDown();
}
else if($(changeWhatObject).val()=="false")
{
$(right_parent).find(child_class).slideUp();
}
else if($(changeWhatObject).val()=="1")
{
$(right_parent).find(child_class).slideDown();
}
else if($(changeWhatObject).val()=="0")
{
$(right_parent).find(child_class).slideUp();
}
else if($(changeWhatObject).val()=="")
{
$(right_parent).find(child_class).slideUp();
}
else if($(changeWhatObject).val()==undefined)
{
alert($(changeWhatObject).val());
$(right_parent).find(child_class).slideUp();
}
else
{
$(right_parent).find(child_class).slideDown();
}
}
}
catch(err)
{
alert(err);
}
};
$('[title]').tooltip({placement:'auto'});
if($("#form_end_year").val() != ''){
var s_year = 2000;
if($("#form_start_year").val() != ''){
s_year = parseInt($("#form_start_year").val());
}
$("#SliderInput").slider({
min: s_year,
max : parseInt($("#form_end_year").val()),
value : parseInt($("#form_end_year").val())
});
$("#SliderVal").text($("#form_end_year").val());
$("#StartYear").val($("#form_end_year").val());
} else {
var d = new Date();
var year = d.getFullYear();
$("#SliderInput").slider({
min: 2000,
max : year,
value : year
});
$("#SliderVal").text(year);
$("#StartYear").val($("#SliderInput").val());
}
$("#SliderInput").on("slideStop", function(slideEvt) {
$("#SliderVal").text(slideEvt.value);
$("#StartYear").val(slideEvt.value);
startedQuerying = true;
submitQueryForm($("#filter-map-form"));
});
$("#filter-map-form").on("change", function(){
startedQuerying = true;
submitQueryForm($(this));
});
$("a.filter-map-control-radio").on("click", function(){
$("."+$(this).data("class")).prop('checked', false);
$("."+$(this).data("class")).removeClass("active");
$("#"+$(this).data("id")).prop('checked', true);
$(this).addClass("active");
if($(this).hasClass("filter-parent")){
try {
parentObj = $(this).parentsUntil(".parent-question").parent();
if($(this).data("value") === "No" || $(this).data("value") === "0" || $(this).data("value") === 0)
{
$(parentObj).find(".child-question").hide();
} else {
$(parentObj).find(".child-question").show();
}
} catch(err)
{
alert(err);
}
} else if($(this).hasClass("filter-child")){
try {
parentObj = $(this).parentsUntil(".parent-question").parent();
if($(this).data("value") === "No" || $(this).data("value") === "0" || $(this).data("value") === 0)
{
$(parentObj).find(".grandchild-question").hide();
} else {
$(parentObj).find(".grandchild-question").show();
}
} catch(err)
{
alert(err);
}
} else {
}
startedQuerying = true;
submitQueryForm($("#filter-map-form"));
});
$("a.filter-map-control-checkbox").on("click", function(){
if($(this).hasClass("active"))
{
$("#"+$(this).data("id")).prop('checked', false);
$(this).removeClass("active");
} else {
$("#"+$(this).data("id")).prop('checked', true);
$(this).addClass("active");
}
if($(this).hasClass("filter-parent")){
try {
parentObj = $(this).parentsUntil(".parent-question").parent();
if($(this).data("value") === "No")
{
$(parentObj).find(".child-question").hide();
} else {
$(parentObj).find(".child-question").show();
}
} catch(err)
{
alert(err);
}
} else if($(this).hasClass("filter-child")){
try {
parentObj = $(this).parentsUntil(".parent-question").parent();
if($(this).data("value") === "No")
{
$(parentObj).find(".grandchild-question").hide();
} else {
$(parentObj).find(".grandchild-question").show();
}
} catch(err)
{
alert(err);
}
} else {
}
startedQuerying = true;
submitQueryForm($("#filter-map-form"));
});
in_edit_mode = sessionStorage.getItem('in_edit_mode');
if(in_edit_mode == "true"){ //can't edit LawAtlas previews, must use LawAtlas
$(".show_on_editor").removeClass("hide");
}
$(".show_on_editor").on("click", function(){
remove_slug = $(this).data("slug");
$("."+remove_slug).hide();
});
$(".clear-question").on("click", function(){
clearInputs($(this).data("question"));
$('.'+$(this).data("class")).removeClass("active");
});
$("#btnShowTable").on("click", function(){
$("#tblModal").modal('show');
});
map2 = new Datamap({
element: document.getElementById('query_map'),
responsive: true,
height: 300,
scope: 'usa',
fills: {
defaultFill: '#FFFFFF'
},
geographyConfig: {
highlightFillColor: '#C5CAE9',
highlightBorderColor: '#000000',
borderColor: '#000000',
},
done: function (datamap) {
}
});
map2.addPlugin('clickLabels', function (layer, options) {
var options = options;
var d3div = d3.select('#query_map');
function stateClick(d, self) {
self.svg.selectAll('.datamaps-subunit').attr('data-click', 0)
self.svg.selectAll('path.datamaps-subunit')
.style('fill', '#FFFFFF')
.style('stroke', '#000000')
.attr('data-click', 0);
var $this = self.svg.select('path.datamaps-subunit.' + d.id);
$this.style('fill', options.clickedColor || '#00FF00'); // clicked fill color
$this.attr('data-click', 1);
options.click(d) || null;
};
var self = this;
options = options || {};
var labelStartCoodinates = this.projection([-67.707617, 42.722131]);
self.svg.selectAll('.datamaps-subunit').attr('data-click', 0); // set all to unclicked
self.svg.selectAll('.datamaps-subunit')
.on('click', function (geography) {
})
.on('mouseout', function (geography) {
var $this = self.svg.select('path.datamaps-subunit.' + geography.id); // select the path for this current hover over state label
var previousAttributes = JSON.parse($this.attr('data-previousAttributes'));
for (var attr in previousAttributes) {
$this.style(attr, previousAttributes[attr]);
}
if ($this.attr('data-click') == 1) {
$this.style('fill', options.clickedColor || '#00FF00')
.style("stroke-width", 1)
}
});
self.svg.selectAll(".datamaps-subunit")
.attr("data-foo", function (d) {
var center = self.path.centroid(d);
var xOffset = 7.5,
yOffset = 5;
if (["FL", "KY", "MI"].indexOf(d.id) > -1) xOffset = -2.5;
if (d.id === "NY") xOffset = -1;
if (d.id === "MI") yOffset = 18;
if (d.id === "LA") xOffset = 13;
var x, y;
x = center[0] - xOffset;
y = center[1] + yOffset;
var smallStateIndex = ["VT", "NH", "MA", "RI", "CT", "NJ", "DE", "MD", "DC"].indexOf(d.id);
if (smallStateIndex > -1) {
var yStart = labelStartCoodinates[1];
x = labelStartCoodinates[0];
y = yStart + (smallStateIndex * (2 + (options.fontSize || 12)));
layer.append("line")
.attr("x1", x - 3)
.attr("y1", y - 5)
.attr("x2", center[0])
.attr("y2", center[1])
.style("stroke", options.labelColor || "#000")
.style("stroke-width", options.lineWidth || 1)
}
layer.append("text")
.attr("x", x)
.attr("y", y)
.style("font-size", options.fontSize || 8)
.style("font-family", options.fontFamily || "Verdana")
.style("fill", options.labelColor || "#000")
.text(d.id).on("mouseover", function () {
var $this = self.svg.select('path.datamaps-subunit.' + d.id); // select the path for this current hover over state label
var previousAttributes = {
'fill': $this.style('fill'),
'stroke': $this.style('stroke'),
'stroke-width': $this.style('stroke-width'),
'fill-opacity': $this.style('fill-opacity')
};
$this
.style('fill', self.options.geographyConfig.highlightFillColor)
.style('stroke', self.options.geographyConfig.highlightBorderColor)
.attr('data-previousAttributes', JSON.stringify(previousAttributes))
.attr('data-click', 0);
})
.on("click", function () {
})
.on('mouseout', function () {
var $this = self.svg.select('path.datamaps-subunit.' + d.id); // select the path for this current hover over state label
if ($this.attr('data-click') != 1) {
var previousAttributes = JSON.parse($this.attr('data-previousAttributes'));
for (var attr in previousAttributes) {
$this.style(attr, previousAttributes[attr]);
}
}
$this.on('mousemove', null);
})
.on('mousemove', function () {
d3.select("body").style("cursor", "default");
var element = self.svg.select('path.datamaps-subunit.' + d.id);
var options = self.options.geographyConfig;
var position = d3.mouse(this);
var svg = self.svg;
})
});
});
map2.clickLabels({
clickedColor: '#A3C2C2',
click: mapClick
});
$('#query_map_wrapper').affix({
offset: {
top: 245,
bottom: 480
}
});
var $body = $(document.body);
var navHeight = $('.navbar-collapse').outerHeight(true) + 80;
$body.scrollspy({
target: '#affix_wrapper',
offset: navHeight
});
});
} else {
}
}
function populateTimelineTab(){
$(".timeline-header-title").html(currentState);
if(stateQueryResult_alltime !== undefined)
{
var line_item = "";
$.each(stateQueryResult_alltime, function(i, row){
if( row.is_deleted != "1")
{
if(i % 2 == 0)
{
line_item_class = "";
badge_class = "info";
} else {
line_item_class = "timeline-inverted";
badge_class = "warning";
}
if( (stateQueryResult_alltime.length - 1) == i)
{
body = 'End
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem dolorem quibusdam, tenetur commodi provident cumque magni voluptatem libero, quis rerum. Fugiat esse debitis optio, tempore. Animi officiis alias, officia repellendus.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laudantium maiores odit qui est tempora eos, nostrum provident explicabo dignissimos debitis vel! Adipisci eius voluptates, ad aut recusandae minus eaque facere.
';
} else {
body = '
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem dolorem quibusdam, tenetur commodi provident cumque magni voluptatem libero, quis rerum. Fugiat esse debitis optio, tempore. Animi officiis alias, officia repellendus.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laudantium maiores odit qui est tempora eos, nostrum provident explicabo dignissimos debitis vel! Adipisci eius voluptates, ad aut recusandae minus eaque facere.
';
}
year = getYearFromDate(row.ObsDate.sec);
title = getFormattedDate(row.ObsDate.sec);
decoded = $('').html(row.ObsLaw).text();
decoded_log = $('').html(row.ObsLog).text();
if(decoded_log){
body = unescape(decoded_log);
has_law = true;
if(body == '')
{
has_law = false;
}
if (!has_law){
body = "No law";
} else {
title += '';
}
line_item += '