1.0.2
This commit is contained in:
@@ -47,6 +47,7 @@ pre{white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; w
|
||||
|
||||
/** 初始化全局标签 **/
|
||||
body{line-height: 24px; font: 14px Helvetica Neue,Helvetica,PingFang SC,\5FAE\8F6F\96C5\9ED1,Tahoma,Arial,sans-serif;}
|
||||
hr{height: 1px; margin: 10px 0; border: 0; background-color: #e2e2e2; clear: both;}
|
||||
a{color: #333; text-decoration:none; }
|
||||
a:hover{color: #777;}
|
||||
a cite{font-style: normal; *cursor:pointer;}
|
||||
@@ -60,9 +61,11 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
/* 单行溢出省略 */.layui-elip{text-overflow: ellipsis; overflow: hidden; white-space: nowrap;}
|
||||
/* 屏蔽选中 */.layui-unselect{-moz-user-select: none; -webkit-user-select: none; -ms-user-select: none;}
|
||||
.layui-disabled,.layui-disabled:hover{color: #d2d2d2 !important; cursor: not-allowed !important;}
|
||||
/* 纯圆角 */.layui-circle{border-radius: 100%;}
|
||||
.layui-show{display: block !important;}
|
||||
.layui-hide{display: none !important;}
|
||||
|
||||
|
||||
/* 布局 */
|
||||
.layui-main{position: relative; width: 1140px; margin: 0 auto;}
|
||||
.layui-header{position: relative; z-index: 1000; height: 65px;}
|
||||
@@ -81,10 +84,13 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
/** 页面元素 **/
|
||||
.layui-btn, .layui-input, .layui-textarea, .layui-upload-button{outline: none; -webkit-transition: border-color .3s cubic-bezier(.65,.05,.35,.5); transition: border-color .3s cubic-bezier(.65,.05,.35,.5); -webkit-box-sizing: border-box !important; -moz-box-sizing: border-box !important; box-sizing: border-box !important;}
|
||||
|
||||
/* 引用 */.layui-elem-quote{margin-bottom: 10px; padding: 15px; border-left: 5px solid #009688; border-radius: 0 2px 2px 0; background-color: #f2f2f2;}
|
||||
/* 字段集合 */.layui-elem-field{padding: 0; border: 1px solid #e2e2e2;}
|
||||
/* 引用 */.layui-elem-quote{margin-bottom: 10px; padding: 15px; line-height: 22px; border-left: 5px solid #009688; border-radius: 0 2px 2px 0; background-color: #f2f2f2;}
|
||||
.layui-quote-nm{border-color: #e2e2e2; border-style: solid; border-width: 1px; border-left-width: 5px; background: none;}
|
||||
/* 字段集合 */.layui-elem-field{margin-bottom: 10px; padding: 0; border: 1px solid #e2e2e2;}
|
||||
.layui-elem-field legend{margin-left: 20px; padding: 0 10px; font-size: 20px; font-weight: 300;}
|
||||
.layui-field-title{margin: 10px 0 20px; border: none; border-top: 1px solid #e2e2e2;}
|
||||
.layui-field-box{padding: 10px 15px;}
|
||||
.layui-field-title .layui-field-box{padding: 10px 0;}
|
||||
|
||||
/* 颜色 */
|
||||
.layui-bg-black{background-color: #393D49; color: #c2c2c2;}
|
||||
@@ -126,7 +132,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-form input[type=checkbox],
|
||||
.layui-form input[type=radio]{display: none;}
|
||||
|
||||
.layui-form-item{margin-bottom: 20px; clear: both; *zoom: 1;}
|
||||
.layui-form-item{margin-bottom: 15px; clear: both; *zoom: 1;}
|
||||
.layui-form-item:after{content:'\20'; clear: both; *zoom: 1; display: block; height:0;}
|
||||
.layui-form-label{position: relative; float: left; display: block; padding: 9px 15px; width: 80px; line-height: 20px; text-align: right;}
|
||||
.layui-form-item .layui-inline{margin-bottom: 5px; margin-right: 10px;}
|
||||
@@ -153,12 +159,12 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-form-selected .layui-edge{margin-top: -3px\0; }
|
||||
:root .layui-form-selected .layui-edge{margin-top: -9px\0/IE9;}
|
||||
|
||||
/* 复选框 */.layui-form-checkbox{position: relative; display: inline-block; vertical-align: middle; height: 38px; line-height: 36px; margin: 0 10px 0 0; padding-right: 43px; border: 1px solid #d2d2d2; background-color: #fff; cursor: pointer; font-size: 0; border-radius: 2px; -webkit-transition: .1s linear; transition: .1s linear; box-sizing: border-box !important;}
|
||||
/* 复选框 */.layui-form-checkbox{position: relative; display: inline-block; vertical-align: middle; height: 30px; line-height: 28px; margin: 4px 10px 0 0; padding-right: 30px; border: 1px solid #d2d2d2; background-color: #fff; cursor: pointer; font-size: 0; border-radius: 2px; -webkit-transition: .1s linear; transition: .1s linear; box-sizing: border-box !important;}
|
||||
.layui-form-checkbox:hover{border: 1px solid #c2c2c2;}
|
||||
.layui-form-checkbox *{display: inline-block; vertical-align: middle;}
|
||||
.layui-form-checkbox span{padding: 0 10px; font-size: 14px; background-color: #d2d2d2; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
|
||||
.layui-form-checkbox:hover span{background-color: #c2c2c2;}
|
||||
.layui-form-checkbox i{position: absolute; right: 0; width: 43px; margin-left: -3px; color: #fff; font-size: 20px;}
|
||||
.layui-form-checkbox i{position: absolute; right: 0; width: 37px; color: #fff; font-size: 20px;}
|
||||
.layui-form-checkbox:hover i{color: #c2c2c2;}
|
||||
.layui-form-checked, .layui-form-checked:hover{border: 1px solid #5FB878;}
|
||||
.layui-form-checked span, .layui-form-checked:hover span{background-color: #5FB878;}
|
||||
@@ -197,7 +203,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layedit-tool-fixed{position: fixed; top: 0; border-top: 1px solid #e2e2e2;}
|
||||
.layui-layedit-tool .layedit-tool-mid,
|
||||
.layui-layedit-tool .layui-icon{display: inline-block; vertical-align: middle; text-align: center; font-size: 14px;}
|
||||
.layui-layedit-tool .layui-icon{position: relative; width: 32px; height: 30px; line-height: 30px; margin: 3px 5px; border-radius: 2px; color: #777; cursor: pointer; -webkit-transition: border-radius: 2px; border-color .3s cubic-bezier(.65,.05,.35,.5); transition: border-color .3s cubic-bezier(.65,.05,.35,.5);}
|
||||
.layui-layedit-tool .layui-icon{position: relative; width: 32px; height: 30px; line-height: 30px; margin: 3px 5px; border-radius: 2px; color: #777; cursor: pointer; border-radius: 2px;}
|
||||
.layui-layedit-tool .layui-icon:hover{color: #393D49;}
|
||||
.layui-layedit-tool .layui-icon:active{color: #000;}
|
||||
.layui-layedit-tool .layedit-tool-active{background-color: #e2e2e2; color: #000;}
|
||||
@@ -216,6 +222,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layedit-tool-image input{position: absolute; font-size: 0; left: 0; top: 0; width: 100%; height: 100%; opacity: 0.01; filter: Alpha(opacity=1); cursor: pointer;}
|
||||
|
||||
.layui-layedit-iframe iframe{display: block; width: 100%;}
|
||||
#LAY_layedit_code{overflow: hidden;}
|
||||
|
||||
/** 表格简单修饰 **/
|
||||
.layui-table{width: 100%; margin: 10px 0;}
|
||||
@@ -436,8 +443,8 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
|
||||
.layui-form-item .layui-inline{display: block; margin-right: 0; margin-bottom: 20px; clear: both;}
|
||||
.layui-form-item .layui-inline:after{content:'\20'; clear:both; display:block; height:0;}
|
||||
.layui-form-item .layui-input-inline{display: block; float: none; left: -1px; width: auto; margin: 0 0 10px 112px; }
|
||||
.layui-form-item .layui-input-inline+.layui-form-mid{margin-left: 110px; top: -5px;}
|
||||
.layui-form-item .layui-form-checkbox{display: block; margin-right: 0; margin-bottom: 10px;}
|
||||
.layui-form-item .layui-input-inline+.layui-form-mid{margin-left: 110px; top: -5px; padding: 0;}
|
||||
.layui-form-item .layui-form-checkbox{margin-right: 5px; margin-bottom: 5px;}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ layui.define(function(exports){
|
||||
Dates.run = function(options){
|
||||
var S = Dates.query, elem = options.elem, devt;
|
||||
|
||||
if(!options.elem) return;
|
||||
if(!elem) return;
|
||||
|
||||
as.elemv = /textarea|input/.test(elem.tagName.toLocaleLowerCase()) ? 'value' : 'innerHTML';
|
||||
if (('init' in options ? options.init : config.init) && (!elem[as.elemv])) elem[as.elemv] = laydate.now(null, options.format || config.format);
|
||||
|
||||
@@ -29,8 +29,7 @@ layui.define(['layer', 'form'], function(exports){
|
||||
,'|'
|
||||
,'left', 'center', 'right'
|
||||
,'|'
|
||||
, 'link', 'unlink', 'face', 'image'
|
||||
|
||||
,'link', 'unlink', 'face', 'image'
|
||||
]
|
||||
,hideTool: []
|
||||
,height: 280 //默认高
|
||||
@@ -78,7 +77,7 @@ layui.define(['layer', 'form'], function(exports){
|
||||
,editor = $(['<div class="'+ ELEM +'">'
|
||||
,'<div class="layui-unselect layui-layedit-tool">'+ tool +'</div>'
|
||||
,'<div class="layui-layedit-iframe">'
|
||||
,'<iframe id="'+ name +'" name="'+ name +'" frameborder="0"></iframe>'
|
||||
,'<iframe id="'+ name +'" name="'+ name +'" textarea="'+ id +'" frameborder="0"></iframe>'
|
||||
,'</div>'
|
||||
,'</div>'].join(''))
|
||||
|
||||
@@ -97,16 +96,24 @@ layui.define(['layer', 'form'], function(exports){
|
||||
|
||||
//获得编辑器中内容
|
||||
Edit.prototype.getContent = function(index){
|
||||
var iframeWin = $('#LAY_layedit_'+ index).prop('contentWindow');
|
||||
if(!iframeWin) return;
|
||||
return iframeWin.document.body.innerHTML;
|
||||
var iframeWin = getWin(index);
|
||||
if(!iframeWin[0]) return;
|
||||
return toLower(iframeWin[0].document.body.innerHTML);
|
||||
};
|
||||
|
||||
//获得编辑器中纯文本内容
|
||||
Edit.prototype.getText = function(index){
|
||||
var iframeWin = $('#LAY_layedit_'+ index).prop('contentWindow');
|
||||
if(!iframeWin) return;
|
||||
return $(iframeWin.document.body).text();
|
||||
var iframeWin = getWin(index);
|
||||
if(!iframeWin[0]) return;
|
||||
return $(iframeWin[0].document.body).text();
|
||||
};
|
||||
|
||||
//将编辑器内容同步到textarea(一般用于异步提交时)
|
||||
Edit.prototype.sync = function(index){
|
||||
var iframeWin = getWin(index);
|
||||
if(!iframeWin[0]) return;
|
||||
var textarea = $('#'+iframeWin[1].attr('textarea'));
|
||||
textarea.val(toLower(iframeWin[0].document.body.innerHTML));
|
||||
};
|
||||
|
||||
//iframe初始化
|
||||
@@ -125,6 +132,7 @@ layui.define(['layer', 'form'], function(exports){
|
||||
,'a{color:#01AAED; text-decoration:none;}a:hover{color:#c00}'
|
||||
,'p{margin-bottom: 10px;}'
|
||||
,'img{display: inline-block; border: none; vertical-align: middle;}'
|
||||
,'pre{margin: 10px 0; padding: 10px; line-height: 20px; border: 1px solid #ddd; border-left-width: 6px; background-color: #F2F2F2; color: #333; font-family: Courier New; font-size: 12px;}'
|
||||
,'</style>'].join(''))
|
||||
,body = conts.find('body');
|
||||
|
||||
@@ -139,6 +147,23 @@ layui.define(['layer', 'form'], function(exports){
|
||||
});
|
||||
}
|
||||
|
||||
//获得iframe窗口对象
|
||||
,getWin = function(index){
|
||||
var iframe = $('#LAY_layedit_'+ index)
|
||||
,iframeWin = iframe.prop('contentWindow');
|
||||
return [iframeWin, iframe];
|
||||
}
|
||||
|
||||
//IE8下将标签处理成小写
|
||||
,toLower = function(html){
|
||||
if(device.ie == 8){
|
||||
html = html.replace(/<.+>/g, function(str){
|
||||
return str.toLowerCase();
|
||||
});
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
//快捷键处理
|
||||
,hotkey = function(iframeWin, iframe, textArea, set){
|
||||
var iframeDOM = iframeWin.document, body = $(iframeDOM.body);
|
||||
@@ -146,11 +171,29 @@ layui.define(['layer', 'form'], function(exports){
|
||||
var keycode = e.keyCode;
|
||||
//处理回车
|
||||
if(keycode === 13){
|
||||
//此处后续还要处理列表等情况
|
||||
var range = Range(iframeDOM);
|
||||
var container = getContainer(range)
|
||||
,parentNode = container.parentNode;
|
||||
|
||||
if(parentNode.tagName.toLowerCase() === 'pre'){
|
||||
if(e.shiftKey) return
|
||||
layer.msg('请暂时用shift+enter');
|
||||
return false;
|
||||
}
|
||||
iframeDOM.execCommand('formatBlock', false, '<p>');
|
||||
}
|
||||
//给textarea同步内容
|
||||
textArea.value = body.html();
|
||||
});
|
||||
|
||||
//给textarea同步内容
|
||||
$(textArea).parents('form').on('submit', function(){
|
||||
var html = body.html();
|
||||
//IE8下将标签处理成小写
|
||||
if(device.ie == 8){
|
||||
html = html.replace(/<.+>/g, function(str){
|
||||
return str.toLowerCase();
|
||||
});
|
||||
}
|
||||
textArea.value = html;
|
||||
});
|
||||
|
||||
//处理粘贴
|
||||
@@ -342,7 +385,12 @@ layui.define(['layer', 'form'], function(exports){
|
||||
}
|
||||
//插入代码
|
||||
,code: function(range){
|
||||
layer.msg('Next Version');
|
||||
code.call(body, function(pre){
|
||||
insertInline.call(iframeWin, 'pre', {
|
||||
text: pre.code
|
||||
,'lay-lang': pre.lang
|
||||
}, range);
|
||||
});
|
||||
}
|
||||
//帮助
|
||||
,help: function(){
|
||||
@@ -431,7 +479,7 @@ layui.define(['layer', 'form'], function(exports){
|
||||
+ ((options.target==='_self' || !options.target) ? 'checked' : '') +'>'
|
||||
,'<input type="radio" name="target" value="_blank" class="layui-input" title="新窗口" '
|
||||
+ (options.target==='_blank' ? 'checked' : '') +'>'
|
||||
,'</div>'
|
||||
,'</div>'
|
||||
,'</li>'
|
||||
,'<li class="layui-form-item" style="text-align: center;">'
|
||||
,'<button type="button" lay-submit lay-filter="layedit-link-yes" class="layui-btn"> 确定 </button>'
|
||||
@@ -445,7 +493,6 @@ layui.define(['layer', 'form'], function(exports){
|
||||
layer.close(index);
|
||||
body.focus();
|
||||
});
|
||||
delete layui.cache.event['form.'+eventFilter];
|
||||
form.on(eventFilter, function(data){
|
||||
layer.close(link.index);
|
||||
callback && callback(data.field);
|
||||
@@ -497,6 +544,61 @@ layui.define(['layer', 'form'], function(exports){
|
||||
});
|
||||
}
|
||||
|
||||
//插入代码面板
|
||||
,code = function(callback){
|
||||
var body = this, index = layer.open({
|
||||
type: 1
|
||||
,id: 'LAY_layedit_code'
|
||||
,area: '550px'
|
||||
,shade: 0.05
|
||||
,shadeClose: true
|
||||
,moveType: 1
|
||||
,title: '插入代码'
|
||||
,skin: 'layui-layer-msg'
|
||||
,content: ['<ul class="layui-form layui-form-pane" style="margin: 15px;">'
|
||||
,'<li class="layui-form-item">'
|
||||
,'<label class="layui-form-label">请选择语言</label>'
|
||||
,'<div class="layui-input-block">'
|
||||
,'<select name="lang">'
|
||||
,'<option value="JavaScript">JavaScript</option>'
|
||||
,'<option value="HTML">HTML</option>'
|
||||
,'<option value="CSS">CSS</option>'
|
||||
,'<option value="Java">Java</option>'
|
||||
,'<option value="PHP">PHP</option>'
|
||||
,'<option value="C#">C#</option>'
|
||||
,'<option value="Python">Python</option>'
|
||||
,'<option value="Ruby">Ruby</option>'
|
||||
,'<option value="Go">Go</option>'
|
||||
,'</select>'
|
||||
,'</div>'
|
||||
,'</li>'
|
||||
,'<li class="layui-form-item layui-form-text">'
|
||||
,'<label class="layui-form-label">代码</label>'
|
||||
,'<div class="layui-input-block">'
|
||||
,'<textarea name="code" lay-verify="required" autofocus="true" class="layui-textarea" style="height: 200px;"></textarea>'
|
||||
,'</div>'
|
||||
,'</li>'
|
||||
,'<li class="layui-form-item" style="text-align: center;">'
|
||||
,'<button type="button" lay-submit lay-filter="layedit-code-yes" class="layui-btn"> 确定 </button>'
|
||||
,'<button style="margin-left: 20px;" type="button" class="layui-btn layui-btn-primary"> 取消 </button>'
|
||||
,'</li>'
|
||||
,'</ul>'].join('')
|
||||
,success: function(layero, index){
|
||||
var eventFilter = 'submit(layedit-code-yes)';
|
||||
form.render('select');
|
||||
layero.find('.layui-btn-primary').on('click', function(){
|
||||
layer.close(index);
|
||||
body.focus();
|
||||
});
|
||||
form.on(eventFilter, function(data){
|
||||
layer.close(code.index);
|
||||
callback && callback(data.field);
|
||||
});
|
||||
}
|
||||
});
|
||||
code.index = index;
|
||||
}
|
||||
|
||||
//全部工具
|
||||
,tools = {
|
||||
html: '<i class="layui-icon layedit-tool-html" title="HTML源代码" lay-command="html" layedit-event="html""></i><span class="layedit-tool-mid"></span>'
|
||||
|
||||
@@ -102,7 +102,7 @@ layui.define(function(exports){
|
||||
}()));
|
||||
}
|
||||
|
||||
return '<div class="layui-laypage layui-laypage-'+ (conf.skin ? (function(skin){
|
||||
return '<div class="layui-box layui-laypage layui-laypage-'+ (conf.skin ? (function(skin){
|
||||
return /^#/.test(skin) ? 'molv' : skin;
|
||||
}(conf.skin)) : 'default') +'" id="layui-laypage-'+ that.config.item +'">'+ view.join('') + function(){
|
||||
return conf.skip
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"use strict";
|
||||
|
||||
var Lay = function(){
|
||||
this.v = '1.0.1'; //版本号
|
||||
this.v = '1.0.2'; //版本号
|
||||
};
|
||||
|
||||
Lay.fn = Lay.prototype;
|
||||
@@ -396,9 +396,15 @@ Lay.fn.stope = function(e){
|
||||
Lay.fn.onevent = function(modName, events, callback){
|
||||
if(typeof modName !== 'string'
|
||||
|| typeof callback !== 'function') return this;
|
||||
config.event[modName + '.' + events] = [callback];
|
||||
|
||||
//不再对多次事件监听做支持
|
||||
/*
|
||||
config.event[modName + '.' + events]
|
||||
? config.event[modName + '.' + events].push(callback)
|
||||
: config.event[modName + '.' + events] = [callback];
|
||||
*/
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user