/** * This class centralize the pfc' Graphic User Interface manipulations * (depends on prototype library) * @author Stephane Gully */ var pfcGui = Class.create(); pfcGui.prototype = { initialize: function() { // this.builder = new pfcGuiBuilder(); this.current_tab = ''; this.current_tab_id = ''; this.tabs = Array(); this.tabids = Array(); this.tabtypes = Array(); this.chatcontent = $H(); this.onlinecontent = $H(); this.scrollpos = $H(); this.elttoscroll = $H(); this.windownotifynb = 0; }, /** * Scroll down the message list area by elttoscroll height * - elttoscroll is a message DOM element which has been appended to the tabid's message list * - this.elttoscroll is an array containing the list of messages that will be scrolled * when the corresponding tab will be shown (see setTabById bellow). * It is necessary to keep in cache the list of hidden (because the tab is inactive) messages * because the 'scrollTop' javascript attribute * will not work if the element (tab content) is hidden. */ scrollDown: function(tabid, elttoscroll) { // check the wanted tabid is the current active one if (this.getTabId() != tabid) { // no it's not the current active one so just cache the elttoscroll in the famouse this.elttoscroll array if (!this.elttoscroll.get(tabid)) this.elttoscroll.set(tabid, Array()); this.elttoscroll.get(tabid).push(elttoscroll); return; } // the wanted tab is active so just scroll down the tab content element // by elttoscroll element height (use 'offsetHeight' attribute) var content = this.getChatContentFromTabId(tabid); // the next line seems to help with IE6 scroll on the first load // http://sourceforge.net/tracker/index.php?func=detail&aid=1568264&group_id=158880&atid=809601 var dudVar = content.scrollTop; content.scrollTop += elttoscroll.offsetHeight+2; this.scrollpos.set(tabid, content.scrollTop); }, isCreated: function(tabid) { /* for (var i = 0; i < this.tabids.length ; i++) { if (this.tabids[i] == tabid) return true; } return false; */ return (indexOf(this.tabids, tabid) >= 0); }, setTabById: function(tabid) { var className = (!is_ie7 && !is_ie6) ? 'class' : 'className'; // first of all save the scroll pos of the visible tab var content = this.getChatContentFromTabId(this.current_tab_id); this.scrollpos.set(this.current_tab_id, content.scrollTop); // start without selected tabs this.current_tab = ''; this.current_tab_id = ''; var tab_to_show = null; // try to fine the tab to select and select it! for (var i=0; i 0) { // on by one for (var i=0; i'; flash += ''; flash += ''; flash += ''; soundcontainer.innerHTML = flash; } }, unnotifyWindow: function() { this.windownotifynb = 0; var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); document.title = document.title.replace(rx,'$1'); // stop the sound var soundcontainer = document.getElementById('pfc_sound_container'); if (pfc.issoundenable) soundcontainer.innerHTML = ''; }, /** * This function change the tab icon in order to catch the attention */ notifyTab: function(tabid) { var className = (!is_ie7 && !is_ie6) ? 'class' : 'className'; // first of all be sure the tab highlighting is cleared this.unnotifyTab(tabid); var tabpos = indexOf(this.tabids, tabid); var tabtype = this.tabtypes[tabpos]; // handle the tab's image modification var img = $('pfc_tabimg'+tabid); if (img) { if (tabtype == 'ch') img.src = pfc.res.getFileUrl('images/ch-active.gif'); if (tabtype == 'pv') img.src = pfc.res.getFileUrl('images/pv-active.gif'); } // handle the blicking effect var div = $('pfc_tabdiv'+tabid); if (div) { if (div.blinkstat == true) { div.setAttribute(className, 'pfc_tabblink1'); } else { div.setAttribute(className, 'pfc_tabblink2'); } div.blinkstat = !div.blinkstat; div.blinktimeout = setTimeout('pfc.gui.notifyTab(\''+tabid+'\');', 500); } }, /** * This function restore the tab icon to its default value */ unnotifyTab: function(tabid) { var className = (!is_ie7 && !is_ie6) ? 'class' : 'className'; var tabpos = indexOf(this.tabids, tabid); var tabtype = this.tabtypes[tabpos]; // restore the tab's image var img = $('pfc_tabimg'+tabid); if (img) { if (tabtype == 'ch') img.src = pfc.res.getFileUrl('images/ch.gif'); if (tabtype == 'pv') img.src = pfc.res.getFileUrl('images/pv.gif'); } // stop the blinking effect var div = $('pfc_tabdiv'+tabid); if (div) { div.removeAttribute(className); clearTimeout(div.blinktimeout); } }, loadSmileyBox: function() { var container = $('pfc_smileys'); var smileys = pfc.res.getSmileyReverseHash();//getSmileyHash(); var sl = smileys.keys(); pfc.res.sortSmileyKeys(); // Sort smiley keys once. for(var i = 0; i < sl.length; i++) { s_url = sl[i]; s_symbol = smileys.get(sl[i]); s_symbol = s_symbol.unescapeHTML(); // Replace " with " for IE and Webkit browsers. // The prototype.js version 1.5.1.1 unescapeHTML() function does not do this. if (is_ie || is_webkit) s_symbol = s_symbol.replace(/"/g,'"'); var img = document.createElement('img'); img.setAttribute('src', s_url); img.setAttribute('alt', s_symbol); img.setAttribute('title', s_symbol); img.s_symbol = s_symbol; img.onclick = function(){ pfc.insertSmiley(this.s_symbol); } container.appendChild(img); container.appendChild(document.createTextNode(' ')); // so smileys will wrap fine if lot of smiles in theme. } }, loadBBCodeColorList: function() { var className = (!is_ie7 && !is_ie6) ? 'class' : 'className'; // color list var clist = $('pfc_colorlist'); var clist_v = pfc_bbcode_color_list; for (var i=0 ; i