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

📄 qqmenu.js

📁 ARCGIS程序,可以实现查、缩放等功能
💻 JS
📖 第 1 页 / 共 2 页
字号:
	
	this.setID			= _QQItem_setID;
	this.setIndex		= _QQItem_setIndex;
	this.content		= _QQItem_content;
	
	this.createItem		= _QQItem_createItem;//�����Ӳ˵��ķ���	
	this.move			= _QQItem_move;			//�˵������ƶ��ķ���	
	this.cleanUp		= _QQItem_cleanUp;		//����ͷ���Դ

	this.setContentHeight = _QQItem_setContentHeight;
	
	this.init();//���ó�ʼ��
}

function _QQItem_cleanUp(){
	this.parent = null;
	for(var i=0;i<this.children.length;i++){
		this.children[i].cleanUp();
		this.children[i] = null;
	}
	
	this.children	= null;	
	this.object		= null;
}

function _QQItem_setContentHeight(height){
	this.object.content.style.height = height;
	this.setIndex(this.object.itemIndex);
}

function _QQItem_init(){
	var htmlCont	= document.createElement("div");
	with( htmlCont.style ){
		visibility	= "visible";	
		position	= "relative";
		marginLeft	= 1;
		marginRight	= 1;
		marginTop	= 0;
		marginBottom= 0;
		width		= "100%";	
	}
	
	this.object		= htmlCont;
	
	//��ֹѡ�й���
	var disableSelect = function(){
		if( event.preventDefault ) event.preventDefault();
		else event.returnValue = false;
	}
	EventManager.Add(this.object,"selectstart",disableSelect);		
	
	var table				= document.createElement("div");	
	this.object.viscera		= table;
	this.object.appendChild(table);
	
	with( table ){
		style.width		= "100%";
		style.fontSize	= "12px";
		style.margin	= "0px";		
		style.margin	= 0;
		border			= 0;
		verticalAlign	= "middle";
	}
	
	var titleTD			= document.createElement("DIV");	
	titleTD.align		= "center";
	titleTD.ownerMenu	= this;
	this.object.caption	= titleTD;
	
	var wrapper = document.createElement("SPAN");
	wrapper.style.marginTop = 2; //������Ŀ�˵�����λ��-WWX
	wrapper.style.width = "100%";
	wrapper.style.height= "50%";
	wrapper.appendChild(document.createTextNode(this.caption));
	
	//titleTD.appendChild(document.createTextNode(this.caption));
	titleTD.appendChild(wrapper);
	
	table.appendChild(titleTD);
	
	with( titleTD.style ){
		cursor		= titleCursor;
		borderTop	= "1px solid #FFFFFF";
		height		= ""+titleHeight;
		margin		= 0;
		background	= titleMiddleBG;
		verticalAlign	= "middle";
		
	}
	
	var switchBG = function(){//�л���˵���title�ı���
		var srcEle = event.srcElement;
		if( srcEle.tagName!='DIV' ) srcEle = srcEle.parentElement;
		if( event.type == 'mouseover' ) srcEle.style.background = titleMiddleBG_h;
		else srcEle.style.background = titleMiddleBG;
	}
	EventManager.Add(titleTD,"mouseover",switchBG);
	EventManager.Add(titleTD,"mouseout",switchBG);
	EventManager.Add(titleTD,"click",_QQItem_titleClick);
	
	var contTD			= document.createElement("DIV");	
	this.object.content = contTD;		
	table.appendChild(contTD);
	
	with( contTD.style ){
		height				= contentHeight;
		background			= contentBackground;
		width					= "100%";
		overflow				= "auto";	
		scrollbar3dLightColor	= "#DCDCDC";
		scrollbarFaceColor	= "#4682B4";		
		scrollbarBaseColor	= "#FFA07A";
		scrollbarShadowColor	= "Navy";
		scrollbarDarkShadowColor	= "#A9A9A9";
		scrollbarHighlightColor	= "#D3D3D3";
		scrollbarTrackColor		= "#ADD8E6";
		

	}
}


function _QQItem_titleClick(){
	var srcEle = event.srcElement;
	if( srcEle.tagName!='DIV' ) srcEle = srcEle.parentElement;
	srcEle.ownerMenu.parent.showItem(srcEle.ownerMenu.object.itemIndex);	
}

function _QQItem_setID(id){this.object.id = id;}

function _QQItem_setIndex(index){
	this.object.itemIndex = index;
	
	this.object.style.top = ""+(-contentHeight*index);	
	
}

function _QQItem_content(){return this.object;}

function _QQItem_createItem(caption,url,target){
	var item = new QQSubItem(caption,url,target);
	
	this.children[this.children.length] = item;
	this.object.content.appendChild(item.content());
	
	return item;
}

function _QQItem_move(offset){
	this.object.style.top = ""+(parseInt(this.object.style.top)+offset);
} 

/**
 * �Ӳ˵��ṹ
 * @param  caption	�Ӳ˵�����
 * @param  url		�˵�t��
 * @param  target	
 */
function QQSubItem(caption,url,target){
	this.caption = caption;
	this.url = url;		
	
	this.children = new Array();
	
	//��������
	this.createItem		= _QQSubItem_createItem;	//�����Ӳ˵�����
	this.open			= _QQSubItem_open;			//չ���˵�
	this.close			= _QQSubItem_close;			//�ϱղ˵�
	this.display		= _QQSubItem_display;		//��ʾ�˵�
	this.content		= _QQSubItem_content;		//��ȡ�˵����ʾ��HTML����
	this.cleanUp		= _QQSubItem_cleanUp;		//����ͷ���Դ
	
	this.object = document.createElement("div");
	with( this.object ){
		style.width = "100%";
		style.whiteSpace = "nowrap";
		style.valign = "top";	
		style.marginLeft = subMenuLeftMargin;
		style.marginTop = subMenuTopMargin;         //�����-WWX-�����Ӳ˵��������ľ���
	}
	
	var title = document.createElement("a");
	title.style.textDecoration = "none";
	title.href = this.url;	
	title.target = target==null?defaultTarget:target;
	title.appendChild(document.createTextNode(caption));
		
	var titleImg = document.createElement("img");
	this.object.img = titleImg;
	with( titleImg ){
		style.cursor = "hand";
		style.marginRight = "2";
		style.border = 0;	
		style.width = 19;
		style.height= 16;
		src = subMenuLeafIcon;	
	}
	titleImg.open = 'none';
	titleImg.owner	= this;
	EventManager.Add(titleImg,"click",_QQSubItem_titleOnclick);	
 			
	this.object.appendChild(titleImg);
	this.object.appendChild(title);
}

function _QQSubItem_cleanUp(){
	for(var i=0;i<this.children.length;i++){
		this.children[i].cleanUp();
		this.children[i] = null;
	}
	
	this.object = null;
}

function _QQSubItem_createItem(caption,url,target){
	var sItem = new QQSubItem(caption,url,target);
	this.children[this.children.length] = sItem;
	this.object.appendChild(sItem.content());
	if( this.object.img.open == 'none' ){
		this.object.img.src = subMenuCloseIcon;
		this.object.img.open = 'false';
	}
	sItem.object.style.display = "none";
	return sItem;
}

function _QQSubItem_titleOnclick(){
	var srcEle = event.srcElement;
	if( srcEle.open=='none' ) return;
	if(srcEle.open=='false'){
		srcEle.src=subMenuOpenIcon;		
		srcEle.open='true';
		srcEle.owner.open();
	}else 
		if(srcEle.open='close'){ 
			srcEle.src=subMenuCloseIcon;
			srcEle.open='false';
			srcEle.owner.close();
		}	
}

function _QQSubItem_open(){
	for(var i=0;i<this.children.length;i++) this.children[i].display(true);	
}

function _QQSubItem_close(){
	for(var i=0;i<this.children.length;i++) this.children[i].display(false);
}

function _QQSubItem_display(visible){
	if( !visible ) this.object.style.display = 'none';
	else	this.object.style.display = 'block';
}

function _QQSubItem_content(){return this.object;}

if (!Array.prototype.push){
    Array.prototype.push = function(elem){
        this[this.length] = elem;
    }
}

var MenuManager = {
	_registry: null,

    Initialise: function(){
        if (this._registry == null){
            this._registry = [];
            EventManager.Add(window, "unload", this.CleanUp);
        }
    },
    
    Add: function(menu){
        this.Initialise();

        if (menu == null) return false;

        this._registry.push({menu: menu});
        return true;
    },
    
    CleanUp: function(){
        for (var i = 0; i < MenuManager._registry.length; i++){
            with (MenuManager._registry[i]){				
				menu.cleanUp();                    
                menu = null;
            }
        }

        MenuManager._registry = null;
    }
};

⌨️ 快捷键说明

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