You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
8.3 KiB

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.wdk.WDKConstant"%>
<%@ page import="org.wdk.WDKCore"%>
<%@ page import="org.wdk.WDK"%>
<%@ page import="com.noblelift.imp.platform.module.portal.source.SessionUser"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
String WDK_ROOT = WDKCore.WDK_ROOT;
SessionUser su = (SessionUser)WDK.getSessionUser(request, response);
WDK.writeSessionUser(out, su);
String RSS_ROOT = WDK_ROOT +"/"+WDKConstant.Theme+"/"+WDKCore.THEME;
String frame_welcomepage = (String)WDKCore.getSysParam("frame_welcomepage");
String frame_welcometitle = (String)WDKCore.getSysParam("frame_welcometitle");
if(null==frame_welcomepage || "".equals(frame_welcomepage)) frame_welcomepage = "wdk/frame/default/ifr_index.jsp";
if(null==frame_welcometitle || "".equals(frame_welcometitle)) frame_welcometitle = "欢迎";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>" target="_self">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页的tab控件</title>
<script type="text/javascript" src="<%=RSS_ROOT%>/core/js/wdk.js"></script>
<script type="text/javascript">
<% if(null==su){%>
$.timeout();
<%}%>
var _tabid;
var index_tabs;
var index_tabsMenu;
var tab_border = false;
var tab_duplicate = false;
var _gfvid;
function doInit(){
index_tabs = $('#tabs').tabs({
fit : true,
border : tab_border,
onContextMenu : function(e, title) {
e.preventDefault();
index_tabsMenu.menu('show', {
left : e.pageX,
top : e.pageY
}).data('tabTitle', title);
},
tools : [ {
iconCls : 'database_refresh',
handler : function() {
var href = index_tabs.tabs('getSelected').panel('options').href;
if (href) {/*说明tab是以href方式引入的目标页面*/
var index = index_tabs.tabs('getTabIndex', index_tabs.tabs('getSelected'));
index_tabs.tabs('getTab', index).panel('refresh');
} else {/*说明tab是以content方式引入的目标页面*/
var panel = index_tabs.tabs('getSelected').panel('panel');
var frame = panel.find('iframe');
try {
if (frame.length > 0) {
for ( var i = 0; i < frame.length; i++) {
frame[i].contentWindow.document.write('');
frame[i].contentWindow.close();
frame[i].src = frame[i].src;
}
if (navigator.userAgent.indexOf("MSIE") > 0) {// IE特有回收内存方法
try {
CollectGarbage();
} catch (e) {
}
}
}
} catch (e) {
}
}
}
}, {
iconCls : 'delete',
handler : function() {
var index = index_tabs.tabs('getTabIndex', index_tabs.tabs('getSelected'));
var tab = index_tabs.tabs('getTab', index);
if (tab.panel('options').closable) {
index_tabs.tabs('close', index);
} else {
$.messager.alert('提示', '[' + tab.panel('options').title + ']不可以被关闭!', 'error');
}
}
} ]
});
index_tabsMenu = $('#index_tabsMenu').menu({
onClick : function(item) {
var curTabTitle = $(this).data('tabTitle');
var type = $(item.target).attr('title');
if (type === 'refresh') {
index_tabs.tabs('getTab', curTabTitle).panel('refresh');
return;
}
if (type === 'close') {
var t = index_tabs.tabs('getTab', curTabTitle);
if (t.panel('options').closable) {
index_tabs.tabs('close', curTabTitle);
}
return;
}
var allTabs = index_tabs.tabs('tabs');
var closeTabsTitle = [];
$.each(allTabs, function() {
var opt = $(this).panel('options');
if (opt.closable && opt.title != curTabTitle && type === 'closeOther') {
closeTabsTitle.push(opt.title);
} else if (opt.closable && type === 'closeAll') {
closeTabsTitle.push(opt.title);
}
});
for ( var i = 0; i < closeTabsTitle.length; i++) {
index_tabs.tabs('close', closeTabsTitle[i]);
}
}
});
/*
$(window).resize(function () {
$('#tabs').tabs({
width: $("#tabs").parent().width(),
height: document.documentElement.clientHeight-1
});
});
$(function() {
$('#tabs').tabs({
width: $("#tabs").parent().width(),
height: document.documentElement.clientHeight-1
});
}); */
}
function init(strparam){
var jparam = $.str2json(strparam);
_tabid = jparam.tabid;
_gfvid = jparam.gfvid;
var tabs = jparam.tabs;
var _border = (('true'==jparam.border) || (true==jparam.border))?true:false;
var _duplicate = (false==jparam.duplicate||'false'==jparam.duplicate)?false:true; //是否允许重复打开
tab_duplicate = _duplicate;
var _onLoad = jparam.onLoad?jparam.onLoad:null;
var _onLoadSuccess = jparam.onLoadSuccess?jparam.onLoadSuccess:null;
var _onSelect = jparam.onSelect?jparam.onSelect:null;
var _onBeforeClose = jparam.onBeforeClose?jparam.onBeforeClose:null;
var _onClose = jparam.onClose?jparam.onClose:null;
var _onAdd = jparam.onAdd?jparam.onAdd:null;
var _onUpdate = jparam.onUpdate?jparam.onUpdate:null;
$('#tabs').tabs({
border :_border
,onLoad:function(panel){
if(_onLoad){
$.method_call(_onLoad,panel);
}
if(_onLoadSuccess){
$.method_call(_onLoadSuccess,panel);
}
}
,onSelect:function(title){
if(_onSelect){
$.method_call(_onSelect,title);
}
}
,onBeforeClose:function(title){
if(_onBeforeClose){
$.method_call(_onBeforeClose,title);
}
}
,onClose:function(title){
if(_onClose){
$.method_call(_onClose,title);
}
}
,onAdd:function(title){
if(_onAdd){
$.method_call(_onAdd,title);
}
}
,onUpdate:function(title){
if(_onUpdate){
$.method_call(_onUpdate,title);
}
}
});
if(tabs){
for(var i=0;i<tabs.length;i++){
var jtab = tabs[i];
tab_add(jtab);
}
}
//给tab绑定双击关闭事件
$('#tabs').tabs('bindDblclick', function(index, title){
var t = $('#tabs').tabs('getTab', title);
if (t.panel('options').closable) {
$('#tabs').tabs('close', title);
}
});
//初始化默认选中第一条
$('#tabs').tabs('select',0);
doInit();
//添加首页
$('#tabs').tabs('add',{
title:'<%=frame_welcometitle%>',
content:'<iframe id="welcome" name="welcome" src="<%=frame_welcomepage%>" width="100%" height="99%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" ></iframe>',
closable:false
});
}
//增加一个页签
function tab_add(jtab){
if(jtab){
//去除重名
var _titlenum = 0; //同名的title数量
var _title = jtab.title;
var tabs = $("#tabs").tabs('tabs');
for(var i=0;i<tabs.length;i++){
var tab = tabs[i];
var title = tab.panel('options').title;
if(title == _title){
_titlenum++;
}else{
var titmp = title.substring(0,_title.length);
if(titmp==_title){
var tinumstr = title.substring(_title.length,title.length);
if(/^[(]\d+[)]$/ig.test(tinumstr)){ //如果后面是形如 (13)
_titlenum++;
}
}
}
}
if(_titlenum>0){
if(tab_duplicate){
_title += '('+_titlenum+')';
}else{
alert('已打开相同页面');
return false;
}
}
var _src = jtab.url;
if(-1==_src.indexOf("?")){
_src += "?tabid="+_tabid+"&tabtitle="+_title+"&gfvid="+_gfvid;
}else{
_src += "&tabid="+_tabid+"&tabtitle="+_title+"&gfvid="+_gfvid;
}
$('#tabs').tabs('add',{
title:_title,
content:'<iframe id="'+_title+'" name="'+_title+'" src="'+_src+'" width="100%" height="99%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" ></iframe>',
closable:(false==jtab.closable)?jtab.closable:true
});
}
}
</script>
</head>
<body id="mybody" style="overflow:hidden;padding:0px;border:0px solid #000000;background-color:#FFFFFF;">
<div id="tabs" style="height:100%; width:100%;overflow: hidden;">
</div>
<div id="index_tabsMenu" style="width: 120px; display: none;">
<div title="refresh" data-options="iconCls:'transmit'">刷新</div>
<div class="menu-sep"></div>
<div title="close" data-options="iconCls:'delete'">关闭</div>
<div title="closeOther" data-options="iconCls:'delete'">关闭其他</div>
<div title="closeAll" data-options="iconCls:'delete'">关闭所有</div>
</div>
</body>
</html>