UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

52 lines (47 loc) 4.07 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var dom_dom = require('../dom/dom.js'); var DEFAULT_CUSTOM_DIALOG_ID = 'customDialogId'; var DEFAULT_CUSTOM_DIALOG_STYLE_ID = 'customDialogStyle'; function initCustomDom(_ref) { var styleId = _ref.styleId, styleContent = _ref.styleContent, dialogId = _ref.dialogId, dialogContent = _ref.dialogContent; dom_dom.insertStyle({ id: styleId, content: styleContent }); dom_dom.insertHtml({ id: dialogId, content: dialogContent }); } function initCustomDialog(_ref2) { var title = _ref2.title, content = _ref2.content, confirmText = _ref2.confirmText, cancelText = _ref2.cancelText, _ref2$styleId = _ref2.styleId, styleId = _ref2$styleId === void 0 ? DEFAULT_CUSTOM_DIALOG_STYLE_ID : _ref2$styleId, _ref2$dialogId = _ref2.dialogId, dialogId = _ref2$dialogId === void 0 ? DEFAULT_CUSTOM_DIALOG_ID : _ref2$dialogId; var styleContent = "\n .tip-toc-dialog-wrap,.tip-toc-operating-layer,.tip-toc-sharetips{position:fixed;top:0;left:0;z-index:9999;width:100%;height:100%;background:rgba(0,0,0,.8)}\n.tip-toc-dialog,.tip-toc-sharedialog,.tip-toc-tipsdialog{position:fixed;top:50%;left:50%;z-index:10000;background:#fff;transform:translate(-50%,-50%)}\n.tip-toc-dialog{padding-top:.32rem;width:5.6rem;border-radius:4px}\n.tip-toc-tipsdialog{padding-top:.48rem;width:5rem;border-radius:4px}\n.tip-toc-sharedialog{width:6.3rem;border-radius:2px}\n.tip-toc-dialog-close{position:absolute;top:.16rem;right:.16rem;display:block;width:.5rem;height:.5rem;background:url(https://image-1251917893.file.myqcloud.com/TIP_GameSystem_2020/toB/icon/ico-close.png) center center no-repeat;background-size:.3rem .3rem}\n.tip-toc-dialog-title{color:#4a4a4a;text-align:center;font-weight:700;font-size:.32rem;line-height:.44rem}\n.tip-toc-dialog-texttips{margin:.16rem auto -.36rem;color:#9b9b9b;text-align:center;font-size:.24rem;line-height:.34rem}\n.tip-toc-dialog-content{padding:.12rem .6rem .24rem}\n.tip-toc-content-tips-normal,.tip-toc-content-tips-warn{text-align:center;font-size:.28rem;line-height:.4rem}\n.tip-toc-content-tips-normal{color:#999}\n.tip-toc-dialogtextbtn{display:flex;border-top:1px solid #d8d8d8}\n.tip-textbtn-cancel,.tip-textbtn-primary{display:block;width:100%;height:.88rem;text-align:center;font-size:.28rem;line-height:.88rem}\n.tip-textbtn-primary{color:#d49b38}\n.tip-textbtn-cancel{border-right:1px solid #d8d8d8;color:#4a4a4a}\n "; var dialogContent = "\n <div\n class=\"tip-toc-dialog-wrap\"\n id=\"".concat(dialogId, "\"\n onclick=\"document.getElementById('").concat(dialogId, "').style.display='none';\"\n >\n <div class=\"tip-toc-tipsdialog\">\n <h4 class=\"tip-toc-dialog-title\">\n ").concat(title, "\n </h4>\n <div class=\"tip-toc-dialog-content\">\n <p class=\"tip-toc-content-tips-normal\">\n ").concat(content, "\n </p>\n </div>\n <div class=\"tip-toc-dialogtextbtn\">\n ").concat(cancelText ? "\n <a\n id=\"cancel_btn\"\n class=\"tip-textbtn-primary\"\n style=\"color: #9b9b9b;border-right: 1px solid #d8d8d8;\"\n onclick=\"document.getElementById('".concat(dialogId, "').style.display='none';\"\n >").concat(cancelText, "</a>\n ") : '', "\n <a\n id=\"confirm_btn\"\n class=\"tip-textbtn-primary\"\n onclick=\"document.getElementById('").concat(dialogId, "').style.display='none';\"\n >\n ").concat(confirmText, "\n </a>\n </div>\n </div>\n</div>\n "); initCustomDom({ styleId: styleId, styleContent: styleContent, dialogId: dialogId, dialogContent: dialogContent }); } function showCustomDialog() { var domId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CUSTOM_DIALOG_ID; var dom = document.getElementById(domId); if (dom) { dom.style.display = 'block'; } } exports.initCustomDialog = initCustomDialog; exports.initCustomDom = initCustomDom; exports.showCustomDialog = showCustomDialog;