lexonomy_custom_editor/src/message/simple_messages.py

29 lines
780 B
Python
Raw Normal View History

2019-11-11 22:04:45 +00:00
from message.message import Message, ClickMessage, msg
from browser import window
2019-11-05 21:18:20 +00:00
2019-11-11 22:04:45 +00:00
class Reset(ClickMessage):
def update_model(self, model):
pass
class NoReset(Reset):
def reset(self):
return False
2019-11-05 21:18:20 +00:00
2019-11-11 22:04:45 +00:00
# a "hack" message for reseting modals #
# everytime a modal closes, run 100ms later model.modal = []
# this is done to achieve nice close animation
# after setting model.modal, do view update to actually update the DOM
class _ModalResetDelayed(Message):
2019-11-05 21:18:20 +00:00
def update_model(self, model):
model.modal_reset()
2019-11-11 22:04:45 +00:00
class ModalNotOkClose(Reset):
def update_model(self, model):
# msg just creates a callback, need to actually run it!
window.setTimeout(lambda: msg(_ModalResetDelayed)(None), 100)