First Commit
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
||||
{% extends "@pagebuilder/admin/form.twig" %}
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
{% extends "@pagebuilder/admin/form.twig" %}
|
||||
Executable
+130
@@ -0,0 +1,130 @@
|
||||
{% extends "layouts/dashboard.twig" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">{{ title }}</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if session_has('success') %}
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ session_get('success') }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if errors|length > 0 %}
|
||||
<div class="alert alert-danger">
|
||||
<ul class="mb-0">
|
||||
{% for error in errors.all() %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form action="{{ page ? url('/admin/pages/' ~ page.pages_id) : url('/admin/pages') }}" method="POST">
|
||||
{% if page %}
|
||||
<input type="hidden" name="_method" value="PUT">
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="mb-3">
|
||||
<label for="pages_title" class="form-label">{{ __('pagebuilder.title') }} *</label>
|
||||
<input type="text" class="form-control" id="pages_title" name="pages_title" value="{{ old('pages_title', page.pages_title ?? '') }}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="mb-3">
|
||||
<label for="pages_slug" class="form-label">{{ __('pagebuilder.slug') }} *</label>
|
||||
<input type="text" class="form-control" id="pages_slug" name="pages_slug" value="{{ old('pages_slug', page.pages_slug ?? '') }}" required>
|
||||
<div class="form-text">{{ __('pagebuilder.slug_help') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="pages_content" class="form-label">{{ __('pagebuilder.form.content_label') }}</label>
|
||||
<div id="quill-editor" style="height: 300px;" data-target="pages_content">{{ old('pages_content', page.pages_content ?? '')|raw }}</div>
|
||||
<textarea class="form-control" id="pages_content" name="pages_content" style="display:none">{{ old('pages_content', page.pages_content ?? '') }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="pages_meta_title" class="form-label">{{ __('pagebuilder.meta_title') }}</label>
|
||||
<input type="text" class="form-control" id="pages_meta_title" name="pages_meta_title" value="{{ old('pages_meta_title', page.pages_meta_title ?? '') }}">
|
||||
<div class="form-text">{{ __('pagebuilder.meta_title_help') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="pages_meta_keywords" class="form-label">{{ __('pagebuilder.meta_keywords') }}</label>
|
||||
<input type="text" class="form-control" id="pages_meta_keywords" name="pages_meta_keywords" value="{{ old('pages_meta_keywords', page.pages_meta_keywords ?? '') }}">
|
||||
<div class="form-text">{{ __('pagebuilder.meta_keywords_help') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="pages_meta_description" class="form-label">{{ __('pagebuilder.meta_description') }}</label>
|
||||
<textarea class="form-control" id="pages_meta_description" name="pages_meta_description" rows="3">{{ old('pages_meta_description', page.pages_meta_description ?? '') }}</textarea>
|
||||
<div class="form-text">{{ __('pagebuilder.meta_description_help') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" id="pages_is_published" name="pages_is_published" value="1" {{ old('pages_is_published', page.pages_is_published ?? false) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="pages_is_published">{{ __('pagebuilder.published') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-4">
|
||||
<a href="{{ url('/admin/pages') }}" class="btn btn-secondary">
|
||||
<i class="bi bi-arrow-left"></i> {{ __('pagebuilder.form.back') }}
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save"></i> {{ page ? __('pagebuilder.form.update_button') : __('pagebuilder.form.create_button') }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Auto-generate slug from title
|
||||
const titleInput = document.getElementById('pages_title');
|
||||
const slugInput = document.getElementById('pages_slug');
|
||||
|
||||
titleInput.addEventListener('input', function() {
|
||||
if (!slugInput.value || slugInput.dataset.autoGenerated === 'true') {
|
||||
slugInput.value = this.value.toLowerCase()
|
||||
.replace(/[^\w\s-]/g, '') // Remove special characters
|
||||
.replace(/\s+/g, '-') // Replace spaces with hyphens
|
||||
.replace(/-+/g, '-'); // Replace multiple hyphens with single hyphen
|
||||
|
||||
slugInput.dataset.autoGenerated = 'true';
|
||||
}
|
||||
});
|
||||
|
||||
slugInput.addEventListener('input', function() {
|
||||
slugInput.dataset.autoGenerated = 'false';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Executable
+142
@@ -0,0 +1,142 @@
|
||||
{% extends "layouts/dashboard.twig" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">{{ __('pagebuilder.manage_pages') }}</h5>
|
||||
<a href="{{ url('admin/pages/create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg"></i> {{ __('pagebuilder.new_page') }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if session_has('success') %}
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ session_get('success') }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if pages|length > 0 %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('pagebuilder.title') }}</th>
|
||||
<th>{{ __('pagebuilder.slug') }}</th>
|
||||
<th>{{ __('pagebuilder.status') }}</th>
|
||||
<th>{{ __('pagebuilder.theme') }}</th>
|
||||
<th>{{ __('pagebuilder.author') }}</th>
|
||||
<th>{{ __('pagebuilder.updated_at') }}</th>
|
||||
<th>{{ __('pagebuilder.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for page in pages %}
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ page.pages_title }}</strong>
|
||||
{% if page.pages_meta_title %}
|
||||
<br><small class="text-muted">{{ __('pagebuilder.meta_title') }}: {{ page.pages_meta_title|slice(0, 50) }}{% if page.pages_meta_title|length > 50 %}...{% endif %}</small>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<code>{{ page.pages_slug }}</code>
|
||||
</td>
|
||||
<td>
|
||||
{% if page.pages_is_published %}
|
||||
<span class="badge bg-success">{{ __('pagebuilder.published') }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">{{ __('pagebuilder.draft') }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if page.theme %}
|
||||
<span class="badge bg-info">{{ page.theme.themes_name }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted">{{ __('pagebuilder.default') }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ page.creator ? page.creator.name : '-' }}</td>
|
||||
<td>{{ page.updated_at|date('d/m/Y H:i') }}</td>
|
||||
<td>
|
||||
<div class="btn-group" role="group">
|
||||
<a href="{{ page.url }}" class="btn btn-sm btn-outline-primary" target="_blank" title="{{ __('pagebuilder.view') }}">
|
||||
<i class="bi bi-eye"></i>
|
||||
</a>
|
||||
<a href="{{ url('/admin/pages/' ~ page.pages_id ~ '/edit') }}" class="btn btn-sm btn-outline-secondary" title="{{ __('pagebuilder.edit') }}">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-outline-info dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" title="{{ __('pagebuilder.more_actions') }}">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{% if page.pages_is_published %}
|
||||
<li>
|
||||
<form action="{{ url('/admin/pages/' ~ page.pages_id ~ '/unpublish') }}" method="POST" style="display: inline;">
|
||||
<button type="submit" class="dropdown-item">
|
||||
<i class="bi bi-file-text"></i> {{ __('pagebuilder.set_as_draft') }}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<form action="{{ url('/admin/pages/' ~ page.pages_id ~ '/publish') }}" method="POST" style="display: inline;">
|
||||
<button type="submit" class="dropdown-item">
|
||||
<i class="bi bi-check-lg"></i> {{ __('pagebuilder.publish') }}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
|
||||
<li>
|
||||
<form action="{{ url('/admin/pages/' ~ page.pages_id) }}" method="POST" onsubmit="return confirm('{{ __('pagebuilder.confirm_delete') }}')" style="display: inline;">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<button type="submit" class="dropdown-item text-danger">
|
||||
<i class="bi bi-trash"></i> {{ __('pagebuilder.delete') }}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% if paginator.total_pages > 1 %}
|
||||
<div class="d-flex justify-content-center mt-4">
|
||||
{% include 'components/paginator.twig' with {'paginator': {
|
||||
'total_pages': paginator.last_page,
|
||||
'current_page': paginator.current_page,
|
||||
'has_prev': paginator.has_previous_pages,
|
||||
'has_next': paginator.has_more_pages,
|
||||
'base_url': url('/admin/pages?page=')
|
||||
}} %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="text-center py-5">
|
||||
<i class="bi bi-file-text fs-1 text-muted mb-3"></i>
|
||||
<h5>{{ __('pagebuilder.no_pages_found') }}</h5>
|
||||
<p class="text-muted">{{ __('pagebuilder.start_creating_page') }}</p>
|
||||
<a href="{{ url('admin/pages/create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg"></i> {{ __('pagebuilder.create_button') }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Executable
+300
@@ -0,0 +1,300 @@
|
||||
{% extends "layouts/base.twig" %}
|
||||
|
||||
{% block title %}{{ title|default(__('index.welcome_title', {'platformName': platformName})) }} - {{ platformName }}{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link href="{{ asset_url('css/landing-page.css') }}" rel="stylesheet">
|
||||
<style>
|
||||
.hero-section {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 100px 0;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
.hero-title {
|
||||
font-size: 3.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 20px;
|
||||
text-shadow: 0 2px 4px rgba(0,0,0,0.3);
|
||||
}
|
||||
.hero-subtitle {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 30px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.feature-card {
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
border: none;
|
||||
border-radius: 15px;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
.feature-card:hover {
|
||||
transform: translateY(-10px);
|
||||
box-shadow: 0 15px 30px rgba(0,0,0,0.15);
|
||||
}
|
||||
.feature-icon {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 20px;
|
||||
color: #667eea;
|
||||
}
|
||||
.stats-section {
|
||||
background-color: #f8f9fa;
|
||||
padding: 80px 0;
|
||||
}
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.stat-number {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
color: #667eea;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.btn-hero {
|
||||
padding: 15px 30px;
|
||||
font-size: 1.2rem;
|
||||
border-radius: 50px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.btn-hero:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
|
||||
}
|
||||
.btn-outline-hero {
|
||||
background: transparent;
|
||||
border: 2px solid white;
|
||||
color: white;
|
||||
margin-left: 15px;
|
||||
}
|
||||
.btn-outline-hero:hover {
|
||||
background: white;
|
||||
color: #667eea;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 20px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
.section-title:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 80px;
|
||||
height: 4px;
|
||||
background: #667eea;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.section-subtitle {
|
||||
text-align: center;
|
||||
max-width: 700px;
|
||||
margin: 0 auto 60px;
|
||||
font-size: 1.1rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block layout_navbar %}
|
||||
{% include 'partials/nav-bar.twig' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block layout_body %}
|
||||
<!-- Hero Section -->
|
||||
<section class="hero-section">
|
||||
<div class="container">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-lg-6">
|
||||
<h1 class="hero-title">{{ title|default(__('index.welcome_title', {'platformName': platformName})) }}</h1>
|
||||
<p class="hero-subtitle">{{ meta_description|default(__('index.welcome_message')) }}</p>
|
||||
<div class="hero-buttons">
|
||||
<a href="{{ url('login') }}" class="btn btn-light btn-hero">{{ __('index.get_started') }}</a>
|
||||
<a href="#features" class="btn btn-outline-hero btn-hero">{{ __('index.learn_more') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<img src="{{ asset_url('img/laptop-593673_1280.jpg') }}" alt="{{ platformName }} Dashboard" class="img-fluid rounded shadow-lg">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% if page and page.content %}
|
||||
<!-- Dynamic Content Section -->
|
||||
<section class="py-5">
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-10">
|
||||
<div class="content">
|
||||
{{ page.content|raw }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% else %}
|
||||
<!-- Default Content -->
|
||||
<!-- Features Section -->
|
||||
<section id="features" class="py-5">
|
||||
<div class="container">
|
||||
<h2 class="section-title">{{ __('index.features_title') }}</h2>
|
||||
<p class="section-subtitle">{{ __('index.features_subtitle', {'platformName': platformName}) }}</p>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card feature-card h-100">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="bi bi-rocket-takeoff"></i>
|
||||
</div>
|
||||
<h3 class="card-title">{{ __('index.feature1_title') }}</h3>
|
||||
<p class="card-text">{{ __('index.feature1_desc') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card feature-card h-100">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="bi bi-shield-check"></i>
|
||||
</div>
|
||||
<h3 class="card-title">{{ __('index.feature2_title') }}</h3>
|
||||
<p class="card-text">{{ __('index.feature2_desc') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card feature-card h-100">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="bi bi-graph-up-arrow"></i>
|
||||
</div>
|
||||
<h3 class="card-title">{{ __('index.feature3_title') }}</h3>
|
||||
<p class="card-text">{{ __('index.feature3_desc') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card feature-card h-100">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="bi bi-people"></i>
|
||||
</div>
|
||||
<h3 class="card-title">{{ __('index.feature4_title') }}</h3>
|
||||
<p class="card-text">{{ __('index.feature4_desc') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card feature-card h-100">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="bi bi-phone"></i>
|
||||
</div>
|
||||
<h3 class="card-title">{{ __('index.feature5_title') }}</h3>
|
||||
<p class="card-text">{{ __('index.feature5_desc') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card feature-card h-100">
|
||||
<div class="card-body text-center p-4">
|
||||
<div class="feature-icon">
|
||||
<i class="bi bi-gear-wide-connected"></i>
|
||||
</div>
|
||||
<h3 class="card-title">{{ __('index.feature6_title') }}</h3>
|
||||
<p class="card-text">{{ __('index.feature6_desc') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Stats Section -->
|
||||
<section class="stats-section">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="stat-item">
|
||||
<div class="stat-number" data-count="500">0</div>
|
||||
<p>{{ __('index.stat1') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="stat-item">
|
||||
<div class="stat-number" data-count="1200">0</div>
|
||||
<p>{{ __('index.stat2') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="stat-item">
|
||||
<div class="stat-number" data-count="99">0</div>
|
||||
<p>{{ __('index.stat3') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="stat-item">
|
||||
<div class="stat-number" data-count="24">0</div>
|
||||
<p>{{ __('index.stat4') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<!-- CTA Section -->
|
||||
<section class="cta-section" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 80px 0; text-align: center;">
|
||||
<div class="container">
|
||||
<h2 class="section-title text-white">{{ __('index.cta_title') }}</h2>
|
||||
<p class="section-subtitle text-white">{{ __('index.cta_subtitle', {'platformName': platformName}) }}</p>
|
||||
<a href="{{ url('login') }}" class="btn btn-light btn-hero">{{ __('index.cta_button') }}</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
// Animated Counter for Stats
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const counters = document.querySelectorAll('.stat-number');
|
||||
const speed = 200;
|
||||
|
||||
const countUp = function() {
|
||||
counters.forEach(counter => {
|
||||
const target = +counter.getAttribute('data-count');
|
||||
const count = +counter.innerText;
|
||||
const increment = target / speed;
|
||||
|
||||
if (count < target) {
|
||||
counter.innerText = Math.ceil(count + increment);
|
||||
setTimeout(countUp, 10);
|
||||
} else {
|
||||
counter.innerText = target;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Trigger counter animation when stats section is in view
|
||||
const statsSection = document.querySelector('.stats-section');
|
||||
if (statsSection) {
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
countUp();
|
||||
observer.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, { threshold: 0.5 });
|
||||
|
||||
observer.observe(statsSection);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user