Opened 6 years ago
Closed 6 years ago
#18403 closed defect (fixed)
Theme Previewer does not render the alternative themese correctly
Reported by: | g00glen00b | Owned by: | bill |
---|---|---|---|
Priority: | undecided | Milestone: | 1.11 |
Component: | Dijit | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Looking at the source code I see this:
var availableThemes = [ { theme: "claro", author: "Dojo", baseUri: "../themes/" }, { theme: "tundra", author: "Dojo", baseUri: "../themes/" }, { theme: "soria", author: "nikolai", baseUri: "../themes/" }, { theme: "nihilo", author: "nikolai", baseUri: "../themes/" } ];
Then I noticed the following code to retrieve the current theme as a string:
var curTheme = location.search.replace(/.*theme=([a-z]+).*/, "$1") || "claro";
To show only the alternative themes, you use the following code:
var tmpString = ''; array.forEach(availableThemes, function(theme){ if(theme != curTheme){ tmpString += '<a href="?theme=' + theme.theme + '">' + theme.theme + '</' + 'a> (' + '<a href="?theme=' + theme.theme + '&dir=rtl">RTL</' + 'a> ' + '<a href="?theme=' + theme.theme + '&a11y=true">high-contrast</' + 'a> ' + '<a href="?theme=' + theme.theme + '&dir=rtl&a11y=true">RTL+high-contrast</' + 'a> )' + ' - by: ' + theme.author + ' <br>'; } });
This will always show all options, because curTheme
is a string while theme
is an object, so comparison will always result in false
. You probably want to compare theme.theme != curTheme
.
Attachments (1)
Change History (9)
Changed 6 years ago by
Attachment: | bugreport.png added |
---|
comment:1 Changed 6 years ago by
I guess you are talking about http://demos.dojotoolkit.org/demos/themePreviewer/demo.html.
Unfortunately, that demo is basically cut-and-pasted from the original version http://download.dojotoolkit.org/release-1.10.2/dojo-release-1.10.2/dijit/themes/themeTester.html, which works.
I have no interest in maintaining 20 pages of cut-and-pasted code but perhaps someone else will do it. Or, I can remove that demo.
comment:3 Changed 6 years ago by
Hmm, good question. I'm addressing this bug because someone on StackOverflow? noticed this and asked a question. It's solved for now (for that user), but it might be confusing for other users as well (unless they find the same issue on StackOverflow?).
That being said, the other issue I reported in #18402 also applies to the original version. Comparing curTheme
with all the available themes will never lead to a truthy test because it's comparing an object to a string.
comment:4 Changed 6 years ago by
comment:5 Changed 6 years ago by
PS: The title of this ticket seems misleading. It says "Theme Previewer does not render the alternative themese correctly" whereas really the problem is merely that the current theme shows up on the "Alternate Themes" tab, right?
Maybe we should just get rid of that tab altogether, as it's redundant with the "Themes" drop down menu.
comment:6 Changed 6 years ago by
Milestone: | tbd → 1.11 |
---|---|
Owner: | set to bill |
Status: | new → assigned |
OK, I'll just remove that tab. Like I said, I think it's redundant.
comment:7 Changed 6 years ago by
Component: | Documentation → Dijit |
---|
comment:8 Changed 6 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Screenshot identifying the problem