From 1d300cd039c7976d39cc0dedcf909ceca5247e66 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Wed, 4 Dec 2024 16:26:08 +0330 Subject: [PATCH] added live edit setting --- .../Controllers/Admin/SettingController.php | 14 ++++ resources/js/client-custom/customize.js | 48 +++++++++++++ resources/js/panel/editor-handle.js | 72 ++++++++++--------- resources/js/panel/panel-window-loader.js | 14 ++-- resources/sass/client-custom/_general.scss | 36 ++++++++++ resources/views/admin/commons/live.blade.php | 49 +++++++++++++ .../views/admin/commons/setting.blade.php | 15 ++++ .../AttachmentWithPreview.blade.php | 4 +- .../SimpleAttachmentList.blade.php | 2 +- .../DenaAttachList/DenaAttachList.blade.php | 2 +- .../CategoriesFavImageLinks.blade.php | 2 +- .../CategoriesGrid/CategoriesGrid.blade.php | 2 +- .../CurveCategories/CurveCategories.blade.php | 2 +- .../FavProductWithMeta.blade.php | 2 +- .../ParallelCategoriesGrid.blade.php | 2 +- .../SubCategoriesGrid.blade.php | 2 +- .../segments/clip/DorClip/DorClip.blade.php | 2 +- .../AutoPlayClips/AutoPlayClips.blade.php | 2 +- .../ClipListGrid/ClipListGrid.blade.php | 2 +- .../SimpleComments/SimpleComments.blade.php | 2 +- .../CompareProducts/CompareProducts.blade.php | 2 +- .../contact/MeloContact/MeloContact.blade.php | 2 +- .../AvisaCustomer/AvisaCustomer.blade.php | 4 +- .../segments/default-assets/pattern2.svg | 42 +++++++++++ .../footer/FireFooter/FireFooter.blade.php | 2 +- .../LittleFooter/LittleFooter.blade.php | 2 +- .../footer/OtherFooter/OtherFooter.blade.php | 2 +- .../ParallaxFooter/ParallaxFooter.blade.php | 2 +- .../SimpleFooter/SimpleFooter.blade.php | 2 +- .../footer/WaveFooter/WaveFooter.blade.php | 2 +- .../GridGallery/GridGallery.blade.php | 2 +- .../GalleriesList/GalleriesList.blade.php | 2 +- .../AparatGallery/AparatGallery.blade.php | 4 +- .../gallery/GallaryGrid/GallaryGrid.blade.php | 2 +- .../SubGroupsGrid/SubGroupsGrid.blade.php | 2 +- .../header/HodHeader/HodHeader.blade.php | 2 +- .../ParallaxHeader/ParallaxHeader.blade.php | 2 +- .../ParallaxHeaderPin.blade.php | 2 +- .../SimpleHeader/SimpleHeader.blade.php | 2 +- .../index/AuthorSlider/AuthorSlider.blade.php | 2 +- .../index/CounterGrid/CounterGrid.blade.php | 2 +- .../index/GisooVideo/GisooVideo.blade.php | 2 +- .../GradientTextLink.blade.php | 2 +- .../index/InlineMap/InlineMap.blade.php | 2 +- .../MainCategoriesIcon.blade.php | 2 +- .../MainCategoriesSlider.blade.php | 2 +- .../MaryamCategoryProducts.blade.php | 2 +- .../NataliaCategories.blade.php | 2 +- .../SimpleTextLink/SimpleTextLink.blade.php | 2 +- .../index/SpliterText/SpliterText.blade.php | 2 +- .../VickushkaMainCategoriesSlider.blade.php | 2 +- .../LianaInvoice/LianaInvoice.blade.php | 2 +- .../login/LoginBigBg/LoginBigBg.blade.php | 2 +- .../LoginPatternBg/LoginPatternBg.blade.php | 2 +- .../segments/menu/AplMenu/AplMenu.blade.php | 2 +- .../menu/DeebaMenu/DeebaMenu.blade.php | 2 +- .../menu/HomayonMenu/HomayonMenu.blade.php | 2 +- .../menu/RecetMenu/RecetMenu.blade.php | 2 +- .../segments/menu/SideMenu/SideMenu.blade.php | 4 +- .../ParallaxShort/ParallaxShort.blade.php | 2 +- .../post/PostSidebar/PostSidebar.blade.php | 2 +- .../post/SimplePost/SimplePost.blade.php | 2 +- .../LongHeightPosts/LongHeightPosts.blade.php | 2 +- .../posts/NoLinkImage/NoLinkImage.blade.php | 2 +- .../PostIndexImage/PostIndexImage.blade.php | 2 +- .../PostsIconSimple/PostsIconSimple.blade.php | 2 +- .../posts/PostsSlider/PostsSlider.blade.php | 2 +- .../GridPostList/GridPostList.blade.php | 2 +- .../GridPostListSidebar.blade.php | 2 +- .../SimplePostList/SimplePostList.blade.php | 2 +- .../SimplePostListSideBar.blade.php | 2 +- .../product/ProductAria/ProductAria.blade.php | 2 +- .../ProductKaren/ProductKaren.blade.php | 2 +- .../ProductYasamin/ProductYasamin.blade.php | 2 +- .../LatestProducts/LatestProducts.blade.php | 2 +- .../ProductGrid/ProductGrid.blade.php | 2 +- .../ProductGridHiddenSidebar.blade.php | 2 +- .../ProductGridSidebar.blade.php | 2 +- .../SimpleRegister/SimpleRegister.blade.php | 2 +- .../ParallaxSlider/ParallaxSlider.blade.php | 2 +- .../SliderSimple/SliderSimple.blade.php | 2 +- .../top/TopSimple/TopSimple.blade.php | 2 +- .../views/website/inc/website-foot.blade.php | 13 ++-- routes/web.php | 1 + 84 files changed, 339 insertions(+), 121 deletions(-) create mode 100644 resources/js/client-custom/customize.js create mode 100644 resources/views/admin/commons/live.blade.php create mode 100644 resources/views/segments/default-assets/pattern2.svg 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') +
+
+
+ +
+ @csrf +
+ + @include('components.err') + @if(count($settings) == 0) +

