zhao
2021-07-09 0821715ebc11d3934d0594a1cc2c39686d808906
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
/**
 * @fileoverview 横排队列发送消息
 * @author 紫英(橘子)<daxingplay@gmail.com>
 * @date 2012-01-11
 */
KISSY.add('gallery/form/1.3/uploader/themes/ershouUploader/message', function(S, Node){
    
    var $ = Node.all,
        LOG_PRE = '[ershouUploader: Message] ';
    
    function Message(config){
        var self = this;
        self.config = S.mix({
            msgContainer: '#J_MsgBoxUpload',
            successMsgCls: 'msg-success',
            hintMsgCls: 'msg-hint',
            errorMsgCls: 'msg-error'
        }, config);
        // Message.superclass.constructor.call(self, config);
        S.log(LOG_PRE + 'Constructed');
    }
    
    S.augment(Message, {
        
        /**
         * 向msg容器发送消息
         */
        send: function(msg, type){
            var self = this;
            if(!msg){
                S.log(LOG_PRE + 'You did not tell me what to show.');
                return false;
            }
            var msgBox = self.config.msgContainer,
                newClsName = self.config[type + 'MsgCls'],
                successCls = self.config.successMsgCls,
                hintCls = self.config.hintMsgCls,
                errorCls = self.config.errorMsgCls;
            if(msgBox){
                switch(type){
                    case 'success':
                    case 'hint':
                    case 'error':
                        $(msgBox).html(msg);
                        $(msgBox).replaceClass([successCls, hintCls, errorCls].join(' '), newClsName);
                        return true;
                        break;
                    default:
                        S.log(LOG_PRE + 'type error');
                        return false;
                        break;
                }
            }
        }
        
    });
    
    return Message;
    
}, {
    requires: [
        'node'
    ]
});