The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Option to hide chatbox

View previous topic View next topic Go down

In progress Option to hide chatbox

Post by Tonight on December 12th 2014, 7:15 pm

Is it possible to create an option to hide chatbox (with cookie)?

Extra question: Also, is it possible to move the chatbox up and down the main page?

Tonight
Forumember

Male Posts : 240
Reputation : 63
Language : Estonian, English, Russian
Location : Estonia

Back to top Go down

In progress Re: Option to hide chatbox

Post by Tonight on December 15th 2014, 6:42 pm

Up. I want like a toggle option.

Tonight
Forumember

Male Posts : 240
Reputation : 63
Language : Estonian, English, Russian
Location : Estonia

Back to top Go down

In progress Re: Option to hide chatbox

Post by Ange Tuteur on December 15th 2014, 10:31 pm

Hello @Tonight,

Could you provide some information please ?

  • The version of your forum
  • Are you using the default chatbox ?


Thanks

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Option to hide chatbox

Post by Tonight on December 15th 2014, 10:44 pm

phpBB3
default chatbox

Tonight
Forumember

Male Posts : 240
Reputation : 63
Language : Estonian, English, Russian
Location : Estonia

Back to top Go down

In progress Re: Option to hide chatbox

Post by Ange Tuteur on December 15th 2014, 11:01 pm

Go to Administration Panel > Modules > JavaScript codes management > Create a new script

Title : Your choice
Placement : In the homepage
Paste the code below and submit :
Code:
$(function() {
  if (!document.getElementById('frame_chatbox')) return;
  var fa = document.getElementById('frame_chatbox'), frame;
 
  // create toggle buttons
  $('#chatbox_top').before('<div class="online-chat">Members in chat : <span id="members-chat" style="color:#F00;">0</span></div><div id="cbOpen" class="cbButton">Click to open chatbox</div><div id="cbClose" class="cbButton">Click to close chatbox</div>');
  $('#chatbox_top, #cbClose').hide();
 
  fa.onload = function() {
    if (fa.contentDocument) frame = fa.contentDocument;
    else if (fa.contentWindow) frame = fa.contentWindow.document;
   
    // kill the interval if archives are toggled
    var a = frame.getElementsByTagName('A');
    for (i=0; i<a.length; i++) if (/archives/.test(a[i].href)) a[i].onclick = function() { window.clearInterval(_chat_refresh) };
   
     // get the amount of members and compare change
    then = frame.getElementById('chatbox_members').getElementsByTagName('li').length;
     var members = document.getElementById('members-chat');
     members.innerHTML = then;
   
    _chat_refresh = window.setInterval(function() {
       var now = frame.getElementById('chatbox_members').getElementsByTagName('li').length;
    
       // change the chat member number
       if (now < 1 || then < 1) members.style.color = '#F00';
      else if (now > 0 || then > 0) members.style.color = '#39C';
    
       // check if there is a change in members
      if (now > then || now < then) {
        members.innerHTML = now;
          then = now;
      }
    },1);
  };
 
  // open chat function
  $('#cbOpen').click(function() {
      $('#chatbox_top, #cbClose').show();
      $('#cbOpen').hide();
    
     // adjust scroll
    if (fa.contentDocument) fa.contentDocument.getElementById('chatbox').scrollTop = 99999;
     else if (fa.contentWindow) fa.contentWindow.document.getElementById('chatbox').scrollTop = 99999;
  });
   
  // close chat function
  $('#cbClose').click(function() {
      $('#chatbox_top, #cbClose').hide();
      $('#cbOpen').show();
  });
});

Then add this to your stylesheet
Display > Colors > CSS stylesheet
Code:
.cbButton {
  cursor:pointer;
  text-align:center;
  font-weight:bold;
  font-size:12px;
  margin:3px;
}

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Option to hide chatbox

Post by Fairfox1 on December 16th 2014, 3:15 am

ange can you make this for phpbb2 defult browser 2. seems like a cool thing to have

Fairfox1
New Member

Posts : 18
Reputation : 1
Language : enlish

http://ffda.forumotion.co.uk/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum