mytoolbarmenu
来源:互联网 发布:淘宝导航条怎么全屏 编辑:程序博客网 时间:2024/06/03 19:28
<script>
Ext.BLANK_IMAGE_URL = '/ext/resources/images/default/s.gif';
Ext.onReady(function(){
var hideFunction = function()
{
var visible = this.hasVisibleMenu();
if (visible)
{
this.hideMenu();
}
};
var showFunction = function()
{
var visible = this.hasVisibleMenu();
if (!visible)
{
this.showMenu();
}
};
<%=request.getSession().getAttribute("treecode").toString()
%>
Ext.ux.TabCloseMenu = function(){
var tabs, menu, ctxItem;
this.init = function(tp){
tabs = tp;
tabs.on('contextmenu', onContextMenu);
}
function onContextMenu(ts, item, e){
if(!menu){ // create context menu on first right click
menu = new Ext.menu.Menu([{
id: tabs.id + '-close',
text: '关闭',
handler : function(){
tabs.remove(ctxItem);
}
},{
id: tabs.id + '-close-others',
text: '除此之外全部关闭',
handler : function(){
tabs.items.each(function(item){
if(item.closable && item != ctxItem){
tabs.remove(item);
}
});
}
}]);
}
ctxItem = item;
var items = menu.items;
items.get(tabs.id + '-close').setDisabled(!item.closable);
var disableOthers = true;
tabs.items.each(function(){
if(this != item && this.closable){
disableOthers = false;
return false;
}
});
items.get(tabs.id + '-close-others').setDisabled(disableOthers);
menu.showAt(e.getPoint());
}
};
var tabs = new Ext.TabPanel({
renderTo:'tabs',
resizeTabs:true, // turn on tab resizing
minTabWidth: 115,
tabWidth:100,
enableTabScroll:true,
width:1006,
height:565,
defaults: {autoScroll:true},
plugins: new Ext.ux.TabCloseMenu()
});
//增加首页tab
addTab({title:'首页',html:'<iframe id=myframe src=/main2/indextab.jsp width=700 height=500></iframe>'});
document.all("myframe").width= document.all("myframe").document.body.scrollWidth-5;
document.all("myframe").height= document.all("myframe").document.body.scrollHeight-80;
});
-----------------
public class TreeWrite {
private static DaoFactory dao = HibernateDaoFactory.getDaoFactory();
static String scripthead=" ";
static String scriptend=" ";
static String scriptbody="";
public static void clear()
{
scripthead=" ";
scriptend=" ";
scriptbody="";
}
public static void init(String operCode)
{
Session session = HibernateSessionManager.getSession(true);
Query query= session.createQuery("from BasicModulenode where nodeid in (select a.nodeid from BasicRolenode a where roleid in (select roleid from BasicOper where operCode='"+operCode+"')) order by nodeid ");
List list=new ArrayList();
list= query.list();
scriptbody=" Ext.QuickTips.init();";
scriptbody+=" function addTab(obj){ var title=obj.title; var html=obj.html; tabs.add({ title: title,iconCls: 'tabs', html: html , closable:true }).show(); }";
scriptbody+="var mytoolbar= new Ext.Toolbar({id:'tb-id'});";
scriptbody+="mytoolbar.render('toolbar'); ";
for(int i=0;i<list.size();i++)
{
BasicModulenode b= (BasicModulenode)list.get(i);
if (b==null) continue;
int level=b.getLevel();
if(level==1)//顶级按扭
{
//定义每个根结点对应的全局变量及对应函数
scriptbody+="var v"+b.getNodeid()+"Hider, v"+b.getNodeid()+"Shower;var autoHS"+b.getNodeid()+"=function (bt){if(!v"+b.getNodeid()+"Hider){v"+b.getNodeid()+"Hider=new Ext.util.DelayedTask(hideFunction, bt);}/nif(!v"+b.getNodeid()+"Shower){v"+b.getNodeid()+"Shower=new Ext.util.DelayedTask(showFunction, bt);}/n var mouseOut = function(){ v"+b.getNodeid()+"Shower.cancel();v"+b.getNodeid()+"Hider.delay(500);};var mouseOver = function(){ v"+b.getNodeid()+"Hider.cancel();v"+b.getNodeid()+"Shower.delay(200);}/nvar autoConfig ={'mouseout': {fn: mouseOut},'mouseover': {fn: mouseOver}}; this.el.on(autoConfig);};";
if(dao.getIndexShowDao().isExistChild(b.getId())==true)
{
scriptbody +="var tbbutton"+b.getId()+"= new Ext.Toolbar.Button({ listeners:{ 'mouseover':function() { this.showMenu(); },'mouseout':function() { } },text:'"+b.getNodename()+"',menu:new Ext.menu.Menu(), handler:addTab.createCallback({title:'"+b.getNodename()+"',html:'<iframe id=myframe scrolling=0 frameBoder=0 src="+b.getNodeurl()+" width=100% height=100%></iframe>'})});/n ";
}
else
{
scriptbody +="var tbbutton"+b.getId()+"= new Ext.Toolbar.Button({ listeners:{ 'mouseover':function() { this.showMenu(); },'mouseout':function() { } },text:'"+b.getNodename()+"', handler:addTab.createCallback({title:'"+b.getNodename()+"',html:'<iframe id=myframe scrolling=0 frameBoder=0 src="+b.getNodeurl()+" width=100% height=100%></iframe>'})});/n ";
}
scriptbody +="tbbutton"+b.getId()+".menu.on('click',function (){this.hide()}) ;";
scriptbody+="mytoolbar.add(tbbutton"+b.getId()+");/n";
scriptbody +="tbbutton"+b.getId()+".on('render',autoHS"+b.getNodeid()+",tbbutton"+b.getId()+",tbbutton"+b.getId()+");";//自动开关
}
else//菜单
{
if(dao.getIndexShowDao().isExistChild(b.getId())==true)
{
scriptbody +="var tbbutton"+b.getId()+"=new Ext.menu.Item({ menu:new Ext.menu.Menu(), text:'"+b.getNodename()+"', handler:addTab.createCallback({title:'"+b.getNodename()+"',html:'<iframe scrolling=0 frameBoder=0 id=myframe src="+b.getNodeurl()+" width=100% height=100%></iframe>'})});/n";//当前菜单
}
else{
scriptbody +="var tbbutton"+b.getId()+"=new Ext.menu.Item({ text:'"+b.getNodename()+"', handler:addTab.createCallback({title:'"+b.getNodename()+"',html:'<iframe scrolling=0 frameBoder=0 id=myframe src="+b.getNodeurl()+" width=100% height=100%></iframe>'})});/n";//当前菜单
}
scriptbody +="tbbutton"+b.getId()+".on('render',autoHS"+dao.getIndexShowDao().getRootNodeId(b.getNodeid())+",tbbutton"+b.getId()+",tbbutton"+b.getId()+");";//自动开关
scriptbody+="tbbutton"+b.getParentid()+".menu.add(tbbutton"+b.getId()+");/n";//
}
}
scriptbody+="mytoolbar.doLayout(); ";
// scriptbody+="var viewPort=new Ext.Viewport({layout:'fit',items:{html:'test',tbar:mytoolbar} });";
}
public static String getTree(String operCode)
{
clear();
init(operCode);
return scripthead+scriptbody+scriptend;
}
}
</script>
<div id=toolbar style="background:3181cd;margin-left:200px;margin-top:2px"></div>
<div id=tabs style="margin-left:1px;margin-top:2px"></div>
- mytoolbarmenu
- oracle中rowid和rownum简介
- 【C++_typedef_疑难定义收集整理】
- Linux0.11内核--几种地址(逻辑地址、线性地址、物理地址)的含义
- fedora13下zend studio 5.5界面空白及乱码解决办法
- 系统管理员限制了系统策略,无法安装 解决办法
- mytoolbarmenu
- string 方法若干
- 整数的全排列
- 整数的全排列
- 搜索引擎工作原理
- 解决windows下path变量容量有限的办法
- JAVA在ACM中的使用
- DedeCms二次开发之简单的查询、插入、更新、删除操作实例
- ora-01033:oracle initialization or shutdown in progress