diff --git a/app/Http/Controllers/Admin/SettingController.php b/app/Http/Controllers/Admin/SettingController.php index 7e57ac7..1fdb4e0 100644 --- a/app/Http/Controllers/Admin/SettingController.php +++ b/app/Http/Controllers/Admin/SettingController.php @@ -99,6 +99,10 @@ class SettingController extends Controller } } } + + if ($request->has('build')){ + Artisan::call('build'); + } logAdmin(__METHOD__,__CLASS__,null); return redirect()->back()->with(['message' => __('Setting of website updated')]); } @@ -121,4 +125,14 @@ class SettingController extends Controller Artisan::call('route:clear'); return redirect()->back()->with(['message' => __('Cache cleared')]); } + + public function liveEdit($slug){ + $settings = Setting::where('active', true)->where('key','LIKE',$slug.'%') + ->orderBy('section')->get(); + $cats = Category::all(['id','name']); + $menus = Menu::all(['id','name']); + $groups = Group::all(['id','name']); + return view('admin.commons.live', + compact('settings', 'cats','groups','menus')); + } } diff --git a/resources/js/client-custom/customize.js b/resources/js/client-custom/customize.js new file mode 100644 index 0000000..f27f9f6 --- /dev/null +++ b/resources/js/client-custom/customize.js @@ -0,0 +1,48 @@ +var onEdit = ''; +document.querySelector('#do-edit')?.addEventListener('click', function () { + this.style.display = 'none'; + let editable = document.createElement('div'); + editable.setAttribute('id', 'customizable'); + editable.innerHTML = ' '; + document.body.appendChild(editable); + document.querySelectorAll('.live-setting')?.forEach(function (el) { + el.addEventListener('mouseenter', function () { + + setTimeout(() => { + let rect = el.getBoundingClientRect(); + onEdit = this.getAttribute('data-live'); + document.querySelector('#customizable b').innerText = onEdit; + document.querySelector('#customizable').style.top = (window.scrollY + rect.top + 5) + 'px'; + }, 50); + }); + el.addEventListener('mouseleave', function () { + + console.log(this.getAttribute('data-live')); + }); + }); + editable.addEventListener('click', function () { + if (document.querySelector('#customize-modal') == null) { + + let custModal = document.createElement('div'); + custModal.setAttribute('id', 'customize-modal'); + custModal.innerHTML = ''; + document.body.appendChild(custModal); + custModal.addEventListener('click', function (e) { + if (e.target == this) { + window.location.reload(); + } + }); + } else { + document.querySelector('#customize-modal').style.display = 'block'; + } + + document.addEventListener('keyup',function (e) { + if (e.code == 'Escape'){ + window.location.reload(); + } + }); + + document.querySelector('#customize-modal iframe').setAttribute('src', document.querySelector('#live-url').value + onEdit); + + }); +}); diff --git a/resources/js/panel/editor-handle.js b/resources/js/panel/editor-handle.js index fe68418..46e6125 100644 --- a/resources/js/panel/editor-handle.js +++ b/resources/js/panel/editor-handle.js @@ -1,45 +1,51 @@ import ContentSEOAnalyzer from './seo-analyzer.js' + let timeOut = null; window.addEventListener('load', function () { - let keywordInput = document.querySelector('#keyword') ; - let dirx = document.querySelector('#panel-dir').value; - let editors = {}; - document.querySelectorAll('.ckeditorx')?.forEach(function (el) { - - const currentDir = el.getAttribute('dir'); - let finalDir = dirx; - if (currentDir != null){ - finalDir = currentDir; - } - editors[el.getAttribute('name')] = CKEDITOR.replace(el.getAttribute('name'), { - filebrowserUploadUrl: xupload, - filebrowserUploadMethod: 'form', - contentsLangDirection: finalDir, - skin: 'moono-dark', - }); - + try { - CKEDITOR.addCss('.cke_editable { background-color: ' + website_bg + '; color: ' + website_text_color + ' ; font-family: ' + website_font + ' }'); - editors[el.getAttribute('name')].on('change', function (evt) { - const content = evt.editor.getData(); - el.value = content; - if (el.classList.contains('seo-analyze')){ - let keyword = keywordInput?.value; + let keywordInput = document.querySelector('#keyword'); + let dirx = document.querySelector('#panel-dir').value; + let editors = {}; + document.querySelectorAll('.ckeditorx')?.forEach(function (el) { - const analyzer = new ContentSEOAnalyzer(content, keyword); - const report = analyzer.generateReport(); - analyzer.displaySEOReport(report,'seo-hint') + const currentDir = el.getAttribute('dir'); + let finalDir = dirx; + if (currentDir != null) { + finalDir = currentDir; } - }); + editors[el.getAttribute('name')] = CKEDITOR.replace(el.getAttribute('name'), { + filebrowserUploadUrl: xupload, + filebrowserUploadMethod: 'form', + contentsLangDirection: finalDir, + skin: 'moono-dark', + }); - if (el.classList.contains('seo-analyze')){ - editors[el.getAttribute('name')].fire('change'); - keywordInput?.addEventListener('input',function () { - editors[el.getAttribute('name')].fire('change'); + CKEDITOR.addCss('.cke_editable { background-color: ' + website_bg + '; color: ' + website_text_color + ' ; font-family: ' + website_font + ' }'); + editors[el.getAttribute('name')].on('change', function (evt) { + const content = evt.editor.getData(); + el.value = content; + if (el.classList.contains('seo-analyze')) { + let keyword = keywordInput?.value; + + const analyzer = new ContentSEOAnalyzer(content, keyword); + const report = analyzer.generateReport(); + analyzer.displaySEOReport(report, 'seo-hint') + } }); - } - }); + + if (el.classList.contains('seo-analyze')) { + editors[el.getAttribute('name')].fire('change'); + keywordInput?.addEventListener('input', function () { + editors[el.getAttribute('name')].fire('change'); + }); + } + + }); + + } catch { + } }); diff --git a/resources/js/panel/panel-window-loader.js b/resources/js/panel/panel-window-loader.js index a55a374..72a7487 100644 --- a/resources/js/panel/panel-window-loader.js +++ b/resources/js/panel/panel-window-loader.js @@ -15,9 +15,13 @@ setTimeout(function () { } },5000); const forceLoad = function () { - const preloader = document.querySelector('#panel-preloader'); - preloader.style.height = 0; - setTimeout( () => { - preloader.style.display = 'none'; - },500); + try { + const preloader = document.querySelector('#panel-preloader'); + preloader.style.height = 0; + setTimeout( () => { + preloader.style.display = 'none'; + },500); + } catch { + } + }; diff --git a/resources/sass/client-custom/_general.scss b/resources/sass/client-custom/_general.scss index 7b87c7b..6975d70 100644 --- a/resources/sass/client-custom/_general.scss +++ b/resources/sass/client-custom/_general.scss @@ -194,3 +194,39 @@ section { display: none; } } + +#customizable{ + position: absolute; + background: var(--xshop-primary); + border: var(--xshop-diff) 1px solid; + color: var(--xshop-diff); + top: -300px; + transition: 500ms; + right: 50px; + left: 50px; + text-align: center; + z-index: 99988; + padding: 1rem; + cursor: pointer; + border-radius: 7px; +} + +#customize-modal{ + z-index: 99999; + position: fixed; + left: 0; + right: 0; + bottom: 0; + top: 0; + background: #ffffff33; + backdrop-filter: blur(14px); +} + +#customize-modal iframe{ + width: 90%; + height: 90vh; + border: silver 1px solid; + margin: 5vh auto; + border-radius: 7px; + display: block; +} diff --git a/resources/views/admin/commons/live.blade.php b/resources/views/admin/commons/live.blade.php new file mode 100644 index 0000000..ffa8c19 --- /dev/null +++ b/resources/views/admin/commons/live.blade.php @@ -0,0 +1,49 @@ +@include('components.panel-header') +