/******************************************************************************* FTab(Floating Tabs) Copyright (c) 2006-2009 uuware.com. All rights reserved. Developed by project@uuware.com, Visit http://www.uuware.com/ for details. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *******************************************************************************/ /******************************************************************************* FTab(Floating TabPage) function FTab(tabID, left, top, width, height, style, showPageIndex) can used like:(notice no 'new' as var o = new FTab(...), but no errors even use 'new'.) var o = FTab(tabID,10,10,200,160,'title:1;minmax:1;close:1;move:0;status:1;resize:1;scroll:1;tab:1;tabrect:1;expandable:0;cookie:1;',0); o.show(pageIndex); also can like this: FTab(tabID,10,10,200,160,'').show(pageIndex); when create FTab,need this params(left, top, and others),but while next time only need tabID to refer to FTab. for styles,default of all params is 1.if no title(title:0),then no close and minmax buttons even set them as 1, and also no moving.and also if no status(status:0),then no resize. user's event: FTabs.OnPageShow = function(ftab,index) { window.status='FTabs.OnPageShow, ftab id:'+ftab.id + ', index:' + index + '.'; } FTabs.OnActing = function(ftab) { window.status='FTabs.OnActing, ftab id:'+ftab.id + '.'; } FTabs.OnDeActing = function(ftab) { window.status='FTabs.OnDeActing, ftab id:'+ftab.id + '.'; } FTabs.OnMinMax = function(ftab, isMin) { window.status='FTabs.OnMinMax, ftab id:'+ftab.id + ', isMin:' + isMin; } FTabs.OnHide = function(ftab) { window.status='FTabs.OnHide, ftab id:'+ftab.id + '.'; } *******************************************************************************/ var FTab_MSIE = (navigator.userAgent.indexOf('MSIE') >= 0 ? true : false); //used to judge as IE. var FTab_JS = 'ftab.js'; //only used for get path of this js. var FTab_PATH = '../img/ftab/'; //path of style and also image. var FTab_M_Lst = []; //for save top win //get relative style&image path(same to js's path) var scripts = document.getElementsByTagName('script'); for(var i = 0; i < scripts.length; i++){ var src = scripts[i].getAttribute('src'); //here not see other dir's 'ftab.js' if(src && (src == FTab_JS || (src.length > FTab_JS.length && (src.substring(src.length - FTab_JS.length - 1) == '/' + FTab_JS || src.substring(src.length - FTab_JS.length - 1) == '\\' + FTab_JS)))){ // FTab_PATH = src.substring(0, src.length - FTab_JS.length); break; } } var FTab_ZIndex = 1001; var FTab_ActWin = null; //oMain for move window FTabs = new Object(); //for user's event function FTab_GetCookie(name) { var start = document.cookie.indexOf(name+"="); var len = start+name.length+1; if((!start) && (name != document.cookie.substring(0,name.length))) return null; if(start == -1) return null; var end = document.cookie.indexOf(";",len); if(end == -1) end = document.cookie.length; return unescape(document.cookie.substring(len,end)); } function FTab_SetCookie(name,value,expires,path,domain,secure) { if(expires) expires = expires * 60*60*24*1000; else expires = 100 * 60*60*24*1000; var today = new Date(); var expires_date = new Date( today.getTime() + (expires) ); var cookieString = name + "=" +escape(value) + ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + ( (path) ? ";path=" + path : "") + ( (domain) ? ";domain=" + domain : "") + ( (secure) ? ";secure" : ""); document.cookie = cookieString; } function FTab_SaveConfig(name,showPageIndex,left,top,width,height,nState,nZIndex) { var sitems = null; var sbuf = FTab_GetCookie(name + '.'); if(sbuf){ sitems = sbuf.split('_'); } if(!sitems || sitems.length != 8) {sitems = new Array();} if(typeof(showPageIndex)=='number') sitems[0] = ''+showPageIndex; if(typeof(left)=='number') sitems[1] = ''+left; if(typeof(top)=='number') sitems[2] = ''+top; if(width) sitems[3] = width; if(height) sitems[4] = height; if(typeof(nState)=='number') sitems[5] = ''+nState; if(nZIndex) sitems[6] = nZIndex; sbuf = ''; for(var i=0;i<7;i++) sbuf = sbuf + (sitems[i] ? sitems[i] : '') + '_' FTab_SetCookie(name + '.', sbuf, 100); } //used for resize function FTab_MMoveTimer() { if(!FTab_ActWin || !FTab_ActWin.M_Moving) return false; if(FTab_ActWin.M_StatusCnt >= 0 && FTab_ActWin.M_StatusCnt < 20){ FTab_ActWin.M_StatusCnt++; setTimeout('FTab_MMoveTimer()', 10); } } function FTab_GetWins() { var r = new Array(); var tabs = document.getElementsByTagName("table"); for(var i = 0; i < tabs.length; i++){ var t = tabs[i].id; if(t && t.length > 8 && t.substring(t.length-8) == '_m_table'){ var m_ID = t.substring(0, t.length-8); var oMain = document.getElementById(m_ID); if(oMain && oMain.objSelf && oMain.m_ID && oMain.objCreated == 1){ r.push(oMain); } } } return r; } function FTab_MScroll(e) { var r = FTab_GetWins(); for(t in r){ if(!r[t]) continue; var oMain = r[t]; if(oMain.objSelf){ if(oMain.objSelf.isFixed() && oMain.style.position == 'absolute'){ var l = 0 + oMain.M_FixX + ( document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ); var t = 0 + oMain.M_FixY + ( document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ); oMain.style.left = l + 'px'; oMain.style.top = t + 'px'; oTmp2 = document.getElementById(oMain.m_ID+'_i_ifrm'); if(oTmp2){ var oTmp = document.getElementById(oMain.m_ID + '_m_table'); oTmp2.style.width = (oTmp.clientWidth+3) + 'px'; oTmp2.style.height = (oTmp.clientHeight+3) + 'px'; } } } } } function FTab_MResize(e) { if(typeof FTab_MScroll == 'function') FTab_MScroll(e); var d = document; m = d.getElementById('SFTab_popmask'); if(m){ var w = d.body.parentNode.clientWidth; var h = d.body.parentNode.clientHeight; var c = document.body; if(d.compatMode && d.compatMode.toLowerCase() == 'css1compat') c = d.documentElement; if(w < c.scrollWidth){ w = c.scrollWidth; } if(h < c.scrollHeight){ h = c.scrollHeight; } m.style.width = w +'px'; m.style.height = h +'px'; } } //if onscroll is used,then need call this at there (window.addEventListener) ? window.addEventListener( "scroll", FTab_MResize, false ) : window.attachEvent("onscroll", FTab_MResize); (window.addEventListener) ? window.addEventListener( "resize", FTab_MResize, false ) : window.attachEvent("onresize", FTab_MResize); ////////////////////////////////////////////////////////////////////////////// //FTab(Floating TabPage) function FTab(tabID, left, top, width, height, style, showPageIndex) { var oMain = document.getElementById(tabID); if(oMain == null || typeof(oMain) != 'object' || !oMain.hasChildNodes()) return null; if(typeof(oMain.objSelf) == 'object' && oMain.m_ID == tabID) return oMain.objSelf; if(oMain.m_ID != tabID || oMain.objCreated != 1) { oMain.m_ID = tabID; oMain.objCreated = 1; oMain.objSelf = new FTab(tabID, left, top, width, height, style, showPageIndex); return oMain.objSelf; } var isInitOK = false; var tabPages = new Array(); var tabTitles = new Array(); var selectedIndex = 0; var m_ID = tabID; var oBody = null; this.id = tabID; this.m_ID = tabID; oMain.tabPages = tabPages; //init,not show until show() init(); //private function function isValid() { return (oMain != null && isInitOK); } //private function function init() { //style = 'title:1;minmax:1;close:1;move:0;status:1;resize:1;scroll:1;tab:1;tabrect:1;expandable:0;cookie:1;'; if(typeof(style) != 'string') style = ''; style = style.replace(/ /g, ''); var noScroll = (style.indexOf('scroll:0')>=0); var noStatus = (style.indexOf('status:0')>=0); var noResize = (noStatus || style.indexOf('resize:0')>=0); var noTitle = (style.indexOf('title:0')>=0); var noFixed = (noTitle || style.indexOf('fixed:0')>=0); var noMinMax = (noTitle || style.indexOf('minmax:0')>=0); var noClose = (noTitle || style.indexOf('close:0')>=0); var noMove = (noTitle || style.indexOf('move:0')>=0); var noTab = (style.indexOf('tab:0')>=0); var expandAble = (style.indexOf('expandable:1')>=0); var noCookie = (style.indexOf('cookie:0')>=0); var noTabRect = (noTitle && !noTab && style.indexOf('tabrect:0')>=0); var modal = (style.indexOf('modal:1')>=0); var center = (style.indexOf('center:1')>=0); if(expandAble){ noTitle = false; noResize = true; noMinMax = true; noClose = true; noMove = true; noStatus = true; noFixed = true; modal = false; center = false; } //get all Page var oPage = oMain.firstChild; while(oPage){ if(oPage.nodeName=='DIV' && typeof(oPage.title)=='string'){ tabPages.push(oPage); } oPage = oPage.nextSibling; } if(tabPages.length <= 0) return false; if(expandAble) oMain.className = 'ftab_main_parent ftab_main_ext'; else oMain.className = 'ftab_main_parent'; oMain.style.display = 'none'; oMain.noMinMax = noMinMax; oMain.noClose = noClose; oMain.noResize = noResize; oMain.modal = modal; oMain.noFixed = noFixed; oMain.expandAble = expandAble; var sbuf = ''; //add Title if(!noTitle){ if(typeof(oMain.title) != 'string') oMain.title = ''; sbuf += ''; } //add Tab if(!noTab){ if(!noTabRect) sbuf += ''; } //add Body if(!noTabRect) sbuf += ''; //add StatusBar if(!noStatus && !noTabRect){ sbuf += ''; } sbuf += '
'; sbuf += ''; if(expandAble) sbuf += ' '; // sbuf += oMain.title + ''; sbuf += oMain.title + ''; if(!noFixed) sbuf += ''; if(!noMinMax) sbuf += ''; if(!noClose) sbuf += ''; sbuf += '
'; else sbuf += '
'; for(var i = 0; i < tabPages.length; i++){ sbuf += '' + tabPages[i].title; sbuf += ' '; } // sbuf += ''; // else sbuf += ' ftab_tab_norecth"/>'; sbuf += '
'; sbuf += '
'; if(!noResize) sbuf += ''; sbuf += '
'; var div = document.createElement('DIV'); oMain.insertBefore(div, oMain.firstChild); div.style.cssText = 'height:100%;width:100%;margin:0px;padding:0px;'; div.innerHTML = sbuf; oBody = document.getElementById(m_ID + '_m_body'); var oTable = document.getElementById(m_ID + '_m_table'); //add Body Contents for(var i = 0; i < tabPages.length; i++) { tabPages[i].className = 'ftab_bodysub'; tabPages[i].title = ''; oBody.appendChild(tabPages[i]); sbuf = '' + tabPages[i].style.cssText; if(noScroll) sbuf = 'overflow-x:hidden;overflow-y:hidden;' + sbuf; else sbuf = 'overflow-x:auto;overflow-y:auto;' + sbuf; if(navigator.userAgent.indexOf('Opera')>=0 && !noScroll) sbuf = 'overflow:scroll;' + sbuf; tabPages[i].style.cssText = sbuf; //'margin:0px;padding:0px;' + } if(!noTitle){ var oTmp = document.getElementById(m_ID + '_t_title').parentNode; oTmp.onselectstart = cancelEvent; oTmp.ondragstart = cancelEvent; oTmp.onmousedown = doMDown; if(expandAble){ oTmp.onclick = function(){switchMinMax();return false;}; oTmp.style.cursor = 'pointer'; } if(!noMove){ oTmp.style.cursor = 'move'; oMain.style.position = 'absolute'; } if(!noFixed){ var oTmp = document.getElementById(m_ID + '_t_fix'); oTmp.onclick = function(){switchFixed();return false;}; } if(!noMinMax){ var oTmp = document.getElementById(m_ID + '_t_min'); oTmp.onclick = function(){switchMinMax();return false;}; } if(!noClose){ var oTmp = document.getElementById(m_ID + '_t_close'); oTmp.onclick = function(){hide();return false;}; } } if(!noTab){ for(var i = 0; i < tabPages.length; i++) { var oTmp = document.getElementById(m_ID + '_p_title' + i); oTmp.onselectstart = cancelEvent; oTmp.ondragstart = cancelEvent; oTmp.onmousedown = cancelEvent; oTmp.save_index = i; oTmp.onclick = function(){show(this.save_index);return false;}; var oTmp = document.getElementById(m_ID + '_p_r' + i); oTmp.onselectstart = cancelEvent; oTmp.ondragstart = cancelEvent; oTmp.onmousedown = cancelEvent; oTmp.save_index = i; oTmp.onclick = function(){show(this.save_index);return false;}; } } oTable.onmousedown = doBringToFront; oBody.onmousedown = doBringToFront; oMain.onmousedown = doBringToFront; var oTmp = document.getElementById(m_ID + '_s_title'); if(oTmp){ oTmp.parentNode.onselectstart = cancelEvent; oTmp.parentNode.ondragstart = cancelEvent; oTmp.parentNode.onmousedown = cancelEvent; var oTmp = document.getElementById(m_ID + '_s_move'); if(oTmp) oTmp.onmousedown = doMDownStatus; } var nState = 1; if(style.indexOf('initmin:0')>=0) nState = 0; var nZIndex = 0; if(!noCookie){ var sbuf = FTab_GetCookie(m_ID + '.'); if(sbuf){ var sitems = sbuf.split('_'); if(sitems.length==8){ if(sitems[0]!='') showPageIndex = sitems[0]/1; if(!expandAble && sitems[1]!='') left = sitems[1]/1; if(!expandAble && sitems[2]!='') top = sitems[2]/1; if(!expandAble && sitems[3]!='') width = sitems[3]/1; if(!expandAble && sitems[4]!='') height = sitems[4]/1; if(sitems[5]!='') nState = sitems[5]/1; if(sitems[6]!='') nZIndex = sitems[6]/1; } } } if(typeof(showPageIndex) != 'number' || showPageIndex >= tabPages.length || showPageIndex < 0) showPageIndex = 0; isInitOK = true; show(showPageIndex); if(nZIndex > 0){ oMain.style.zIndex = nZIndex; if(FTab_ZIndex < nZIndex) FTab_ZIndex = nZIndex; FTab_SaveConfig(m_ID, false,false,false,false,false,false,nZIndex); } //if not noMove,must set left&top if(!noMove){ if(typeof(left) != 'number') left = oMain.offsetLeft; if(typeof(top) != 'number') top = oMain.offsetTop; } if(typeof(left) == 'number') oMain.style.left = left + 'px'; else if(typeof(left) == 'string') oMain.style.left = left; if(typeof(top) == 'number') oMain.style.top = top + 'px'; else if(typeof(top) == 'string') oMain.style.top = top; //if not noResize,must set width&height if(!noResize){ if(typeof(width) != 'number') width = oTable.clientWidth; if(typeof(height) != 'number') height = oTable.clientHeight; } if(typeof(width) == 'number'){ minWidth(oMain); if(width < oMain.M_MinWidth) width = oMain.M_MinWidth; oMain.style.width = width + 'px'; for(var i = 0; i < tabPages.length; i++) tabPages[i].style.width = width + 'px'; } else if(typeof(width) == 'string') oMain.style.width = width; if(typeof(height) == 'number'){ oMain.M_OffsetH = (oMain.clientHeight - tabPages[selectedIndex].clientHeight); height -= oMain.M_OffsetH; if(height < 0) height = 0; height += oMain.M_OffsetH; oMain.style.height = height + 'px'; oMain.M_OffsetH = height; var oTmp = document.getElementById(m_ID + '_t_title'); if(oTmp) height -= oTmp.parentNode.clientHeight; var oTmp = document.getElementById(m_ID + '_s_title'); if(oTmp) height -= oTmp.parentNode.clientHeight; oMain.M_OffsetH -= height; for(var i = 0; i < tabPages.length; i++) tabPages[i].style.height = height + 'px'; oBody.style.height = height + 'px'; } else if(typeof(height) == 'string') oMain.style.height = height; if(FTab_MSIE && !noMove){ //only while not parent ftab var hasp = false; var o = oMain.parentNode; while(o && o.tagName != 'body'){ if(o.objSelf && o.objCreated){ hasp = true; break; } o = o.parentNode; } if(!hasp){ var iframe = document.createElement('