notice.js 7.51 KB
   var x0=0,y0=0,x1=0,y1=0;
//     var offx=6,offy=6;
    var moveable=false;//鼠标是否是按下状态
//     var hover='orange',normal='slategray';//color;
    var hover='slategray',normal='slategray';//color;
    var index=10000;//z-index;
    
    //创建一个对象;
    function xWin(id,tit,msg,url){
     index = index+2;
     if(id==1){
	    isShow_chinnal=false;
	 }else if(id==2){
	    isShow_liveApply=false;
	 }
     this.id      = id;
     this.width   = 300;//主窗体宽度
     this.height  = 200;//主窗体高度
     this.right   = 0;//位置距右
     this.bottom  = 0;//位置距下
     this.zIndex  = index;
     this.title   = tit;//标题
     this.message = msg;//消息体
     this.url     = url;//url
     this.obj     = null;
     this.bulid   = bulid;
     this.bulid();
    }
    //初始化;
    function bulid(){
     var str = ""
      + "<div id=xMsg" + this.id + " "
      + "style='"
      + "z-index:" + this.zIndex + ";"
      + "width:" + this.width + "px;"
      + "height:" + this.height + "px;"
      + "right:" + this.right + ";"
      + "bottom:" + this.bottom + ";"
      + "background-color:white;"
      + "color:" + normal + ";"
      + "font-size:18px;"
      + "font-family:Verdana;"
      + "position:fixed;"
      + "cursor:default;"
      + "-webkit-user-select:none;"
      + "-moz-user-select:none;"
      + "-ms-user-select:none;"
      + "user-select:none;"
      + "border:2px solid " + normal + ";"
      + "' "
      + "οnmοusedοwn='getFocus(this)'"
      +">"
//       标题开始
       + "<div "
       + "style='"
       + "background-color:" + normal + ";"
       + "width:" + (this.width-2*2) + "px;"
       + "height:28px;"
       + "color:white;"
       + "' "
       + "onmousedown='startDrag(this)' "
       + "onmouseup='stopDrag(this)' " 
       + "onmousemove='drag(this)' " 
       + "ondblclick='min(this.childNodes[1])'" 
       + ">"
        + "<span style='width:" + (this.width-2*25-4) + "px;padding-left:3px; display:-moz-inline-box; display:inline-block;'>" + this.title + "</span>"
        + "<span style='width:25px;border-width:0px;color:white;font-family:webdings;display:-moz-inline-box; display:inline-block;' onclick='min(this)'>0</span>"
        + "<span style='width:25px;border-width:0px;color:white;font-family:webdings;display:-moz-inline-box; display:inline-block;' onclick='cls(this," + this.id + ")'>r</span>"
       + "</div>"
//         主窗体开始
    	+ "<div style='"
        + "width:100%;"
        + "height:" + (this.height-28-4) + "px;"
        + "min-height:" + (this.height-28-4) + "px;"
        + "background-color:white;"
        + "word-break:break-all;"
        + "padding:3px;"
        + "'>" 
//     主窗体的内容部分
    	+ "<div style='"
        + "width:100%;"
        + "height:" + (this.height-28-4-50) + "px;"
        + "min-height:" + (this.height-28-4-50) + "px;"
        + "line-height:20px;"
        + "text-align: center;"
        + "word-break:break-all;"
        + "padding:3px;"
        + "padding-top: 40px;"
    	+ "color:red;"
        + "'>" 
        + this.message 
    	+ "</div>"
//     	主窗体的按钮部分(按钮1)
		+ "<div style='"
      	+ "width:60px;"
      	+ "height:30px;"
      	+ "color: #fff;"
      	+ "line-height: 30px;"
      	+ "text-align: center;"
      	+ "font-size: 15px;"
      	+ "float:left;"
      	+ "margin-left: 120px;"
     	+ "background-color:" + normal + ";"
     	+ "'"
    	+" type='button'"
    	+" onclick='cls(this," + this.id + ")'"
    	+">确定</div>"
//     	主窗体的按钮部分(按钮2)
		+ "<div style='"
      	+ "width:60px;"
      	+ "height:30px;"
      	+ "color: #fff;"
      	+ "line-height: 30px;"
      	+ "text-align: center;"
      	+ "font-size: 15px;"
      	+ "float:right;"
      	+ "margin-right:20px;"
     	+ "background-color:" + normal + ";"
     	+ "'"
    	+" type='button'"
    	+" onclick=\"toLink('"+this.url+"'," + this.id + ")\"" 
    	+">查看</div>"
    	+ "</div>"
      
     
    + "</div>";
     document.body.insertAdjacentHTML("beforeEnd",str);
    }
    
  //开始拖动;
    function startDrag(obj){
     if(event.button==0){
      //锁定标题栏;
//       obj.setCapture();
      //定义对象;
      var win = obj.parentNode;
//       var sha = win.nextSibling;
      //记录鼠标和层位置;
      x0 = event.clientX;
      y0 = event.clientY;
      x1 = parseInt(win.style.right.replace("px",""));
      y1 = parseInt(win.style.bottom.replace("px",""));
      //记录颜色;
      normal = obj.style.backgroundColor;
      //改变风格;
      obj.style.backgroundColor = hover;
      win.style.borderColor = hover;
      obj.nextSibling.style.color = hover;
//       sha.style.right = (x1 - offx)+"px";
//       sha.style.bottom  = (y1 - offy)+"px";
      moveable = true;
     }
    }
    //拖动;
    function drag(obj){
     if(moveable){
      var win = obj.parentNode;
//       var sha = win.nextSibling;
      win.style.right = ( x1+x0-event.clientX)+"px";
      win.style.bottom  = ( y1+y0-event.clientY)+"px";
//       sha.style.right = (parseInt(win.style.right.replace("px","")) - offx)+"px";
//       sha.style.bottom  = (parseInt(win.style.bottom.replace("px","")) - offy)+"px";
     }
    }
    //停止拖动;
    function stopDrag(obj){
     if(moveable){
      var win = obj.parentNode;
//       var sha = win.nextSibling;
      var msg = obj.nextSibling;
      win.style.borderColor     = normal;
      obj.style.backgroundColor = normal;
      msg.style.color           = normal;
//       sha.style.right = obj.parentNode.style.right;
//       sha.style.bottom  = obj.parentNode.style.bottom;
//       obj.releaseCapture();
      moveable = false;
     }
    }
    //获得焦点;
    function getFocus(obj)
    {
     if(obj.style.zIndex!=index)
     {
      index = index + 2;
      var idx = index;
      obj.style.zIndex=idx;
      obj.nextSibling.style.zIndex=idx-1;
     }
    }
    //最小化;
    function min(obj){
     var win = obj.parentNode.parentNode;
//      var sha = win.nextSibling;
     var tit = obj.parentNode;
     var msg = tit.nextSibling;
     var flg = msg.style.display=="none";
     if(flg)
     {
      win.style.height  = (parseInt(msg.style.height.replace("px","")) + parseInt(tit.style.height.replace("px","")) + 2*2)+"px";
//       sha.style.height  = win.style.height;
      msg.style.display = "block";
      obj.innerHTML = "0";
     }
     else
     {
      win.style.height  = (parseInt(tit.style.height.replace("px","")) + 2*2)+"px";
//       sha.style.height  = win.style.height;
      obj.innerHTML = "2";
      msg.style.display = "none";
     }
    }
    //关闭;
    function cls(obj,id){
     var win = obj.parentNode.parentNode;
//      var sha = win.nextSibling;
     win.style.visibility = "hidden";
//      sha.style.visibility = "hidden";
	    if(id==1){
	    	isShow_chinnal=true;
	    }else if(id==2){
	    	isShow_liveApply=true;
	    }
    }
    //点击查看跳转链接
    function toLink(url,id){
    	if(id==1){
	    	isShow_chinnal=true;
	    }else if(id==2){
	    	isShow_liveApply=true;
	    }    	window.location.href= url;
//     	window.location.href= window.location.protocol+"//"+window.location.host+"/channel/page?shenhe_status=0&receive=0";
    }