Skip to content

Commit 1d300cd

Browse files
committed
added live edit setting
1 parent 600273e commit 1d300cd

File tree

84 files changed

+339
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+339
-121
lines changed

app/Http/Controllers/Admin/SettingController.php

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public function update(Request $request)
9999
}
100100
}
101101
}
102+
103+
if ($request->has('build')){
104+
Artisan::call('build');
105+
}
102106
logAdmin(__METHOD__,__CLASS__,null);
103107
return redirect()->back()->with(['message' => __('Setting of website updated')]);
104108
}
@@ -121,4 +125,14 @@ public function cacheClear(){
121125
Artisan::call('route:clear');
122126
return redirect()->back()->with(['message' => __('Cache cleared')]);
123127
}
128+
129+
public function liveEdit($slug){
130+
$settings = Setting::where('active', true)->where('key','LIKE',$slug.'%')
131+
->orderBy('section')->get();
132+
$cats = Category::all(['id','name']);
133+
$menus = Menu::all(['id','name']);
134+
$groups = Group::all(['id','name']);
135+
return view('admin.commons.live',
136+
compact('settings', 'cats','groups','menus'));
137+
}
124138
}
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var onEdit = '';
2+
document.querySelector('#do-edit')?.addEventListener('click', function () {
3+
this.style.display = 'none';
4+
let editable = document.createElement('div');
5+
editable.setAttribute('id', 'customizable');
6+
editable.innerHTML = '<i class="ri-edit-2-line"></i> <b></b>';
7+
document.body.appendChild(editable);
8+
document.querySelectorAll('.live-setting')?.forEach(function (el) {
9+
el.addEventListener('mouseenter', function () {
10+
11+
setTimeout(() => {
12+
let rect = el.getBoundingClientRect();
13+
onEdit = this.getAttribute('data-live');
14+
document.querySelector('#customizable b').innerText = onEdit;
15+
document.querySelector('#customizable').style.top = (window.scrollY + rect.top + 5) + 'px';
16+
}, 50);
17+
});
18+
el.addEventListener('mouseleave', function () {
19+
20+
console.log(this.getAttribute('data-live'));
21+
});
22+
});
23+
editable.addEventListener('click', function () {
24+
if (document.querySelector('#customize-modal') == null) {
25+
26+
let custModal = document.createElement('div');
27+
custModal.setAttribute('id', 'customize-modal');
28+
custModal.innerHTML = '<iframe></iframe>';
29+
document.body.appendChild(custModal);
30+
custModal.addEventListener('click', function (e) {
31+
if (e.target == this) {
32+
window.location.reload();
33+
}
34+
});
35+
} else {
36+
document.querySelector('#customize-modal').style.display = 'block';
37+
}
38+
39+
document.addEventListener('keyup',function (e) {
40+
if (e.code == 'Escape'){
41+
window.location.reload();
42+
}
43+
});
44+
45+
document.querySelector('#customize-modal iframe').setAttribute('src', document.querySelector('#live-url').value + onEdit);
46+
47+
});
48+
});

resources/js/panel/editor-handle.js

