Created
July 17, 2017 21:05
-
-
Save kingsleyh/0994e0d4e0d40078210184e94d26ffd3 to your computer and use it in GitHub Desktop.
Halogen wrapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
exports.alert_ = function(callback) { | |
return function(config) { | |
return function() { | |
var title = config.title; | |
var text = config.text; | |
var confirmButton = config.confirmButton; | |
var cancelButton = config.cancelButton; | |
var showCancelButton = config.showCancelButton; | |
return sweetAlert({ | |
reverseButtons: true, | |
title: title, | |
html: text, | |
showCancelButton: showCancelButton, | |
confirmButtonText: confirmButton, | |
cancelButtonText: cancelButton, | |
buttonsStyling: false, | |
confirmButtonClass: 'button-master button-primary', | |
cancelButtonClass: 'button-master button-cancel', | |
allowOutsideClick: false | |
}).then(function() { | |
callback(true)(); | |
}).catch(function() { | |
callback(false)(); | |
}); | |
}; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module UserManagement.SweetAlert (Config, alert) where | |
import UserManagement.Models | |
import Control.Monad.Eff.Exception (EXCEPTION, throw) | |
import Control.Monad.Eff.Console (log, CONSOLE) | |
import Control.Monad.Aff (Aff, makeAff) | |
import Network.HTTP.Affjax (AJAX, get, put) | |
import Prelude (Unit) | |
import Control.Monad.Eff | |
type Config = { | |
title :: String | |
, text :: String | |
, confirmButton :: String | |
, cancelButton :: String | |
, showCancelButton :: Boolean | |
} | |
foreign import alert_ :: forall e. (Boolean -> Eff e Unit) -> Config -> Eff e Unit | |
alert :: forall e. Config -> Aff e Boolean | |
alert config = makeAff (\error success -> alert_ success config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment