⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.js

📁 上传的控件
💻 JS
📖 第 1 页 / 共 2 页
字号:
        fixImage: function(img, width, height) {
           
           if (!G.Browser.IsIE)
              return;

           var currentSrc = img.src;

           var imgStyle = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + currentSrc + "', sizingMethod='scale')";
           img.src = 'images/clearpixel.gif';
           img.style.width  = width + "px";
           img.style.height = height + "px";
           img.style.filter =  imgStyle;
        },
        
         
         //检测是否是有效的图片文件
         CheckValidPic:function(fileName,maxSize){
                var str = "";
                var thisPic = new Image();
                thisPic.src = fileName;
                if(thisPic.src=="") str = '请选择您要上传的图片';
                else{
                      var picSize = thisPic.fileSize/1024;
                      if(picSize>maxSize) str = '上传的图片不要大于'+maxSize+'KB,您的图片有'+picSize+'KB';
                      else{
                           var sPic = thisPic.src.split(".");
                           var pf = sPic[sPic.length-1].toLowerCase();
                           str = '未知的图片格式!';
                           var picF = new Array("gif","jpg","jpeg","bmp");
                           for (var i=0;i<picF.length;i++){
                                if (pf==picF[i]){
                                     str = "";
                                     break;
                                    }
                                }
                            }
                    }
                 return str;

         }
     },
    //把对象定位到指定的对象旁边显示,这两个参数对象都是DIV控件
    //传入参数:CurObj=要定位的对象 TargetObj=目标对象 两个对象都是div对象
    PosToFather: function(CurObj,TopTargetObj,leftTargetObj){
            CurObj.style.position = "absolute";
            CurObj.style.left = "0px";  
            CurObj.style.top = "0px";
            
            if(isNaN(TopTargetObj))//typeof TopTargetObj != "string"&&typeof leftTargetObj!="string")
            {
                CurObj.style.left =   (G.findPosX(leftTargetObj) + parseInt(leftTargetObj.clientWidth)) + 5 + "px";//可能要加菜单的客户端宽度
                CurObj.style.top = (G.findPosY(TopTargetObj) - parseInt(TopTargetObj.clientHeight) - 3) + "px"; 
                
            }
            else
            {
                CurObj.style.left = leftTargetObj + "px";//可能要加菜单的客户端宽度
                CurObj.style.top = TopTargetObj + "px"; 
                
            }         
     },
    //从JS文件载入JS对象,一般这种情况就是编辑模板类的载入    
    //传入参数:FileURL 
    LoadJSObj: function(TMPURL,FatherObj,SucessHandler)
    {
       //用ajax动态获取JS文件对象成功
       //new  Ajax.Request(TMPURL,{method:'get',parameters:null,onComplete:SucessHandler.bind(FatherObj)})
       G_RequestObj.send(TMPURL,null,SucessHandler.bind(FatherObj),"get");
         //URL,params,SuccessFunc,Method
        
    } ,
    
    
    //转换成HTML编码
   htmlEncode: function(text) {
	return text.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    }  

    
}
if(!browser)
  var browser = G.getBrowserType();

//浏览器特性
G.Browser={                  
            isIE: /ie.*/g.test(browser),//|(typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined'),            
            isMoz:/moz.*/g.test(browser),
            isOpera:/opera.*/g.test(browser),
            isFirefox:(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1),
            isOther:/other.*/g.test(browser)  
  } 


if (G.Browser.isMoz) {
	HTMLElement.prototype.removeNode = function() {
		this.parentNode.removeChild(this);
	}
}
  
//页面上有关HTML的操作方法  
G.HTMLPro = {
    //把一段html代码插入指定的对象最后面
    insertBottom:function(pObj, pContent)
    {
	    var tElement = $(pObj);
	    if(tElement.insertAdjacentHTML)
	    {			
		    if(tElement.tagName == 'TABLE')
		    {
			    //在表格中不能直接以HTML的方式把一行插入进到, 所以上面的方法不行
			    var tDiv=document.createElement("div"),tRows;
			    tDiv.innerHTML = "<table>"+pContent+"</table>"
			    tRows= tDiv.childNodes[0].tBodies[0].rows;
			    while(tRows.length>0){
				    pObj.tBodies[0].appendChild(tRows[0])
			    }
		    }else
		    {
			    tElement.insertAdjacentHTML('beforeEnd', pContent);	
		    }
		    tRows = null;
		    tDiv = null;
	    }else
	    {
		    var tRange = tElement.ownerDocument.createRange();//系统对象				
  		    initializeRange(tRange,tElement);//初始化范围对象				
		    insertContent([tRange.createContextualFragment(pContent)],tElement);
		    tRange = null;
	    }
    },


    initializeRange:function(pRange,pElement){
        pRange.selectNodeContents(pElement);
        pRange.collapse(pElement);
    },

    insertContent:function(fragments,pElement) {
        fragments.each((function(fragment) {	
          pElement.appendChild(fragment);
        }).bind(this));
    }
}  
  