+ {{__("There is nothing to show!")}} +

+ @else +
+ @foreach($settings as $setting) + @include('components.setting-field') + @endforeach +
+ @endif +
+ + + + @if(config('app.env') == 'production') + + @endif +
+@include('components.panel-footer') diff --git a/resources/views/admin/commons/setting.blade.php b/resources/views/admin/commons/setting.blade.php index 53447be..062b5d0 100644 --- a/resources/views/admin/commons/setting.blade.php +++ b/resources/views/admin/commons/setting.blade.php @@ -134,6 +134,21 @@ > + @if(config('app.env') == 'production') + + @endif
diff --git a/resources/views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview.blade.php b/resources/views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview.blade.php index 11b284a..e51ad38 100644 --- a/resources/views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview.blade.php +++ b/resources/views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview.blade.php @@ -1,5 +1,5 @@ -
-
+
+

{{$attachment->title}}

diff --git a/resources/views/segments/attachments/SimpleAttachmentList/SimpleAttachmentList.blade.php b/resources/views/segments/attachments/SimpleAttachmentList/SimpleAttachmentList.blade.php index 2827c38..a0fb55c 100644 --- a/resources/views/segments/attachments/SimpleAttachmentList/SimpleAttachmentList.blade.php +++ b/resources/views/segments/attachments/SimpleAttachmentList/SimpleAttachmentList.blade.php @@ -1,4 +1,4 @@ -
+
@if(count($data['attachs']) > 0)

diff --git a/resources/views/segments/attachments_page/DenaAttachList/DenaAttachList.blade.php b/resources/views/segments/attachments_page/DenaAttachList/DenaAttachList.blade.php index 81ef187..1064853 100644 --- a/resources/views/segments/attachments_page/DenaAttachList/DenaAttachList.blade.php +++ b/resources/views/segments/attachments_page/DenaAttachList/DenaAttachList.blade.php @@ -1,4 +1,4 @@ -
+

{{$title}} diff --git a/resources/views/segments/categories/CategoriesFavImageLinks/CategoriesFavImageLinks.blade.php b/resources/views/segments/categories/CategoriesFavImageLinks/CategoriesFavImageLinks.blade.php index 7a3cb19..2c31b30 100644 --- a/resources/views/segments/categories/CategoriesFavImageLinks/CategoriesFavImageLinks.blade.php +++ b/resources/views/segments/categories/CategoriesFavImageLinks/CategoriesFavImageLinks.blade.php @@ -1,4 +1,4 @@ -