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

📄 menu.js

📁 MVM MALL网上商店系统 V4.1.0功能文档说明 欢迎各商城用户定制模板及特殊功能 欢迎各大中小企业及个人定模板风格.
💻 JS
字号:

function PwMenu(){
	this.pid  = null;
	this.obj  = null;
	this.w	  = null;
	this.w	  = null;
	this.t	  = 0;
	this.menu = null;
	this.init();
}
PwMenu.prototype = {

	get : function(){
		if(ajax.request.responseText.indexOf('<') != -1){
			read.menu.innerHTML = ajax.request.responseText;
			read.menu.className = 'menu';
			read.menupz(read.obj,1);
		} else{
			closep();
			ajax.guide();
		}
	},

	init : function(){
		this.menu = document.createElement('div');
		document.body.insertBefore(this.menu,document.body.firstChild);
	},

	guide : function(){
		read.menu.innerHTML = '<div style="padding:13px 30px"><img src="'+imgpath+'/loading.gif" align="absbottom" /> 正在加载数据...</div>';
		read.menu.className = 'menu';
		read.menupz(read.obj,1);
	},

	close : function(){
		read.t = setTimeout("read.menu.style.display='none';",400);
	},

	submit : function(obj,recall){
		if(typeof recall == 'undefined' || typeof recall != 'function'){
			recall = ajax.guide;
		}
		var d = '';
		var o = obj.elements;
		for(var i=0;i<o.length;i++){
			if(o[i].name && (o[i].type != 'radio' && o[i].type != 'checkbox' || o[i].checked === true))
				d += "&" + o[i].name + "=" + ajax.convert(o[i].value);
		}
		ajax.send(obj.action,d,recall);
		closep();
	},

	move : function(e){
		if(is_ie){
			document.body.onselectstart = function(){return false;}
		}
		var e  = is_ie ? window.event : e;
		var o  = read.menu;
		var x  = e.clientX;
		var y  = e.clientY;
		read.w = e.clientX - parseInt(o.offsetLeft);
		read.h = e.clientY - parseInt(o.offsetTop);
		document.onmousemove = read.moving;
		document.onmouseup   = read.moved;
	},

	moving : function(e){
		var e  = is_ie ? window.event : e;
		var x  = e.clientX;
		var y  = e.clientY;
		read.menu.style.left = x - read.w + 'px';
		read.menu.style.top  = y - read.h + 'px';
	},

	moved : function(){
		if(is_ie){
			document.body.onselectstart = function(){return true;}
		}
		document.onmousemove = '';
		document.onmouseup   = '';
	},

	open : function(idName,object,type){
		clearTimeout(read.t);
		if(typeof type == "undefined"){
			type = 1;
		}
		read.menu.innerHTML = getObj(idName).innerHTML;
		read.menu.className = getObj(idName).className;
		read.menupz(object,type);
		if(type!=2){
			getObj(object).onmouseout = read.close;
			read.menu.onmouseout = read.close;
			read.menu.onmouseover = function(){
				clearTimeout(read.t);
			}
		}
	},

	menupz : function(obj,type){
		read.menu.onmouseout = '';
		read.menu.style.display = '';
		read.menu.style.cssText = 'FILTER:Alpha(opacity=95);opacity:0.95;left:-500px;z-index:3000';
		if(typeof obj == 'string'){
			obj = getObj(obj);
		}
		if(obj == null){
			read.menu.style.top  = (ietruebody().clientHeight - read.menu.offsetHeight)/2 + ietruebody().scrollTop + 'px';
			read.menu.style.left = (ietruebody().clientWidth - read.menu.offsetWidth)/2 + 'px';
		} else{
			var top  = findPosY(obj);
			var left = findPosX(obj);
			
			if(top < ietruebody().clientHeight/2 || type>3){
				top += ietruebody().scrollTop + obj.offsetHeight;
			} else{
				top += ietruebody().scrollTop - read.menu.offsetHeight;
			}
			if(left > (ietruebody().clientWidth)*3/5){
				left -= read.menu.offsetWidth - obj.offsetWidth;
			}
			read.menu.style.top  = top  + 'px';
			read.menu.style.left = left + 'px';
		}
	}
}
var read = new PwMenu();

function closep(){
	read.menu.style.display = 'none';
}
function findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if(obj.x){
		curleft += obj.x;
	}
	return curleft - ietruebody().scrollLeft;
}
function findPosY(obj){
	var curtop = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if(obj.y){
		curtop += obj.y;
	}
	return curtop - ietruebody().scrollTop;
}
function in_array(str,a){
	for(var i=0;i<a.length;i++){
		if(str == a[i])	return true;
	}

	return false;
}
function loadjs(path){
	var header = document.getElementsByTagName("head")[0];
	var s = document.createElement("script");
	s.src = path;
	header.appendChild(s);
}
function ck(o){
	var nowtime	 = new Date().getTime();
	o.src = 'ck.php?nowtime=' + nowtime;
}
function checkinput(obj,val){
	if (obj.value==obj.defaultValue && obj.className.indexOf('gray') != -1) {
		obj.value = '';
		obj.className = obj.className.replace('gray', 'black');
	} else if (val && obj.value=='') {
		obj.value = obj.defaultValue = val;
		if (obj.className.indexOf('black') == -1) {
			obj.className += ' gray';
		} else {
			obj.className = obj.className.replace('black', 'gray');
		}
	}
}

⌨️ 快捷键说明

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