//[Preview Menu Javascript] //Project: Riday Admin - Responsive Admin Template //Primary use: This file is for demo purposes only. $(function () { 'use strict' /** * Get access to plugins */ $('[data-toggle="control-sidebar"]').controlSidebar() $('[data-toggle="push-menu"]').pushMenu() var $pushMenu = $('[data-toggle="push-menu"]').data('lte.pushmenu') var $controlSidebar = $('[data-toggle="control-sidebar"]').data('lte.controlsidebar') var $layout = $('body').data('lte.layout') /** * List of all the available themes * * @type Array */ var mySkins = [ 'theme-primary', 'theme-secondary', 'theme-info', 'theme-success', 'theme-danger', 'theme-warning', ] /** * Get a prestored setting * * @param String name Name of of the setting * @returns String The value of the setting | null */ function get(name) { if (typeof (Storage) !== 'undefined') { return localStorage.getItem(name) } else { window.alert('Please use a modern browser to properly view this template!') } } /** * Store a new settings in the browser * * @param String name Name of the setting * @param String val Value of the setting * @returns void */ function store(name, val) { if (typeof (Storage) !== 'undefined') { localStorage.setItem(name, val) } else { window.alert('Please use a modern browser to properly view this template!') } } /** * Toggles layout classes * * @param String cls the layout class to toggle * @returns void */ function changeLayout(cls) { $('body').toggleClass(cls) if ($('body').hasClass('fixed') && cls == 'fixed') { $pushMenu.expandOnHover() $layout.activate() } $controlSidebar.fix() } /** * Replaces the old skin with the new skin * @param String cls the new skin class * @returns Boolean false to prevent link's default action */ function changeSkin(cls) { $.each(mySkins, function (i) { $('body').removeClass(mySkins[i]) }) $('body').addClass(cls) store('theme', cls) return false } /** * Retrieve default settings and apply them to the template * * @returns void */ function setup() { var tmp = get('theme') if (tmp && $.inArray(tmp, mySkins)) changeSkin(tmp) // Add the change skin listener $('[data-theme]').on('click', function (e) { if ($(this).hasClass('knob')) return e.preventDefault() changeSkin($(this).data('theme')) }) // Add the layout manager $('[data-layout]').on('click', function () { changeLayout($(this).data('layout')) }) $('[data-controlsidebar]').on('click', function () { changeLayout($(this).data('controlsidebar')) var slide = !$controlSidebar.options.slide $controlSidebar.options.slide = slide if (!slide) $('.control-sidebar').removeClass('control-sidebar-open') }) $('[data-enable="expandOnHover"]').on('click', function () { $(this).attr('disabled', true) $pushMenu.expandOnHover() if (!$('body').hasClass('sidebar-collapse')) $('[data-layout="sidebar-collapse"]').click() }) $('[data-enable="rtl"]').on('click', function () { $(this).attr('disabled', true) $pushMenu.expandOnHover() if (!$('body').hasClass('rtl')) $('[data-layout="rtl"]').click() }) $('[data-mainsidebarskin="toggle"]').on('click', function () { var $sidebar = $('body') if ($sidebar.hasClass('dark-skin')) { $sidebar.removeClass('dark-skin') $sidebar.addClass('light-skin') } else { $sidebar.removeClass('light-skin') $sidebar.addClass('dark-skin') } }) // Reset options if ($('body').hasClass('fixed')) { $('[data-layout="fixed"]').attr('checked', 'checked') } if ($('body').hasClass('layout-boxed')) { $('[data-layout="layout-boxed"]').attr('checked', 'checked') } if ($('body').hasClass('sidebar-collapse')) { $('[data-layout="sidebar-collapse"]').attr('checked', 'checked') } if ($('body').hasClass('rtl')) { $('[data-layout="rtl"]').attr('checked', 'checked') } // if ($('body').hasClass('dark')) { // $('[data-layout="dark"]').attr('checked', 'checked') // } } // Create the new tab var $tabPane = $('
', { 'id' : 'control-sidebar-theme-demo-options-tab', 'class': 'tab-pane active' }) // Create the tab button var $tabButton = $('
  • ', { 'class': 'nav-item' }) .html('' + '' + '') // Add the tab button to the right sidebar tabs $('[href="#control-sidebar-home-tab"]') .parent() .before($tabButton) // Create the menu var $demoSettings = $('
    ') // Layout options $demoSettings.append( '

    ' + '

    ' // Theme Skin Toggle + '
    ' + '' + '' + '
    ' ) // Layout options $demoSettings.append( '

    ' + '

    ' // rtl layout + '
    ' + '' + '' + '
    ' ) // Layout options $demoSettings.append( '

    ' + '

    ' // Sidebar Toggle + '
    ' + '' + '' + '
    ' // Control Sidebar Toggle + '
    ' + '' + '' + '
    ' ) var $skinsList = $('
      ', { 'class': 'list-unstyled clearfix theme-switch' }) // Dark sidebar skins var $themePrimary = $('
    • ', { style: 'padding: 5px;' }) .append('' + '') $skinsList.append($themePrimary) var $themeSecondary = $('
    • ', { style: 'padding: 5px;' }) .append('' + '') $skinsList.append($themeSecondary) var $themeInfo = $('
    • ', { style: 'padding: 5px;' }) .append('' + '') $skinsList.append($themeInfo) var $themeSuccess = $('
    • ', { style: 'padding: 5px;' }) .append('' + '') $skinsList.append($themeSuccess) var $themeDanger = $('
    • ', { style: 'padding: 5px;' }) .append('' + '') $skinsList.append($themeDanger) var $themeWarning = $('
    • ', { style: 'padding: 5px;' }) .append('' + '') $skinsList.append($themeWarning) $demoSettings.append('

      Skin Colors

      ') $demoSettings.append($skinsList) $tabPane.append($demoSettings) $('#control-sidebar-home-tab').after($tabPane) setup() $('[data-toggle="tooltip"]').tooltip() });// End of use strict $(function () { 'use strict' $('.theme-switch li a').click(function () { $('.theme-switch li a').removeClass('active').addClass('inactive'); $(this).toggleClass('active inactive'); }); });// End of use strict