Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Change js File - Suggestions? 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
US
I am thinking this should be a simple change that I'm trying to do, but I'm missing something.

I have a website running on Drupal 7 that I'm building, and for one of the tools (modules), it creates a toolbar that shows at the top of the screen. I found some custom code that hides it by default, and shows it when you press the tilde (~) key on your keyboard.

I would rather it show by default, and then show or hide when I press the tilde.

Is this possible to change? I tried a little so far, but I know I'm missing something.

Here's the original:
Code:
/***************************************************************************************************
 * Found the following piece from [URL unfurl="true"]http://mrtheme.com/cms/drupal/drupal-7-pimping-admin-menu-module/[/URL]
 * installed 20111210 by manually pasting author's code
 ***************************************************************************************************/
Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) {  
    $adminMenu.find('> div').hide();  
    $(window).bind('keypress', function(e) {  
        var kcode = (e.which);  
        if(kcode == '96') {  
            $adminMenu.find('> div').slideToggle('slow');  
        }  
    });  
}

All I've tried doing so far is swapping ....hide(); with ....slideToggle..

Well, that didn't work out so well... when I did that, it would slowly hide when loading the site, and then I couldn't get it to show at all.

Can anybody help me sort this out to where it will show by default, and only hide upon the keypress?

Thanks for any help here. Javascript is not something I've really delved into before.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
either
Code:
*************************************************************/
Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) {  
    $adminMenu.find('> div').show();  
    $(window).bind('keypress', function(e) {  
        var kcode = (e.which);  
        if(kcode == '96') {  
            $adminMenu.find('> div').slideToggle('slow');  
        }  
    });  
}
or
Code:
*************************************************************/
Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) {  
    $(window).bind('keypress', function(e) {  
        var kcode = (e.which);  
        if(kcode == '96') {  
            $adminMenu.find('> div').slideToggle('slow');  
        }  
    });  
}
should work. the first explicitly shows the toolbar, while the second assumes the toolbar is visible by default.

Jason Meckley
Senior Programmer

faq855-7190
faq732-7259
My Blog
 
Thanks! I tried the 2nd one, and it worked great! I guess in that one, it's just deleting the .hide portion, duh should have tried that.


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top