/** * Created by Pensare Software. * User: Theo Weijmer * Date: 13/12/2017 * Time: 17:08 */ var tellMe = function ( options, callback ) { dbo.tellmeModel.init( options, callback ); } dbo.tellmeModel = { 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.tellmeModel; vm.callback = callback; vm.setOptions( options ); $( "#tell-me" ).modal({ show:true } ); }, setOptions: function ( options ) { var vm = dbo.tellmeModel; 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 () { var vm = dbo.tellmeModel; if ( typeof( vm.callback ) == 'function' ) vm.callback( false ); vm.closeTellme(); }, closeYes: function () { var vm = dbo.tellmeModel; if ( typeof( vm.callback ) == 'function' ) vm.callback( true ); vm.closeTellme(); }, closeOk: function () { var vm = dbo.tellmeModel; if ( typeof( vm.callback ) == 'function' ) vm.callback(); vm.closeTellme(); }, close: function () { var vm = dbo.tellmeModel; if ( typeof( vm.callback ) == 'function' ) vm.callback(); }, closeTellme: function(){ $( "#tell-me" ).modal( 'hide'); } } ko.applyBindings( dbo.tellmeModel, document.getElementById( "tell-me" ) ); $(document).on('show.bs.modal', '.modal', function (event) { var zIndex = 1040 + (10 * $('.modal:visible').length); $(this).css('z-index', zIndex); setTimeout(function() { $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack'); }, 0); });