diff --git a/resources/views/segments/footer/ParallaxFooter/ParallaxFooter.php b/resources/views/segments/footer/ParallaxFooter/ParallaxFooter.php index ff050dd..350d0a7 100644 --- a/resources/views/segments/footer/ParallaxFooter/ParallaxFooter.php +++ b/resources/views/segments/footer/ParallaxFooter/ParallaxFooter.php @@ -69,6 +69,7 @@ class ParallaxFooter Setting::where('key',$part->area->name . '_' . $part->part.'_title2')->first()?->delete(); Setting::where('key',$part->area->name . '_' . $part->part.'_group')->first()?->delete(); Setting::where('key',$part->area->name . '_' . $part->part.'_last')->first()?->delete(); + Setting::where('key',$part->area->name . '_' . $part->part.'_jpg')->first()?->delete(); } public static function onMount(Part $part = null) { diff --git a/resources/views/segments/index/CounterGrid/CounterGrid.blade.php b/resources/views/segments/index/CounterGrid/CounterGrid.blade.php new file mode 100644 index 0000000..1cfa03f --- /dev/null +++ b/resources/views/segments/index/CounterGrid/CounterGrid.blade.php @@ -0,0 +1,18 @@ +
+
+ +
+ @for($i = 1; $i <= \Resources\Views\Segments\CounterGrid::$count; $i++) +
+ +

+ {{getSetting($data->area->name.'_'.$data->part.'_title'.$i)}} +

+
+ 0 +
+
+ @endfor +
+
+
diff --git a/resources/views/segments/index/CounterGrid/CounterGrid.js b/resources/views/segments/index/CounterGrid/CounterGrid.js new file mode 100644 index 0000000..6f40cf9 --- /dev/null +++ b/resources/views/segments/index/CounterGrid/CounterGrid.js @@ -0,0 +1,69 @@ +var intervals = []; +var counters = []; +var steps = []; +var isCounterInited = false; + +function isElementInViewport(el) { + const rect = el.getBoundingClientRect(); + return ( + rect.top >= 0 && + rect.left >= 0 && + rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && + rect.right <= (window.innerWidth || document.documentElement.clientWidth) + ); +} + +function uncommafy(txt) { + return txt.split(',').join(''); +} + +function commafy(num) { + if (typeof num !== 'string') { + num = num.toString(); + } + let str = uncommafy(num.toString()).split('.'); + if (str[0].length >= 4) { + str[0] = str[0].replace(/(\d)(?=(\d{3})+$)/g, '$1,'); + } + if (str[1] && str[1].length >= 4) { + str[1] = str[1].replace(/(\d{3})/g, '$1 '); + } + return str.join('.'); +} + +document.addEventListener('DOMContentLoaded', function () { + + window.addEventListener('scroll', function() { + const container = document.getElementById('CounterGrid'); + if (isElementInViewport(container)) { + if (!isCounterInited){ + isCounterInited = true; + document.querySelectorAll('.grid-counter').forEach(function (el, key) { + + let max = parseInt(el.getAttribute('data-max')); + let min = parseInt(el.getAttribute('data-min')); + let diff = max - min; + counters[key] = 0; + steps[key] = parseInt(diff / 99); + + let tmp = setInterval(() => { + counters[key] += steps[key]; + document.querySelectorAll('.grid-counter')[key].innerHTML = commafy(counters[key]); + }, 100); + setTimeout(function () { + for (const i in intervals) { + clearInterval(intervals[i]); + document.querySelectorAll('.grid-counter')[key].innerHTML = commafy(document.querySelectorAll('.grid-counter')[key].getAttribute('data-max')); + } + + }, 9900); + intervals.push(tmp); + }); + } + // Remove event listener if you only want to alert once + this.removeEventListener('scroll', arguments.callee); + } + }); + + +}); diff --git a/resources/views/segments/index/CounterGrid/CounterGrid.json b/resources/views/segments/index/CounterGrid/CounterGrid.json new file mode 100644 index 0000000..a3e018c --- /dev/null +++ b/resources/views/segments/index/CounterGrid/CounterGrid.json @@ -0,0 +1,10 @@ +{ + "name": "CounterGrid", + "version": "1.0", + "author": "xStack", + "email": "xshop@xstack.ir", + "license": "GPL-3.0-or-later", + "url": "https:\/\/xstack.ir", + "author_url": "https:\/\/4xmen.ir", + "packages": [] +} \ No newline at end of file diff --git a/resources/views/segments/index/CounterGrid/CounterGrid.php b/resources/views/segments/index/CounterGrid/CounterGrid.php new file mode 100644 index 0000000..b7d7059 --- /dev/null +++ b/resources/views/segments/index/CounterGrid/CounterGrid.php @@ -0,0 +1,63 @@ +section = 'theme'; + $setting->key = $part->area->name . '_' . $part->part.'_title'.$i; + $setting->value = "Counter ".$i; + $setting->size = 4; + $setting->type = 'TEXT'; +// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]); + $setting->title = $part->area->name . ' ' . $part->part. ' title '.$i; + $setting->save(); + + $setting = new Setting(); + $setting->section = 'theme'; + $setting->key = $part->area->name . '_' . $part->part.'_icon'.$i; + $setting->value = 'ri-user-line'; + $setting->size = 4; + $setting->type = 'ICON'; +// $setting->data = json_encode(['xmin' => 2, 'xmax' => 6]); + $setting->title = $part->area->name . ' ' . $part->part. ' icon '.$i; + $setting->save(); + + $setting = new Setting(); + $setting->section = 'theme'; + $setting->key = $part->area->name . '_' . $part->part.'_number'.$i; + $setting->value = rand(100,4000); + $setting->size = 4; + $setting->type = 'NUMBER'; + $setting->data = json_encode(['xmin' => 0, 'xmax' => 9007199254740992]); + $setting->title = $part->area->name . ' ' . $part->part. ' number '.$i; + $setting->save(); + } + } + public static function onRemove(Part $part = null) + { + for ($i = 1; $i <= self::$count; $i++) { + Setting::where('key',$part->area->name . '_' . $part->part.'_title'.$i)->first()?->delete(); + Setting::where('key',$part->area->name . '_' . $part->part.'_icon'.$i)->first()?->delete(); + Setting::where('key',$part->area->name . '_' . $part->part.'_number'.$i)->first()?->delete(); + + } + } + public static function onMount(Part $part = null) + { + return $part; + } +} diff --git a/resources/views/segments/index/CounterGrid/CounterGrid.scss b/resources/views/segments/index/CounterGrid/CounterGrid.scss new file mode 100644 index 0000000..b65d9be --- /dev/null +++ b/resources/views/segments/index/CounterGrid/CounterGrid.scss @@ -0,0 +1,16 @@ +#CounterGrid { + padding: 4rem; + background: var(--xshop-secondary); + color: var(--xshop-diff); + text-align: center; + i{ + font-size: 128px; + display: block; + margin: .5rem auto; + -webkit-text-stroke: 6px var(--xshop-secondary); + } + + .grid-counter{ + font-size: 35px; + } +} diff --git a/resources/views/segments/index/CounterGrid/screenshot.png b/resources/views/segments/index/CounterGrid/screenshot.png new file mode 100644 index 0000000..15c3839 Binary files /dev/null and b/resources/views/segments/index/CounterGrid/screenshot.png differ