📄 divviewchange.js
字号:
/*
*this file is part of nseer erp
*Copyright (C)2006-2010 Nseer(Beijing) Technology co.LTD/http://www.nseer.com
*
*This program is free software; you can redistribute it and/or
*modify it under the terms of the GNU General Public License
*as published by the Free Software Foundation; either
*version 2 of the License, or (at your option) any later version.
*/
try{
var n_D=new Nseer_DivViewChange('n_D');
document.onmousedown=function (e){n_D.initDrag(e);}
document.onmouseup=function (e){n_D.dragimg(e);}
document.body.onmousemove=function (e){n_D.mouseStyle(e);}
function Nseer_DivViewChange(name){
this.Version = "NSEER ERP V7.0-js1.0";
this.name=name;
this.onmousedown = document.onmousedown;
this.onmousemove = document.onmousemove;
this.onmouseup = document.onmouseup;
this.onselectstart = document.onselectstart;
this.dE=document.getElementById&&!document.all;
this.mouse_tag=0;
this.isdrag=false;
this.oDragObj=null;
this.nseerZindex=0;
this.port_X=0;
this.port_Y=0;
this.port_X1=0;
this.port_Y1=0;
this.left1=0;
this.top1=0;
this.tag=0;
this.min_tag=0;
this.max_tag=0;
this.data=new Array();
this.v=0;
this.db_max_return=0;
this.def=0;
this.nseerDef=0;
this.scrollW=document.body.scrollWidth;
this.detachEvent=function(){//注销事件
document.onselectstart=this.onselectstart;
}
this.coverSelect=function(div){//注销事件
var n_iframe=document.createElement('iframe');
n_iframe.src="javascript:false";
n_iframe.style.cssText="position:absolute;visibility:inherit;top:0px;left:0px;width:100%;height:100%;z-index:-1;filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'";
div.appendChild(n_iframe);
}
this.initDrag=function (e){//初始化层方法开始
e=e||window.event;//区分ie和firefox的event
this.mouse_tag=1;
var oDragHandle = this.dE ? e.target : e.srcElement;
var topElement = "HTML";
while (oDragHandle.tagName != topElement && oDragHandle.getAttribute("nseerDef") != "dragAble"&&oDragHandle.getAttribute("nseerDef") != "dragonly"){//在ie和firfox都可以使用getAttribute获取自定义属性
oDragHandle = this.dE ? oDragHandle.parentNode : oDragHandle.parentElement;
}
if(oDragHandle.getAttribute("nseerDef")!=null&&oDragHandle.getAttribute("nseerDef")!='undefined'){
if(oDragHandle.getAttribute("nseerDef")=="dragAble"){this.nseerDef=1;}
if(oDragHandle.getAttribute("nseerDef")=="dragonly"){this.nseerDef=2;}
if(this.nseerDef==1||this.nseerDef==2){
this.isdrag = true;
this.oDragObj = oDragHandle;
//*********************************************
//this.oDragObj.style.zIndex=++this.nseerZindex;
this.oDragObj.style.overflow='hidden';
this.port_X1=e.clientX;
this.port_Y1=e.clientY;
var x12=parseInt(this.getStyle(this.oDragObj,"left","left"))+parseInt(this.getStyle(this.oDragObj,"width","width"));
var y12=parseInt(this.getStyle(this.oDragObj,"top","top"))+parseInt(this.getStyle(this.oDragObj,"height","height"));
this.left1=parseInt(this.getStyle(this.oDragObj,"left","left"));
this.top1=parseInt(this.getStyle(this.oDragObj,"top","top"));
this.loadDiv(this.oDragObj,0,e);
//*****************************
if(this.tag==0){
document.onselectstart=this.onselectstart;
}else{
document.onselectstart = function() { return false;};
}
eval('document.onmousemove=function (e){'+this.name+'.moveMouse(e);}');
return false;
}
}
}
this.loadDiv=function (obj,t,e){//点下鼠标时改变鼠标样式同时置标识位
e=e||window.event;
var nseer_r=obj;
var w = obj.offsetWidth;
var h = obj.offsetHeight;
var x = obj.offsetLeft;
var y = obj.offsetTop;
while(obj=obj.offsetParent){
x += obj.offsetLeft;
y += obj.offsetTop;
}
if(this.nseerDef==1){
if(parseInt(e.clientX)>parseInt(x)&&parseInt(e.clientX)<parseInt(x)+10&&parseInt(e.clientY)<parseInt(y)+h-15&&parseInt(e.clientY)>parseInt(y)+15){//左侧边界
if(t!=0){
nseer_r.style.cursor='e-resize';
}else{
this.tag=8;//左侧边界
}
}else if(parseInt(e.clientX)<parseInt(x)+15&&parseInt(e.clientY)<parseInt(y)+15){
if(t!=0){
nseer_r.style.cursor='nw-resize';//左上角
}else{
this.tag=7;//左上角
}
}else if(parseInt(e.clientX)<parseInt(x)+w&&parseInt(e.clientX)>parseInt(x)+w-10&&parseInt(e.clientY)<parseInt(y)+h-15&&parseInt(e.clientY)>parseInt(y)+15){//右侧边界
if(t!=0){
nseer_r.style.cursor='e-resize';
}else{
this.tag=1;//右侧边界
}
}else if(parseInt(e.clientX)>parseInt(x)+w-5&&parseInt(e.clientY)<parseInt(y)+5){
if(t!=0){
nseer_r.style.cursor='ne-resize';//右上角
}else{
this.tag=5;//右上角
}
}else if(parseInt(e.clientY)<parseInt(y)+5&&parseInt(e.clientX)<parseInt(x)+w-15&&parseInt(e.clientX)>parseInt(x)+15){
if(t!=0){
nseer_r.style.cursor='s-resize';////上侧边界
}else{
this.tag=6;//上侧边界
}
}else if(parseInt(e.clientX)<parseInt(x)+15&&parseInt(e.clientY)>parseInt(y)+h-15){
if(t!=0){
nseer_r.style.cursor='ne-resize';//左下角
}else{
this.tag=9;//左下角
}
}else if(parseInt(e.clientY)<parseInt(y)+h+5&&parseInt(e.clientY)>parseInt(y)+h-5&&parseInt(e.clientX)<parseInt(x)+w-15&&parseInt(e.clientX)>parseInt(x)+15){
if(t!=0){
nseer_r.style.cursor='s-resize';//下边界
}else{
this.tag=2;//下侧边界
}
}else if(parseInt(e.clientX)>parseInt(x)+w-15&&parseInt(e.clientY)>parseInt(y)+h-15){
if(t!=0){
nseer_r.style.cursor='nw-resize';//右下角
}else{
this.tag=3;//右下角
}
}else if(parseInt(e.clientY)>parseInt(y)+10&&parseInt(e.clientY)<parseInt(y)+33&&parseInt(e.clientX)<parseInt(x)+parseInt(w)-70&&parseInt(e.clientX)>parseInt(x)){
if(t!=0){
nseer_r.style.cursor='move';//移动区域
}else{
this.tag=4;
}
}else{
if(t!=0){
nseer_r.style.cursor='default';//中间区域
}else{
this.tag=0;
}
}
}else if(this.nseerDef==2){
if(parseInt(e.clientY)>parseInt(y)+10&&parseInt(e.clientY)<parseInt(y)+33&&parseInt(e.clientX)<parseInt(x)+parseInt(w)-70&&parseInt(e.clientX)>parseInt(x)){
if(t!=0){
nseer_r.style.cursor='move';//移动区域
}else{
this.tag=4;
}
}else{
if(t!=0){
nseer_r.style.cursor='default';//中间区域
}else{
this.tag=0;
}
}
}
}
this.moveMouse=function (e){//根据鼠标点下时给tag赋的不同值对当前层进行不同操作
if(this.isdrag==true&&this.max_tag==0){
e=e||window.event;
var x12=parseInt(this.getStyle(this.oDragObj,"left","left"))+parseInt(this.getStyle(this.oDragObj,"width","width"));
var y12=parseInt(this.getStyle(this.oDragObj,"top","top"))+parseInt(this.getStyle(this.oDragObj,"height","height"));
if(this.tag==0){
this.port_X=e.clientX;
this.port_Y=e.clientY;
document.body.scrollTop=0;
document.body.scrollLeft=0;
this.left1=parseInt(this.getStyle(this.oDragObj,"left","left"));
this.top1=parseInt(this.getStyle(this.oDragObj,"top","top"));
}
if(this.tag==1){
this.port_X=e.clientX;
this.port_Y=e.clientY;
document.body.scrollTop=0;
document.body.scrollLeft=0;
if(this.port_X>0&&this.port_X>parseInt(this.left1)) this.oDragObj.style.width=this.port_X-parseInt(this.left1)+2;
}
if(this.tag==8){
this.port_X=e.clientX;
this.port_Y=e.clientY;
document.body.scrollTop=0;
document.body.scrollLeft=0;
if(this.port_X>0&&this.port_X<x12){
this.oDragObj.style.left=this.port_X-2;
this.oDragObj.style.width=x12-this.port_X+2;
}
}
if(this.tag==2){
this.port_X=e.clientX;
this.port_Y=e.clientY;
document.body.scrollTop=0;
document.body.scrollLeft=0;
if(this.port_Y>0&&this.port_Y>parseInt(this.top1)) this.oDragObj.style.height=this.port_Y-parseInt(this.top1);
}
if(this.tag==6){
this.port_X=e.clientX;
this.port_Y=e.clientY;
document.body.scrollTop=0;
document.body.scrollLeft=0;
if(this.port_Y>0&&this.port_Y<y12){
this.oDragObj.style.top=this.port_Y-2;
this.oDragObj.style.height=y12-this.port_Y+2;
}
}
if(this.tag==3){
this.port_X=e.clientX;
this.port_Y=e.clientY;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -