zhitong.yu
2025-02-14 c4cce49f5e6fd1f74b9962cd86dd201694c3765e
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
 * UI v1.1.0
 * Copyright 2017-2018 Muyao
 * Licensed under the Muyao License 1.0 
 */
(function (window, document, $) {
    'use strict';
 
    // 父级dom节点
    $.parentFrame = $(window.parent.document);
 
    // 父级方法&属性
    var parentFrame = window.parentFrame = window.parent;
 
    // 项目名称
    $.ctx = parentFrame.$.ctx;
 
    // 配置颜色获取方法
    $.colors = parentFrame.$.colors;
 
    // 注册组件默认配置参数获取方法
    $.po = parentFrame.$.po;
 
    // 本地存储对象操作
    $.storage = parentFrame.$.storage;
    $.sessionStorage = parentFrame.$.sessionStorage;
 
    // 网址基础设置对象
    $.site = parentFrame.$.site;
    if ($.site && $.site.contentTabs)
        $.site.contentTabs.ifameTabs(document);
 
    // 配置信息存储管理
    $.configs = parentFrame.$.configs;
 
    // 注册组件初始化
    if (parentFrame.$.components)
        parentFrame.$.components.init(document, window);
 
    // 公用对象
    window.Breakpoints = parentFrame.Breakpoints;
    window.toastr = parentFrame.toastr;
    window.layer = parentFrame.layer;
    window.haoutil = parentFrame.haoutil;
    window.notifyFn = parentFrame.$.notifyFn;
 
    // 自定义扩展对象
    var _objExtend = _objExtend || {};
 
    $.extend(_objExtend, {
        _queue: {
            prepare: [],
            run: [],
            complete: []
        },
        run: function () {
            var self = this;
            this._dequeue('prepare', function () {
                self._trigger('before.run', self);
            });
 
            this._dequeue('run', function () {
                self._dequeue('complete', function () {
                    self._trigger('after.run', self);
                });
            });
        },
        _dequeue: function (name, done) { // 队列当前状态离队,进行下一步操作
            var self = this,
                queue = this._getQueue(name),
                fn = queue.shift(),
                next = function () {
                    self._dequeue(name, done);
                };
 
            if (fn) {
                fn.call(this, next);
            } else if ($.isFunction(done)) {
                done.call(this);
            }
        },
        _getQueue: function (name) { // 获取队列状态信息
            if (!$.isArray(this._queue[name])) {
                this._queue[name] = [];
            }
 
            return this._queue[name];
        },
        extend: function (obj) { // 公用模块对象扩展方法
            $.each(this._queue, function (name, queue) {
                if ($.isFunction(obj[name])) {
                    queue.unshift(obj[name]);
 
                    delete obj[name];
                }
            });
            $.extend(this, obj);
            return this;
        },
        _trigger: function (name, data, $el) { // 离队状态执行动作
 
            if (typeof name === 'undefined') {
                return;
            }
            if (typeof $el === 'undefined') {
                $el = $("#admui-pageContent");
            }
 
            $el.trigger(name + '.app', data);
        }
    });
 
    // 通用功能对象(可配置增加,也可扩展)
    var _app = {
        pageAside: function () { // 小屏幕下侧边栏(展开&收起)操作
            var pageAside = $(".page-aside"),
                isOpen = pageAside.hasClass('open');
 
            pageAside.toggleClass('open', !isOpen);
        },
        run: function (next) {
            var self = this;
 
            // 侧边栏开关
            $(document).on('click', '.page-aside-switch', function (e) {
                self.pageAside();
                e.stopPropagation();
            });
 
            next();
        }
    };
 
    window.App = $.extend({}, _objExtend);
    App.extend(_app);
 
})(window, document, jQuery);