NavigationHelpButtonViewModel.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import knockout from "../../ThirdParty/knockout.js";
  2. import createCommand from "../createCommand.js";
  3. /**
  4. * The view model for {@link NavigationHelpButton}.
  5. * @alias NavigationHelpButtonViewModel
  6. * @constructor
  7. */
  8. function NavigationHelpButtonViewModel() {
  9. /**
  10. * Gets or sets whether the instructions are currently shown. This property is observable.
  11. * @type {Boolean}
  12. * @default false
  13. */
  14. this.showInstructions = false;
  15. const that = this;
  16. this._command = createCommand(function () {
  17. that.showInstructions = !that.showInstructions;
  18. });
  19. this._showClick = createCommand(function () {
  20. that._touch = false;
  21. });
  22. this._showTouch = createCommand(function () {
  23. that._touch = true;
  24. });
  25. this._touch = false;
  26. /**
  27. * Gets or sets the tooltip. This property is observable.
  28. *
  29. * @type {String}
  30. */
  31. this.tooltip = "Navigation Instructions";
  32. knockout.track(this, ["tooltip", "showInstructions", "_touch"]);
  33. }
  34. Object.defineProperties(NavigationHelpButtonViewModel.prototype, {
  35. /**
  36. * Gets the Command that is executed when the button is clicked.
  37. * @memberof NavigationHelpButtonViewModel.prototype
  38. *
  39. * @type {Command}
  40. */
  41. command: {
  42. get: function () {
  43. return this._command;
  44. },
  45. },
  46. /**
  47. * Gets the Command that is executed when the mouse instructions should be shown.
  48. * @memberof NavigationHelpButtonViewModel.prototype
  49. *
  50. * @type {Command}
  51. */
  52. showClick: {
  53. get: function () {
  54. return this._showClick;
  55. },
  56. },
  57. /**
  58. * Gets the Command that is executed when the touch instructions should be shown.
  59. * @memberof NavigationHelpButtonViewModel.prototype
  60. *
  61. * @type {Command}
  62. */
  63. showTouch: {
  64. get: function () {
  65. return this._showTouch;
  66. },
  67. },
  68. });
  69. export default NavigationHelpButtonViewModel;