all files / app/main/ui/theme-colors/dialogs/custom-theme/ custom-theme-dialog.controller.js

26.32% Statements 5/19
0% Branches 0/2
25% Functions 1/4
26.32% Lines 5/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                                                                                      
(function ()
{
    'use strict';
 
    angular
        .module('app.ui.theme-colors')
        .controller('CustomThemeDialogController', CustomThemeDialogController);
 
    /** @ngInject */
    function CustomThemeDialogController(fuseTheming, $mdDialog, fuseGenerator, $cookies, $window)
    {
        // Data
        var vm = this;
        vm.palettes = fuseTheming.getRegisteredPalettes();
        vm.themes = fuseTheming.getRegisteredThemes();
 
        // Delete Unnecessary hue value
        delete vm.palettes.grey['1000'];
 
        // Methods
        vm.rgba = fuseGenerator.rgba;
        vm.setTheme = setTheme;
        vm.closeDialog = closeDialog;
 
        //////////
 
        // If custom theme exist keep using it otherwise set default as a custom
        if ( !vm.themes.custom )
        {
            vm.theme = angular.copy(vm.themes['default'].colors);
        }
        else
        {
            vm.theme = vm.themes.custom.colors;
        }
 
        /**
         * Put custom theme into the cookies
         * and reload for generate styles
         */
        function setTheme()
        {
            $cookies.putObject('customTheme', vm.theme);
            $cookies.put('selectedTheme', 'custom');
            $window.location.reload();
        }
 
        /**
         * Close dialog
         */
        function closeDialog()
        {
            $mdDialog.hide();
        }
    }
})();