目录
drag:function(e){
if(!dragging) return;
var l = Math.min(startLeft + e.pageX - startX,maxLeft);
var t = Math.min(startTop + e.pageY - startY,maxTop);
$dom.css({left:Math.max(0,l),top:Math.max(0,t)});
},
drop:function(){
dragging = false;
$title.css('cursor','default');
}
};
$title.bind({
'mousedown':fn.down,
'mouseover':fn.drag,
'mouseup':fn.drop
});
$(document).bind({
'mousemove':fn.drag,
'mouseup':fn.drop
});
},
btnEvent:function(){
var btn = ops.btn;
var l = btn.length;
for(var i=0;i<l;i++){
if(btn[i].ele&&btn[i].fn){
btn[i].ele.click(btn[i].fn);
}
}
},
init:function(){
var self = this;
this.render();
if(ops.isDrag){
$win.resize(function(){
self.dragndrop();
});
}
if(ops.isModal){
$win.resize(function(){
self.showShadow();
});
}
if(ops.btn.length){
self.btnEvent();
}
}
};
var handler={
close:function(){
if(ops.isModal){
$shadow.hide();
}
$dom.hide();
},
open:function(str){
if(ops.isModal){
// to set the height when open dialog.
var h = Math.max($win.innerHeight(),$("body").innerHeight());
var w = Math.max($win.innerWidth(),$("body").innerWidth());
$shadow.css({height:h,width:w});
$shadow.show();
}
if(str){
$dom.find(".dialog-body").html(str)
}
$dom.show();
},
setPosition:function(style){
$dom.css(style);
}
};
dialog.init();
return handler;
}})})(jQuery);