From eea113d2d5b57111e7d5329fa4d20d0c2b11ead3 Mon Sep 17 00:00:00 2001 From: Alaguraj0361 Date: Thu, 11 Jun 2026 18:19:21 +0530 Subject: [PATCH] Add stats counter functionality and update theme styles for improved aesthetics --- .../dine360_theme_shivasakthi/__manifest__.py | 1 + .../static/src/js/stats_counter.js | 92 +++++++++++++++++++ .../static/src/scss/theme.scss | 4 + .../views/blog_page.xml | 2 - .../views/faq_page.xml | 2 - .../dine360_theme_shivasakthi/views/pages.xml | 13 +-- 6 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 addons/dine360_theme_shivasakthi/static/src/js/stats_counter.js diff --git a/addons/dine360_theme_shivasakthi/__manifest__.py b/addons/dine360_theme_shivasakthi/__manifest__.py index c14e410..0c820ae 100644 --- a/addons/dine360_theme_shivasakthi/__manifest__.py +++ b/addons/dine360_theme_shivasakthi/__manifest__.py @@ -30,6 +30,7 @@ 'dine360_theme_shivasakthi/static/src/scss/shop.scss', 'dine360_theme_shivasakthi/static/src/js/deal_switcher.js', 'dine360_theme_shivasakthi/static/src/js/category_slider.js', + 'dine360_theme_shivasakthi/static/src/js/stats_counter.js', ], }, 'images': [ diff --git a/addons/dine360_theme_shivasakthi/static/src/js/stats_counter.js b/addons/dine360_theme_shivasakthi/static/src/js/stats_counter.js new file mode 100644 index 0000000..afaf27e --- /dev/null +++ b/addons/dine360_theme_shivasakthi/static/src/js/stats_counter.js @@ -0,0 +1,92 @@ +/** @odoo-module **/ + +import publicWidget from "@web/legacy/js/public/public_widget"; + +publicWidget.registry.StatsCounter = publicWidget.Widget.extend({ + selector: '.s_stats_section', + start: function () { + this.$counters = this.$('.stat-counter'); + if (!this.$counters.length) { + return this._super.apply(this, arguments); + } + + // Initialize IntersectionObserver to track when stats section is in view + this.observer = new IntersectionObserver((entries) => { + entries.forEach(entry => { + if (entry.isIntersecting) { + this._animateCounters(); + } else { + this._resetCounters(); + } + }); + }, { threshold: 0.1 }); + + this.observer.observe(this.el); + + return this._super.apply(this, arguments); + }, + + destroy: function () { + if (this.observer) { + this.observer.disconnect(); + } + this._super.apply(this, arguments); + }, + + /** + * Formats numerical value to human readable format (e.g. 2000 -> 2K) + * @param {number} value + * @returns {string|number} + */ + _formatValue: function (value) { + if (value >= 1000) { + const kValue = value / 1000; + return kValue % 1 === 0 ? kValue.toFixed(0) + 'K' : kValue.toFixed(1) + 'K'; + } + return value; + }, + + _animateCounters: function () { + this.$counters.each((index, el) => { + const $el = $(el); + if ($el.data('animating')) return; + $el.data('animating', true); + + const target = parseFloat($el.data('target')) || 0; + const suffix = $el.data('suffix') || ''; + const duration = 1500; // 1.5 seconds animation + const startTime = performance.now(); + + const updateCount = (currentTime) => { + const elapsedTime = currentTime - startTime; + const progress = Math.min(elapsedTime / duration, 1); + + // easeOutQuad easing function + const easeProgress = progress * (2 - progress); + + const currentValue = Math.floor(easeProgress * target); + $el.text(this._formatValue(currentValue) + suffix); + + if (progress < 1) { + requestAnimationFrame(updateCount); + } else { + $el.text(this._formatValue(target) + suffix); + $el.data('animating', false); + } + }; + + requestAnimationFrame(updateCount); + }); + }, + + _resetCounters: function () { + this.$counters.each((index, el) => { + const $el = $(el); + const suffix = $el.data('suffix') || ''; + $el.text('0' + suffix); + $el.data('animating', false); + }); + } +}); + +export default publicWidget.registry.StatsCounter; diff --git a/addons/dine360_theme_shivasakthi/static/src/scss/theme.scss b/addons/dine360_theme_shivasakthi/static/src/scss/theme.scss index d8ea031..5f4be68 100644 --- a/addons/dine360_theme_shivasakthi/static/src/scss/theme.scss +++ b/addons/dine360_theme_shivasakthi/static/src/scss/theme.scss @@ -3185,3 +3185,7 @@ body.o_edit_mode { box-shadow: 0 5px 15px rgba(255,184,0,0.2) !important; outline: none !important; } + +/* Enforce section title font size and weight */ +section h2.display-4, section h2.display-5, section h2.testi-main-title, section h2.thali-subtitle, section h2 { font-size: 56px !important; font-weight: 400 !important; } + diff --git a/addons/dine360_theme_shivasakthi/views/blog_page.xml b/addons/dine360_theme_shivasakthi/views/blog_page.xml index 953d786..f34a6e3 100644 --- a/addons/dine360_theme_shivasakthi/views/blog_page.xml +++ b/addons/dine360_theme_shivasakthi/views/blog_page.xml @@ -26,9 +26,7 @@
- BLOG -

News & Articles

diff --git a/addons/dine360_theme_shivasakthi/views/faq_page.xml b/addons/dine360_theme_shivasakthi/views/faq_page.xml index 21153d9..a0ccf82 100644 --- a/addons/dine360_theme_shivasakthi/views/faq_page.xml +++ b/addons/dine360_theme_shivasakthi/views/faq_page.xml @@ -30,9 +30,7 @@
- Shivasakthi -

Frequently Asked Questions

diff --git a/addons/dine360_theme_shivasakthi/views/pages.xml b/addons/dine360_theme_shivasakthi/views/pages.xml index e2e6c01..e799f2f 100644 --- a/addons/dine360_theme_shivasakthi/views/pages.xml +++ b/addons/dine360_theme_shivasakthi/views/pages.xml @@ -130,10 +130,7 @@
- - - - +
@@ -148,9 +145,7 @@
- Real . authentic . South Indian -

Welcome to Shiva Sakthi Restaurant

@@ -181,19 +176,19 @@

-

20+

+

0+

~~~~

Experience Chefs

-

2K+

+

0+

~~~~

Happy Customers

-

40+

+

0+

~~~~

Favorite Dishes