Skip to content

Commit

Permalink
.defaultPageTitle() added - fixed #276
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeetienne committed Mar 18, 2013
1 parent 02e3c7c commit 93468c6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions plugins/boilerplate/tquery.world.boilerplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tQuery.World.registerInstance('pageTitle', function(element){
console.assert( element instanceof HTMLElement, ".pageTitle(element) needs a HTMLElement");
// set element.style
element.style.position = "absolute";
element.style.top = '0px'
element.style.width = "100%";
element.style.textAlign = "center";
element.style.fontWeight= "bolder";
Expand All @@ -42,6 +43,42 @@ tQuery.World.registerInstance('pageTitle', function(element){
return this;
});

/**
* define a default page title for plugins
*/
tQuery.World.registerInstance('defaultPageTitle', function(){
var location = window.location;
var matches = location.pathname.match(/^\/plugins\/([^/]+)\//);
var isPlugin = matches ? true : false;
// create the element
var element = document.createElement('div');
if( isPlugin ){
var pluginName = isPlugin ? matches[1] : null;
element.innerHTML= [
'Example of tQuery.'+pluginName+' plugins - ',
'<a href="https://github.com/mrdoob/three.js/" target="_blank">three.js</a> thru ',
'<a href="http://jeromeetienne.github.com/tquery/" target="_blank">tQuery API</a>',
'<br/>',
'Try it in a ',
'<a href="../../../www/live/editor/#U/../../../',
location.pathname+'" target="_blank">live editor</a>'
].join('\n');
}else{
element.innerHTML= [
'Example of tQuery - ',
'<a href="https://github.com/mrdoob/three.js/" target="_blank">three.js</a> thru ',
'<a href="http://jeromeetienne.github.com/tquery/" target="_blank">tQuery API</a>',
].join('\n');
}
document.body.appendChild(element)

// set it up as page Title
this.pageTitle(element)
// for chained API
return this;
});


tQuery.World.registerInstance('devicePixelRatio', function(ratio){
// change devicePixelRatio
var tRenderer = this.tRenderer();
Expand Down

0 comments on commit 93468c6

Please sign in to comment.