Files
dbois/public/js/lib/modules/specials/notifyModule.js
T
2017-12-19 17:23:34 +01:00

68 lines
1.7 KiB
JavaScript

/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 13/12/2017
* Time: 17:08
*/
var notifyMe = function ( options, callback ) {
dbo.notifyModel.init( options, callback );
}
dbo.notifyModel = {
title : ko.observable( null ),
message : ko.observable( null ),
notify : ko.observable( false ),
alert : ko.observable( false ),
noText : ko.observable( null ),
yesText : ko.observable( null ),
closeText : ko.observable( null ),
modalClass: ko.observable( null ),
callback : null,
init: function ( options, callback ) {
var vm = dbo.notifyModel;
vm.callback = callback;
vm.setOptions( options );
$( "#notify-me" ).modal( 'show' );
},
setOptions: function ( options ) {
var vm = dbo.notifyModel;
vm.title( options.title || '' );
vm.message( options.message || '' );
vm.notify( options.notify || false );
vm.noText( options.noText || 'Nee' );
vm.yesText( options.yesText || 'Ja' );
vm.closeText( options.closeText || 'ok' );
vm.modalClass( options.modalClass || 'modal-primary' )
},
closeNo: function () {
if ( typeof( dbo.notifyModel.callback ) == 'function' ) callback( false );
},
closeYes: function () {
if ( typeof( dbo.notifyModel.callback ) == 'function' ) callback( true );
},
closeOk: function () {
if ( typeof( dbo.notifyModel.callback ) == 'function' ) callback();
},
close: function () {
if ( typeof( dbo.notifyModel.callback ) == 'function' ) callback();
}
}
ko.applyBindings( dbo.notifyModel, document.getElementById( "notify-me" ) );