jquery扩展

$(function () {
    var dialog = null;
    var password = null;
    $("#userInfo").click(function () {
        dialog = App.dialog({
            title: Msg.user.userTitle,
            action: 'modifyUser',
            resizable: false,
            width: 650,
            height: 'auto'
        });
        var option = {
            header: [Msg.user.userInfo, Msg.user.aInfo],
            listURL: 'groupUser/getUserInfo',
            submitURL: 'groupUser/modifyUserInfo',
            fnListSuccess: listSuccess,
            fnListError: listError,
            fnSubmitSuccess: submitSuccess,
            fnSubmitError: submitError,
            fnModifyData: modifyData,
            config: "status,name",
            type: 'view',
            model: [
                [
                    [
                        {
                            input: 'input',
                            type: 'text',
                            show: Msg.user.name,
                            name: 'username',
                            rule: {required: true, stringCheck: true, maxlength: 20, nullCheck: true}
                        },
                        {
                            input: 'select',
                            type: 'select',
                            show: Msg.user.sex,
                            name: 'sex',
                            rule: {},
                            options: [{value: ''}, {value: 1, text: Msg.user.boy}, {value: 2, text: Msg.user.girl}],
                            fnInit: changeSex
                        }
                    ],
                    [
                        {
                            input: 'input',
                            type: 'text',
                            show: Msg.user.mobile,
                            name: 'tel',
                            rule: {mobile: true, space: true, maxlength: 30}
                        },
                        {
                            input: 'input',
                            type: 'text',
                            show: Msg.user.email,
                            name: 'mail',
                            rule: {email: true, space: true, maxlength: 30}
                        }
                    ],
                    [
                        {
                            input: 'input',
                            type: 'text',
                            show: Msg.user.qq,
                            name: 'qq',
                            rule: {qq: true, space: true, maxlength: 30}
                        }
                    ]
                ],
                [
                    [
                        {
                            input: 'input',
                            type: 'text',
                            show: Msg.user.acountName,
                            name: 'name',
                            rule: {space: true, maxlength: 30},
                            fnInit: canNotFocus
                        },
                        {
                            input: 'select',
                            type: 'select',
                            show: Msg.user.status,
                            name: 'status',
                            rule: {},
                            options: [{value: ''}, {value: 'ACTIVE'}, {value: 'LOCKED'}],
                            fnInit: changeStatus
                        }
                    ],
                    [
                        {
                            input: 'textarea',
                            type: 'textarea',
                            show: Msg.user.description,
                            name: 'description',
                            rule: {maxlength: 200},
                            width: 453,
                            height: 70
                        },
                        {   
                        	input: 'input',
                        	type:  'image-form',
                        	name:  'electrPic',
                        	show:  Msg.user.elecSingal,
                        	fnInit: addElecSingal
                        }
                    ],
                    [
                        {
                            input: 'input',
                            type: 'password',
                            show: Msg.user.curPassword,
                            name: 'curPassword',
                            rule: {required: true, space: true, maxlength: 128}
                        }
                    ]
                ]
            ]
        };
        option.type = 'modify';
        dialog.ValidateForm('modifyuser', option);

    });

    function listSuccess(data) {
    }

    function listError(data) {
        $.omcConfirm(Msg.user.listError, mac.exeLogout, function (data) {
            dialog.remove();
        });
    }

    function changeSex(selector, value) {
        if (value) {
            $(selector).val(value);
        } else {
            $(selector).val('');
        }
    }

   
});
================================================================================
define(['jquery'], function ($) {
    

    App.dialog = function (c, f, cb) {
    	debugger
        var b = c.action;
        var a = $('<div id="' + b + '"></div>');
        a.callback = f;
        a.dialog({
            appendTo: '#main_view',
            title: c.title,
            width: c.width,
            height: c.height,
            resizable: c.resizable,
            draggable: c.draggable,
            autoOpen: true,
            closeText: Msg.close,
            modal: true,
            close: function () {
                $(this).remove();
            }
        });
        return a;
    };

    /**
     * 消息提示框
     * @param p {Object} 参数设置
     * @param c {Function} 点击OK回调方法
     * @param r {Function} 点击关闭按钮回调方法
     *     <pre>
     *     例如: App.alert({id: id, title: "title", message: "Content", ……});
     *     </pre>
     * @returns {*}
     */
    App.alert = function (p, c, r) {
        var a;
        if (p.id) {
            a = $('<div id="' + p.id + '"></div>');
        } else {
            a = $('<div></div>');
        }

        var co = p.content
            || $('<p style="margin: 0;">' + p.message + '</p>');

        a.append(co);
        var setting = {
            appendTo: '#main_view',
            modal: true,
            resizable: false,
            closeText: Msg.close,
            buttons: p.btns || [
                {
                    id: 'okId',
                    text: Msg.sure || 'OK',
                    click: function () {
                        $(this).dialog("close");
                        if (c)
                            c();
                    }
                }
            ],
            close: function () {
                if (r)
                    r();
                $(this).remove();
            }
        };
        $.extend(setting, p);
        a.dialog(setting);
        return a;
    };

定制组件
对应cookie中的全局变量
jquery扩展方法及对验证规则的扩展


});

相关推荐