+39-33
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
11
import ContentSEOAnalyzer from './seo-analyzer.js'
2+
23
let timeOut = null;
34
window.addEventListener('load', function () {
45

5-
let keywordInput = document.querySelector('#keyword') ;
6-
let dirx = document.querySelector('#panel-dir').value;
7-
let editors = {};
8-
document.querySelectorAll('.ckeditorx')?.forEach(function (el) {
9-
10-
const currentDir = el.getAttribute('dir');
11-
let finalDir = dirx;
12-
if (currentDir != null){
13-
finalDir = currentDir;
14-
}
15-
editors[el.getAttribute('name')] = CKEDITOR.replace(el.getAttribute('name'), {
16-
filebrowserUploadUrl: xupload,
17-
filebrowserUploadMethod: 'form',
18-
contentsLangDirection: finalDir,
19-
skin: 'moono-dark',
20-
});
21-
6+
try {
227

23-
CKEDITOR.addCss('.cke_editable { background-color: ' + website_bg + '; color: ' + website_text_color + ' ; font-family: ' + website_font + ' }');
24-
editors[el.getAttribute('name')].on('change', function (evt) {
25-
const content = evt.editor.getData();
26-
el.value = content;
27-
if (el.classList.contains('seo-analyze')){
28-
let keyword = keywordInput?.value;
8+
let keywordInput = document.querySelector('#keyword');
9+
let dirx = document.querySelector('#panel-dir').value;
10+
let editors = {};
11+
document.querySelectorAll('.ckeditorx')?.forEach(function (el) {
2912

30-
const analyzer = new ContentSEOAnalyzer(content, keyword);
31-
const report = analyzer.generateReport();
32-
analyzer.displaySEOReport(report,'seo-hint')
13+
const currentDir = el.getAttribute('dir');
14+
let finalDir = dirx;
15+
if (currentDir != null) {
16+
finalDir = currentDir;
3317
}
34-
});
18+
editors[el.getAttribute('name')] = CKEDITOR.replace(el.getAttribute('name'), {
19+
filebrowserUploadUrl: xupload,
20+
filebrowserUploadMethod: 'form',
21+
contentsLangDirection: finalDir,
22+
skin: 'moono-dark',
23+
});
3524

3625

37-
if (el.classList.contains('seo-analyze')){
38-
editors[el.getAttribute('name')].fire('change');
39-
keywordInput?.addEventListener('input',function () {
40-
editors[el.getAttribute('name')].fire('change');
26+
CKEDITOR.addCss('.cke_editable { background-color: ' + website_bg + '; color: ' + website_text_color + ' ; font-family: ' + website_font + ' }');
27+
editors[el.getAttribute('name')].on('change', function (evt) {
28+
const content = evt.editor.getData();
29+
el.value = content;
30+
if (el.classList.contains('seo-analyze')) {
31+
let keyword = keywordInput?.value;
32+
33+
const analyzer = new ContentSEOAnalyzer(content, keyword);
34+
const report = analyzer.generateReport();
35+
analyzer.displaySEOReport(report, 'seo-hint')
36+
}
4137
});
42-
}
4338

44-
});
39+
40+
if (el.classList.contains('seo-analyze')) {
41+
editors[el.getAttribute('name')].fire('change');
42+
keywordInput?.addEventListener('input', function () {
43+
editors[el.getAttribute('name')].fire('change');
44+
});
45+
}
46+
47+
});
48+
49+
} catch {
50+
}
4551
});

resources/js/panel/panel-window-loader.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ setTimeout(function () {
1515
}
1616
},5000);
1717
const forceLoad = function () {
18-
const preloader = document.querySelector('#panel-preloader');
19-
preloader.style.height = 0;
20-
setTimeout( () => {
21-
preloader.style.display = 'none';
22-
},500);
18+
try {
19+
const preloader = document.querySelector('#panel-preloader');
20+
preloader.style.height = 0;
21+
setTimeout( () => {
22+
preloader.style.display = 'none';
23+
},500);
24+
} catch {
25+
}
26+
2327
};

resources/sass/client-custom/_general.scss

+36
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,39 @@ section {
194194
display: none;
195195
}
196196
}
197+
198+
#customizable{
199+
position: absolute;
200+
background: var(--xshop-primary);
201+
border: var(--xshop-diff) 1px solid;
202+
color: var(--xshop-diff);
203+
top: -300px;
204+
transition: 500ms;
205+
right: 50px;
206+
left: 50px;
207+
text-align: center;
208+
z-index: 99988;
209+
padding: 1rem;
210+
cursor: pointer;
211+
border-radius: 7px;
212+
}
213+
214+
#customize-modal{
215+
z-index: 99999;
216+
position: fixed;
217+
left: 0;
218+
right: 0;
219+
bottom: 0;
220+
top: 0;
221+
background: #ffffff33;
222+
backdrop-filter: blur(14px);
223+
}
224+
225+
#customize-modal iframe{
226+
width: 90%;
227+
height: 90vh;
228+
border: silver 1px solid;
229+
margin: 5vh auto;
230+
border-radius: 7px;
231+
display: block;
232+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@include('components.panel-header')
2+
<div id="panel-preloader">
3+
<div class="loader"></div>
4+
</div>
5+
<input type="hidden" id="panel-dir" @if(langIsRTL(config('app.locale'))) value="rtl" @else value="ltr" @endif>
6+
<form action="{{route('admin.setting.update')}}" method="post" enctype="multipart/form-data">
7+
@csrf
8+
<div class="container pt-3" id="app">
9+
10+
@include('components.err')
11+
@if(count($settings) == 0)
12+
<h3 class="text-center pt-2">
13+
{{__("There is nothing to show!")}}
14+
</h3>
15+
@else
16+
<div class="row">
17+
@foreach($settings as $setting)
18+
@include('components.setting-field')
19+
@endforeach
20+
</div>
21+
@endif
22+
</div>
23+
<button class="action-btn circle-btn"
24+
data-bs-toggle="tooltip"
25+
data-bs-placement="top"
26+
data-bs-custom-class="custom-tooltip"
27+
data-bs-title="{{__("Save all settings")}}"
28+
>
29+
<i class="ri-save-2-line"></i>
30+
</button>
31+
32+
33+
@if(config('app.env') == 'production')
34+
<button
35+
href="{{getRoute('sort')}}"
36+
class="action-btn circle-btn"
37+
data-bs-toggle="tooltip"
38+
data-bs-placement="top"
39+
data-bs-custom-class="custom-tooltip"
40+
data-bs-title="{{__("Save and build")}}"
41+
name="build"
42+
value="1"
43+
style="inset-inline-end: 1.2rem;inset-inline-start: auto;"
44+
>
45+
<i class="ri-hammer-line"></i>
46+
</button>
47+
@endif
48+
</form>
49+
@include('components.panel-footer')

