Files
dbois/public/js/lib/modules/specials/notifyModule.js
T
2017-12-14 10:17:13 +01:00

67 lines
1.6 KiB
JavaScript

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