Commit 5097eece authored by Pat Kira's avatar Pat Kira Committed by Cecilia Vela Gurovic
Browse files

Bug 1657565 - Configurable theme new navigation

- Updated configurable customcss.tpl for new navigation
- Moved background checking and correct logo display to be part of
  existing code, custom/theme.js

Change-Id: Icc46a35677838bf001599074b7bc76611cf757e8
parent 05ae30cd
......@@ -121,14 +121,14 @@ jQuery(function($) {
* Initialise masonry for thumbnail gallery
*/
function initThumbnailMasonry() {
$('.js-masonry.thumbnails').masonry({
itemSelector: '.thumb'
});
$('.js-masonry.thumbnails').masonry({
itemSelector: '.thumb'
});
}
function initUserThumbnailMasonry() {
$('.js-masonry.user-thumbnails').masonry({
itemSelector: '.user-icon'
itemSelector: '.user-icon'
});
}
......@@ -202,6 +202,25 @@ jQuery(function($) {
}
}
// Checks background color of header
function isDark(color) {
var match = /rgb\((\d+).*?(\d+).*?(\d+)\)/.exec(color);
return ( match[1] & 255 )
+ ( match[2] & 255 )
+ ( match[3] & 255 )
< 3 * 256 / 2;
}
function displayCorrectLogo() {
var headerBgColour = $('.navbar-default').css("background-color");
if (isDark(headerBgColour)) {
$('.logo img').attr('src', config.wwwroot + 'theme/raw/images/site-logo-light.png');
}
else {
$('.logo img').attr('src', config.wwwroot + 'theme/raw/images/site-logo-dark.png');
}
}
$(window).on('resize colresize', function(){
carouselHeight();
initThumbnailMasonry();
......@@ -227,13 +246,24 @@ jQuery(function($) {
}
});
$('.navbar-main .navbar-collapse.collapse').on('show.bs.collapse', function(event) {
event.stopPropagation();
$('.navbar-collapse.collapse.in').collapse('hide');
});
$('.navbar-main .child-nav.collapse').on('show.bs.collapse', function(event) {
event.stopPropagation();
$('.child-nav.collapse.in').collapse('hide');
});
affixSize();
siteMessages();
focusOnOpen();
resetOnCollapse();
attachTooltip();
calculateObjectVideoAspectRatio();
responsiveObjectVideo()
responsiveObjectVideo();
displayCorrectLogo();
if ($('.js-dropdown-group').length > 0) {
attachInputDropdown();
......@@ -246,29 +276,3 @@ jQuery(function($) {
$(".js-select2 select").select2({});
});
// Checks background color of header
function isDark( color ) {
var match = /rgb\((\d+).*?(\d+).*?(\d+)\)/.exec(color);
return ( match[1] & 255 )
+ ( match[2] & 255 )
+ ( match[3] & 255 )
< 3 * 256 / 2;
}
jQuery(function($) {
"use strict";
// If the background is dark, use light logo, otherwise use dark logo
$(document).ready(function() {
if (isDark($('.navbar.header').css("background-color"))) {
$('.logo img').attr('src', config.wwwroot + 'theme/raw/images/site-logo-light.png');
}
else {
$('.logo img').attr('src', config.wwwroot + 'theme/raw/images/site-logo-dark.png');
}
});
});
{* this template powers the css that is stored in the database for the configurable theme *}
.navbar-default {
background-color: {$data.background};
border-color: {$data.background};
}
.navbar-toggle .icon {
color: {$data.backgroundfg};
}
.navbar-default .navbar-toggle {
border-color: transparent;
}
.navbar-default .navbar-collapse {
border-color: transparent;
}
.navbar-toggle:hover,
.navbar-toggle:focus {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wkPAhEFWvh1jAAAAA1JREFUCNdjYGBgcAAAAEUAQT9reqQAAAAASUVORK5CYII=') {$data.background};
}
.navbar-main .navbar-nav > li > a {
color: {$data.navfg};
background-color: {$data.navbg};
border-color: transparent;
}
.navbar-main .navbar-nav > li > a:hover,
.navbar-main .navbar-nav > li > a:focus {
color: #333;
background-color: #f9f9f9;
}
.navbar-main .navbar-nav > li.active > a {
font-weight: bold;
}
.navbar-toggle.navbar-showchildren .icon {
color: {$data.navfg};
}
.navbar-main .navbar-nav > .active .navbar-showchildren,
.navbar-toggle.navbar-showchildren:hover,
.navbar-toggle.navbar-showchildren:focus {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wkPAhEFWvh1jAAAAA1JREFUCNdjYGBgcAAAAEUAQT9reqQAAAAASUVORK5CYII=') {$data.background};
}
.navbar-toggle.navbar-showchildren:hover .icon,
.navbar-toggle.navbar-showchildren:focus .icon {
color: {$data.navfg};
}
.navbar-main .child-nav > li > a {
color: {$data.navbg};
background-color: {$data.navfg};
}
.navbar-main .child-nav > li > a:hover,
.navbar-main .child-nav > li > a:focus {
color: #333;
background-color: #f9f9f9;
}
.header.navbar,
.modal-docked .modal-header,
.modal-header {
background: {$data.background};
......@@ -11,17 +69,6 @@
background-color: #666;
}
.navbar.header {
border-color: {$data.background};
}
@media (max-width: 767px) {
.top-nav.navbar-nav {
/* 1px alpha channel black to darken by 25% */
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wkPAhEFWvh1jAAAAA1JREFUCNdjYGBgcAAAAEUAQT9reqQAAAAASUVORK5CYII=') {$data.background};
}
}
.dashboard-widget-container .widget-heading {
border-top-color: {$data.headings};
}
......@@ -52,9 +99,6 @@ a.panel-footer:hover .icon.pull-right,
.search-toggle {
color: {$data.backgroundfg};
}
.navbar-default .navbar-toggle .icon-bar {
background-color: {$data.backgroundfg};
}
.close {
text-shadow: none;
}
......@@ -138,83 +182,6 @@ a.btn-primary {
border-color: {$data.background};
}
.main-nav {
background: {$data.navbg};
}
.main-nav li a,
.main-nav li a:link,
.main-nav li a:visited,
.main-nav li a:active,
.main-nav li a:hover,
.main-nav li a:focus,
.navbar-inverse .navbar-nav > li > a:focus,
.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-link,
.navbar-inverse .navbar-link:hover,
.navbar-inverse .navbar-link:focus {
color: {$data.navfg};
}
.main-nav .dropdown-nav-home li a,
.main-nav .dropdown-nav-home li a:link {
color: {$data.link};
}
.main-nav .dropdown-nav-home li a:active,
.main-nav .dropdown-nav-home li a:hover,
.main-nav .dropdown-nav-home li a:focus {
color: #555 !important;
}
.main-nav .nav > li a:hover,
.main-nav .nav > li a:focus,
.main-nav .nav > li a:active {
color: {$data.navfg};
background-color: rgba(223,223,223,.5);
}
.navbar-default .navbar-text.navbar-link,
.navbar-default .navbar-text.navbar-link:hover,
.navbar-default .navbar-text.navbar-link:focus {
color: {$data.navfg};
}
@media (max-width: 767px) {
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .active > a:focus,
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-showchildren.collapsed .icon {
color: {$data.navfg};
}
.main-nav .child-nav a {
color: #333 !important;
}
.main-nav .nav > li > a {
border-top-color: transparent;
border-bottom-color: transparent;
}
}
#sub-nav.navbar-default .navbar-nav > .active > a,
#sub-nav.navbar-default .navbar-nav > .active > a:link,
#sub-nav.navbar-default .navbar-nav > .active > a:visited {
background: {$data.background};
color: {$data.backgroundfg};
border-radius: 3px;
}
#sub-nav.navbar-default .navbar-nav > .active > a:active,
#sub-nav.navbar-default .navbar-nav > .active > a:hover {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wkPAhMnva5W6gAAAA1JREFUCNdj+P//vz0ACTsDPd3TBh4AAAAASUVORK5CYII=') {$data.background};
}
#sub-nav.navbar-default .navbar-nav > li > a:focus,
#sub-nav.navbar-default .navbar-nav > li > a:hover {
background: #f9f9f9;
}
a.admin-site {
color: {$data.backgroundfg};
}
......@@ -229,19 +196,6 @@ a.admin-site {
border-left-color: #DBDBDB;
}
header.header .header-search-form .form-control {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3wkPAic6ZYLJxAAAAA1JREFUCNdj+P//vzwACRsDHRWss5MAAAAASUVORK5CYII=') {$data.background};
border: 1px solid #ccc;
color: {$data.backgroundfg};
}
header.header .header-search-form .form-control:focus {
background-color: {$data.backgroundfg};
color: {$data.background};
}
.header .header-search-form .input-group-btn {
border-left: 1px solid #ccc;
}
.admin .arrow-bar {
background-color: #f9f9f9;
}
......
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