tripfy.js handles all UI enhancements and theming, while separate service worker files (serviceworker.js and firebase-messaging-sw.js) handle PWA caching and push notifications. Application assets are compiled through Vite.
tripfy.js — the main UI script
public/assets/themes/adventra/js/tripfy.js is the single JavaScript file loaded by the Adventra theme. It is an IIFE (immediately-invoked function expression) that runs with 'use strict'.
It covers:
Theme toggle
Reads and writes
localStorage key tf_theme. Applies data-theme to <html> before first paint to prevent flash.Scroll reveal
Uses
IntersectionObserver to add .tf-visible to .tf-reveal elements as they enter the viewport.Animated counters
Triggers number count-up animations on stat elements via
IntersectionObserver.Checkout steps
Exports
window.goToStep(n) to drive the multi-step checkout form with smooth scroll and fade transitions.Image zoom
Clicking
.open-modal[data-image] opens a full-screen overlay with the full-size image. Press Escape or click to close.Gateway selector
Clicking a
.gateway-option card selects that payment gateway and checks its underlying radio input.Theme system
tripfy.js exposes a unified TripfyTheme global so you can interact with the theme from any inline script:
window.HSThemeAppearance) used by the admin and user dashboard panels.
Any element with class tf-theme-toggle or attribute data-tf-theme-toggle is automatically wired as a toggle button after DOMContentLoaded.
Scroll reveal
Add the classtf-reveal to any element to opt it into the scroll-reveal animation. tripfy.js also automatically applies tf-reveal to a default set of selectors on DOMContentLoaded:
0.35s).
Sticky header
The header element with class.header-section receives a .scrolled class when the user scrolls more than 50px. Use this class in tripfy.css to apply a shadow or background change.
Checkout step manager
The checkout flow useswindow.goToStep(n) to show and hide .checkout-panel elements and update .checkout-step progress indicators:
tf-fadein keyframe. After switching steps, the page scrolls to the top.
Theme mode endpoint
For authenticated users, the selected theme is persisted server-side. The route is:{themeType} is one of auto, default, or dark. The route validates the value and updates auth()->user()->theme_mode:
GET /admin/themeMode/{themeType?} that stores the preference in the session instead.
AJAX patterns
The application makes AJAX calls for several features. All POST requests include the CSRF token from<meta name="csrf-token">.
Coupon check
Coupon check
Sends the coupon code to the server and returns the discount amount. The route is
POST /coupon/check (changed from GET to avoid coupon codes appearing in server logs):Chat
Chat
The messaging system uses several AJAX endpoints:
| Method | Route | Purpose |
|---|---|---|
POST | /chat/reply | Send a message |
GET | /chat/list | Load conversation list |
GET | /chat/search | Search conversations |
POST | /chat/details | Load messages for a conversation |
DELETE | /chat/{id}/delete | Delete a message |
POST | /chat/{id}/nickname-set | Set a nickname for a conversation |
Booking confirmation
Booking confirmation
Booking accept/reject operations use POST (changed from GET to prevent CSRF via URL):
Vite build setup
The project uses Vite with the Laravel Vite plugin. The entry points areresources/sass/app.scss and resources/js/app.js:
package.json:
| Package | Version | Purpose |
|---|---|---|
vite | ^4.0.0 | Build tool |
laravel-vite-plugin | ^0.7.5 | HMR and manifest integration |
bootstrap | ^5.2.3 | CSS framework |
@popperjs/core | ^2.11.6 | Bootstrap dropdown dependency |
sass | ^1.56.1 | SCSS compilation |
axios | ^1.1.2 | HTTP client for JS |
The Adventra theme’s
tripfy.css and tripfy.js are pre-built static assets in public/assets/themes/adventra/ and are not compiled by Vite. Vite only processes files in resources/sass/ and resources/js/.PWA service worker
serviceworker.js (in the project root) is the PWA service worker. It uses a versioned cache name based on the current timestamp:
app.js via:
Firebase push notifications
firebase-messaging-sw.js (in the project root) handles background push notifications via Firebase Cloud Messaging (FCM) v8: