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)

bugreport.png (68.1 KB) - added by g00glen00b 6 years ago.
Screenshot identifying the problem

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by g00glen00b

Attachment: bugreport.png added

Screenshot identifying the problem

comment:1 Changed 6 years ago by bill

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:2 Changed 6 years ago by bill

#18402 is a duplicate of this ticket.

comment:3 Changed 6 years ago by g00glen00b

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 bill

Woops, I was thinking that #18402 and #18403 were duplicates. I think you made a typo though, and you meant to say that this ticket applies to the original themeTester, whereas #18402 applies only to the duplicated code?

comment:5 Changed 6 years ago by bill

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 bill

Milestone: tbd1.11
Owner: set to bill
Status: newassigned

OK, I'll just remove that tab. Like I said, I think it's redundant.

comment:7 Changed 6 years ago by bill

Component: DocumentationDijit

comment:8 Changed 6 years ago by Bill Keese <[email protected]…>

Resolution: fixed
Status: assignedclosed

In ca4f43e11b675a50c98d89977a5bc11b8095df05/dijit:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 
Note: See TracTickets for help on using tickets.