Authored by 鲁尚清

【无】带有[title]的元素实现点击复制内容

@@ -3895,6 +3895,11 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'echarts', 'sessions', 'xmSele @@ -3895,6 +3895,11 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'echarts', 'sessions', 'xmSele
3895 } 3895 }
3896 } 3896 }
3897 }) 3897 })
  3898 + //lsq 带有title的元素点击复制元素内容 2022-09-23
  3899 + setTimeout(function(){
  3900 + layui.pageTips.copyTitle();
  3901 + },1000)
  3902 +
3898 }, 3903 },
3899 yes: function (index) { 3904 yes: function (index) {
3900 layer.close(index); 3905 layer.close(index);
@@ -4090,6 +4095,8 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'echarts', 'sessions', 'xmSele @@ -4090,6 +4095,8 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'echarts', 'sessions', 'xmSele
4090 $btn.removeClass("hide"); 4095 $btn.removeClass("hide");
4091 } 4096 }
4092 }); 4097 });
  4098 + //lsq 带有title的元素点击复制元素内容 2022-09-23
  4099 + layui.pageTips.copyTitle();
4093 filterSuppressMonitor(resId) 4100 filterSuppressMonitor(resId)
4094 } 4101 }
4095 }); 4102 });
@@ -19,6 +19,9 @@ layui.define(['element', 'admin'], function (exports) { @@ -19,6 +19,9 @@ layui.define(['element', 'admin'], function (exports) {
19 19
20 that.bindClickEvent(); 20 that.bindClickEvent();
21 21
  22 + //lsq给带有title的元素绑定点击事件复制元素内容 2022-09-05
  23 + that.copyTitle();
  24 +
22 if (that.data.contextmenus.length > 0) { 25 if (that.data.contextmenus.length > 0) {
23 that.bindContextMenuEvent(); 26 that.bindContextMenuEvent();
24 return that.data.contextmenus; 27 return that.data.contextmenus;
@@ -293,6 +296,25 @@ layui.define(['element', 'admin'], function (exports) { @@ -293,6 +296,25 @@ layui.define(['element', 'admin'], function (exports) {
293 $(document).on('click', function (event) { 296 $(document).on('click', function (event) {
294 layer.closeAll('tips'); 297 layer.closeAll('tips');
295 }) 298 })
  299 + },
  300 + /**
  301 + * lsq
  302 + * 2022-09-13
  303 + * 给带有title的元素绑定点击事件
  304 + */
  305 + copyTitle() {
  306 + $('[title]').unbind('click.title').on('click.title',(function (e){
  307 + e.preventDefault();
  308 + let oInput = document.createElement('input');
  309 + oInput.value = $(this).attr('title').trim();
  310 + document.body.appendChild(oInput);
  311 + oInput.select();
  312 + document.execCommand("Copy");
  313 + oInput.className = 'oInput';
  314 + oInput.style.display = 'none';
  315 + layer.msg('内容复制成功', {icon: 1, time: 2000});
  316 +
  317 + }))
296 } 318 }
297 } 319 }
298 320