mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
browser title added, setTitle method added to head_setter module in utils
This commit is contained in:
parent
ef9bbb548d
commit
f5a37ab4a9
@ -29,7 +29,7 @@ import NavRoutesLinks from './nav_routes_links';
|
||||
import { mergeOptions } from '../utils/general_utils';
|
||||
import { getLangText } from '../utils/lang_utils';
|
||||
|
||||
import {constructHead} from '../utils/head_setter';
|
||||
import {constructHead, setTitle} from '../utils/head_setter';
|
||||
|
||||
let Header = React.createClass({
|
||||
propTypes: {
|
||||
@ -64,9 +64,11 @@ let Header = React.createClass({
|
||||
WhitelabelStore.unlisten(this.onChange);
|
||||
},
|
||||
getLogo(){
|
||||
constructHead(this.state.whitelabel.head);
|
||||
if (this.state.whitelabel.subdomain !== 'www'){
|
||||
return <img className="img-brand" src={this.state.whitelabel.logo}/>;
|
||||
let whitelabel = this.state.whitelabel;
|
||||
setTitle(whitelabel.title)
|
||||
constructHead(whitelabel.head);
|
||||
if (whitelabel.subdomain !== 'www'){
|
||||
return <img className="img-brand" src={whitelabel.logo}/>;
|
||||
}
|
||||
else {
|
||||
return (
|
||||
|
@ -8,18 +8,17 @@
|
||||
// elementAttributes: hash table containing the attributes of the relevant element
|
||||
|
||||
let constructHeadElement = function(elementType, elementId, elementAttributes) {
|
||||
console.log('setfavicon invoked');
|
||||
var head = (document.head || document.getElementsByTagName('head')[0]);
|
||||
var element = document.createElement(elementType);
|
||||
var oldElement = document.getElementById(elementId);
|
||||
try {
|
||||
for (let k in elementAttributes){
|
||||
console.log('Setting ', k, elementAttributes[k]);
|
||||
element.setAttribute(k, elementAttributes[k]);
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
console.log(e.message());
|
||||
console.log(e.message);
|
||||
console.log(elementAttributes);
|
||||
}
|
||||
if (oldElement) {
|
||||
head.removeChild(oldElement);
|
||||
@ -32,8 +31,6 @@ let constructHeadElement = function(elementType, elementId, elementAttributes) {
|
||||
// {link : {id1: {rel: ... }}}
|
||||
// traverses a tree of depth 3 (no backtracking)
|
||||
export function constructHead(headObject){
|
||||
console.log('Going to set all favicons');
|
||||
console.log(headObject);
|
||||
for (let k in headObject){
|
||||
let favicons = headObject[k];
|
||||
for (let f in favicons){
|
||||
@ -41,3 +38,7 @@ export function constructHead(headObject){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function setTitle(titleString){
|
||||
document.title = titleString;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user