Ilya, could you please give an example code block for how one might do that? That's a lot of code and I don't want to mess something up.
Ilya, could you please give an example code block for how one might do that? That's a lot of code and I don't want to mess something up.
Hi Ave,
Please try following solution:
1 Import needed themes.
Details: http://prntscr.com/82rygl/direct
2 Create new JS asset.
3 Populate it with following JS code:
precode
var themes = [
"dendrite",
"ios-like",
"gelato",
"flat-ui",
"ios7",
"jqm",
"jqm-classic",
"olive",
"pastel",
"winter"
];
var GetThemeUrl = function(themeName, isFull){
var currentAppPath = location.pathname.replace(/\/[\/]*$/gi, "");
Code: Select all
var cssUrl = (isFull ? (currentAppPath + "/") : "") + "files/resources/lib/theme/" + themeName + "/" + themeName + ".css"
return cssUrl;
};
var ActivateTheme = function(themeName){
Code: Select all
//Remove all avaliable themes.
for(var i = 0; i < themes.length; i++){
var cssRelatedUrl = GetThemeUrl(themes[i]);
jQuery('link[href="' + cssRelatedUrl + '"]').remove();
console.log("cssRelatedUrl = " + cssRelatedUrl + " = " + themes[i]);
};
//Add new css.
var goalThemeUrl = GetThemeUrl(themeName, true);
var newCss = jQuery("<link>");
newCss.attr("rel", "stylesheet");
newCss.attr("href", goalThemeUrl);
jQuery("head").append(newCss);
};
/code/pre
4 Okay now you can use following code to change theme in runtime when you need on any event:
precode
//to Activate "ios-like" theme.
ActivateTheme("ios-like");
//to Activate "winter" theme.
//ActivateTheme("winter");
//You can use any theme name from array from 1st step.
/code/pre
Regards.
How do I make sure when the user reloads the app their preferences remain?
Hello,
Your problem is not clear at this time.
Please specify more details about your problem.
Regards.