uitools.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. class UiTools {
  2. constructor(ui) {
  3. this.ui = ui;
  4. }
  5. yesNo(msg, yesCallback, noCallback) {
  6. const yesButton = mxUtils.button("Yes", () => {
  7. this.ui.hideDialog();
  8. yesCallback();
  9. });
  10. yesButton.className = 'geBtn';
  11. const noButton = mxUtils.button("No", () => {
  12. this.ui.hideDialog();
  13. noCallback();
  14. });
  15. noButton.className = 'geBtn';
  16. this._showpopup(msg, [yesButton, noButton]);
  17. }
  18. msgBox(msg) {
  19. const ok = mxUtils.button("OK", () => {
  20. this.ui.hideDialog();
  21. });
  22. ok.className = 'geBtn gePrimaryBtn';
  23. this._showpopup(msg, [ok]);
  24. }
  25. _showpopup(msg, buttonlist) {
  26. const popupDiv = document.createElement('div');
  27. popupDiv.innerHTML = msg;
  28. const buttonsDiv = document.createElement('div')
  29. buttonlist.forEach(b => buttonsDiv.appendChild(b));
  30. buttonsDiv.style.marginTop = '20px';
  31. popupDiv.appendChild(buttonsDiv);
  32. popupDiv.style.textAlign = 'center';
  33. this.ui.showDialog(popupDiv,
  34. 250, 130, // w, h
  35. false, // modal
  36. false); // closable
  37. }
  38. }