Go Back   vb.org Archive > vBulletin Modifications > vBulletin 3.8 Modifications > vBulletin 3.8 Add-ons

Reply
 
Thread Tools
Floating notice box in forumhome. Details »»
Floating notice box in forumhome.
Version: 1.00, by Simon Lloyd Simon Lloyd is offline
Developer Last Online: May 2023 Show Printable Version Email this Page

Category: Miscellaneous Hacks - Version: 3.8.x Rating:
Released: 11-22-2009 Last Update: Never Installs: 18
Supported Template Edits
Re-useable Code Translations  

This "Mod" will allow you to have a floating notice box in your Forumhome, however it can easily be adapted to show wherever you like!

The original javascript for the float and the box are from here http://www.jtricks.com/javascript/na.../floating.html all the information here does is help you understand where to put the code and how to use it etc

Go to AdminCp>Style Manager>YOUR STYLE>Header and underneath
PHP Code:
$ad_headerEnd 
add this (currently it is set to only show to unregistered users)
PHP Code:
<!-- float div -->
<if 
condition="THIS_SCRIPT == 'index' AND is_member_of($bbuserinfo,1)"><script type="text/javascript"><!--
/* Script by: www.jtricks.com
 * Version: 20071017
 * Latest version:
 * www.jtricks.com/javascript/navigation/floating.html
 */
var floatingMenuId 'floatdiv';
var 
floatingMenu =
{
    
targetX: -290,
    
targetY90,

    
hasInnertypeof(window.innerWidth) == 'number',
    
hasElementtypeof(document.documentElement) == 'object'
        
&& typeof(document.documentElement.clientWidth) == 'number',

    
menu:
        
document.getElementById
        
document.getElementById(floatingMenuId)
        : 
document.all
          
document.all[floatingMenuId]
          : 
document.layers[floatingMenuId]
};

floatingMenu.move = function ()
{
    
floatingMenu.menu.style.left floatingMenu.nextX 'px';
    
floatingMenu.menu.style.top floatingMenu.nextY 'px';
}

floatingMenu.computeShifts = function ()
{
    var 
de document.documentElement;

    
floatingMenu.shiftX =  
        
floatingMenu.hasInner  
        
pageXOffset  
        
floatingMenu.hasElement  
          
de.scrollLeft  
          
document.body.scrollLeft;  
    if (
floatingMenu.targetX 0)
    {
        
floatingMenu.shiftX +=
            
floatingMenu.hasElement
            
de.clientWidth
            
document.body.clientWidth;
    }

    
floatingMenu.shiftY 
        
floatingMenu.hasInner
        
pageYOffset
        
floatingMenu.hasElement
          
de.scrollTop
          
document.body.scrollTop;
    if (
floatingMenu.targetY 0)
    {
        if (
floatingMenu.hasElement && floatingMenu.hasInner)
        {
            
// Handle Opera 8 problems
            
floatingMenu.shiftY +=
                
de.clientHeight window.innerHeight
                
window.innerHeight
                
de.clientHeight
        
}
        else
        {
            
floatingMenu.shiftY +=
                
floatingMenu.hasElement
                
de.clientHeight
                
document.body.clientHeight;
        }
    }
}

floatingMenu.calculateCornerX = function()
{
    if (
floatingMenu.targetX != 'center')
        return 
floatingMenu.shiftX floatingMenu.targetX;

    var 
width parseInt(floatingMenu.menu.offsetWidth);

    var 
cornerX =
        
floatingMenu.hasElement
        
? (floatingMenu.hasInner
           
pageXOffset
           
document.documentElement.scrollLeft) + 
          (
document.documentElement.clientWidth width)/2
        
document.body.scrollLeft 
          (
document.body.clientWidth width)/2;
    return 
cornerX;
};

