<html>
<head>
<title>163邮箱选项卡效果</title>
<script>
</script>
<style>
ul,li
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
margin:0;
padding:0;
list-style:none;
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*for close location*/
position:relative;
}
li
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
display:block;
width:130px;
height:25px;
float:left;
cursor:pointer;
overflow:hidden;
}
span
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
font-size:10pt;
color:#22b5d9;
font-weight:bold;
display:block;
}
#asgardCard li
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
font-size:10pt;
font-weight:bold;
color:#22b5d9;
border:1px solid #22b5d9;
margin:10px;
text-align:center;
line-height:1.5;
}
</style>
<style>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Asgard CardProgram Css Start*/
#itemsPanel,#itemsPanel li
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
margin:0;
padding:0;
list-style:none;
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*for close location*/
position:relative;
}
ul:after
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
#cardContent
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
height:auto;
min-height:300px;
border:2px solid #cccccc;
clear:both;
}
#itemsPanel li
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
display:block;
width:130px;
height:25px;
float:left;
cursor:pointer;
overflow:hidden;
}
#cardFrame
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
width:100%;height:100%;border:1px solid #ffffff;margin:0;
}
.active
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
background:url('/upload/163tab.jpg') 0 0 no-repeat;
}
.default
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
background:url('/upload/163tab.jpg') 0 -25px no-repeat;
}
.title
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
font-size:10pt;
font-weight:bold;
line-height:2;
padding-left:10px;
display:block;
width:105px;
height:25px;
}
li .close
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
position:absolute;
top:9px;
left:115px;
display:block;
width:10px;
height:10px;
overflow:hidden;
}
.active .close
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
background:url('/upload/163tab.jpg') 0 -50px no-repeat;
}
.default .title
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
color:#999999;
}
.active .title
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
color:#000000;
}
.active .close:hover
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
background:url('/upload/163tab.jpg') -10px -50px no-repeat;
}
.default .close
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
background:url('/upload/163tab.jpg') -20px -50px no-repeat;
}
.default .close:hover
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
background:url('/upload/163tab.jpg') -30px -50px no-repeat;
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*Asgard CardProgram Css End*/
</style>
</head>
<body>
<span>1.代码效果示例:</span>
<ul>
<li class="active">
<nobr class="title">Kiss</nobr>
<a href="#nogo" class="close" title="关闭"></a>
</li>
<li class="default">
<nobr class="title">Andy</nobr>
<a href="#nogo" class="close" title="关闭"></a>
</li>
</ul>
<p />
<span>注:以上代码为DOM动态组织的代码参考<span>
<p style="clear:both;"/>
<p />
<span>2.点击下表,更换内容</span>
<ul id="asgardCard">
<li title="webkey">IT人家</li>
<li title="google">Google中国</li>
<li title="email126">Email-126</li>
<li title="companyease">企易动力</li>
</ul>
<p style="clear:both;"/>
<span>3.以下为动态创建:</span>
<div>
<ul id="itemsPanel">
</ul>
<div id="cardContent">
<iframe id="cardFrame">
</iframe>
</div>
</div>
</body>
<script>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
* Field Declare ^-^
*/
var Asgard;
if(!Asgard)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
Asgard=
{};
if(!Asgard.CardProgram)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
Asgard.CardProgram=
{};
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:define Object ItemsPanel
*/
Asgard.CardProgram.ItemsPanel=function(id,frameId)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
this.element=$(id);
this.register=new Array();
this.currentItem=null;
this.cardFrame=$(frameId);
this.element.className='itemsPanel';
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:add item from panel
*/
Asgard.CardProgram.ItemsPanel.prototype.addItem=function(item)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
if(this.validateExist(item.element.getAttribute('id')))
return;
item.panel=this;
this.visitedRegister(item,"add");
this.element.appendChild(item.element);
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:delete item from panel
*/
Asgard.CardProgram.ItemsPanel.prototype.deleteItem=function(item)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
this.visitedRegister(item,"delete");
this.element.removeChild(item.element);
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*Ajax or other
*/
Asgard.CardProgram.ItemsPanel.prototype.changeSubPage=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
if(this.register.length==0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.cardFrame.src="";
return;
}
this.cardFrame.src=this.currentItem.url;
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*
*这里用户可以自己定义想要的页面,如果你想内嵌IFrame。
*/
}
Asgard.CardProgram.ItemsPanel.prototype.validateExist=function(id)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
for(var i=0;i<this.register.length;i++)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
if(this.register[i].element.id==id)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
return true;
}
}
return false;
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:register visited sequence
* type--add | delete | active
*/
Asgard.CardProgram.ItemsPanel.prototype.visitedRegister=function(item,type)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
var i=this.register.length;
if(type=="add")
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
for(var k=0;k<i;k++)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.register[k].resetItem();
}
this.currentItem=item;
this.register[i]=item;
this.currentItem.element.className="active";
this.changeSubPage();
}
else if(type=="delete")
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
for(k=0;k<i;k++)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
if(this.register[k]==item)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.register.splice(k,1);
break;
}
}
if(item==this.currentItem)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
i=this.register.length;
if(i>0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.currentItem=this.register[i-1];
this.currentItem.element.className="active";
}
else
this.currentItem=null;
}
this.changeSubPage();
}
else if(type=="active")
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
if(this.currentItem==item)
return;
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
for(k=0;k<i;k++)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
if(this.register[k]==item)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.register.splice(k,1);
break;
}
}
i=this.register.length;
for(k=0;k<i;k++)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.register[k].resetItem();
}
this.currentItem=item;
this.register.push(item);
}
this.changeSubPage();
}
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:define Object Item
*/
Asgard.CardProgram.Item=function(id,title,url,flag)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
this.element=this.$C();
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
this.panel=
{};
this.id=id;
this.title=title;
this.url=url;
this.flag=flag;
this.init();
};
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:init item
*/
Asgard.CardProgram.Item.prototype.init=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
this.element.setAttribute('id',this.id);
this.element.className="default";
var mirror=this;
if(!this.flag)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.element.innerHTML="<nobr class='title' title='"+this.title+"'>"+this.title+"</nobr>"+"<a href='#nogo' class='close' title='关闭'></a>";
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
this.addEventListener(this.$ES(this.element,'nobr')[0],'click',function()
{mirror.activeItem();});
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
this.addEventListener(this.$ES(this.element,'a')[0],'click',function()
{mirror.destroyItem();});
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
this.element.innerHTML="<nobr class='title' title='"+this.title+"'>"+this.title+"</nobr>";
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
this.addEventListener(this.$ES(this.element,'nobr')[0],'click',function()
{mirror.activeItem();});
}
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*active item
*/
Asgard.CardProgram.Item.prototype.activeItem=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
this.panel.visitedRegister(this,"active");
this.element.className="active";
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:reset item
*/
Asgard.CardProgram.Item.prototype.resetItem=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
this.element.className="default";
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:destroy item
*/
Asgard.CardProgram.Item.prototype.destroyItem=function()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
this.panel.deleteItem(this);
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:addListener to item
*/
Asgard.CardProgram.Item.prototype.addEventListener=function(element,type,handler)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
if(element.addEventListener)
element.addEventListener(type,handler,true);
else
element.attachEvent("on"+type,handler,true);
}
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//*
*function:usefull functions
*/
Asgard.CardProgram.Item.prototype.$C=function(tag)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
if(tag && typeof tag =="string")
return document.createElement(tag);
else
return document.createElement('li');
}
Asgard.CardProgram.Item.prototype.$ES=function(element,tag)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
return element.getElementsByTagName(tag);
}
function $(id)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
return document.getElementById(id);
}
</script>
<script>
function attachExampleEvent()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
var lists=$('asgardCard').getElementsByTagName('li');
for(var i=0;i<lists.length;i++)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
lists[i].;
}
}
function exampleClickListener(e)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
e=e || window.event;
var source=e.target || e.srcElement;
if(source.getAttribute('title')=='webkey')
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
itemsPanel.addItem(new Asgard.CardProgram.Item("webkey","IT人家","http://www.webkey.cn",false));
}
else if(source.getAttribute('title')=='google')
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
itemsPanel.addItem(new Asgard.CardProgram.Item("google","Google中国","http://www.google.cn",false));
}
else if(source.getAttribute('title')=='email126')
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
itemsPanel.addItem(new Asgard.CardProgram.Item("email126","Email-126","http://mail.126.com",false));
}
else if(source.getAttribute('title')=='companyease')
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
itemsPanel.addItem(new Asgard.CardProgram.Item("companyease","企易动力","http://www.companyease.com",false));
}
}
var itemsPanel=null;
function exampleStartMethod()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
attachExampleEvent();
if(itemsPanel==null)
itemsPanel=new Asgard.CardProgram.ItemsPanel("itemsPanel","cardFrame");
itemsPanel.addItem(new Asgard.CardProgram.Item("index","动力博客","http://www.companye.net",true));
}
window.;
</script>
</html>
posted @
2008-02-14 18:57
龍峸.大卫
阅读(
1286)
评论()
编辑
收藏
举报