SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    toggle, hide nav bar

    I know it looks like PHP, but it's suppose to be outputting an array of javascript... I think. It's the Admin defined shortcut keys in CIBonfire, using the JWerty library (which their homepage is 404, but the github is still there.) anyways, I"m trying to change the last line of this array to an action that would hide my .navbar_class.and preferably be able to "toggle" it back on too.
    HTML Code:
    $config['ui.current_shortcuts'] = array(
    	'form_save'      => array('description' => 'Save any form in the admin area.', 'action' => '$("input[name=save]").click();return false;'),
    	'create_new'     => array('description' => 'Create a new record in the module.', 'action' => 'window.location.href=$("a#create_new").attr("href");'),
    	'select_all'     => array('description' => 'Select all records in an index page.', 'action' => '$("table input[type=checkbox]").click();return false;'),
    	'delete'         => array('description' => 'Delete the record(s).', 'action' => '$("#delete-me.btn-danger").click();'),
    	'module_index'   => array('description' => 'Return to the index of the current module.', 'action' => 'window.location.href=$("a#list").attr("href");'),
    	'goto_content'   => array('description' => 'Jump to the Content context.', 'action' => 'window.location.href=$("#tb_content").attr("href")'),
    	'goto_reports'   => array('description' => 'Jump to the Reports context.', 'action' => 'window.location.href=$("#tb_reports").attr("href")'),
    	'goto_settings'  => array('description' => 'Jump to the Settings context.', 'action' => 'window.location.href=$("#tb_settings").attr("href")'),
    	'goto_developer' => array('description' => 'Jump to the Developer context.', 'action' => 'window.location.href=$("#tb_developer").attr("href")'),
    	'hid_ui' => array('description' => 'Hide the navigation bar.', 'action' => '$("input[name=save]").click();return false;'),

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,997
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    No idea if it'll help at all, but the easiest way to toggle an element using jQuery is:

    Code:
    $(selector).toggle();
    However, you will want to stick this in an click event handler and attach it to a different element than the one you want to toggle, as otherwise, when the element is invisible, you won't be able to make it visible again.

    E.g.

    Code:
    <div id="myDiv">Hello</div>
    <a href="#" id="myLink">Click Me</a>
    
    $("#myLink").click(function(){
        $("#myDiv").toggle();
    });
    So for you, that'll be something like:

    Code:
    'hide_nav_bar' => array('description' => 'Hide the navigation bar.', 'action' => '$(".navbar_class").toggle();')
    HTH


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •