add popup component and poppup document
parent
36bbd7a29a
commit
9210e170bd
|
|
@ -89,6 +89,14 @@
|
|||
"type": 1,
|
||||
"openType": "_iframe",
|
||||
"href": "view/document/tag.html"
|
||||
},
|
||||
{
|
||||
"id": 209,
|
||||
"title": "弹出层",
|
||||
"icon": "layui-icon layui-icon-face-cry",
|
||||
"type": 1,
|
||||
"openType": "_iframe",
|
||||
"href": "view/document/popup.html"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
layui.define(['layer', 'jquery', 'element'], function(exports) {
|
||||
"use strict";
|
||||
|
||||
var MOD_NAME = 'popup',
|
||||
$ = layui.jquery,
|
||||
layer = layui.layer,
|
||||
element = layui.element;
|
||||
|
||||
var popup = new function() {
|
||||
|
||||
this.success = function(msg) {
|
||||
layer.msg(msg, {
|
||||
icon: 1,
|
||||
time: 1000
|
||||
})
|
||||
},
|
||||
this.failure = function(msg) {
|
||||
layer.msg(msg, {
|
||||
icon: 2,
|
||||
time: 1000
|
||||
})
|
||||
},
|
||||
this.warming = function(msg) {
|
||||
layer.msg(msg, {
|
||||
icon: 3,
|
||||
time: 1000
|
||||
})
|
||||
},
|
||||
this.success = function(msg, callback) {
|
||||
layer.msg(msg, {
|
||||
icon: 1,
|
||||
time: 1000
|
||||
}, callback);
|
||||
},
|
||||
this.failure = function(msg, callback) {
|
||||
layer.msg(msg, {
|
||||
icon: 2,
|
||||
time: 1000
|
||||
}, callback);
|
||||
},
|
||||
this.warming = function(msg, callback) {
|
||||
layer.msg(msg, {
|
||||
icon: 3,
|
||||
time: 1000
|
||||
}, callback);
|
||||
}
|
||||
};
|
||||
exports(MOD_NAME, popup);
|
||||
})
|
||||
|
|
@ -19,5 +19,6 @@ layui.config({
|
|||
drawer: "drawer",
|
||||
notice: "notice",
|
||||
step:"step",
|
||||
tag:"tag"
|
||||
tag:"tag",
|
||||
popup:"popup"
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,127 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="../../component/pear/css/pear.css" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-row layui-col-space10">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">开发环境</div>
|
||||
<div class="layui-card-body">
|
||||
Popup 基于 Layer 的二次封装
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-collapse">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">显示代码</h2>
|
||||
<div class="layui-colla-content">
|
||||
<pre class="layui-code" lay-encode="true">
|
||||
<link rel="stylesheet" href="component/pear/css/pear.css" />
|
||||
并
|
||||
<script src="component/layui/layui.js"></script>
|
||||
并
|
||||
<script src="component/pear/pear.js"></script>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">提示消息</div>
|
||||
<div class="layui-card-body">
|
||||
<button class="success pear-btn pear-btn-primary">成功消息</button>
|
||||
<button class="failure pear-btn pear-btn-danger">失败消息</button>
|
||||
<button class="warming pear-btn pear-btn-warming">警告消息</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-collapse">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">显示代码</h2>
|
||||
<div class="layui-colla-content">
|
||||
<pre class="layui-code" lay-encode="true">
|
||||
layui.use(['popup'], function() {
|
||||
var popup = layui.popup;
|
||||
|
||||
popup.success("成功消息")
|
||||
popup.failure("失败消息")
|
||||
popup.warming("警告消息")
|
||||
})
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">回调函数</div>
|
||||
<div class="layui-card-body">
|
||||
<button class="success-callback pear-btn pear-btn-primary">成功消息</button>
|
||||
<button class="failure-callback pear-btn pear-btn-danger">失败消息</button>
|
||||
<button class="warming-callback pear-btn pear-btn-warming">警告消息</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-collapse">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">显示代码</h2>
|
||||
<div class="layui-colla-content">
|
||||
<pre class="layui-code" lay-encode="true">
|
||||
layui.use(['popup'], function() {
|
||||
var popup = layui.popup;
|
||||
|
||||
popup.success("成功消息",callback)
|
||||
popup.failure("失败消息",callback)
|
||||
popup.warming("警告消息",callback)
|
||||
})
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="../../component/layui/layui.js"></script>
|
||||
<script src="../../component/pear/pear.js"></script>
|
||||
<script>
|
||||
layui.use(['popup', 'jquery', 'layer', 'code'], function() {
|
||||
var popup = layui.popup;
|
||||
var $ = layui.jquery;
|
||||
|
||||
layui.code();
|
||||
|
||||
$(".success").click(function() {
|
||||
popup.success("成功消息")
|
||||
})
|
||||
$(".failure").click(function() {
|
||||
popup.failure("失败消息")
|
||||
})
|
||||
$(".warming").click(function() {
|
||||
popup.warming("警告消息")
|
||||
})
|
||||
$(".success-callback").click(function() {
|
||||
popup.success("成功消息", function() {
|
||||
layer.msg("回调函数")
|
||||
})
|
||||
})
|
||||
$(".failure-callback").click(function() {
|
||||
popup.failure("失败消息", function() {
|
||||
layer.msg("回调函数")
|
||||
})
|
||||
})
|
||||
$(".warming-callback").click(function() {
|
||||
popup.warming("警告消息", function() {
|
||||
layer.msg("回调函数")
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -186,8 +186,7 @@
|
|||
<button lay-id="33" type="button" class="tag-item tag-item-danger">权限分配</button>
|
||||
<button lay-id="44" type="button" class="tag-item tag-item-danger">商品管理</button>
|
||||
</div>
|
||||
|
||||
// 删除响应事件
|
||||
|
||||
tag.on('delete(demo)', function(data) {
|
||||
console.log('删除');
|
||||
console.log(this);
|
||||
|
|
@ -225,8 +224,7 @@
|
|||
<button lay-id="33" type="button" class="tag-item">权限分配</button>
|
||||
<button lay-id="44" type="button" class="tag-item">商品管理</button>
|
||||
</div>
|
||||
|
||||
// 新增响应事件
|
||||
|
||||
tag.on('add(demo)', function(data) {
|
||||
console.log('新建');
|
||||
console.log(this);
|
||||
|
|
|
|||
Loading…
Reference in New Issue