From ac40d95aca496f17c2d1ef5ed22dd4ccb8fa693d Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Mon, 4 Nov 2024 10:13:00 -0600 Subject: [PATCH] new: source code copy to clipboard, and css with font-awesome --- cms/static/css/source-code.css | 2 ++ cms/static/js/menu.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/cms/static/css/source-code.css b/cms/static/css/source-code.css index e46f72c..a78ff23 100644 --- a/cms/static/css/source-code.css +++ b/cms/static/css/source-code.css @@ -8,6 +8,8 @@ border-left:8px solid #CAD5E0; margin-left:10px; font-weight: bold; font-size:14px; } +.source-code .fa-copy {float:right; margin:4px; cursor:pointer} +/* .source-code .fa-copy:hover */ .editor { background-color:#f3f3f3; diff --git a/cms/static/js/menu.js b/cms/static/js/menu.js index ddeb441..04a2f1b 100644 --- a/cms/static/js/menu.js +++ b/cms/static/js/menu.js @@ -111,6 +111,11 @@ menu.events._dialog = function (_item,_context){ // var url = _args['url'] _item.type = (_item.type == null)? 'redirect' :_item.type 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('dom',(_item.title)?_item.title:'dialog') // 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){ 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.type == 'dialog') { + // console.log(this.data) menu.events._dialog(this.data,_context) }else{ 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('') + setTimeout(function(){ + $(_node).empty() + $(_node).html('') + },750) +} \ No newline at end of file