floatingMenu.calculateCornerY = function()
{
    if (
floatingMenu.targetY != 'center')
        return 
floatingMenu.shiftY floatingMenu.targetY;

    var 
height parseInt(floatingMenu.menu.offsetHeight);

    
// Handle Opera 8 problems
    
var clientHeight 
        
floatingMenu.hasElement && floatingMenu.hasInner
        
&& document.documentElement.clientHeight 
            
window.innerHeight
        
window.innerHeight
        
document.documentElement.clientHeight

    
var cornerY =
        
floatingMenu.hasElement
        
? (floatingMenu.hasInner  
           
pageYOffset
           
document.documentElement.scrollTop) + 
          (
clientHeight height)/2
        
document.body.scrollTop 
          (
document.body.clientHeight height)/2;
    return 
cornerY;
};

floatingMenu.doFloat = function()
{
    
// Check if reference to menu was lost due
    // to ajax manipuations
    
if (!floatingMenu.menu)
    {
        
menu document.getElementById
            
document.getElementById(floatingMenuId)
            : 
document.all
              
document.all[floatingMenuId]
              : 
document.layers[floatingMenuId];

        
initSecondary();
    }

    var 
stepXstepY;

    
floatingMenu.computeShifts();

    var 
cornerX floatingMenu.calculateCornerX();

    var 
stepX = (cornerX floatingMenu.nextX) * .07;
    if (
Math.abs(stepX) < .5)
    {
        
stepX cornerX floatingMenu.nextX;
    }

    var 
cornerY floatingMenu.calculateCornerY();

    var 
stepY = (cornerY floatingMenu.nextY) * .07;
    if (
Math.abs(stepY) < .5)
    {
        
stepY cornerY floatingMenu.nextY;
    }

    if (
Math.abs(stepX) > ||
        
Math.abs(stepY) > 0)
    {
        
floatingMenu.nextX += stepX;
        
floatingMenu.nextY += stepY;
        
floatingMenu.move();
    }

    
setTimeout('floatingMenu.doFloat()'20);
};

// addEvent designed by Aaron Moore
floatingMenu.addEvent = function(elementlistenerhandler)
{
    if(
typeof element[listener] != 'function' || 
       
typeof element[listener '_num'] == 'undefined')
    {
        
element[listener '_num'] = 0;
        if (
typeof element[listener] == 'function')
        {
            
element[listener 0] = element[listener];
            
element[listener '_num']++;
        }
        
element[listener] = function(e)
        {
            var 
true;
            
= (e) ? window.event;
            for(var 
element[listener '_num'] -1>= 0i--)
            {
                if(
element[listener i](e) == false)
                    
false;
            }
            return 
r;
        }
    }

    
//if handler is not already stored, assign it
    
for(var 0element[listener '_num']; i++)
        if(
element[listener i] == handler)
            return;
    
element[listener element[listener '_num']] = handler;
    
element[listener '_num']++;
};

floatingMenu.init = function()
{
    
floatingMenu.initSecondary();
    
floatingMenu.doFloat();
};

// Some browsers init scrollbars only after
// full document load.
floatingMenu.initSecondary = function()
{
    
floatingMenu.computeShifts();
    
floatingMenu.nextX floatingMenu.calculateCornerX();
    
floatingMenu.nextY floatingMenu.calculateCornerY();
    
floatingMenu.move();
}

if (
document.layers)
    
floatingMenu.addEvent(window'onload'floatingMenu.init);
else
{
    
floatingMenu.init();
    
floatingMenu.addEvent(window'onload',
        
floatingMenu.initSecondary);
}

//--></script><script type="text/javascript"><!--
/* Script by: www.jtricks.com
 * Version: 20080801
 * Latest version:
 * www.jtricks.com/javascript/navigation/floating_close.html
 */
floatingMenu.hide = function()
{
    
floatingMenu.menu.style.display='none';
    return 
false;
}

floatingMenu.show = function()
{
    
floatingMenu.menu.style.display='block';
    return 
false;
}
//--></script>
</if>
<!-- 
float div end --> 
Now go to Headinclude and right at the very bottom add
PHP Code:
<if condition="THIS_SCRIPT == 'index' AND is_member_of($bbuserinfo,1)"><<div id="floatdiv" style="   
    position:absolute;   
    width:200px;height:50px;left:0px;top:0px;   
    padding:16px;background:#FFFFFF;   
    border:2px double #2266AA"
