Skip to content

Commit f1dc603

Browse files
committed
Iterate on black bar facets
1 parent df508d9 commit f1dc603

File tree

7 files changed

+98
-62
lines changed

7 files changed

+98
-62
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ We've configured the system to build with NPM (no need for gulp or bower).
144144
#### Deploying with NPM
145145
Releases are available via NPM at https://www.npmjs.com/package/ebi-framework
146146

147+
## Developing locally
148+
1. Edit any CSS or JS and build with `npm run scss` or `npm run js`
149+
2. Serve index.html with `jekyll serve --port 99`
150+
3. Open http://127.0.0.1:99/EBI-Framework/
151+
152+
Todo: Run the build process and serve with gulp and browsersync.
153+
147154
## Roadmap
148155
- v1.1: Major update to the 2013 look and functionality
149156
- v1.2: [Major improvements around modularity, structure and visual refinements](https://github.com/ebiwd/EBI-Framework/issues/61)

_includes/footer.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<script defer="defer" src="{{ site.baseurl }}/js/script.js"></script>
2222

2323
<!-- The Foundation theme JavaScript -->
24-
<script src="libraries/foundation-6/js/foundation.js"></script>
24+
<script src="{{ site.baseurl }}/libraries/foundation-6/js/foundation.js"></script>
2525
<script src="{{ site.baseurl }}/js/foundationExtendEBI.js"></script>
2626
<!-- <script src="//www.ebi.ac.uk/web_guidelines/EBI-Framework/v1.2/libraries/foundation-6/js/foundation.js"></script> -->
2727
<!-- <script src="//www.ebi.ac.uk/web_guidelines/EBI-Framework/v1.2/js/foundationExtendEBI.js"></script> -->

_includes/head.html

+13-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@
1010
<meta name="theme-color" content="#70BDBD"> <!-- Android Chrome mobile browser tab color -->
1111

1212
<!-- Add information on the life cycle of this page -->
13-
<meta name="ebi:owner" content="John Doe"> <!-- Who should be contacted about changes -->
14-
<meta name="ebi:review-cycle" content="30"> <!-- In days, how often should the content be reviewed -->
15-
<meta name="ebi:last-review" content="2015-12-20"> <!-- The last time the content was reviewed -->
16-
<meta name="ebi:expiry" content="2016-01-20"> <!-- When this content is no longer relevant -->
13+
<meta name="ebi:owner" content="EMBL-EBI Web Development"> <!-- Who should be contacted about changes -->
14+
<meta name="ebi:review-cycle" content="180"> <!-- In days, how often should the content be reviewed -->
15+
<meta name="ebi:last-review" content="2017-12-20"> <!-- The last time the content was reviewed -->
16+
<meta name="ebi:expiry" content="2018-06-20"> <!-- When this content is no longer relevant -->
17+
18+
<!-- For the EMBL global nav (optional) -->
19+
<meta name="embl:rational" content="{{page.embl_rational}}" />
20+
<meta name="embl:external" content="{{page.embl_external}}" />
21+
<meta name="embl:active" content="{{page.embl_active}}" />
22+
<meta name="embl:parent-1" content="{{page.embl_parent_1}}" />
23+
<meta name="embl:parent-2" content="{{page.embl_parent_2}}" />
1724

1825
<!-- If you link to any other sites frequently, consider optimising performance with a DNS prefetch -->
19-
<link rel="dns-prefetch" href="//ebi.ac.uk" />
26+
<link rel="dns-prefetch" href="https://ebi.ac.uk" />
27+
<link rel="dns-prefetch" href="https://ebi.emblstatic.net" />
2028

2129
<!-- If you have custom icon, replace these as appropriate.
2230
You can generate them at realfavicongenerator.net -->

_layouts/default.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="masthead-inner row">
1010
<!-- local-title -->
1111
<div class="columns medium-7" id="local-title">
12-
<h1><a href="{{ site.domain }}{{ site.baseurl }}" title="Back to {{ site.name }} homepage">{{ page.active_facet }}</a></h1>
12+
<h1><a href="{{ site.domain }}{{ site.baseurl }}" title="Back to {{ site.name }} homepage">{{ page.title }}</a></h1>
1313
</div>
1414
<!-- /local-title -->
1515
<!-- local-nav -->

index-test.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
layout: default
3+
title: Research sample
4+
embl_rational: 0
5+
embl_external: 0
6+
embl_active: "what:research"
7+
embl_parent_1: "where:ebi"
8+
embl_parent_2: "none"
9+
group: "in_local_navigation"
10+
order: 3
11+
---
12+
## Sample research overview page

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: default
33
title: Project home
4-
active_facet: Research
4+
embl_active: Research
55
group: "in_local_navigation"
66
order: 1
77
---

js/ebi-global-includes/script/4_ebiFrameworkContent.js

+63-54
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ function ebiToggleClass(element, toggleClass){
1212
element.className = newClass.trim();
1313
}
1414

15+
/**
16+
* Utility function to add classes (only once).
17+
*/
18+
function ebiActivateClass(element, cssClass){
19+
element.classList.remove(cssClass);
20+
element.classList.add(cssClass);
21+
}
22+
23+
/**
24+
* Utility function to remove classes.
25+
*/
26+
function ebiRemoveClass(element, cssClass){
27+
element.classList.remove(cssClass);
28+
}
29+
1530
/**
1631
* Remove global-nav/global-nav-expanded from header/footer if body.no-global-nav is set
1732
*/
@@ -66,12 +81,12 @@ function ebiFrameworkPopulateBlackBar() {
6681
barContents.innerHTML = '<nav class="row">'+
6782
'<ul id="global-nav" class="menu global-nav text-right">'+
6883
'<li class="home-mobile"><a href="https://www.ebi.ac.uk"></a></li>'+
69-
'<li class="location embl hide"><a href="http://www.embl.org">EMBL</a></li>'+
70-
'<li class="location barcelona hide"><a href="#">Barcelona</a></li>'+
71-
'<li class="location hamburg hide"><a href="#">Hamburg</a></li>'+
72-
'<li class="location grenoble hide"><a href="#">Heidelberg</a></li>'+
73-
'<li class="location grenoble hide"><a href="#">Grenoble</a></li>'+
74-
'<li class="location rome hide"><a href="#">Rome</a></li>'+
84+
'<li class="where embl hide"><a href="http://www.embl.org">EMBL</a></li>'+
85+
'<li class="where barcelona hide"><a href="#">Barcelona</a></li>'+
86+
'<li class="where hamburg hide"><a href="#">Hamburg</a></li>'+
87+
'<li class="where grenoble hide"><a href="#">Heidelberg</a></li>'+
88+
'<li class="where grenoble hide"><a href="#">Grenoble</a></li>'+
89+
'<li class="where rome hide"><a href="#">Rome</a></li>'+
7590
'<li id="embl-selector" class="float-right show-for-medium embl-selector">'+
7691
'<button class="button float-right">&nbsp;</button>'+
7792
'</li>'+
@@ -84,7 +99,7 @@ function ebiFrameworkPopulateBlackBar() {
8499
'<li class="what training"><a href="https://www.ebi.ac.uk/training">Training</a></li>'+
85100
'<li class="what research"><a href="https://www.ebi.ac.uk/research">Research</a></li>'+
86101
'<li class="what services"><a href="https://www.ebi.ac.uk/services">Services</a></li>'+
87-
'<li class="location ebi"><a href="https://www.ebi.ac.uk">EMBL-EBI</a></li>'+
102+
'<li class="where ebi"><a href="https://www.ebi.ac.uk">EMBL-EBI</a></li>'+
88103
// '<li class="float-right embl-selector">'+
89104
// '<a class="button float-right">&nbsp;</a>'+
90105
// '</li>'+
@@ -96,40 +111,42 @@ function ebiFrameworkPopulateBlackBar() {
96111
catch(err) {};
97112
}
98113

114+
/**
115+
* Reusable function to get part of the black bar
116+
*/
117+
function ebiGetFacet(passedAttribute){
118+
var tag = "#masthead-black-bar ." + passedAttribute.toLowerCase();
119+
return document.querySelectorAll(tag)[0];
120+
}
121+
99122
/**
100123
* Active tabs in `#masthead-black-bar` accoriding to metadata
101124
*/
102125
function ebiFrameworkActivateBlackBar() {
103126
// Look at the embl:facet-* meta tags to set active states
104-
// <meta name="embl:facet-who" content="primary" data-tag="Sample group" />
105-
// <meta name="embl:facet-what" content="parent" data-tag="Research" />
106-
// <meta name="embl:facet-where" content="parent" data-tag="EBI" />
127+
// <meta name="embl:rational" content="-3" />
128+
// <meta name="embl:external" content="8" />
129+
// <meta name="embl:active" content="what:*" />
130+
// <meta name="embl:parent-1" content="" />
131+
// <meta name="embl:parent-2" content="" />
107132
try {
108133

109-
function ebiGetFacet(passedAttribute){
110-
var tag = "#masthead-black-bar ." + passedAttribute.toLowerCase();
111-
return document.querySelectorAll(tag)[0];
112-
}
113134
var metas = document.getElementsByTagName('meta');
114135
for (var i = 0; i < metas.length; i++) {
115-
if (metas[i].getAttribute("name") == "embl:facet-who") {
116-
if (metas[i].getAttribute("content").toLowerCase() == "parent") {
117-
var targetFacet = ebiGetFacet(metas[i].getAttribute("data-tag"));
118-
// todo: insert this as a new facet, i think?
119-
}
136+
if (metas[i].getAttribute("name") == "embl:active") {
137+
var targetFacet = ebiGetFacet(metas[i].getAttribute("content").replace(':','.'));
138+
ebiRemoveClass(targetFacet,'hide');
139+
ebiActivateClass(targetFacet,'active');
120140
}
121-
if (metas[i].getAttribute("name") == "embl:facet-what") {
122-
if (metas[i].getAttribute("content").toLowerCase() == "parent") {
123-
var targetFacet = ebiGetFacet(metas[i].getAttribute("data-tag"));
124-
ebiToggleClass(targetFacet,'active');
125-
}
141+
if (metas[i].getAttribute("name") == "embl:parent-1") {
142+
var targetFacet = ebiGetFacet(metas[i].getAttribute("content").replace(':','.'));
143+
ebiRemoveClass(targetFacet,'hide');
144+
ebiActivateClass(targetFacet,'active');
126145
}
127-
if (metas[i].getAttribute("name") == "embl:facet-where") {
128-
if (metas[i].getAttribute("content").toLowerCase() == "parent") {
129-
var targetFacet = ebiGetFacet(metas[i].getAttribute("data-tag"));
130-
ebiToggleClass(targetFacet,'active');
131-
ebiToggleClass(targetFacet,'hide'); // as we hide these by default
132-
}
146+
if (metas[i].getAttribute("name") == "embl:parent-2") {
147+
var targetFacet = ebiGetFacet(metas[i].getAttribute("content").replace(':','.'));
148+
ebiRemoveClass(targetFacet,'hide');
149+
ebiActivateClass(targetFacet,'active');
133150
}
134151
}
135152

@@ -225,34 +242,26 @@ function ebiFrameworkInsertEMBLdropdown() {
225242
window.scrollTo(0, 0);
226243
}, false);
227244

228-
// we do this bit with jquery to prototype, would need ro rewire as vanilla JS..
229-
$('#masthead-black-bar .where.active').on('mouseover', function() {
230-
emblResetContext(); // clear any other states
231-
$('#masthead-black-bar .where.hide').addClass('hover').removeClass('hide');
245+
// we do this bit with jquery to prototype; need to rewire as vanilla JS.
246+
ebiGetFacet('where.active').addEventListener("mouseenter", function( event ) {
247+
$('#masthead-black-bar .where.hide').addClass('hover float-left').removeClass('hide');
232248
// $('#masthead-black-bar .where.hide').removeClass('hide').addClass('hover');
233249
$('#masthead-black-bar .what').addClass('hide');
234-
});
235-
$('#masthead-black-bar .what.active').on('mouseover', function() {
236-
emblResetContext(); // clear any other states
237-
$('#masthead-black-bar .what.mission').removeClass('hide');
238-
$('#masthead-black-bar .what').addClass('hover');
239-
});
240-
250+
}, false);
251+
ebiGetFacet('what.active').addEventListener("mouseenter", function( event ) {
252+
$('#masthead-black-bar .what').removeClass('hide float-left');
253+
$('#masthead-black-bar .what').addClass('hover float-left');
254+
$('#masthead-black-bar .where').addClass('hide');
255+
}, false);
241256

242-
// reset when user engages with content
243-
function emblResetContext() {
244-
// ebiFrameworkActivateBlackBar();
245-
$('#masthead-black-bar .where.hover').removeClass('hover').addClass('hide');
257+
// reset black bar contenxts when mousing out
258+
blackBar.addEventListener("mouseleave", function( event ) {
259+
console.log('purged');
260+
$('#masthead-black-bar .hover').removeClass('hover float-left');
246261
$('#masthead-black-bar .what').removeClass('hide');
247-
$('#masthead-black-bar .what.mission').addClass('hide');
248-
$('#masthead-black-bar .what.hover').removeClass('hover');
249-
250-
// reset everything on the next mouse into content
251-
$('#content').one('mouseover', function() {
252-
console.log('purged');
253-
emblResetContext();
254-
});
255-
}
262+
$('#masthead-black-bar .where').addClass('hide');
263+
ebiFrameworkActivateBlackBar();
264+
});
256265

257266
}
258267
catch(err) {};

0 commit comments

Comments
 (0)