mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +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 { mergeOptions } from '../utils/general_utils';
|
||||||
import { getLangText } from '../utils/lang_utils';
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
|
||||||
import {constructHead} from '../utils/head_setter';
|
import {constructHead, setTitle} from '../utils/head_setter';
|
||||||
|
|
||||||
let Header = React.createClass({
|
let Header = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -64,9 +64,11 @@ let Header = React.createClass({
|
|||||||
WhitelabelStore.unlisten(this.onChange);
|
WhitelabelStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
getLogo(){
|
getLogo(){
|
||||||
constructHead(this.state.whitelabel.head);
|
let whitelabel = this.state.whitelabel;
|
||||||
if (this.state.whitelabel.subdomain !== 'www'){
|
setTitle(whitelabel.title)
|
||||||
return <img className="img-brand" src={this.state.whitelabel.logo}/>;
|
constructHead(whitelabel.head);
|
||||||
|
if (whitelabel.subdomain !== 'www'){
|
||||||
|
return <img className="img-brand" src={whitelabel.logo}/>;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (
|
return (
|
||||||
|
@ -8,18 +8,17 @@
|
|||||||
// elementAttributes: hash table containing the attributes of the relevant element
|
// elementAttributes: hash table containing the attributes of the relevant element
|
||||||
|
|
||||||
let constructHeadElement = function(elementType, elementId, elementAttributes) {
|
let constructHeadElement = function(elementType, elementId, elementAttributes) {
|
||||||
console.log('setfavicon invoked');
|
|
||||||
var head = (document.head || document.getElementsByTagName('head')[0]);
|
var head = (document.head || document.getElementsByTagName('head')[0]);
|
||||||
var element = document.createElement(elementType);
|
var element = document.createElement(elementType);
|
||||||
var oldElement = document.getElementById(elementId);
|
var oldElement = document.getElementById(elementId);
|
||||||
try {
|
try {
|
||||||
for (let k in elementAttributes){
|
for (let k in elementAttributes){
|
||||||
console.log('Setting ', k, elementAttributes[k]);
|
|
||||||
element.setAttribute(k, elementAttributes[k]);
|
element.setAttribute(k, elementAttributes[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(e){
|
catch(e){
|
||||||
console.log(e.message());
|
console.log(e.message);
|
||||||
|
console.log(elementAttributes);
|
||||||
}
|
}
|
||||||
if (oldElement) {
|
if (oldElement) {
|
||||||
head.removeChild(oldElement);
|
head.removeChild(oldElement);
|
||||||
@ -32,8 +31,6 @@ let constructHeadElement = function(elementType, elementId, elementAttributes) {
|
|||||||
// {link : {id1: {rel: ... }}}
|
// {link : {id1: {rel: ... }}}
|
||||||
// traverses a tree of depth 3 (no backtracking)
|
// traverses a tree of depth 3 (no backtracking)
|
||||||
export function constructHead(headObject){
|
export function constructHead(headObject){
|
||||||
console.log('Going to set all favicons');
|
|
||||||
console.log(headObject);
|
|
||||||
for (let k in headObject){
|
for (let k in headObject){
|
||||||
let favicons = headObject[k];
|
let favicons = headObject[k];
|
||||||
for (let f in favicons){
|
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