|
From: Lo?c C. <lo...@us...> - 2001-04-04 16:21:27
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib In directory usw-pr-cvs1:/tmp/cvs-serv4960/lib Added Files: users_popup.lib.js Log Message: The users popups are running :) --- NEW FILE --- // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | Set of JavaScript functions used to handle the the collapsible list of | // | rooms at the users popup with IE & NS 4+ browsers (DHTML stuff). | // | | // | This library is called by the 'chat/lib/users_popup.php3' script. | // | | // | It is is based on the 'Expandable Outlines' script from WebReference | // | (http://webreference.com/). | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: users_popup.lib.js,v 1.1 2001/04/04 16:21:23 loic1 Exp $ // // Handle the expandable/collapsible list of rooms at the users popup. // var jsIsNS4 = (typeof(document.layers) != 'undefined') ? 1 : 0; var jsIsIE4 = ((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >= 4)) ? 1 : 0; var jsIsVersion4 = (jsIsNS4 || jsIsIE4) ? 1 : 0; var jsIsExpanded = false; var jsRoomsCnt = 0; var jsOpenedRoomsCnt = 0; var jsImgBigOpened = new Image(13,13); jsImgBigOpened.src = 'images/open_big.gif'; var jsImgBigClosed = new Image(13,13); jsImgBigClosed.src = 'images/closed_big.gif'; var jsImgOpened = new Image(9,9); jsImgOpened.src = 'images/open.gif'; var jsImgClosed = new Image(9,9); jsImgClosed.src = 'images/closed.gif'; /** * Do reloads the popup if the Netscape window has been resized * * @access private */ function reDo() { if (innerWidth != origWidth || innerHeight != origHeight) location.reload(true); } // end of the 'reDo()' function /** * Positioned element resize bug under NN */ if (jsIsNS4) { var origWidth = innerWidth; var origHeight = innerHeight; onresize = reDo; } /** * Add styles for positioned layers; */ if (jsIsVersion4) { with (document) { write('<style type="text/css">'); if (jsIsNS4) { write('.parent {position:absolute; visibility:visible}'); write('.child {position:absolute; visibility:visible}'); write('.regular {position:absolute; visibility:visible}'); } else { write('.child {display:none}'); } write('<\/style>'); } } /** * Gets the id of the first collapsible room * * @param string the name of the first collapsible room * * @return integer the index number corresponding to this room * * @access public */ function pmcGetIndex(el) { var ind = null; for (var i = 0; i < document.layers.length; i++) { var whichEl = document.layers[i]; if (whichEl.id == el) { ind = i; break; } } return ind; } // end of the 'pmcGetIndex()' function /** * Positions layers under NS4+ * * @access public */ function pmcNsArrangeList() { if (jsFirstInd != null) { var nextY = document.layers[jsFirstInd].pageY + document.layers[jsFirstInd].document.height; for (var i = jsFirstInd + 1; i < document.layers.length; i++) { var whichEl = document.layers[i]; if (whichEl.visibility != 'hide') { whichEl.pageY = nextY; nextY += whichEl.document.height; } } } } // end of the 'pmcNsArrangeList()' function /** * Defines the state of the big +/- icon * * @access public */ function pmcSetBigIcon() { if (jsRoomsCnt == 0) return; var bigImg = (jsIsNS4) ? document.images['imgExpandAll'] : document.images.item('imgExpandAll'); if (jsOpenedRoomsCnt == jsRoomsCnt) { jsIsExpanded = true; bigImg.src = jsImgBigOpened.src; } else if (jsIsExpanded) { jsIsExpanded = false; bigImg.src = jsImgBigClosed.src; } } // end of the 'pmcSetBigIcon()' function /** * Collapses/expands rooms (depends on the state of the room before the page * reloads) each time the web page is loaded * * @access public */ function pmcInitList() { if (!jsIsVersion4) return; var parentElts = new Array(); jsOpenedRoomsCnt = 0; if (jsIsNS4) { for (var i = 0; i < document.layers.length; i++) { var whichEl = document.layers[i]; if (whichEl.id.indexOf('Parent') != -1) var parentEl = whichEl; if (whichEl.id.indexOf('Child') != -1) { var currentId = whichEl.id.substring(5); if (jsChildCnt[currentId] > 10) { whichEl.visibility = 'hide'; } else { jsOpenedRoomsCnt++; whichEl.visibility = 'show'; if (!parentElts[parentEl.id]) { parentElts[parentEl.id] = 1; parentEl.document.images['imEx'].src = jsImgOpened.src; } } } } pmcNsArrangeList(); } // end of the NS4 case else { divColl = document.all.tags('div'); for (var i = 0; i < divColl.length; i++) { var whichEl = divColl(i); if (whichEl.className == 'parent') var parentEl = whichEl; if (whichEl.className == 'child') { var currentId = whichEl.id.substring(5); if (jsChildCnt[currentId] > 10) { whichEl.style.display = 'none'; } else { jsOpenedRoomsCnt++; whichEl.style.display = 'block'; if (!parentElts[parentEl.id]) { parentElts[parentEl.id] = 1; parentEl.all.tags('IMG').item('imEx').src = jsImgOpened.src; } } } } } // end of the IE4 case parentElts = null; jsChildCnt = null; pmcSetBigIcon(); } // end of the 'pmcInitList()' function /** * Collapses/expands a room when the user require this to be done and store * the new state of the room * * @param string the name of the room to act on * * @access public */ function pmcExpandRoom(el) { if (!jsIsVersion4) return; if (jsIsIE4) { var whichEl = document.all('Child' + el); var whichIm = event.srcElement; if (whichEl.style.display == 'none') { jsOpenedRoomsCnt++; whichEl.style.display = 'block'; whichIm.src = jsImgOpened.src; } else { jsOpenedRoomsCnt--; whichEl.style.display = 'none'; whichIm.src = jsImgClosed.src; } } // end of the IE4 case else { var whichEl = document.layers['Child' + el]; var whichIm = document.layers['Parent' + el].document.images['imEx']; if (whichEl.visibility == 'hide') { jsOpenedRoomsCnt++; whichEl.visibility = 'show'; whichIm.src = jsImgOpened.src; } else { jsOpenedRoomsCnt--; whichEl.visibility = 'hide'; whichIm.src = jsImgClosed.src; } pmcNsArrangeList(); } // end of the NS4 case pmcSetBigIcon(); } // end of the 'pmcExpandRoom()' function /** * Collapses/expands all rooms when the user require this to be done and store * the new state of these rooms * * @access public */ function pmcExpandAll() { if (!jsIsVersion4) return; var newBigSrc = (jsIsExpanded) ? jsImgBigClosed.src : jsImgBigOpened.src; var newSrc = (jsIsExpanded) ? jsImgClosed.src : jsImgOpened.src; jsOpenedRoomsCnt = (jsIsExpanded) ? 0 : jsRoomsCnt; if (jsIsNS4) { document.images['imgExpandAll'].src = newBigSrc; if (jsFirstInd != null) { if (document.layers.length) { for (var i = jsFirstInd; i < document.layers.length; i++) { var whichEl = document.layers[i]; if (whichEl.id.indexOf('Parent') != -1) whichEl.document.images['imEx'].src = newSrc; if (whichEl.id.indexOf('Child') != -1) whichEl.visibility = (jsIsExpanded) ? 'hide' : 'show'; } } pmcNsArrangeList(); if (jsIsExpanded) scrollTo(0, document.layers[jsFirstInd].pageY); } } // end of the NS4 case else { var divColl = document.all.tags('div'); for (var i = 0; i < divColl.length; i++) { if (divColl(i).className == 'child') divColl(i).style.display = (jsIsExpanded) ? 'none' : 'block'; } document.images.item('imgExpandAll').src = newBigSrc; var imColl = document.images.item('imEx'); if (imColl) { for (var i = 0; i < imColl.length; i++) { imColl(i).src = newSrc; } if (!imColl.length) document.imEx.src = newSrc; } } // end of the IE4 case jsIsExpanded = (!jsIsExpanded); } // end of the 'pmcExpandAll()' function onload = pmcInitList; |