Commit 50d77142 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

legend doesn't use jsf anymore

parent 618a4e27
......@@ -2,8 +2,9 @@
var ConfigurationType = {
DEFAULT_MAP : "DEFAULT_MAP",
LOGO_IMG : "LOGO_IMG",
LOGO_IMG : "LOGO_IMG",
LOGO_LINK : "LOGO_LINK",
LEGEND_FILES : "LEGEND_FILES",
};
module.exports = ConfigurationType;
......@@ -202,4 +202,22 @@ Functions.overlayToColor = function(elementOverlay) {
}
};
Functions.getElementByName = function(element, name) {
if (element !== undefined) {
if (element.getAttribute("name") === name) {
return element;
}
var children = element.children;
for (var i = 0; i < children.length; i++) {
var child = children[i];
var res = this.getElementByName(child, name);
if (res !== undefined) {
return res;
}
}
}
return undefined;
};
module.exports = Functions;
......@@ -104,20 +104,6 @@ GuiConnector.getImgPrefix = function() {
return "resources/images/";
};
/**
* Shows legend.
*/
GuiConnector.showLegend = function() {
document.getElementById(ServerConnector.formIdentifier + ':legend').style.display = "block";
};
/**
* Hides legend.
*/
GuiConnector.hideLegend = function() {
document.getElementById(ServerConnector.formIdentifier + ':legend').style.display = "none";
};
/**
* Hides right click menu.
*/
......
......@@ -571,7 +571,7 @@ ServerConnector.getConfigurationParam = function(paramId) {
var self = this;
return new Promise(function(resolve, reject) {
if (paramId === undefined) {
reject("Invalid param identifier");
reject(new Error("Invalid param identifier"));
} else if (self._configurationParam[paramId] !== undefined) {
resolve(self._configurationParam[paramId]);
} else {
......@@ -585,8 +585,22 @@ ServerConnector.getConfigurationParam = function(paramId) {
var value = conf.value;
self._configurationParam[type] = value;
}
self._configurationParam[ConfigurationType.LEGEND_FILES] = [];
if (self._configurationParam["LENGEND_FILE_1"]!==undefined) {
self._configurationParam[ConfigurationType.LEGEND_FILES].push(self._configurationParam["LENGEND_FILE_1"]);
}
if (self._configurationParam["LENGEND_FILE_2"]!==undefined) {
self._configurationParam[ConfigurationType.LEGEND_FILES].push(self._configurationParam["LENGEND_FILE_2"]);
}
if (self._configurationParam["LENGEND_FILE_3"]!==undefined) {
self._configurationParam[ConfigurationType.LEGEND_FILES].push(self._configurationParam["LENGEND_FILE_3"]);
}
if (self._configurationParam["LENGEND_FILE_4"]!==undefined) {
self._configurationParam[ConfigurationType.LEGEND_FILES].push(self._configurationParam["LENGEND_FILE_4"]);
}
if (self._configurationParam[paramId] === undefined) {
reject("Cannot find param config: " + paramId);
reject(new Error("Cannot find param config: " + paramId));
}
resolve(self._configurationParam[paramId]);
});
......
......@@ -354,27 +354,7 @@ CustomMap.prototype.createMapMenu = function() {
submenuDiv.appendChild(commentCheckbox);
submenuDiv.appendChild(element);
var submenuButtonDiv = document.createElement('input');
submenuButtonDiv.type = "checkbox";
submenuButtonDiv.name = "Legend";
submenuButtonDiv.id = "lengend_checkbox";
submenuButtonDiv.onclick = (function() {
var selfButton = submenuButtonDiv;
return function() {
if (selfButton.checked) {
GuiConnector.showLegend();
} else {
GuiConnector.hideLegend();
}
};
})();
element = document.createElement('label');
element.innerHTML = "LEGEND";
element.setAttribute("for", "lengend_checkbox");
submenuDiv.appendChild(submenuButtonDiv);
submenuDiv.appendChild(element);
submenuButtonDiv = document.createElement('button');
var submenuButtonDiv = document.createElement('button');
submenuButtonDiv.id = "refresh_comments_button";
submenuButtonDiv.innerHTML = "<i class='fa fa-refresh' style='font-size:21px; font-weight:400;'></i>";
submenuButtonDiv.className = "overview_button";
......
......@@ -6,6 +6,7 @@ var AbstractDbOverlay = require('./map/overlay/AbstractDbOverlay');
var ChemicalDbOverlay = require('./map/overlay/ChemicalDbOverlay');
var ChemicalPanel = require('./gui/ChemicalPanel');
var CommentDbOverlay = require('./map/overlay/CommentDbOverlay');
var ConfigurationType = require('./ConfigurationType');
var ControlType = require('./map/ControlType');
var CustomMap = require('./map/CustomMap');
var DrugDbOverlay = require('./map/overlay/DrugDbOverlay');
......@@ -87,6 +88,45 @@ function restoreMiRnaQuery(customMap) {
}
}
function createLegendIndicator(file, index) {
var result = document.createElement("li");
result.setAttribute("data-target", "legend");
result.setAttribute("data-slide-to", ""+index);
if (index ===0) {
result.className="active";
}
return result;
}
function createLegendSlide(file, index) {
var result = document.createElement("div");
if (index ===0) {
result.className="item active";
} else {
result.className="item";
}
var img = document.createElement("img");
img.src = file;
result.appendChild(img);
return result;
}
function createLegend(element) {
return new Promise(function(resolve,reject){
var menu = functions.getElementByName(element,"indicators");
var slides = functions.getElementByName(element,"slides");
ServerConnector.getConfigurationParam(ConfigurationType.LEGEND_FILES).then(function(legendFiles){
for (var i=0; i<legendFiles.length;i++) {
var legendFile = legendFiles[i];
menu.appendChild(createLegendIndicator(legendFile, i));
slides.appendChild(createLegendSlide(legendFile, i));
}
$(element).carousel();
resolve();
}).catch(reject);
});
}
function create(params) {
var project = params.project;
if (project===undefined) {
......@@ -196,7 +236,16 @@ function create(params) {
}).then(function(){
return restoreMiRnaQuery(result);
}).then(function(){
return createLegend(document.getElementById("legend"));
}).then(function(){
document.getElementsByName("legendCheckbox")[0].onclick = function(){
var legend = document.getElementById("legend");
if (this.checked) {
legend.style.display="block";
} else {
legend.style.display="none";
}
};
if (ServerConnector.getSessionData().getShowComments()) {
result.getControl(ControlType.COMMENT_CHECKBOX).checked=true;
return result.refreshComments();
......@@ -223,7 +272,6 @@ function create(params) {
// when I try to hide legend from the beginning or in the same thread it's
// hidden forever... ;/
setTimeout(function() {
GuiConnector.hideLegend();
var submodelId = GuiConnector.getParams["submap"];
if (submodelId !== undefined) {
ServerConnector.createSubmodelDialog(submodelId);
......
......@@ -144,6 +144,38 @@ Helper.prototype.createSubmapTab = function() {
return result;
};
Helper.prototype.createMenuDiv = function() {
var result = document.createElement("div");
result.id = "menuDiv";
var legendCheckbox = document.createElement("input");
legendCheckbox.setAttribute("type", "checkbox");
legendCheckbox.setAttribute("name", "legendCheckbox");
result.appendChild(legendCheckbox);
return result;
};
Helper.prototype.createLegendDiv = function() {
var result = document.createElement("div");
result.id = "legend";
result.className= "carousel slide legendBox";
result.setAttribute("data-ride","carousel");
var indicators = document.createElement("div");
indicators.className= "carousel-indicators";
indicators.setAttribute("name", "indicators");
result.appendChild(indicators);
var slides = document.createElement("div");
slides.className= "carousel-inner";
slides.setAttribute("name", "slides");
slides.setAttribute("role", "listbox");
result.appendChild(slides);
return result;
};
Helper.prototype.createOverlayTab = function() {
var result = document.createElement("div");
result.id = "overlayTab";
......
......@@ -38,6 +38,12 @@ describe('minerva global', function() {
global.submapTab = helper.createSubmapTab();
document.body.appendChild(global.submapTab);
global.legendDiv = helper.createLegendDiv();
document.body.appendChild(global.legendDiv);
global.menuDiv = helper.createMenuDiv();
document.body.appendChild(global.menuDiv);
});
afterEach(function() {
......@@ -48,6 +54,8 @@ describe('minerva global', function() {
document.body.removeChild(global.overlayTab);
document.body.removeChild(global.userTab);
document.body.removeChild(global.submapTab);
document.body.removeChild(global.legendDiv);
document.body.removeChild(global.menuDiv);
});
it('create', function() {
......
......@@ -8,21 +8,6 @@
<h:outputStylesheet library="css" name="map.css"/>
<h:form id="_gmapForm">
<p:galleria id="legend" styleClass="legendBox" panelWidth="600" panelHeight="480">
<h:panelGroup layout="block" rendered ="#{not empty configurationMB.legendFile1}">
<img src="#{configurationMB.legendFile1}" alt="legend 1/4"/>
</h:panelGroup>
<h:panelGroup layout="block" rendered ="#{not empty configurationMB.legendFile2}">
<img src="#{configurationMB.legendFile2}" alt="legend 2/4"/>
</h:panelGroup>
<h:panelGroup layout="block" rendered ="#{not empty configurationMB.legendFile3}">
<img src="#{configurationMB.legendFile3}" alt="legend 3/4"/>
</h:panelGroup>
<h:panelGroup layout="block" rendered ="#{not empty configurationMB.legendFile4}">
<img src="#{configurationMB.legendFile4}" alt="legend 4/4"/>
</h:panelGroup>
</p:galleria>
<p:contextMenu id="contextMenu" model="#{exportMB.contextMenu}" />
<p:contextMenu id="selectionContextMenu" model="#{exportMB.imageExportMenu}" />
......
......@@ -33,8 +33,7 @@
<security:intercept-url pattern="/api**" access="permitAll"/>
<security:intercept-url pattern="/api/**" access="permitAll"/>
<security:intercept-url pattern="/api2**" access="permitAll"/>
<security:intercept-url pattern="/api2/**" access="permitAll"/>
<security:intercept-url pattern="/fonts/**" access="permitAll"/>
<security:intercept-url pattern="/**" access="isAuthenticated()"/>
......
......@@ -102,6 +102,26 @@
<servlet-name>default</servlet-name>
<url-pattern>*.pdf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.ttf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.svg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.eot</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.woff</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.woff2</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -115,7 +115,30 @@ function initMap(){
</div>
<div style="display: table-cell;height:100%;width:100%;">
<div id="menuDiv" style="background-color:#ff0000;float:left;width:100%;height:30px ">
<input type="checkbox" name ="legendCheckbox" />
<label for ="legendCheckbox" >LEGEND</label>
</div>
<div id="mapElement" class="mapClass"/>
<div id="legend" class="carousel slide legendBox" style="display:none">
<ol name="indicators" class="carousel-indicators">
</ol>
<div name="slides" class="carousel-inner" role="listbox">
</div>
<!-- Controls -->
<a class="left carousel-control" href="#legend" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#legend" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<ui:include src="/WEB-INF/components/map/map.xhtml" />
......
.legendBox {
position: absolute;
bottom: 10px;
right:10px;
box-shadow:0 3px 20px #999999;
border-top:6px solid #017DA7;
padding-top:15px;
};
.searchPanel {
height: 100%;
background-color: #FFFFFF;
......@@ -111,4 +120,4 @@
.tt-suggestion.tt-cursor {
color: #fff;
background-color: #0097cf;
}
\ No newline at end of file
}
......@@ -1117,9 +1117,6 @@ input[type=file] {width:280px !important; top:15px !important;}
.tabNavigation a i { padding-top:4px;font-size:13px; opacity:1;transition: opacity 0.4s ease-in-out 0s;}
.tabNavigation a:hover i {opacity:0.5;transition:opacity 0.4s ease-in-out 0s;}
.legendBox {position: absolute !important; bottom: 10px !important; right:10px !important; box-shadow:0 3px 20px #999999; border-top:6px solid #017DA7; padding-top:15px;}
#content p span {font-weight:400}
.overviewContainerClass {width:100%; height:100%;}
......
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