📄 floating_window_with_tabs.js
字号:
/************************************************************************************************************
Floating window with tabs
Copyright (C) October 2005 DTHMLGoodies.com, Alf Magne Kalleland
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.
Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com
************************************************************************************************************/
var activeFloatingWindow = false;
var activeFloatingWindowContent = false;
var activeFloatingWindowTabDiv = false;
var activeFloatingWindowStatusDiv = false;
var activeFloatingWindowMoveBar = false;
var currentZIndex = 1000;
var floatingWindowMaxZIndex = 1000;
var floatingWindowMinimumWidth = new Array();
var floatingWindowTabDivs = new Array();
var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;
var floatingWindowMoveCounter = -1;
var floatingWindowResizeCounter = -1;
var initEventX = false;
var initEventY = false;
var window_posX = false;
var window_posY = false;
var window_height = false;
var window_width = false;
var floatingWindowStates = new Array();
switch(floating_window_skin){
case 2:
document.getElementById('cssRef').href = 'floating_window_with_tabs-skin2.css';
var tabRightInActive = "./images/skin2_tab_right_inactive.gif";
var tabRightActive = "./images/skin2_tab_right_active.gif";
var tabImagePrefix = "./images/skin2_tab_right_";
var closeButtonMouseOverColor = '#006BF8';
break;
default:
var tabRightInActive = "./images/tab_right_inactive.gif";
var tabRightActive = "./images/tab_right_active.gif";
var tabImagePrefix = "./images/tab_right_";
var closeButtonMouseOverColor = '#317082';
break;
}
/*
These cookie functions are downloaded from
http://www.mach5.com/support/analyzer/manual/html/General/CookiesJavaScript.htm
*/
function Get_Cookie(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));
}
// This function has been slightly modified
function Set_Cookie(name,value,expires,path,domain,secure) {
expires = expires * 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 cancelWindowEvent()
{
return (floatingWindowMoveCounter==-1 && floatingWindowResizeCounter==-1 && this.tagName!='IMG')?true:false;
}
function showHideWindowTab()
{
var parentEl = this.parentNode;
if(!activeFloatingWindow)activeFloatingWindow = parentEl.parentNode;
var windowIndex = parentEl.parentNode.id.replace(/[^\d]/g,'');
var subDiv = parentEl.getElementsByTagName('DIV')[0];
counter=0;
var contentDiv = contentDivs[windowIndex][0];
var tabFound = false;
do{
if(subDiv.tagName=='DIV' && subDiv.className!='floatingWindowCloseButton'){
if(!tabFound)zIndex = counter;else zIndex = 100-counter;
if(subDiv!=this){
subDiv.className = 'floatingWindowTab_inactive';
var img = subDiv.getElementsByTagName('IMG')[0];
img.src = tabRightInActive
subDiv.style.zIndex = zIndex;
contentDiv.style.display='none';
}else{
this.className='floatingWindowTab_active';
this.style.zIndex = 500;
var img = this.getElementsByTagName('IMG')[0];
img.src = tabRightActive;
if(floatingWindowStates[activeFloatingWindow.id.replace(/[^0-9]/gi,'')])
contentDiv.style.display=floatingWindowStates[activeFloatingWindow.id.replace(/[^0-9]/gi,'')];
else
contentDiv.style.display='block'
tabFound = true;
Set_Cookie('floating_window_activeTab' + windowIndex,counter,100);
}
counter++;
}
subDiv = subDiv.nextSibling;
if(contentDiv.nextSibling)contentDiv = contentDiv.nextSibling;
}while(subDiv);
}
function toggleCloseButton()
{
this.style.color='#FFF';
this.style.backgroundColor = closeButtonMouseOverColor;
}
function toggleOffCloseButton()
{
this.style.color='';
this.style.backgroundColor = '';
}
function closeFloatingWindow()
{
this.parentNode.parentNode.style.display='none';
}
function minimizeFloatingWindow()
{
var action = this.getAttribute('action');
var aTag = this.getElementsByTagName('SPAN')[0];
if(action=='minimize'){
this.setAttribute('action','maximize');
activeFloatingWindowContent.style.display='none';
aTag.style.top = '-10px';
}else{
this.setAttribute('action','minimize');
activeFloatingWindowContent.style.display='block';
aTag.style.top = '0px';
}
floatingWindowStates[activeFloatingWindow.id.replace(/[^0-9]/gi,'')] = activeFloatingWindowContent.style.display;
}
function initFloatingWindowResize(e)
{
if(document.all)e = event;
floatingWindowResizeCounter = 0;
bringFloatingWindowToFront(false,this.parentNode.parentNode);
initEventX = e.clientX;
initEventY = e.clientY;
window_height = activeFloatingWindowContent.offsetHeight;
window_width = activeFloatingWindow.offsetWidth;
timerFloatingWindowMove();
return false;
}
function initFloatingWindowMove(e)
{
if(document.all)e = event;
floatingWindowMoveCounter = 0;
bringFloatingWindowToFront(false,this.parentNode);
initEventX = e.clientX;
initEventY = e.clientY;
window_posX = activeFloatingWindow.style.left.replace('px','')/1;
window_posY = activeFloatingWindow.style.top.replace('px','')/1;
timerFloatingWindowMove();
return false;
}
function timerFloatingWindowMove()
{
if(floatingWindowMoveCounter>=0 && floatingWindowMoveCounter<10){
floatingWindowMoveCounter = floatingWindowMoveCounter + 1;
setTimeout('timerFloatingWindowMove()',10);
}
if(floatingWindowResizeCounter>=0 && floatingWindowResizeCounter<10){
floatingWindowResizeCounter = floatingWindowResizeCounter + 1;
setTimeout('timerFloatingWindowMove()',10);
}
}
var allowFloatingResize = true;
var windowMoveInProgress = false;
function floatingWindowMove(e)
{
if(windowMoveInProgress)return;
windowMoveInProgress = true;
if(document.all)e = event;
if(floatingWindowMoveCounter>=10){
var leftPos = window_posX + e.clientX - initEventX;
var topPos = window_posY + e.clientY - initEventY;
if(topPos<0)topPos=0;
if(leftPos<0)leftPos=0;
activeFloatingWindow.style.left = leftPos + 'px';
activeFloatingWindow.style.top = topPos + 'px';
windowMoveInProgress = false;
return;
}
if(floatingWindowResizeCounter>=10 && allowFloatingResize){
var width = window_width + e.clientX - initEventX;
var height = window_height + e.clientY - initEventY;
if(width<floatingWindowMinimumWidth[activeFloatingWindow.id])width = floatingWindowMinimumWidth[activeFloatingWindow.id];
if(height<0)height = 0;
activeFloatingWindowMoveBar.style.width = (width - 4) + 'px';
activeFloatingWindow.style.width = width + 'px';
var numericID = activeFloatingWindow.id.replace(/[^\d]/g,'');
for(var no=0;no<contentDivs[numericID].length;no++){
if(navigatorVersion<6 && MSIE){
contentDivs[numericID][no].style.width = (width) + 'px';
}else{
contentDivs[numericID][no].style.width = (width - 4) + 'px';
}
contentDivs[numericID][no].style.height = height + 'px';
}
if(navigatorVersion<6 && MSIE){
activeFloatingWindowMoveBar.style.width = (width) + 'px';
}
if(document.all){
allowFloatingResize = false;
setTimeout('allowFloatingResize=true',30);
}
windowMoveInProgress = false;
}
windowMoveInProgress = false;
}
function initSetSize(windowObj,width,height)
{
if(width<floatingWindowMinimumWidth[windowObj.id])width = floatingWindowMinimumWidth[windowObj.id];
windowObj.style.width = width + 'px';
var subDivs = windowObj.getElementsByTagName('DIV');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -