Thread: Profile Enhancements - Mood Manager - with AJAX mood update.
View Single Post
  #674  
Old 10-11-2007, 12:49 AM
rwilkins108's Avatar
rwilkins108 rwilkins108 is offline
 
Join Date: Oct 2006
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've made some changes in this that I thought would be good for updating this plugin. For the most part, the changes only affect image drop downs.

#1 I've gotten rid of the multiple optgroups and replaced them with just options. This has resulted in a much smaller code size, plus, the selected image is no longer blurred out and it looks much better and is faster.

#2 Since I've got a lot of animated .gifs and they have different sizes, I had a problem with overlapping images and it was hard to select those moods. So what I've done is made the size of the selections changeable. I made the size the biggest gif I had, in my case 36px x 100px. This makes the selections more spaced out, but I think it looks nicer. These changes have my defaults in them. I've also separated out the style info into a css tag, so that should make the code smaller as well.

Hopefully you'll find this useful.

If you're not comfortable making these changes, please don't or at least back things up...

The changes are in 2 places:
#1 replace the contents of the template quick_mood_change_by_sniper with
Code:
<!-- / dropdown mood select by sniper start -->
<style>
.moods_option {
 height: 36px; width: 100px; background-repeat: no-repeat; background-position: center;
}
</style>

<div class="vbmenu_popup" id="moods_menu" style="display:none">
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="thead" valign="middle">$vbphrase[change_mood]:</td>
    </tr>
    <tr>
        <td class="alt1" valign="middle">
        <form action="index.php?do=ajax_mood_update" method="post" id="mood_form">
            <input type="hidden" name="s" value="$session[sessionhash]" />
                <select name="mood" size="7" onchange="change_mood(this.value);">
                    <option style="text-align: center;" value=""<if condition="empty($bbuserinfo[mood])"> Selected</if>>$vbphrase[no_mood]</option>
                    $vbmoods[mood]
                </select>
        </form>
        </td>
    </tr>
</table>
</div>

<div><strong>$vbphrase[change_mood]:</strong> <a href="#" id="moods"><if condition="!empty($bbuserinfo[mood])"><img src="$vboptions[bburl]/images/mood/$bbuserinfo[mood].gif" border="0" align="absmiddle"/><else />$vbphrase[change_mood]</if></a> <script type="text/javascript"> vbmenu_register("moods", 1); </script></div>
<!-- / dropdown mood select by sniper end -->


#2
replace the contents of the plugin [Mood Manager] - Make Drop Down Menu with
PHP Code:
if ($vbulletin->options['moodmanageronoff'] AND $vbulletin->userinfo['userid'] AND !in_array($vbulletin->userinfo['usergroupid'], explode("|"$vbulletin->options['moodmanagerusergroup'])))
{
    
$vbulletin->templatecache['header'] .= '<script type=\"text/javascript\">
<!--
    function update_mood()
    {
        fetch_object(\'moods\').innerHTML = \'Updating...\';
        if (ajax_mood.handler.readyState == 4 && ajax_mood.handler.status == 200 && ajax_mood.handler.responseText)
        {
            fetch_object(\'moods\').innerHTML = ajax_mood.handler.responseText;
        }
    }

    function change_mood(mood)
    {
        ajax_mood = new vB_AJAX_Handler(true);
        ajax_mood.onreadystatechange(update_mood);
        ajax_mood.send(\'ajax.php\', \'do=insertmood&mood=\' + PHP.urlencode(mood));
    }
//-->
</script>'
;

$moodslist explode("\n"$vbulletin->options['moodmanagermoods']);
if (
$vbulletin->options['moodmanagerimages'] && !eregi("MSIE"$_SERVER['HTTP_USER_AGENT'])) 
{
    
$vbmoods['mood'] .= '<optgroup>';
}
foreach (
$moodslist AS $mood)
{
    
$mood trim($mood);

    if (
$mood == $vbulletin->userinfo['mood']) { $selectedmood ' Selected'; } else { $selectedmood ''; }

    if (!
$vbulletin->options['moodmanagerimages'] || eregi("MSIE"$_SERVER['HTTP_USER_AGENT']))
    {
        
$vbmoods['mood'] .= '<option value="' .$mood'"' .$selectedmood'>' .$mood'</option>';
    }
    else
    {
        
$vbmoods['mood'] .= '<option class="moods_option" style="background-image: url(images/mood/' .$mood'.gif);" value="' .$mood'"' .$selectedmood'></option>';
    }
    
}
if (
$vbulletin->options['moodmanagerimages'] && !eregi("MSIE"$_SERVER['HTTP_USER_AGENT'])) 
{
    
$vbmoods['mood'] .= '</optgroup>';
}

    if (
$vbulletin->options['moodmanagerglobal'])
    {
        
$search_text '$vbphrase[private_messages_nav]';
        
$vbulletin->templatecache['navbar'] = str_replace($search_text$search_text "<br />" fetch_template('quick_mood_change_by_sniper'), $vbulletin->templatecache['navbar']);
    }
    else
    {
        eval(
'$usermoods = "' fetch_template('quick_mood_change_by_sniper') . '";');
    }

To change the size of the amount of space each gif takes, modify
.moods_option
height: 36px; width: 100px;
to the size you want.


Here's a picture of what it looks like on my site:
(Sorry for the poor quality animated gif!)


you can try it out on my site by registering on http://www.u-assist.com
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01325 seconds
  • Memory Usage 1,818KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete