Blame view

app-ht/views/layouts/_lte.php 2.36 KB
2e86c939   xu   “首次提交”
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
57
58
59
60
61
62
<script>
    $frameApp.require([
        'plugins/jquery.slimscroll/1.3.8/jquery.slimscroll.js',
    ], function () {
        $.LTE = {};
        /* --------------------
         * - Options -
         * --------------------
         */
        $.LTE.options = {
            sidebarSlimScroll: true, //Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
            controlSidebarOptions: {
                selector: ".control-sidebar",//The sidebar selector
            }
        };

        $.LTE.layout = {
            activate: function () {
                var _this = this;
                _this.fix();
                _this.fixSidebar();
                $('body, html, .wrapper').css('height', 'auto');
                $(window, ".wrapper").resize(function () {
                    _this.fix();
                    _this.fixSidebar();
                });
            },
            fix: function () {
                $(".wrapper").css('overflow', 'hidden');
                var window_height = $(window).height();
                $(".main-right").css('min-height', window_height);
            },
            fixSidebar: function () {
                //Make sure the body tag has the .fixed class
                if (!$("body").hasClass("fixed")) {
                    if (typeof $.fn.slimScroll != 'undefined') {
                        $(".sidebar").slimScroll({destroy: true}).height("auto");
                    }
                    return;
                } else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
                    window.console.error("Error: the fixed layout requires the slimscroll plugin!");
                }
                //Enable slimscroll for fixed layout
                if ($.LTE.options.sidebarSlimScroll) {
                    if (typeof $.fn.slimScroll != 'undefined') {
                        //Destroy if it exists
                        $(".sidebar").slimScroll({destroy: true}).height("auto");
                        //Add slimscroll
                        $(".sidebar").slimScroll({
                            height: ($(window).height() - $(".main-header").height()) + "px",
                            color: "rgba(0,0,0,0.2)",
                            size: "3px"
                        });
                    }
                }
            }
        };

        $.LTE.layout.activate();
    });

</script>