todo-webclient/client/modal.ls

68 lines
1.6 KiB
Plaintext

h = require 'maquette' .h
# formulaire création de listes
# formulaire création de tâches
# confirmation de suppression de listes, de tâches, de colonnes
Modal = (args, caller) ->
self = {
modal-args: args.modal-args || {}
visible: args.visible || false
content: args.content || []
content-render: args.content-render || ->
background-args: args.background-args || { onclick: ->
self.visible := false
self.on-cancellation!
}
on-validation: args.on-validation || ->
on-cancellation: args.on-cancellation || ->
validation-label: args.validation-label || "Ok"
cancellation-label: args.cancellation-label || "Cancel"
}
self.render = ->
is-active = (if self.visible == true then \.is-active else "")
h \div.modal + is-active, self.modal-args, [
h \div.modal-background self.background-args
h \div.modal-content {} [
h \div.box [
self.content
self.content-render caller
h \hr []
h \div.columns {} [
h \div.column {} [
h \button.button.is-fullwidth {
onclick: ->
self.visible := false
self.on-validation self
} [ self.validation-label ]
]
h \div.column {} [
h \button.button.is-fullwidth {
onclick: ->
self.visible := false
self.on-cancellation self
} [ self.cancellation-label ]
]
]
]
h \a.modal-close {
aria-label: "close"
onclick: ->
self.visible := false
self.on-cancellation self
} []
]
]
self
module.exports = Modal