新增 `laydate.hint(id, opts)` 方法

pull/1220/head
贤心 2023-03-26 16:43:44 +08:00
parent 7c5a558e26
commit f7695d5279
1 changed files with 28 additions and 12 deletions

View File

@ -715,24 +715,33 @@
return that; return that;
}; };
//提示 // 提示
Class.prototype.hint = function(content){ Class.prototype.hint = function(opts){
var that = this var that = this;
,options = that.config var options = that.config;
,div = lay.elem('div', { var div = lay.elem('div', {
"class": ELEM_HINT "class": ELEM_HINT
}); });
if(!that.elem) return; if(!that.elem) return;
// 兼容旧版参数
if(typeof opts === 'object'){
opts = opts || {};
} else {
opts = {
content: opts
}
}
div.innerHTML = content || ''; div.innerHTML = opts.content || '';
lay(that.elem).find('.'+ ELEM_HINT).remove(); lay(that.elem).find('.'+ ELEM_HINT).remove();
that.elem.appendChild(div); that.elem.appendChild(div);
clearTimeout(that.hinTimer); clearTimeout(that.hinTimer);
that.hinTimer = setTimeout(function(){ that.hinTimer = setTimeout(function(){
lay(that.elem).find('.'+ ELEM_HINT).remove(); lay(that.elem).find('.'+ ELEM_HINT).remove();
}, 3000); }, 'ms' in opts ? opts.ms : 3000);
}; };
//获取递增/减后的年月 //获取递增/减后的年月
@ -2167,13 +2176,20 @@
return thisModule.call(inst); return thisModule.call(inst);
}; };
// 获取 // 获取对应 ID 的实例
laydate.getInst = function (key) { laydate.getInst = function (id) {
var that = thisModule.getThis(key); var that = thisModule.getThis(id);
if (that) { if(that){
return that.inst; return that.inst;
} }
} };
// 面板提示
laydate.hint = function(id, opts){
var that = thisModule.getThis(id);
if(!that) return;
return that.hint(opts);
};
//将指定对象转化为日期值 //将指定对象转化为日期值
laydate.parse = function(dateTime, format, one){ laydate.parse = function(dateTime, format, one){