Skip to content

Commit

Permalink
Fix alt attribute of toggle buttons
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Etchells <[email protected]>
  • Loading branch information
Tim Etchells committed Sep 17, 2019
1 parent f700017 commit 79e8b8a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions dev/src/command/webview/ManageTemplateReposPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,17 @@ export default function getManageReposPage(repos: ITemplateRepo[]): string {
const newEnablement = toggleBtn.getAttribute("${REPO_ENABLED_ATTR}") != "true";
toggleBtn.setAttribute("${REPO_ENABLED_ATTR}", newEnablement);
let newToggleImg;
let newToggleImg, newToggleAlt;
if (newEnablement) {
newToggleImg = "${getStatusToggleIconSrc(true)}";
newToggleAlt = "${getStatusToggleAlt(true)}";
}
else {
newToggleImg = "${getStatusToggleIconSrc(false)}";
newToggleAlt = "${getStatusToggleAlt(false)}";
}
toggleBtn.src = newToggleImg;
toggleBtn.alt = newToggleAlt;
sendMsg("${ManageReposWVMessages.ENABLE_DISABLE}", { repos: [ getRepoEnablementObj(toggleBtn) ] });
}
Expand Down Expand Up @@ -174,13 +177,16 @@ function buildRepoRow(repo: ITemplateRepo): string {
}

function getStatusToggleTD(repo: ITemplateRepo): string {
const alt = repo.enabled ? `Disable ${repo.description}` : `Enable ${repo.description}`;
return `<td class="repo-toggle-cell">
<input type="image" alt="${alt}" ${REPO_ID_ATTR}="${repo.url}" ${REPO_ENABLED_ATTR}="${repo.enabled}" class="${REPO_TOGGLE_CLASS} btn"
src="${getStatusToggleIconSrc(repo.enabled)}" onclick="onToggleRepo(this)"/>
<input type="image" alt="${getStatusToggleAlt(repo.enabled)}" ${REPO_ID_ATTR}="${repo.url}" ${REPO_ENABLED_ATTR}="${repo.enabled}"
class="${REPO_TOGGLE_CLASS} btn" src="${getStatusToggleIconSrc(repo.enabled)}" onclick="onToggleRepo(this)"/>
</td>`;
}

function getStatusToggleAlt(enabled: boolean): string {
return enabled ? `Disable source` : `Enable source`;
}

function getStatusToggleIconSrc(enabled: boolean): string {
return WebviewUtil.getIcon(enabled ? Resources.Icons.ToggleOnThin : Resources.Icons.ToggleOffThin);
}
Expand Down

0 comments on commit 79e8b8a

Please sign in to comment.