>   
This is a floating javascript menu.   
</
div>  </if> 
the reason for capturing the SCRIPT and the USERGROUP in both places is to prevent a page script error (denoted by a little yellow triangle at the bottom left of your browser)

I used a little css to jazz mine up, again go to your style>Main CSS and in the additional CSS Definitions add this
PHP Code:
/* ***** Notice colours ***** */
.notice,{padding:.8em;margin-bottom:1.6em;border:2px solid #ddd;}
.notice {background:#FFF6BF;color:#514721;border-color:#FFD324;}
.notice a {color:#514721; background:none; padding:0; margin:0; } 
now in your headinclude change this
PHP Code:
<div id="floatdiv" style="   
    position:absolute;   
    width:200px;height:50px;left:0px;top:0px;   
    padding:16px;background:#FFFFFF;   
    border:2px solid #2266AA"

for this
PHP Code:
<div id="floatdiv" style="position:absolute" class="notice"><img src="images/statusicon/announcement_new.gif" alt=""/> 
And thats it, you should now be able to see the floating box with your message when you aren't logged in at your forumhome.

I'm not a coder but will help as much as i can with problems on this!

AS THERE IS NO FILE TO DOWNLOAD IF YOU USE THIS PLEASE MARK AS INSTALLED

Support will be given to those that have marked this installed!

Screenshots

File Type: jpg floatscreenie.jpg (126.6 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 11-23-2009, 01:14 AM
Reycer Reycer is offline
 
Join Date: Jul 2008
Location: Lebanon, MO (USA)
Posts: 747
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nice idea. This sounds like a good idea for an ad banner. Any screenshots?
Reply With Quote
  #3  
Old 11-23-2009, 01:56 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here you go, but you can see it in action at http://www.thecodecage.com/forumz
Attachment 106592
Reply With Quote
  #4  
Old 11-23-2009, 03:17 AM
Frank Sinatra's Avatar
Frank Sinatra Frank Sinatra is offline
 
Join Date: Nov 2008
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks lets try it
Reply With Quote
  #5  
Old 11-23-2009, 03:21 AM
saadessa saadessa is offline
 
Join Date: Jan 2008
Posts: 284
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice Thank You
Reply With Quote
  #6  
Old 11-23-2009, 08:47 AM
Reycer Reycer is offline
 
Join Date: Jul 2008
Location: Lebanon, MO (USA)
Posts: 747
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool Thanks for this.
Reply With Quote
  #7  
Old 11-23-2009, 12:30 PM
yamahapaul's Avatar
yamahapaul yamahapaul is offline
 
Join Date: Aug 2008
Location: UK
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great work Simon I was going to suggest that you do this, believe it or not One question before I install it, which I think I know the answer to but I want to check first, does it take the colour from whatever your standard notice background is, ie default, or do you adjust it to your own preference?
Reply With Quote
  #8  
Old 11-23-2009, 12:34 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by yamahapaul View Post
Great work Simon I was going to suggest that you do this, believe it or not One question before I install it, which I think I know the answer to but I want to check first, does it take the colour from whatever your standard notice background is, ie default, or do you adjust it to your own preference?
If you follow the instructions given and do the CSS part you can choose to have the floating box whatever colour you desire, you can match it to your background, notices.....etc its just a matter of changing the colour in the css.
Reply With Quote
  #9  
Old 11-23-2009, 12:35 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Frank Sinatra View Post
thanks lets try it
Quote:
Originally Posted by saadessa View Post
Nice Thank You
Quote:
Originally Posted by mdelcour View Post
Cool Thanks for this.
Glad it was of some use to you

If you haven't done so don't forget to click installed.
Reply With Quote
  #10  
Old 02-25-2010, 04:59 AM
Abhik's Avatar
Abhik Abhik is offline
 
Join Date: Jun 2006
Location: Kolkata, India
Posts: 144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:01 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07188 seconds
  • Memory Usage 2,421KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete