feat(#I10TI9): 图标集增加拷贝到剪切板功能

#Comment
comment #I10TI9

#Issue
close https://gitee.com/LongbowEnterprise/dashboard/issues?id=I10TI9
This commit is contained in:
Argo Zhang 2019-08-18 18:45:47 +08:00
parent 59be8816ee
commit dd33743dbe
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
3 changed files with 70 additions and 49 deletions

View File

@ -7,7 +7,14 @@
if (result) { if (result) {
var $html = $('#main-content').html(result); var $html = $('#main-content').html(result);
var $iconList = $('div.fontawesome-icon-list').on('click', 'a', function () { var $iconList = $('div.fontawesome-icon-list').on('click', 'a', function () {
window.console.log($(this).children('i').attr('class')); var text = $(this).children('i').attr('class');
window.console.log(text);
if ($.copyText(text)) {
toastr.success('拷贝成功');
}
else {
toastr.error('拷贝失败');
}
return false; return false;
}); });

View File

@ -57,27 +57,6 @@
}; };
} }
// 扩展format
$.extend({
"format": function (source, params) {
if (params === undefined || params === null) {
return null;
}
if (arguments.length > 2 && params.constructor !== Array) {
params = $.makeArray(arguments).slice(1);
}
if (params.constructor !== Array) {
params = [params];
}
$.each(params, function (i, n) {
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function () {
return n;
});
});
return source;
}
});
// enhance window.console.log // enhance window.console.log
if (!window.console) { if (!window.console) {
window.console = { window.console = {
@ -111,6 +90,34 @@
}; };
$.extend({ $.extend({
"format": function (source, params) {
if (params === undefined || params === null) {
return null;
}
if (arguments.length > 2 && params.constructor !== Array) {
params = $.makeArray(arguments).slice(1);
}
if (params.constructor !== Array) {
params = [params];
}
$.each(params, function (i, n) {
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function () {
return n;
});
});
return source;
},
copyText: function (ele) {
if (typeof ele !== "string") return false;
var input = document.createElement('input');
input.setAttribute('type', 'text');
input.setAttribute('value', ele);
document.body.appendChild(input);
input.select();
var ret = document.execCommand('copy');
document.body.removeChild(input);
return ret;
},
fullScreenStatus: function fullScreenStatus(value) { fullScreenStatus: function fullScreenStatus(value) {
if (value !== undefined) window.fullscreen = value; if (value !== undefined) window.fullscreen = value;
return document.fullscreen || return document.fullscreen ||

View File

@ -57,27 +57,6 @@
}; };
} }
// 扩展format
$.extend({
"format": function (source, params) {
if (params === undefined || params === null) {
return null;
}
if (arguments.length > 2 && params.constructor !== Array) {
params = $.makeArray(arguments).slice(1);
}
if (params.constructor !== Array) {
params = [params];
}
$.each(params, function (i, n) {
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function () {
return n;
});
});
return source;
}
});
// enhance window.console.log // enhance window.console.log
if (!window.console) { if (!window.console) {
window.console = { window.console = {
@ -111,6 +90,34 @@
}; };
$.extend({ $.extend({
"format": function (source, params) {
if (params === undefined || params === null) {
return null;
}
if (arguments.length > 2 && params.constructor !== Array) {
params = $.makeArray(arguments).slice(1);
}
if (params.constructor !== Array) {
params = [params];
}
$.each(params, function (i, n) {
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function () {
return n;
});
});
return source;
},
copyText: function (ele) {
if (typeof ele !== "string") return false;
var input = document.createElement('input');
input.setAttribute('type', 'text');
input.setAttribute('value', ele);
document.body.appendChild(input);
input.select();
var ret = document.execCommand('copy');
document.body.removeChild(input);
return ret;
},
fullScreenStatus: function fullScreenStatus(value) { fullScreenStatus: function fullScreenStatus(value) {
if (value !== undefined) window.fullscreen = value; if (value !== undefined) window.fullscreen = value;
return document.fullscreen || return document.fullscreen ||