PDA

View Full Version : Change Theme



blade226
5 Mar 2014, 1:43 AM
Hi,
i want to have an option to change theme like theme example.
How to create this option.

I included options-toolbar.js

How I start the change?

In Forum i found only to create a new theme.

Thx for reply

adam.jimenez
5 Mar 2014, 2:04 AM
I declare themes like so:


<link rel="stylesheet" type="text/css" href="//extjs.cachefly.net/ext/gpl/4.2.1/resources/ext-theme-classic/ext-theme-classic-all.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Blue" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="Grey" href="//extjs.cachefly.net/ext/gpl/4.2.1/resources/ext-theme-gray/ext-theme-gray-all.css" />

Then switch them using:


function setTheme(theme){
var i, cacheobj, altsheets = [""];
for (i = 0;
(cacheobj = document.getElementsByTagName("link")[i]); i++) {
if (cacheobj.getAttribute("rel").toLowerCase() === "alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
cacheobj.disabled = true;
altsheets.push(cacheobj); //store reference to alt stylesheets inside array
if (cacheobj.getAttribute("title") === theme) { //enable alternate stylesheet with theme that matches parameter
cacheobj.disabled = false; //enable chosen style sheet
}
}
}
}

e.g. setTheme('Blue');

blade226
5 Mar 2014, 3:37 AM
How did you do then the selection box created?

I mean the widget in theme example