if(clicked == undefined || obj == undefined || dif == undefined){
return false;
}
if(typeof obj == 'string')
{
obj = new Array(obj);
}
var modalNums = obj.length;
//drag effects begin
var i = 0;
for (i = 0; i < modalNums; i++) {
dif[obj[i]] = {'difx': 0,'dify': 0};
}
$("html").off('mousemove').on('mousemove',function (event) {
if (clicked == "0") {
for (i = 0; i < modalNums; i++) {
dif[obj[i]].difx = event.pageX - $("#" + obj[i]).offset().left;
dif[obj[i]].dify = event.pageY - $("#" + obj[i]).offset().top;
}
}
if (clicked > 0 && clicked <= modalNums) {
var clickedObj = obj[clicked - 1];
var newx = event.pageX - dif[clickedObj].difx - $("#" + clickedObj).css("marginLeft").replace('px','');
var newy = event.pageY - dif[clickedObj].dify - $("#" + clickedObj).css("marginTop").replace('px','');
$("#" + clickedObj).css({top: newy,left: newx});
}
});
$("html").off('mouseup').on('mouseup',function (event) {
clicked = "0";
});
for(i = 0; i < modalNums; i++){
//注重此处不能直接传入i值,此处即为添加多窗口时的效果使用
$("#" + obj[i] + " .modal-header").off().on('mousedown',{index: i},function (event) {
clicked = event.data.index + 1;
});
$("#" + obj[i] + " .modal-footer").off().on('mousedown',function (event) {
clicked = event.data.index + 1;
});
$('#' + obj[i]).on('hide.bs.modal',function () { //关闭时打开选中
$('html').off('selectstart').on('selectstart',function () {
return true;
});
});
}
}