resources/views/admin/commons/setting.blade.php

+15
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ class="form-control @error('size') is-invalid @enderror"
134134
>
135135
<i class="ri-save-2-line"></i>
136136
</button>
137+
@if(config('app.env') == 'production')
138+
<button
139+
href="{{getRoute('sort')}}"
140+
class="action-btn circle-btn"
141+
data-bs-toggle="tooltip"
142+
data-bs-placement="top"
143+
data-bs-custom-class="custom-tooltip"
144+
data-bs-title="{{__("Save and build")}}"
145+
name="build"
146+
value="1"
147+
style="inset-inline-end: 1.2rem;inset-inline-start: auto;"
148+
>
149+
<i class="ri-hammer-line"></i>
150+
</button>
151+
@endif
137152
</form>
138153
</div>
139154
<div class="mb-5">

resources/views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<section class='AttachmentWithPreview'>
2-
<div class="{{gfx()['container']}}">
1+
<section class='AttachmentWithPreview live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
2+
<div class="{{gfx()['container']}}">
33
<h1>
44
{{$attachment->title}}
55
</h1>

resources/views/segments/attachments/SimpleAttachmentList/SimpleAttachmentList.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='SimpleAttachmentList'>
1+
<section class='SimpleAttachmentList live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
@if(count($data['attachs']) > 0)
44
<h2 class="my-3">

resources/views/segments/attachments_page/DenaAttachList/DenaAttachList.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='DenaAttachList content'>
1+
<section class='DenaAttachList content live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
<h1>
44
{{$title}}

resources/views/segments/categories/CategoriesFavImageLinks/CategoriesFavImageLinks.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section id='CategoriesFavImageLinks'>
1+
<section id='CategoriesFavImageLinks' class='live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22

33
<div class="{{gfx()['container']}}">
44
<h1>

resources/views/segments/categories/CategoriesGrid/CategoriesGrid.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='CategoriesGrid'>
1+
<section class='CategoriesGrid live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
<h1>
44
{{getSetting($data->area_name.'_'.$data->part.'_title')}}

resources/views/segments/categories/CurveCategories/CurveCategories.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section id='CurveCategories'>
1+
<section id='CurveCategories' class=' live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22

33

44
<div id="curve-cat-top">

resources/views/segments/categories/FavProductWithMeta/FavProductWithMeta.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@php($productFav = getCategoryProductBySetting($data->area_name.'_'.$data->part,1) )
22
@if(count($productFav) > 0)
3-
<section class="FavProductWithMeta py-5">
3+
<section class="FavProductWithMeta py-5 live-setting" data-live="{{$data->area_name.'_'.$data->part}}" >
44
<div class="{{gfx()['container']}}">
55
<h4 class="text-center text-muted">
66
{{getSetting($data->area_name.'_'.$data->part.'_title')}}

resources/views/segments/category/ParallelCategoriesGrid/ParallelCategoriesGrid.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='ParallelCategoriesGrid'>
1+
<section class='ParallelCategoriesGrid live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
@if(count($category->parallelCategories()) > 0)
44
<div>

resources/views/segments/category/SubCategoriesGrid/SubCategoriesGrid.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='SubCategoriesGrid content'>
1+
<section class='SubCategoriesGrid content live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
@if($category->children()->count() > 0)
44
<div>

resources/views/segments/clip/DorClip/DorClip.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='DorClip content'>
1+
<section class='DorClip content live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
<h1>
44
{{$title}}

resources/views/segments/clips/AutoPlayClips/AutoPlayClips.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='AutoPlayClips'>
1+
<section class='AutoPlayClips live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
<h1>
44
{{getSetting($data->area_name.'_'.$data->part.'_title')}}

resources/views/segments/clips_page/ClipListGrid/ClipListGrid.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='ClipListGrid content'>
1+
<section class='ClipListGrid content live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
<h1>
44
{{$title}}

resources/views/segments/comments/SimpleComments/SimpleComments.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='SimpleComments'>
1+
<section class='SimpleComments live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
<h5>
44
{{__("Comments")}}

resources/views/segments/compare/CompareProducts/CompareProducts.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='CompareProducts content'>
1+
<section class='CompareProducts content live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33
<h1>
44
{{$title}}

resources/views/segments/contact/MeloContact/MeloContact.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class='MeloContact'>
1+
<section class='MeloContact live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
22
<div class="{{gfx()['container']}}">
33

44
<h1 class="text-center fw-light mb-3">

resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<section id='AvisaCustomer'>
2-
<div class="{{gfx()['container']}}">
1+
<section id='AvisaCustomer' class=' live-setting' data-live="{{$data->area_name.'_'.$data->part}}">
2+
<div class="{{gfx()['container']}}">
33
<div class="row">
44
<div class="col-lg-3">
55
<img src="{{auth('customer')->user()->avatar()}}" alt="[avatar]" class="avisa-avatar" onclick="document.querySelector('#avatar').click();">

0 commit comments

Comments
 (0)