todo-webclient/client/modal.ls

72 lines
1.7 KiB
Plaintext
Raw Normal View History

2019-12-04 23:30:12 +01:00
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) ->
2019-12-06 04:07:19 +01:00
self = {
modal-args: args.modal-args || {}
visible: args.visible || false
content: args.content || []
content-render: args.content-render || ->
2019-12-08 04:08:21 +01:00
background-args: args.background-args || { onclick: ->
self.visible := false
self.on-cancellation!
}
2019-12-06 04:07:19 +01:00
on-validation: args.on-validation || ->
on-cancellation: args.on-cancellation || ->
validation-label: args.validation-label || "Ok"
cancellation-label: args.cancellation-label || "Cancel"
2019-12-26 08:18:55 +01:00
validation-classes: args.validation-classes || {}
cancellation-classes: args.cancellation-classes || {}
2019-12-06 04:07:19 +01:00
}
2019-12-04 23:30:12 +01:00
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 [
2019-12-04 23:30:12 +01:00
self.content
self.content-render caller
2019-12-04 23:30:12 +01:00
h \hr []
h \div.columns {} [
h \div.column {} [
h \button.button.is-fullwidth {
onclick: ->
self.visible := false
self.on-validation self
2019-12-26 08:18:55 +01:00
classes: self.validation-classes
2019-12-04 23:30:12 +01:00
} [ self.validation-label ]
]
h \div.column {} [
h \button.button.is-fullwidth {
onclick: ->
self.visible := false
self.on-cancellation self
2019-12-26 08:18:55 +01:00
classes: self.cancellation-classes
2019-12-04 23:30:12 +01:00
} [ self.cancellation-label ]
]
]
]
2019-12-20 01:34:41 +01:00
h \a.modal-close {
2019-12-04 23:30:12 +01:00
aria-label: "close"
onclick: ->
self.visible := false
self.on-cancellation self
} []
]
]
self
module.exports = Modal