Skip to content
Snippets Groups Projects
Commit adb3a1b3 authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Much more concise pubdatevis colors JS.

Giving into stubbornness against including another element on the page.
parent 9f5eec26
No related merge requests found
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -236,7 +236,7 @@ footer { ...@@ -236,7 +236,7 @@ footer {
/* --- PubDateVis --- */ /* --- PubDateVis --- */
#dateVisColorSettings { #dateVisColorSettings {
background: #ffffff; // background of box background-color: #fff; // background of box
fill: rgb(234,234,234); // fillColor fill: rgb(234,234,234); // fillColor
outline-color: #e8cfac; // selection color outline-color: #e8cfac; // selection color
stroke: @brand-primary; // color stroke: @brand-primary; // color
......
...@@ -589,7 +589,7 @@ label.list-group-item { ...@@ -589,7 +589,7 @@ label.list-group-item {
} }
/* --- PubDateVis --- */ /* --- PubDateVis --- */
#dateVisColorSettings { #dateVisColorSettings {
background: #ffffff; background-color: #ffffff;
fill: #eaeaea; fill: #eaeaea;
outline-color: #e8cfac; outline-color: #e8cfac;
stroke: #265680; stroke: #265680;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -20,26 +20,15 @@ function PadDigits(n, totalDigits) ...@@ -20,26 +20,15 @@ function PadDigits(n, totalDigits)
function loadVis(facetFields, searchParams, baseURL, zooming) { function loadVis(facetFields, searchParams, baseURL, zooming) {
// Get colors from CSS // Get colors from CSS
var cssColorSettings = { var cssColorSettings = {
'background': '#ffffff', // background of box 'background-color': '#ffffff', // background of box
'fill': 'rgb(234,234,234)', // fillColor 'fill': 'rgb(234,234,234)', // fillColor
'outline-color': '#e8cfac', // selection color 'outline-color': '#e8cfac', // selection color
'stroke': '#265680' // color 'stroke': '#265680' // color
} }
var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules; var $dateVisColorSettings = $('#dateVisColorSettings');
for(var i=classes.length;i--;) { for(var rule in cssColorSettings) {
if(classes[i].selectorText == '#dateVisColorSettings') { if($dateVisColorSettings.css(rule)) {
// Get rule definition cssColorSettings[rule] = $dateVisColorSettings.css(rule).match(/rgb[a]?\([^\)]+\)|#[a-fA-F0-9]+/)[0];
rules = classes[i].cssText ? classes[i].cssText : classes[i].style.cssText;
rules = rules.match(/\{\s*([^\}]*)/);
rules = rules[1].split(/;\s*/);
// Extract colors
for(var j=rules.length;j--;) {
var parts = rules[j].split(/\s*:\s*/);
if(parts.length > 1) {
cssColorSettings[parts[0]] = parts[1].match(/rgb[a]?\([^\)]+\)|#[a-fA-F0-9]+/)[0];
}
}
break;
} }
} }
// options for the graph, TODO: make configurable // options for the graph, TODO: make configurable
...@@ -57,7 +46,7 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { ...@@ -57,7 +46,7 @@ function loadVis(facetFields, searchParams, baseURL, zooming) {
xaxis: { tickDecimals: 0 }, xaxis: { tickDecimals: 0 },
yaxis: { min: 0, ticks: [] }, yaxis: { min: 0, ticks: [] },
selection: {mode: "x", color: cssColorSettings['outline-color']}, selection: {mode: "x", color: cssColorSettings['outline-color']},
grid: { backgroundColor: cssColorSettings['background'] } grid: { backgroundColor: cssColorSettings['background-color'] }
}; };
// AJAX call // AJAX call
......
...@@ -190,7 +190,7 @@ label.list-group-item {border-radius:0;font-weight:normal;margin-top:0;padding-l ...@@ -190,7 +190,7 @@ label.list-group-item {border-radius:0;font-weight:normal;margin-top:0;padding-l
/* --- PubDateVis --- */ /* --- PubDateVis --- */
#dateVisColorSettings { #dateVisColorSettings {
background: #ffffff; // background of box background-color: #fff; // background of box
fill: rgb(234,234,234); // fillColor fill: rgb(234,234,234); // fillColor
outline-color: #e8cfac; // selection color outline-color: #e8cfac; // selection color
stroke: @brand-primary; // color stroke: @brand-primary; // color
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
</div> </div>
</div> </div>
<? endforeach; ?> <? endforeach; ?>
<div id="dateVisColorSettings"></div>
<? <?
$js = "loadVis('" . $this->recommend->getFacetFields() . "', '" $js = "loadVis('" . $this->recommend->getFacetFields() . "', '"
. $this->recommend->getSearchParams() . "', path, " . $this->recommend->getSearchParams() . "', path, "
......
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