new: source code copy to clipboard, and css with font-awesome

pull/12/head
Steve Nyemba 3 weeks ago
parent 3540f73a84
commit ac40d95aca

@ -8,6 +8,8 @@
border-left:8px solid #CAD5E0; margin-left:10px; font-weight: bold; border-left:8px solid #CAD5E0; margin-left:10px; font-weight: bold;
font-size:14px; font-size:14px;
} }
.source-code .fa-copy {float:right; margin:4px; cursor:pointer}
/* .source-code .fa-copy:hover */
.editor { .editor {
background-color:#f3f3f3; background-color:#f3f3f3;

@ -111,6 +111,11 @@ menu.events._dialog = function (_item,_context){
// var url = _args['url'] // var url = _args['url']
_item.type = (_item.type == null)? 'redirect' :_item.type _item.type = (_item.type == null)? 'redirect' :_item.type
var http = HttpClient.instance() var http = HttpClient.instance()
_regex = /uri=(.+)/;
if (_item.uri.match(_regex)) {
_seg = _item.uri.match(_regex)
_item.uri = _seg[_seg.length - 1]
}
http.setHeader('uri',_item.uri) http.setHeader('uri',_item.uri)
http.setHeader('dom',(_item.title)?_item.title:'dialog') http.setHeader('dom',(_item.title)?_item.title:'dialog')
// http.setHeader('dom',_args.text) // http.setHeader('dom',_args.text)
@ -121,6 +126,11 @@ menu.events._dialog = function (_item,_context){
}) })
} }
menu.events._openTabs = function (_TabContentPane, _id) {
_id = _id[0] != '.' ? ('.'+_id) : _id
$(_TabContentPane).children().slideUp('fast')
$(_id).slideDown()
}
menu.events._open = function (id,uri,_context){ menu.events._open = function (id,uri,_context){
id = id.replace(/ /g,'-') id = id.replace(/ /g,'-')
@ -243,6 +253,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) {
if(this.data.uri && this.data.type != 'open') { if(this.data.uri && this.data.type != 'open') {
if (this.data.type == 'dialog') { if (this.data.type == 'dialog') {
// console.log(this.data)
menu.events._dialog(this.data,_context) menu.events._dialog(this.data,_context)
}else{ }else{
menu.events._open(menu.utils.format(this.data.text),this.data.uri,_context) menu.events._open(menu.utils.format(this.data.text),this.data.uri,_context)
@ -417,3 +428,22 @@ menu.init =function (_layout,_context){
} }
/***
*
* Source Code
*/
if (! code){
var code = {}
}
code.copy = function(_node) {
var _code = $(_node.parentNode).text().trim().replace(/ {8}/g,'').replace(/ {4}/g,'\t').replace(/\r/g,'\n')
navigator.clipboard.writeText(_code);
$(_node).empty()
$(_node).html('<i class="fa-solid fa-check"></i>')
setTimeout(function(){
$(_node).empty()
$(_node).html('<i class="fa-regular fa-copy"></i>')
},750)
}
Loading…
Cancel
Save