hdButtonPlugin.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { AbstractViewerNavbarButton } from "../viewerTemplatePlugin";
  2. import { DefaultViewer } from "../../viewer/defaultViewer";
  3. import { EventCallback, Template } from "../templateManager";
  4. export class HDButtonPlugin extends AbstractViewerNavbarButton {
  5. constructor(private _viewer: DefaultViewer) {
  6. super("hd", "hd-button", HDButtonPlugin.HtmlTemplate);
  7. }
  8. onEvent(event: EventCallback): void {
  9. let button = event.template.parent.querySelector(".hd-button");
  10. if (button) {
  11. button.classList.contains("hd-toggled") ? button.classList.remove("hd-toggled") : button.classList.add("hd-toggled");
  12. }
  13. this._viewer.toggleHD();
  14. }
  15. protected static HtmlTemplate: string = `
  16. {{#unless hideHd}}
  17. <style>
  18. .hd-icon:after {
  19. font-size: 16px;
  20. content: "\\F765";
  21. }
  22. .hd-toggled span.hd-icon:after {
  23. content: "\\F766";
  24. }
  25. </style>
  26. <button class="hd-button" title="{{text.hdButton}}">
  27. <span class="icon hd-icon"></span>
  28. </button>
  29. {{/unless}}
  30. `;
  31. }