todo-webclient/client/modal.ls

72 lines
1.7 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"
validation-classes: args.validation-classes || {}
cancellation-classes: args.cancellation-classes || {}
}
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
classes: self.validation-classes
} [ self.validation-label ]
]
h \div.column {} [
h \button.button.is-fullwidth {
onclick: ->
self.visible := false
self.on-cancellation self
classes: self.cancellation-classes
} [ self.cancellation-label ]
]
]
]
h \a.modal-close {
aria-label: "close"
onclick: ->
self.visible := false
self.on-cancellation self
} []
]
]
self
module.exports = Modal