github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/root/js/matrix.js (about) 1 2 $(document).ready(function(){ 3 4 5 6 // === Sidebar navigation === // 7 8 $('.submenu > a').click(function(e) 9 { 10 e.preventDefault(); 11 var submenu = $(this).siblings('ul'); 12 var li = $(this).parents('li'); 13 var submenus = $('#sidebar li.submenu ul'); 14 var submenus_parents = $('#sidebar li.submenu'); 15 if(li.hasClass('open')) 16 { 17 if(($(window).width() > 768) || ($(window).width() < 479)) { 18 submenu.slideUp(); 19 } else { 20 submenu.fadeOut(250); 21 } 22 li.removeClass('open'); 23 } else 24 { 25 if(($(window).width() > 768) || ($(window).width() < 479)) { 26 submenus.slideUp(); 27 submenu.slideDown(); 28 } else { 29 submenus.fadeOut(250); 30 submenu.fadeIn(250); 31 } 32 submenus_parents.removeClass('open'); 33 li.addClass('open'); 34 } 35 }); 36 37 var ul = $('#sidebar > ul'); 38 39 $('#sidebar > a').click(function(e) 40 { 41 e.preventDefault(); 42 var sidebar = $('#sidebar'); 43 if(sidebar.hasClass('open')) 44 { 45 sidebar.removeClass('open'); 46 ul.slideUp(250); 47 } else 48 { 49 sidebar.addClass('open'); 50 ul.slideDown(250); 51 } 52 }); 53 54 // === Resize window related === // 55 $(window).resize(function() 56 { 57 if($(window).width() > 479) 58 { 59 ul.css({'display':'block'}); 60 $('#content-header .btn-group').css({width:'auto'}); 61 } 62 if($(window).width() < 479) 63 { 64 ul.css({'display':'none'}); 65 fix_position(); 66 } 67 if($(window).width() > 768) 68 { 69 $('#user-nav > ul').css({width:'auto',margin:'0'}); 70 $('#content-header .btn-group').css({width:'auto'}); 71 } 72 }); 73 74 if($(window).width() < 468) 75 { 76 ul.css({'display':'none'}); 77 fix_position(); 78 } 79 80 if($(window).width() > 479) 81 { 82 $('#content-header .btn-group').css({width:'auto'}); 83 ul.css({'display':'block'}); 84 } 85 86 // === Tooltips === // 87 $('.tip').tooltip(); 88 $('.tip-left').tooltip({ placement: 'left' }); 89 $('.tip-right').tooltip({ placement: 'right' }); 90 $('.tip-top').tooltip({ placement: 'top' }); 91 $('.tip-bottom').tooltip({ placement: 'bottom' }); 92 93 // === Search input typeahead === // 94 $('#search input[type=text]').typeahead({ 95 source: ['Dashboard','Form elements','Common Elements','Validation','Wizard','Buttons','Icons','Interface elements','Support','Calendar','Gallery','Reports','Charts','Graphs','Widgets'], 96 items: 4 97 }); 98 99 // === Fixes the position of buttons group in content header and top user navigation === // 100 function fix_position() 101 { 102 var uwidth = $('#user-nav > ul').width(); 103 $('#user-nav > ul').css({width:uwidth,'margin-left':'-' + uwidth / 2 + 'px'}); 104 105 var cwidth = $('#content-header .btn-group').width(); 106 $('#content-header .btn-group').css({width:cwidth,'margin-left':'-' + uwidth / 2 + 'px'}); 107 } 108 109 // === Style switcher === // 110 $('#style-switcher i').click(function() 111 { 112 if($(this).hasClass('open')) 113 { 114 $(this).parent().animate({marginRight:'-=190'}); 115 $(this).removeClass('open'); 116 } else 117 { 118 $(this).parent().animate({marginRight:'+=190'}); 119 $(this).addClass('open'); 120 } 121 $(this).toggleClass('icon-arrow-left'); 122 $(this).toggleClass('icon-arrow-right'); 123 }); 124 125 $('#style-switcher a').click(function() 126 { 127 var style = $(this).attr('href').replace('#',''); 128 $('.skin-color').attr('href','css/maruti.'+style+'.css'); 129 $(this).siblings('a').css({'border-color':'transparent'}); 130 $(this).css({'border-color':'#aaaaaa'}); 131 }); 132 133 $('.lightbox_trigger').click(function(e) { 134 135 e.preventDefault(); 136 137 var image_href = $(this).attr("href"); 138 139 if ($('#lightbox').length > 0) { 140 141 $('#imgbox').html('<img src="' + image_href + '" /><p><i class="icon-remove icon-white"></i></p>'); 142 143 $('#lightbox').slideDown(500); 144 } 145 146 else { 147 var lightbox = 148 '<div id="lightbox" style="display:none;">' + 149 '<div id="imgbox"><img src="' + image_href +'" />' + 150 '<p><i class="icon-remove icon-white"></i></p>' + 151 '</div>' + 152 '</div>'; 153 154 $('body').append(lightbox); 155 $('#lightbox').slideDown(500); 156 } 157 158 }); 159 160 161 $('#lightbox').live('click', function() { 162 $('#lightbox').hide(200); 163 }); 164 165 }); 166