Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
/**
2
Demo script to handle the theme demo
3
**/
4
var Demo = function () {
5
 
6
    // Handle Theme Settings
7
    var handleTheme = function () {
8
 
9
        var panel = $('.theme-panel');
10
 
11
        if ($('.page-head > .container-fluid').size() === 1) {
12
            $('.theme-setting-layout', panel).val("fluid");
13
        } else {
14
            $('.theme-setting-layout', panel).val("boxed");
15
        }
16
 
17
        if ($('.top-menu li.dropdown.dropdown-dark').size() > 0) {
18
            $('.theme-setting-top-menu-style', panel).val("dark");
19
        } else {
20
            $('.theme-setting-top-menu-style', panel).val("light");
21
        }
22
 
23
        if ($('body').hasClass("page-header-top-fixed")) {
24
            $('.theme-setting-top-menu-mode', panel).val("fixed");
25
        } else {
26
            $('.theme-setting-top-menu-mode', panel).val("not-fixed");
27
        }
28
 
29
        if ($('.hor-menu.hor-menu-light').size() > 0) {
30
            $('.theme-setting-mega-menu-style', panel).val("light");
31
        } else {
32
            $('.theme-setting-mega-menu-style', panel).val("dark");
33
        }
34
 
35
        if ($('body').hasClass("page-header-menu-fixed")) {
36
            $('.theme-setting-mega-menu-mode', panel).val("fixed");
37
        } else {
38
            $('.theme-setting-mega-menu-mode', panel).val("not-fixed");
39
        }
40
 
41
        //handle theme layout
42
        var resetLayout = function () {
43
            $("body").
44
            removeClass("page-header-top-fixed").
45
            removeClass("page-header-menu-fixed");
46
 
47
            $('.page-header-top > .container-fluid').removeClass("container-fluid").addClass('container');
48
            $('.page-header-menu > .container-fluid').removeClass("container-fluid").addClass('container');
49
            $('.page-head > .container-fluid').removeClass("container-fluid").addClass('container');
50
            $('.page-content > .container-fluid').removeClass("container-fluid").addClass('container');
51
            $('.page-prefooter > .container-fluid').removeClass("container-fluid").addClass('container');
52
            $('.page-footer > .container-fluid').removeClass("container-fluid").addClass('container');              
53
        };
54
 
55
        var setLayout = function () {
56
 
57
            var layoutMode = $('.theme-setting-layout', panel).val();
58
            var headerTopMenuStyle = $('.theme-setting-top-menu-style', panel).val();
59
            var headerTopMenuMode = $('.theme-setting-top-menu-mode', panel).val();
60
            var headerMegaMenuStyle = $('.theme-setting-mega-menu-style', panel).val();
61
            var headerMegaMenuMode = $('.theme-setting-mega-menu-mode', panel).val();
62
 
63
            resetLayout(); // reset layout to default state
64
 
65
            if (layoutMode === "fluid") {
66
                $('.page-header-top > .container').removeClass("container").addClass('container-fluid');
67
                $('.page-header-menu > .container').removeClass("container").addClass('container-fluid');
68
                $('.page-head > .container').removeClass("container").addClass('container-fluid');
69
                $('.page-content > .container').removeClass("container").addClass('container-fluid');
70
                $('.page-prefooter > .container').removeClass("container").addClass('container-fluid');
71
                $('.page-footer > .container').removeClass("container").addClass('container-fluid');
72
 
73
                //Metronic.runResizeHandlers();
74
            }
75
 
76
            if (headerTopMenuStyle === 'dark') {
77
                $(".top-menu > .navbar-nav > li.dropdown").addClass("dropdown-dark");
78
            } else {
79
                $(".top-menu > .navbar-nav > li.dropdown").removeClass("dropdown-dark");
80
            }
81
 
82
            if (headerTopMenuMode === 'fixed') {
83
                $("body").addClass("page-header-top-fixed");
84
            } else {
85
                $("body").removeClass("page-header-top-fixed");
86
            }
87
 
88
            if (headerMegaMenuStyle === 'light') {
89
                $(".hor-menu").addClass("hor-menu-light");
90
            } else {
91
                $(".hor-menu").removeClass("hor-menu-light");
92
            }
93
 
94
            if (headerMegaMenuMode === 'fixed') {
95
                $("body").addClass("page-header-menu-fixed");
96
            } else {
97
                $("body").removeClass("page-header-menu-fixed");
98
            }          
99
        };
100
 
101
        // handle theme colors
102
        var setColor = function (color) {
103
            var color_ = (Metronic.isRTL() ? color + '-rtl' : color);
104
            $('#style_color').attr("href", Layout.getLayoutCssPath() + 'themes/' + color_ + ".css");
105
            $('.page-logo img').attr("src", Layout.getLayoutImgPath() + 'logo-' + color + '.png');
106
        };
107
 
108
        $('.theme-colors > li', panel).click(function () {
109
            var color = $(this).attr("data-theme");
110
            setColor(color);
111
            $('.theme-colors > li', panel).removeClass("active");
112
            $(this).addClass("active");
113
        });
114
 
115
        $('.theme-setting-top-menu-mode', panel).change(function(){
116
            var headerTopMenuMode = $('.theme-setting-top-menu-mode', panel).val();
117
            var headerMegaMenuMode = $('.theme-setting-mega-menu-mode', panel).val();            
118
 
119
            if (headerMegaMenuMode === "fixed") {
120
                alert("The top menu and mega menu can not be fixed at the same time.");
121
                $('.theme-setting-mega-menu-mode', panel).val("not-fixed");  
122
                headerTopMenuMode = 'not-fixed';
123
            }                
124
        });
125
 
126
        $('.theme-setting-mega-menu-mode', panel).change(function(){
127
            var headerTopMenuMode = $('.theme-setting-top-menu-mode', panel).val();
128
            var headerMegaMenuMode = $('.theme-setting-mega-menu-mode', panel).val();            
129
 
130
            if (headerTopMenuMode === "fixed") {
131
                alert("The top menu and mega menu can not be fixed at the same time.");
132
                $('.theme-setting-top-menu-mode', panel).val("not-fixed");  
133
                headerTopMenuMode = 'not-fixed';
134
            }                
135
        });
136
 
137
        $('.theme-setting', panel).change(setLayout);
138
 
139
        $('.theme-setting-layout', panel).change(function(){
140
            Index.redrawCharts();  // reload the chart on layout width change
141
        });
142
    };
143
 
144
    // handle theme style
145
    var setThemeStyle = function(style) {
146
        var file = (style === 'rounded' ? 'components-rounded' : 'components');
147
        file = (Metronic.isRTL() ? file + '-rtl' : file);
148
 
149
        $('#style_components').attr("href", Metronic.getGlobalCssPath() + file + ".css");
150
 
151
        if ($.cookie) {
152
            $.cookie('layout-style-option', style);
153
        }
154
 
155
 
156
    };
157
 
158
    return {
159
 
160
        //main function to initiate the theme
161
        init: function() {
162
            // handles style customer tool
163
            handleTheme();
164
 
165
            // handle layout style change
166
            $('.theme-panel .theme-setting-style').change(function() {
167
                 setThemeStyle($(this).val());
168
            });
169
 
170
            // set layout style from cookie
171
            if ($.cookie && $.cookie('layout-style-option') === 'rounded') {
172
                setThemeStyle($.cookie('layout-style-option'));  
173
                $('.theme-panel .theme-setting-style').val($.cookie('layout-style-option'));
174
            }            
175
        }
176
    };
177
 
178
}();