//*********************************************拖动服务对象**********************//
//检测是否拖动处理完毕,如果完毕则隐藏装饰框DM(在页面上的框架)
var CheckMoveIsEnd = {
    CheckObj:{
        DM:null,
        FeedObj:null,
        curColObj:null  
     },
    Init:function(DM,FeedObj,curColObj)
    {
        this.CheckObj.DM = DM;
        this.CheckObj.FeedObj = FeedObj; 
        this.CheckObj.curColObj = curColObj;
        this.Check();       
    },
    Check: function(){
       if(this.CheckObj.DM.IsMoveEnd)
       {
            this.CheckObj.curColObj.Frame.replaceChild(this.CheckObj.FeedObj.Frame, G.MoveDisplayDiv);
            //交换在数组中的位置            
            G.MoveDisplayDiv.style.display = "none";
            this.CheckObj.FeedObj.Frame.style.position = "static";     
           
           this.CheckObj.DM.style.display = "none";
           this.CheckObj.FeedObj.Frame.style.visibility="visible";
           this.CheckObj.DM.innerHTML = "";
           
            this.CheckObj.DM = null;
            this.CheckObj.FeedObj = null; 
            this.CheckObj.curColObj = null;
           
       }
       else
       { 
           setTimeout("CheckMoveIsEnd.Check()", 200);
       }
    }

}

//在页面上显示信息
G.DM = function(divID,message,isadd)
{
    if(isadd)
           $(divID).innerHTML += message;
     else      
        $(divID).innerHTML = message;       
}

//指定控件在页面上滑动
//原理:从原始宽度以加速度的形式到指定的值,
//然后再以指定的加速度的形式停止到指定的宽度
//传入参数:MoveObj=移动对象 ObjWidth= 对象的原始宽度,AcceleValue=开始递增的值
G.SlideObj = function(MoveObj,ObjWidth,AcceleValue)
{
     MoveObj = $(MoveObj);
     if(ObjWidth <= MoveObj.clientWidth)
     {
           window.clearTimeout();
           MoveObj.style.width = ObjWidth + "px"; 
     }
     else
     {
        MoveObj.style.width = MoveObj.clientWidth + AcceleValue + "px";
        window.setTimeout("G.SlideObj('"+MoveObj.id +"',"+ObjWidth+","+AcceleValue+")", 10);
     }     
}

//隐藏清空提示框
//传入参数:ObjID=控制控件的ID EventType=事件类型 HOD=隐藏还是显示,为真则显示否则隐藏
G.HiddenODisplayFrame = function(ObjID,EventType,HOD)
{
    var PageObj = $(ObjID);
    var firstChild = PageObj.firstChild;
    if(firstChild != null)
     {
        firstChild.removeNode(true);
     }
    switch (EventType)
    {
        case "mouseover":
        {            
             PageObj.style.display = "block";     
             PageObj.innerHTML = "";            
            break;
        }
        case "mouseout":
        {            
             PageObj.style.display = "none";
                  
             PageObj.innerHTML = "";
            break;
        }
        case "click":
        {     
            //主要是针对菜单附件的隐藏或显示
           //当点击菜单时则显示控件,当点击关闭按钮时则隐藏控件 
           if(HOD)
           {      
                 PageObj.style.display = "block";     
                 PageObj.innerHTML = "";
           }
           else
           {
                PageObj.style.display = "none";     
                PageObj.innerHTML = "";
           }             
            break;
        }
    }   
}


//拖动时显示框
G.MoveDisplayDiv = document.createElement("div");
G.MoveDisplayDiv.ID = "MoveDisplayDiv";
G.MoveDisplayDiv.className = "MoveDisplayDiv";
//*********************************************页面上显示数据的方法**********************//
G.DisplayInfo = function(PageObj,Info){
    
    var pageobj = $(PageObj);
    pageobj.innerHTML = Info;
}

var EditTMP = new Object();
var ContentTMP = new Object();


//请求对象,把所有的请求统一起来,以便于管理
var G_RequestObj = new Object();
//传入参数:URL=请求地址,params=参数,SuccessFunc=成功返回处理方法 Method=Get或POST
G_RequestObj.send = function(URL,params,SuccessFunc,Method,RIObj){
   if(typeof URL != "undefined"&&URL != "")
     new  Ajax.Request(URL,{method:Method,asynchronous:true,parameters:params,onComplete:SuccessFunc,onFailure:SuccessFunc})
   else
   {
        if(typeof RIObj != "undefined")
        {
            RIObj.Stop1();
        }
   }  
}


//Request.send = function(url, method, callback, data, urlencoded) {
//    var req;          
//        if (window.XMLHttpRequest) {
//            req = new XMLHttpRequest();
//        } else if (window.ActiveXObject) {
//            req = new ActiveXObject("Microsoft.XMLHTTP");
//        }
//	//为状态改变事件定义方法
//    req.onreadystatechange = function() {
//        if (req.readyState == 4) {
//            if (req.status < 400) {
//                (method=="POST") ? callback(req) : callback(req,data);
//            } else {
//                callback(req);
//            }
//        }
//    }
//    if (method=="POST") {
//        req.open("POST", url, false);
//        if (urlencoded) req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//        req.send(data);
//    } else {
//        if(url.indexOf("getUserData")!=-1)
//            url = "servlet/getUserData.html";
//        if(url.indexOf("xmlProx") !=-1)
//            
//           url = "http://dodoor.net/servlet/xmlProxy?url=rss%2Fsina%2Fddt.xml";
//            
//        if(url.indexOf("getUserData")!=-1||url.indexOf("xmlProx") !=-1) {
//        req.open("GET", url, false);
//        req.send(null);}
//    }

//    return req;
//}

//Request.sendRawPOST = function(url, data, callback) {
//    Request.send(url, "POST", callback, data, true);
//}

G.PopMessage = function(){
    alert('ok');
}

G.OpenMenu = function(){ 
     var PageObj = $(G.PageObj.Div_Nav);
     
     //G.PosToFather(PageObj,G.getScrollXY().top+200,G.getScrollXY().left+1); 
     G.PosToFather(PageObj,208,G.getScrollXY().left+1); 
     PageObj.IsClose = false;   
}

//document.domain = "192.168.1.76";







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -