目录
/**
?* Created with jing.zhao2013
?* Date: 13-11-28
?* Time: 上午10:40
?* ???{
?* ?????cls: "", ??????????//自定义的class样式
?* ?????closeCls:"", ??????//关闭按钮的鼠标滑class样式
?* ?????open:true, ????????//是否为打开状态
?* ?????isModal:false, ????//是否模态窗口
?* ?????isDrag:false ?????//是否可拖动
?* ???}
?*/
(function($){$.fn.extend({"dialog":function(options){
????var ops = $.extend({
????????cls: "",
????????closeCls:"",
????????open:true,
????????isModal:false,
????????isDrag:false,
????????btn:[]
},options);
????var $dom = $(this),
????????$shadow = $("<div style='-moz-opacity:0.25;opacity:0.25;filter:alpha(opacity=25);position:absolute;border:none;background:#000;top:0;left:0;z-index:9999;display:none;'></div>"),
????????$win = $(window);
????if(!$dom.get(0)) return;
????var dialog = {
????????render:function(){
????????????$dom.addClass(ops.cls);
????????????$dom.css("z-index","10000");
????????????if(ops.isModal){
????????????????this.showShadow();
????????????}
????????????if(!ops.open){
????????????????$dom.hide();
????????????????if(ops.isModal){$shadow.hide();}
????????????}
????????????var $close = $dom.find(".dialog-close-button");
????????????if($close.get(0)){
????????????????$close.bind({
????????????????????'click':function(e){if(ops.isModal){$shadow.hide();}$dom.hide();e.stopPropagation();},
??????????????????'mouseover':function(e){$(this).addClass(ops.closeCls);e.stopPropagation();},
????????????????????'mouseout':function(){ $(this).removeClass(ops.closeCls);},
????????????????????'mousedown':function(e){e.stopPropagation();}
????????????????});
????????????}
????????????if(ops.isDrag){
????????????????this.dragndrop();
????????????}
????????},
????????showShadow:function(){
????????????var h = Math.max($win.innerHeight(),$("body").innerHeight());
????????????Var
?w = Math.max($win.innerWidth(),$("body").innerWidth());
????????????$shadow.css({height:h,width:w});
????????????$("body").append($shadow);
????????},
????????dragndrop:function(){
????????????var $title = $dom.find(".dialog-top");
????????????var startX,startY,startLeft,startTop,dragging = false;
????????????var maxLeft = $win.innerWidth()-$dom.outerWidth();
????????????var maxTop = $win.innerHeight()-$dom.outerHeight();
????????????var fn={
????????????????down:function(e){
????????????????????dragging = true;
????????????????????$title.css('cursor','move');
????????????????????startX = e.pageX;
????????????????????startY = e.pageY;
????????????????????startLeft=$dom.offset().left;
????????????????????startTop=$dom.offset().top;
????????????????????e.stopPropagation();
????????????????},