lexonomy_custom_editor/src/message/simple_messages.py

30 lines
783 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
2019-11-17 20:15:35 +00:00
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!
2019-11-17 20:15:35 +00:00
window.setTimeout(lambda: msg(_ModalResetDelayed())(None), 100)
2019-11-11 22:04:45 +00:00