function jBootstrap(type, options) {
//$j.fn.jBootstrap = function(action,options){
    var settings = $j.extend(
              {  uid : null,
                 title   : 'title default',
                 content : 'content default',
                 modal_dialog_scrollable: false,
                 modal_dialog_centered: true,
                 modal_footer: '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>',
                 size: '',
                 backdrop_static: false,
                 onOpen : function(){},
                 onClose : function(){}
              }, options);

    if (type=='Modal') modal() ;
    if (type=='Notice') notice() ;

    function modal()
    {  var modal_dialog_scrollable=(settings.modal_dialog_scrollable)? 'modal-dialog-scrollable':'' ;
       var modal_dialog_centered=(settings.modal_dialog_centered)? 'modal-dialog-centered':'' ;
       var modal_footer=(settings.modal_footer)? '<div class="modal-footer">\n'+settings.modal_footer+'</div>\n':'' ;
       var size='' ;
       var backdrop=(settings.backdrop_static)? 'data-backdrop="static"':'' ;
       switch(settings.size)
       { case 'small': size='modal-sm' ; break ;
         case 'large': size='modal-lg' ; break ;
         case 'extra_large': size='modal-xl' ; break ;
       }

        // перед открытием окна закрываем другие модальные окна
        $j('div.modal').modal('hide');



       $j('body').append('<div class="modal fade" id="modal_window_'+settings.uid+'" '+backdrop+' tabindex="-1" role="dialog" aria-labelledby="modal_window_'+settings.uid+'_label" aria-hidden="true">\n'+
                          '          <div class="modal-dialog '+modal_dialog_scrollable+' '+modal_dialog_centered+' '+size+'" role="document">\n'+
                          '            <div class="modal-content">\n'+
                          '              <div class="modal-header">\n'+
                          '                <h5 class="modal-title" id="modal_window_'+settings.uid+'_label">'+settings.title+'</h5>'+
                          '                <div class="close" data-dismiss="modal" aria-label="Close"><svg width=12 height="12" viewBox="0 0 24 24"><path d="M22.2,4c0,0,0.5,0.6,0,1.1l-6.8,6.8l6.9,6.9c0.5,0.5,0,1.1,0,1.1L20,22.3c0,0-0.6,0.5-1.1,0L12,15.4l-6.9,6.9c-0.5,0.5-1.1,0-1.1,0L1.7,20c0,0-0.5-0.6,0-1.1L8.6,12L1.7,5.1C1.2,4.6,1.7,4,1.7,4L4,1.7c0,0,0.6-0.5,1.1,0L12,8.5l6.8-6.8c0.5-0.5,1.1,0,1.1,0L22.2,4z"></path></svg></div>'+
                          '              </div>\n'+
                          '              <div class="modal-body">\n'+settings.content+'</div>\n'+modal_footer+
                          '            </div>\n'+
                          '          </div>\n'+
                          '        </div>') ;



        $j('#modal_window_'+settings.uid).modal({keyboard: false}) ;

        //$j('#modal_window_'+settings.uid).on('show.bs.modal', function (event) {console.log('show 123')}) ; - не работает
        $j('#modal_window_'+settings.uid).on('shown.bs.modal', settings.onOpen) ;
        $j('#modal_window_'+settings.uid).on('hidden.bs.modal', settings.onClose) ;
        $j('#modal_window_'+settings.uid).on('hidden.bs.modal', function(){$j('#modal_window_'+settings.uid).remove();}) ;
        $j('#modal_window_'+settings.uid).on('click','button.cancel',function(){$j('#modal_window_'+settings.uid).modal('hide')}) ;




    }

    function notice()
    {
        if (!$j('div#notice_container').length) $j('body').append('<div id=notice_container aria-live="polite" aria-atomic="true" style="position: absolute; top:0;right:0;min-height: 200px;"><div style="position: absolute; top: 0; right: 0;"></div></div>') ;

        $j('#notice_container').prepend('<div id="toast_'+settings.uid+'" class="toast" role="alert" aria-live="assertive" aria-atomic="true">\n'+
                          '  <div class="toast-header">\n'+
                          '    <img src="" class="rounded mr-2" alt="...">\n'+
                          '    <strong class="mr-auto">Bootstrap</strong>\n'+
                          '    <small>11 mins ago</small>\n'+
                          '    <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">\n'+
                          '      <span aria-hidden="true">&times;</span>\n'+
                          '    </button>\n'+
                          '  </div>\n'+
                          '  <div class="toast-body">\n'+settings.content+'.\n</div>\n'+
                          '</div>') ;

        $j('#toast_'+settings.uid).toast({ animation: true,
                                           autohide: true,
                                           delay: 3000,
                                        }) ;

        $j('#toast_'+settings.uid).toast('show');

        console.log('toast create') ;


        $j('#toast_'+settings.uid).on('hidden.bs.toast', function(){$j('#toast_'+settings.uid).remove();console.log('toast destroy')}) ;



    }
}
