main.js 2.22 KB
//Main JS file; here is the JS needed for all the pages/subpages 


$("table").addClass('table table-bordered table-striped');
$("p").addClass('editable');
$("img").addClass('img-responsive');



		
//Sidebar dropdown; it allows sub-menus to drop on click
( function( $ ) {
$( document ).ready(function() {

$('#sidebar-wrapper ul ul li:odd').addClass('odd');
$('#sidebar-wrapper ul ul li:even').addClass('even');


$('#sidebar-wrapper > ul > li > a').click(function() {
	var checkElement = $(this).next();

 if ($(this).closest('li').hasClass('active') && (checkElement.is('ul')) && (checkElement.is(':visible')) && (checkElement.closest('li').has('#sub-active') ))
 {
	 $(checkElement).slideUp('normal');
	 return false;
	 	
 };	
	 

  $('#sidebar-wrapper li').removeClass('active');
  $(this).closest('li').addClass('active');	
  
 
  
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
    $(this).closest('li').removeClass('active');
    checkElement.slideUp('normal');
  }
 
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
    $('#sidebar-wrapper ul ul:visible').slideUp('normal');
    checkElement.slideDown('normal');
  }
  if($(this).closest('li').find('ul').children().length == 0) {
    return true;
  } else {
    return false;	
  }		

});
});
} )( jQuery );

//menu-toggle
$("#menu-toggle").click(function(e) {
    e.preventDefault();
    $("#wrapper").toggleClass("toggled");

});

$(".sidebar-link").click(function() {

    var viewportwidth;

    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

    if (typeof window.innerWidth != 'undefined')
    {
        viewportwidth = window.innerWidth
    }

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

    else if (typeof document.documentElement != 'undefined'
        && typeof document.documentElement.clientWidth !=
        'undefined' && document.documentElement.clientWidth != 0)
    {
        viewportwidth = document.documentElement.clientWidth
    }

    // older versions of IE

    else
    {
        viewportwidth = document.getElementsByTagName('body')[0].clientWidth
    }
    if (viewportwidth < 1200)
    $("#wrapper").toggleClass("toggled");

});