diff --git a/build/js/custom.js b/build/js/custom.js index 623e4272..a4a94009 100644 --- a/build/js/custom.js +++ b/build/js/custom.js @@ -36,14 +36,14 @@ $(document).ready(function() { var $li = $(this).parent(); if ($li.is('.active')) { - $li.removeClass('active'); + $li.removeClass('active active-sm'); $('ul:first', $li).slideUp(function() { setContentHeight(); }); } else { // prevent closing menu if we are on child menu if (!$li.parent().is('.child_menu')) { - $SIDEBAR_MENU.find('li').removeClass('active'); + $SIDEBAR_MENU.find('li').removeClass('active active-sm'); $SIDEBAR_MENU.find('li ul').slideUp(); } @@ -58,19 +58,15 @@ $(document).ready(function() { // toggle small or large menu $MENU_TOGGLE.on('click', function() { if ($BODY.hasClass('nav-md')) { - $BODY.removeClass('nav-md').addClass('nav-sm'); - - if ($SIDEBAR_MENU.find('li').hasClass('active')) { - $SIDEBAR_MENU.find('li.active').addClass('active-sm').removeClass('active'); - } + $SIDEBAR_MENU.find('li.active ul').hide(); + $SIDEBAR_MENU.find('li.active').addClass('active-sm').removeClass('active'); } else { - $BODY.removeClass('nav-sm').addClass('nav-md'); - - if ($SIDEBAR_MENU.find('li').hasClass('active-sm')) { - $SIDEBAR_MENU.find('li.active-sm').addClass('active').removeClass('active-sm'); - } + $SIDEBAR_MENU.find('li.active-sm ul').show(); + $SIDEBAR_MENU.find('li.active-sm').addClass('active').removeClass('active-sm'); } + $BODY.toggleClass('nav-md nav-sm'); + setContentHeight(); }); @@ -137,7 +133,7 @@ $(document).ready(function() { // Progressbar if ($(".progress .progress-bar")[0]) { - $('.progress .progress-bar').progressbar(); // bootstrap 3 + $('.progress .progress-bar').progressbar(); } // /Progressbar @@ -244,7 +240,6 @@ if (typeof NProgress != 'undefined') { NProgress.done(); }); } - /** * Resize function without multiple trigger * diff --git a/build/js/custom.min.js b/build/js/custom.min.js index a87b54db..216b8229 100644 --- a/build/js/custom.min.js +++ b/build/js/custom.min.js @@ -1 +1 @@ -function countChecked(){"all"===checkState&&$(".bulk_action input[name='table_records']").iCheck("check"),"none"===checkState&&$(".bulk_action input[name='table_records']").iCheck("uncheck");var e=$(".bulk_action input[name='table_records']:checked").length;e?($(".column-title").hide(),$(".bulk-actions").show(),$(".action-cnt").html(e+" Records Selected")):($(".column-title").show(),$(".bulk-actions").hide())}var CURRENT_URL=window.location.href.split("?")[0],$BODY=$("body"),$MENU_TOGGLE=$("#menu_toggle"),$SIDEBAR_MENU=$("#sidebar-menu"),$SIDEBAR_FOOTER=$(".sidebar-footer"),$LEFT_COL=$(".left_col"),$RIGHT_COL=$(".right_col"),$NAV_MENU=$(".nav_menu"),$FOOTER=$("footer");$(document).ready(function(){var e=function(){$RIGHT_COL.css("min-height",$(window).height());var e=$BODY.outerHeight(),t=$BODY.hasClass("footer_fixed")?0:$FOOTER.height(),n=$LEFT_COL.eq(1).height()+$SIDEBAR_FOOTER.height(),i=n>e?n:e;i-=$NAV_MENU.height()+t,$RIGHT_COL.css("min-height",i)};$SIDEBAR_MENU.find("a").on("click",function(t){var n=$(this).parent();n.is(".active")?(n.removeClass("active"),$("ul:first",n).slideUp(function(){e()})):(n.parent().is(".child_menu")||($SIDEBAR_MENU.find("li").removeClass("active"),$SIDEBAR_MENU.find("li ul").slideUp()),n.addClass("active"),$("ul:first",n).slideDown(function(){e()}))}),$MENU_TOGGLE.on("click",function(){$BODY.hasClass("nav-md")?($BODY.removeClass("nav-md").addClass("nav-sm"),$SIDEBAR_MENU.find("li").hasClass("active")&&$SIDEBAR_MENU.find("li.active").addClass("active-sm").removeClass("active")):($BODY.removeClass("nav-sm").addClass("nav-md"),$SIDEBAR_MENU.find("li").hasClass("active-sm")&&$SIDEBAR_MENU.find("li.active-sm").addClass("active").removeClass("active-sm")),e()}),$SIDEBAR_MENU.find('a[href="'+CURRENT_URL+'"]').parent("li").addClass("current-page"),$SIDEBAR_MENU.find("a").filter(function(){return this.href==CURRENT_URL}).parent("li").addClass("current-page").parents("ul").slideDown(function(){e()}).parent().addClass("active"),$(window).smartresize(function(){e()}),$.fn.mCustomScrollbar&&$(".menu_fixed").mCustomScrollbar({autoHideScrollbar:!0,theme:"minimal",mouseWheel:{preventDefault:!0}})}),$(document).ready(function(){$(".collapse-link").on("click",function(){var e=$(this).closest(".x_panel"),t=$(this).find("i"),n=e.find(".x_content");e.attr("style")?n.slideToggle(200,function(){e.removeAttr("style")}):(n.slideToggle(200),e.css("height","auto")),t.toggleClass("fa-chevron-up fa-chevron-down")}),$(".close-link").click(function(){var e=$(this).closest(".x_panel");e.remove()})}),$(document).ready(function(){$('[data-toggle="tooltip"]').tooltip({container:"body"})}),$(".progress .progress-bar")[0]&&$(".progress .progress-bar").progressbar(),$(document).ready(function(){if($(".js-switch")[0]){var e=Array.prototype.slice.call(document.querySelectorAll(".js-switch"));e.forEach(function(e){new Switchery(e,{color:"#26B99A"})})}}),$(document).ready(function(){$("input.flat")[0]&&$(document).ready(function(){$("input.flat").iCheck({checkboxClass:"icheckbox_flat-green",radioClass:"iradio_flat-green"})})}),$("table input").on("ifChecked",function(){checkState="",$(this).parent().parent().parent().addClass("selected"),countChecked()}),$("table input").on("ifUnchecked",function(){checkState="",$(this).parent().parent().parent().removeClass("selected"),countChecked()});var checkState="";$(".bulk_action input").on("ifChecked",function(){checkState="",$(this).parent().parent().parent().addClass("selected"),countChecked()}),$(".bulk_action input").on("ifUnchecked",function(){checkState="",$(this).parent().parent().parent().removeClass("selected"),countChecked()}),$(".bulk_action input#check-all").on("ifChecked",function(){checkState="all",countChecked()}),$(".bulk_action input#check-all").on("ifUnchecked",function(){checkState="none",countChecked()}),$(document).ready(function(){$(".expand").on("click",function(){$(this).next().slideToggle(200),$expand=$(this).find(">:first-child"),"+"==$expand.text()?$expand.text("-"):$expand.text("+")})}),"undefined"!=typeof NProgress&&($(document).ready(function(){NProgress.start()}),$(window).load(function(){NProgress.done()})),function(e,t){var n=function(e,t,n){var i;return function(){function c(){n||e.apply(a,o),i=null}var a=this,o=arguments;i?clearTimeout(i):n&&e.apply(a,o),i=setTimeout(c,t||100)}};jQuery.fn[t]=function(e){return e?this.bind("resize",n(e)):this.trigger(t)}}(jQuery,"smartresize"); \ No newline at end of file +function countChecked(){"all"===checkState&&$(".bulk_action input[name='table_records']").iCheck("check"),"none"===checkState&&$(".bulk_action input[name='table_records']").iCheck("uncheck");var e=$(".bulk_action input[name='table_records']:checked").length;e?($(".column-title").hide(),$(".bulk-actions").show(),$(".action-cnt").html(e+" Records Selected")):($(".column-title").show(),$(".bulk-actions").hide())}var CURRENT_URL=window.location.href.split("?")[0],$BODY=$("body"),$MENU_TOGGLE=$("#menu_toggle"),$SIDEBAR_MENU=$("#sidebar-menu"),$SIDEBAR_FOOTER=$(".sidebar-footer"),$LEFT_COL=$(".left_col"),$RIGHT_COL=$(".right_col"),$NAV_MENU=$(".nav_menu"),$FOOTER=$("footer");$(document).ready(function(){var e=function(){$RIGHT_COL.css("min-height",$(window).height());var e=$BODY.outerHeight(),t=$BODY.hasClass("footer_fixed")?0:$FOOTER.height(),n=$LEFT_COL.eq(1).height()+$SIDEBAR_FOOTER.height(),i=n>e?n:e;i-=$NAV_MENU.height()+t,$RIGHT_COL.css("min-height",i)};$SIDEBAR_MENU.find("a").on("click",function(t){var n=$(this).parent();n.is(".active")?(n.removeClass("active active-sm"),$("ul:first",n).slideUp(function(){e()})):(n.parent().is(".child_menu")||($SIDEBAR_MENU.find("li").removeClass("active active-sm"),$SIDEBAR_MENU.find("li ul").slideUp()),n.addClass("active"),$("ul:first",n).slideDown(function(){e()}))}),$MENU_TOGGLE.on("click",function(){$BODY.hasClass("nav-md")?($SIDEBAR_MENU.find("li.active ul").hide(),$SIDEBAR_MENU.find("li.active").addClass("active-sm").removeClass("active")):($SIDEBAR_MENU.find("li.active-sm ul").show(),$SIDEBAR_MENU.find("li.active-sm").addClass("active").removeClass("active-sm")),$BODY.toggleClass("nav-md nav-sm"),e()}),$SIDEBAR_MENU.find('a[href="'+CURRENT_URL+'"]').parent("li").addClass("current-page"),$SIDEBAR_MENU.find("a").filter(function(){return this.href==CURRENT_URL}).parent("li").addClass("current-page").parents("ul").slideDown(function(){e()}).parent().addClass("active"),$(window).smartresize(function(){e()}),$.fn.mCustomScrollbar&&$(".menu_fixed").mCustomScrollbar({autoHideScrollbar:!0,theme:"minimal",mouseWheel:{preventDefault:!0}})}),$(document).ready(function(){$(".collapse-link").on("click",function(){var e=$(this).closest(".x_panel"),t=$(this).find("i"),n=e.find(".x_content");e.attr("style")?n.slideToggle(200,function(){e.removeAttr("style")}):(n.slideToggle(200),e.css("height","auto")),t.toggleClass("fa-chevron-up fa-chevron-down")}),$(".close-link").click(function(){var e=$(this).closest(".x_panel");e.remove()})}),$(document).ready(function(){$('[data-toggle="tooltip"]').tooltip({container:"body"})}),$(".progress .progress-bar")[0]&&$(".progress .progress-bar").progressbar(),$(document).ready(function(){if($(".js-switch")[0]){var e=Array.prototype.slice.call(document.querySelectorAll(".js-switch"));e.forEach(function(e){new Switchery(e,{color:"#26B99A"})})}}),$(document).ready(function(){$("input.flat")[0]&&$(document).ready(function(){$("input.flat").iCheck({checkboxClass:"icheckbox_flat-green",radioClass:"iradio_flat-green"})})}),$("table input").on("ifChecked",function(){checkState="",$(this).parent().parent().parent().addClass("selected"),countChecked()}),$("table input").on("ifUnchecked",function(){checkState="",$(this).parent().parent().parent().removeClass("selected"),countChecked()});var checkState="";$(".bulk_action input").on("ifChecked",function(){checkState="",$(this).parent().parent().parent().addClass("selected"),countChecked()}),$(".bulk_action input").on("ifUnchecked",function(){checkState="",$(this).parent().parent().parent().removeClass("selected"),countChecked()}),$(".bulk_action input#check-all").on("ifChecked",function(){checkState="all",countChecked()}),$(".bulk_action input#check-all").on("ifUnchecked",function(){checkState="none",countChecked()}),$(document).ready(function(){$(".expand").on("click",function(){$(this).next().slideToggle(200),$expand=$(this).find(">:first-child"),"+"==$expand.text()?$expand.text("-"):$expand.text("+")})}),"undefined"!=typeof NProgress&&($(document).ready(function(){NProgress.start()}),$(window).load(function(){NProgress.done()})),function(e,t){var n=function(e,t,n){var i;return function(){function c(){n||e.apply(a,o),i=null}var a=this,o=arguments;i?clearTimeout(i):n&&e.apply(a,o),i=setTimeout(c,t||100)}};jQuery.fn[t]=function(e){return e?this.bind("resize",n(e)):this.trigger(t)}}(jQuery,"smartresize"); \ No newline at end of file diff --git a/src/js/custom.js b/src/js/custom.js index 623e4272..e917fe49 100644 --- a/src/js/custom.js +++ b/src/js/custom.js @@ -36,14 +36,14 @@ $(document).ready(function() { var $li = $(this).parent(); if ($li.is('.active')) { - $li.removeClass('active'); + $li.removeClass('active active-sm'); $('ul:first', $li).slideUp(function() { setContentHeight(); }); } else { // prevent closing menu if we are on child menu if (!$li.parent().is('.child_menu')) { - $SIDEBAR_MENU.find('li').removeClass('active'); + $SIDEBAR_MENU.find('li').removeClass('active active-sm'); $SIDEBAR_MENU.find('li ul').slideUp(); } @@ -58,19 +58,15 @@ $(document).ready(function() { // toggle small or large menu $MENU_TOGGLE.on('click', function() { if ($BODY.hasClass('nav-md')) { - $BODY.removeClass('nav-md').addClass('nav-sm'); - - if ($SIDEBAR_MENU.find('li').hasClass('active')) { - $SIDEBAR_MENU.find('li.active').addClass('active-sm').removeClass('active'); - } + $SIDEBAR_MENU.find('li.active ul').hide(); + $SIDEBAR_MENU.find('li.active').addClass('active-sm').removeClass('active'); } else { - $BODY.removeClass('nav-sm').addClass('nav-md'); - - if ($SIDEBAR_MENU.find('li').hasClass('active-sm')) { - $SIDEBAR_MENU.find('li.active-sm').addClass('active').removeClass('active-sm'); - } + $SIDEBAR_MENU.find('li.active-sm ul').show(); + $SIDEBAR_MENU.find('li.active-sm').addClass('active').removeClass('active-sm'); } + $BODY.toggleClass('nav-md nav-sm'); + setContentHeight(); }); @@ -137,7 +133,7 @@ $(document).ready(function() { // Progressbar if ($(".progress .progress-bar")[0]) { - $('.progress .progress-bar').progressbar(); // bootstrap 3 + $('.progress .progress-bar').progressbar(); } // /Progressbar @@ -243,40 +239,4 @@ if (typeof NProgress != 'undefined') { $(window).load(function () { NProgress.done(); }); -} - -/** - * Resize function without multiple trigger - * - * Usage: - * $(window).smartresize(function(){ - * // code here - * }); - */ -(function($,sr){ - // debouncing function from John Hann - // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ - var debounce = function (func, threshold, execAsap) { - var timeout; - - return function debounced () { - var obj = this, args = arguments; - function delayed () { - if (!execAsap) - func.apply(obj, args); - timeout = null; - } - - if (timeout) - clearTimeout(timeout); - else if (execAsap) - func.apply(obj, args); - - timeout = setTimeout(delayed, threshold || 100); - }; - }; - - // smartresize - jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; - -})(jQuery,'smartresize'); \ No newline at end of file +} \ No newline at end of file diff --git a/src/js/helper.js b/src/js/helper.js new file mode 100644 index 00000000..7d97489b --- /dev/null +++ b/src/js/helper.js @@ -0,0 +1,35 @@ +/** + * Resize function without multiple trigger + * + * Usage: + * $(window).smartresize(function(){ + * // code here + * }); + */ +(function($,sr){ + // debouncing function from John Hann + // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ + var debounce = function (func, threshold, execAsap) { + var timeout; + + return function debounced () { + var obj = this, args = arguments; + function delayed () { + if (!execAsap) + func.apply(obj, args); + timeout = null; + } + + if (timeout) + clearTimeout(timeout); + else if (execAsap) + func.apply(obj, args); + + timeout = setTimeout(delayed, threshold || 100); + }; + }; + + // smartresize + jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; + +})(jQuery,'smartresize'); \ No newline at end of file