1
1

Links.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /// <reference path="../../Elements/Modules/CurrentTurnHandler.ts" />
  2. interface CustomLinkOptions {
  3. mouseover? : () => void;
  4. mouseout? : () => void;
  5. click? : (e : MouseEvent) => void;
  6. }
  7. module Controls.Links {
  8. export function makeCustomLink (element : Element, options : CustomLinkOptions) {
  9. if (options.mouseover != undefined && options.mouseout != undefined) {
  10. element.addEventListener("mouseover", options.mouseover);
  11. element.addEventListener("mouseout", options.mouseout);
  12. }
  13. element.addEventListener("click", options.click);
  14. }
  15. export function makeLink (element : Element, action : Action) {
  16. makeCustomLink(element, {
  17. mouseover : () => { Elements.HyperlinkHandler.hoverAction(action); },
  18. mouseout : () => { Elements.HyperlinkHandler.unhoverAction(); },
  19. click : (e) => {
  20. TurnSequence.execute(action);
  21. Elements.HyperlinkHandler.unhoverAction();
  22. e.stopPropagation();
  23. e.preventDefault();
  24. }
  25. });
  26. }
  27. }