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):
|
2019-11-11 23:34:52 +00:00
|
|
|
model.modal_reset()
|
2019-11-20 21:25:31 +00:00
|
|
|
|
|
|
|
def data_change(self):
|
|
|
|
return False
|
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-20 21:25:31 +00:00
|
|
|
|
|
|
|
def data_change(self):
|
|
|
|
return False
|
2019-11-11 22:04:45 +00:00
|
|
|
|
|
|
|
|