• AmazeUI 模态框封装


    /**
     * 模态窗口
     */
    window.Modal = {
        tpls:{
            alert:'<div class="am-modal am-modal-alert" tabindex="-1"><div class="am-modal-dialog"><div class="am-modal-hd message-text"></div><div class="am-modal-footer"><span class="am-modal-btn">确定</span></div></div></div>',
            confirm:'<div class="am-modal am-modal-confirm" tabindex="-1" ><div class="am-modal-dialog"><div class="am-modal-bd message-text"></div><div class="am-modal-footer"><span class="am-modal-btn btn-cancel" data-am-modal-cancel>取消</span><span class="am-modal-btn btn-confirm" data-am-modal-confirm>确定</span></div></div></div>',
            loading:'<div class="am-modal am-modal-loading am-modal-no-btn" tabindex="-1"><div class="am-modal-dialog"><div class="am-modal-hd message-text">正在载入...</div><div class="am-modal-bd"><span class="am-icon-spinner am-icon-spin"></span></div></div></div>'
        },
        register:function(events){
            events = events || [];
            if(events.length == 0){
                events = ['alert', 'confirm', 'loading'];
            }
            var body = $(document.body);
            this.modal = {};
            for(var i=0; i<events.length; i++){
                var event = events[i];
                var tpl = this.tpls[event];
                if(tpl){
                    this.modal[event] = $(tpl);
                    body.append(this.modal[event]);
                }
            }
        },
        alert:function(message, config){
            config = config || {};
            var confirmText = config.confirmText || "确定";
            this.modal.alert.find(".am-modal-btn").text(confirmText);
            this.modal.alert.find(".message-text").html(message);
            this.modal.alert.modal("open");
        },
        confirm:function(message, config){
            config = config || {};
            var confirmText = config.confirmText || "确定";
            var cancelText = config.cancelText || "取消";
            this.modal.confirm.find(".btn-confirm").text(confirmText);
            this.modal.confirm.find(".btn-cancel").text(cancelText);
            this.modal.confirm.find(".message-text").html(message);
            this.modal.confirm.modal(config).modal("open");
        },
        loading:function(message){
            this.modal.loading.find(".message-text").html(message);
            this.modal.loading.modal("open");
        },
        dismissLoading:function(){
            this.modal.loading.find(".message-text").html("");
            this.modal.loading.modal("close");
        }
    };
    Modal.register();
  • 相关阅读:
    20 行代码:Serverless 架构下用 Python 轻松搞定图像分类
    Serverless 的内存配置与超时时间
    Serverless 架构与事件规范
    如何用 Serverless 优雅地给网站图片加水印
    修改rpmbuild构建目录的位置
    rpmbuild之构建目录结构解析
    全量编译与增量编译
    c堆排序的实现
    c优先队列的实现
    c栈的实现
  • 原文地址:https://www.cnblogs.com/rubekid/p/5427472.html
Copyright © 2020-2023  润新知