BootstrapDialog 응용 프로그램

6104 단어 Web
var newBootstrapDialog =  BootstrapDialog.show({
              title:'dialog ',
              type:BootstrapDialog.TYPE_DEFAULT,
              message:' ',
              animate:false,
              draggable: true,
              autodestroy:true,
              closeByBackdrop: false,
              onshown: function(dialogRef){},
              onhidden: function(dialogRef){},
              buttons:[{
                          label:' ',
                          cssClass:'btn-default',
                          action:function(dialogRef){}
              }]
});

 
function addDialog(divId,title,msg,buttons,size,dialogOnHidden,dialogOnShown,position) {
    var newBootstrapDialog = BootstrapDialog.show({
        title:title,     
        type:BootstrapDialog.TYPE_DEFAULT ,
        message: msg,
        animate:false,
        draggable: true,
        autodestroy:true,
        closeByBackdrop: false,
        onshown: function(dialogRef){          
            dialogRef.getModalHeader().css("padding",4); 
            dialogRef.getModalFooter().css("padding",8);
            dialogRef.getModalDialog().on('mousedown', function(event) {
                var src = event.target || window.event.srcElement;
                if(src.tagName === "INPUT" || src.tagName === "TEXTAREA" || src.tagName === "SELECT" ||src.tagName === "CHECKBOX"||src.tagName === "RADIO"||src.tagName === "BUTTON"){
                    return;
                }
                if(src.tagName === "DIV"){
                    if($(src).css('overflow') !== 'visible') return;
                }
                
                var dialog = dialogRef;
                dialog.draggableData.isMouseDown = true;
                var dialogOffset = dialog.getModalContent().offset();
                dialog.draggableData.mouseOffset = {
                    top: event.clientY - dialogOffset.top,
                    left: event.clientX - dialogOffset.left
                };
            });
            var offsetHorizontal = 0;
            if(position){                  
                offsetHorizontal = position;
            }
            if(size){
                dialogRef.getModalDialog().css("width",size[0]);               
                dialogRef.getModalContent().css("height",size[1]);
                dialogRef.getModalDialog().css("height",size[1]);
            }
            dialogRef.getModalDialog().css("top",(document.documentElement.clientHeight-dialogRef.getModalDialog().height())/2+offsetHorizontal);
            
            if(dialogOnShown){
                dialogOnShown();
            }
            if($("#"+divId)[0]){
                $("#"+divId)[0].dialogObj=dialogRef;
            }
            
        },
        onhidden: function(dialogRef){  
            if(dialogOnHidden){
                dialogOnHidden();
            }         
        },
        buttons:buttons 

    });  
    return newBootstrapDialog;
}

 
 
function addCloseConfirm(message,windowId){
    var buttons=[{label: $('#confirmOkBtn').val(),
        cssClass: 'btn-primary',
        action: function(dialogRef){
            dialogRef.close();
            if (windowId) {
                closeDialog(windowId);
            }
        }},{label: $('#confirmCancelBtn').val(),
            cssClass: 'btn-default',
            action: function(dialogRef){        
                dialogRef.close();
            }}
    ];
    var dialog=addDialog("colseConfirmDialog",null,message,buttons,[400],null,null);
    dialog.getModalHeader().hide();
}

 
function addSubmitConfirm(message,doOkMethod,submit,refresh,doCancelMethod){
    if (typeof(submit) === "undefined") {
        submit = true;
    }
    if (typeof(refresh) === "undefined") {
        refresh = true;
    }
    var buttons=[{label: $('#confirmYesBtn').val(),
        cssClass: 'btn-primary',
        action: function(dialogRef){
            if (!submitLock) {
                if (doOkMethod) {
                    doOkMethod();
                }
                if (submit) {
                    submitLock = true;
                }
            } 
            
            if (!refresh) {
                submitLock = false;
                dialogRef.close();
            }
        }},{label: $('#confirmNoBtn').val(),
            cssClass: 'btn-default',
            action: function(dialogRef){ 
                if (doCancelMethod) {
                    doCancelMethod();
                }
                dialogRef.close();
            }}
    ];
    var dialog=addDialog("submitConfirmDialog",null,message,buttons,[425],null,null);
    dialog.getModalHeader().hide();
}

 
function addWindow(divId,title,url,size,dialogOnHidden,dialogOnShown,position){
    var html = $.ajax({
        url: url,
        async: false
       }).responseText; 
    var msg=$("<div id="+divId+"></div>").append(html);
    var buttons=[];
    var newBootstrapDialog = addDialog(divId,title,msg,buttons,size,dialogOnHidden,dialogOnShown,position);
    return newBootstrapDialog;
}

좋은 웹페이지 즐겨찾기