Latest News:
Latest Mods: Latest Tutorials:


 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customization Tutorial How-to: Add jQuery fading Category Descriptions to your theme
Author Message
euantor
Designer/Themer

Support

Posts: 765
Joined: Jun 2009
Reputation: 6
Post: #1
How-to: Add jQuery fading Category Descriptions to your theme
jQuery is cool. Fading is cool. Clutter most certainly is not. Add all these together and you come up with an elegant solution for displaying category descriptions. In this tutorial, I'll show you how to add fading category descriptions using jQuery.

First of all, why not take a look at what we'll be creating. You can do this by visiting my jsFiddle for it. Feel free to fork it, edit it, share it whatever you wish to it - it mainly existed for me to prototype my styling and html: http://jsfiddle.net/euantor/sPUWh/

Okay, so let's make a start. We first of all need to add jQuery if you don't already have it loaded. The best way to do this is to load it from google. It trims down your bandwidth usage and, chances are, google's servers are at least 9000 times better than yours. Head over to the Templates & Style section of the ACP and load up the headerinclude template for you theme. You can add the code wherever you like in here truth be told. I like to place it below the rest of the JS being initialised, so here we go:

Find:

PHP Code:
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/popup_menu.js?ver=1600"></script> 

After, add:

PHP Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 


Right, step one done. Consider yourself maybe a third through the tutorial. Next step is to edit the forumbit_depth1_cat template. Load it up. In here, we're going to apply a few ID selectors and a few classes etc. This whole step could be entirely different for your theme. I'm writing from the perspective of editing the default theme.

Find:

PHP Code:
<div><strong><a href="{$forum_url}">{$forum['name']}</a></strong><br /><div class="smalltext">{$forum['description']}</div></div

Replace with:

PHP Code:
<div><span id="{$forum['fid']}name"><a href="{$forum_url}">{$forum['name']}</a></span> &nbsp; <span class="smalltext forumdesc" id="{$forum['fid']}description">{$forum['description']}</span></div

At the bottom of this file, add the following too. Make sure it's right at the bottom. Got it? Bottom.

PHP Code:
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {

    
jQuery("#{$forum['fid']}description").hide();

    
jQuery("#{$forum['fid']}name").mouseover(function() {

        var 
content jQuery("#{$forum['fid']}description").text();

        if (
content === "") {} else {
            
jQuery("#{$forum['fid']}description").fadeIn('slow', function() {
                
// Animation complete
            
});
        }

    });

    
jQuery("#{$forum['fid']}name").mouseout(function() {
        
jQuery("#{$forum['fid']}description").stop(truetrue).fadeOut('slow', function() {
            
// Animation complete
        
});

    });

});
</script> 

That's our jQuery magic. No conflicts or errors. Just delicious jQuery goodness. You can, of course, style the description using the forumdesc class. For example:

PHP Code:
.forumdesc {
    
backgroundrgba(0000.5);
    
padding4px;







That's all there is to it. Simple, eh? This technique can, of course, be replicated for individual forum descriptions. I'll leave you to play with it on that front though
02-25-2011, 04:42 AM


1master1
Member


Posts: 89
Joined: Aug 2010
Reputation: 0
Post: #2
RE: How-to: Add jQuery fading Category Descriptions to your theme
is it possible to have this effect for title tag? so that every title tag on the board will be replaced with this cool effect.
02-25-2011, 04:54 AM
euantor
Designer/Themer

Support

Posts: 765
Joined: Jun 2009
Reputation: 6
Post: #3
RE: How-to: Add jQuery fading Category Descriptions to your theme
It would be possible, yes. Why though?
02-25-2011, 04:56 AM
Mr-Trainor
Senior Member

Support

Posts: 293
Joined: Mar 2010
Reputation: 5
Post: #4
RE: How-to: Add jQuery fading Category Descriptions to your theme
Just tried this and it works very well, nice tutorial and a great effect .
02-25-2011, 04:57 AM
euantor
Designer/Themer

Support

Posts: 765
Joined: Jun 2009
Reputation: 6
Post: #5
RE: How-to: Add jQuery fading Category Descriptions to your theme
Thanks Glad you like it ^^
02-25-2011, 04:59 AM
1master1
Member


Posts: 89
Joined: Aug 2010
Reputation: 0
Post: #6
RE: How-to: Add jQuery fading Category Descriptions to your theme
thanks euantor

i found what i needed. thanks for the suggestion.

replacing the

"#{$forum['fid']}description"
to
"[title]"
worked fine
02-25-2011, 10:10 AM
euantor
Designer/Themer

Support

Posts: 765
Joined: Jun 2009
Reputation: 6
Post: #7
RE: How-to: Add jQuery fading Category Descriptions to your theme
I'm glad I wasn't entirely sure if that would work.
02-25-2011, 03:46 PM
Jasonl1331
Member


Posts: 61
Joined: Oct 2010
Reputation: 1
Post: #8
RE: How-to: Add jQuery fading Category Descriptions to your theme
I did it and it completely ruined my skin :(.
02-25-2011, 10:21 PM
x-Treme
MyBB Freak!

Support

Posts: 347
Joined: Sep 2008
Reputation: 6
Post: #9
RE: How-to: Add jQuery fading Category Descriptions to your theme
(02-25-2011 10:21 PM)Jasonl1331 Wrote:  I did it and it completely ruined my skin :(.

What theme were you using?
02-25-2011, 10:29 PM
euantor
Designer/Themer

Support

Posts: 765
Joined: Jun 2009
Reputation: 6
Post: #10
RE: How-to: Add jQuery fading Category Descriptions to your theme
Yeah, if you tell me or theme and/or link em to your site, I can help. Without that basic info, I can't do anything.
02-25-2011, 11:44 PM
 




User(s) browsing this thread: 2 Guest(s)