Now.js Framework Documentation
Now.js Framework
Now.js Framework
Modern JavaScript Framework that Minimizes Code Writing
Write Less JavaScript, Achieve More with the Power of Data Attributes
Overview
Now.js is a JavaScript Framework designed to minimize JavaScript coding by using Data Attributes to control web page behavior and automatically invoke pre-installed features.
Core Philosophy
<!-- Instead of writing JavaScript like this... -->
<script>
document.querySelector('#myForm').addEventListener('submit', async (e) => {
e.preventDefault();
const data = new FormData(e.target);
await fetch('/api/submit', { method: 'POST', body: data });
});
</script>
<!-- Just use Data Attributes! -->
<form data-form data-action="/api/submit" data-method="POST">
<!-- Your form content -->
</form>No additional JavaScript needed! The framework handles everything automatically.
Key Features
Zero JavaScript Writing
- No JavaScript required for common tasks
- Control everything through HTML Data Attributes
- Automatic initialization on page load
Component-Based Architecture
- Powerful Component System
- Two-Way Reactive Data Binding
- Built-in Template Engine
- Automatic State Management
Rich UI Components
- Form Management - Automatic form handling
- DataTable - Data tables with sorting, filtering, pagination
- Animation System - Easy-to-use animation system
- Modal & Dialog - Ready-to-use popups and dialogs
- Autocomplete - Automatic search system
- Calendar - Calendar and date picker
- File Upload - File upload with preview
- Tags Input - Easy-to-use tag system
Advanced Features
- Router System - Single Page Application (SPA) Routing
- HTTP Client - Automatic API request handling
- Authentication - Auth system with Token Management
- i18n Support - Multi-language support
- Service Worker - PWA Support
- Error Handling - Automatic error management
- Event System - Powerful event system
Framework Goals
Now.js aims to:
- Minimize JavaScript writing as much as possible
- Increase development efficiency using Data Attributes
- Work automatically without additional code
- Simplify complexity for developers
- Support all use cases from simple websites to large SPAs
Getting Started
Installation
<!-- Method 1: Use CDN -->
<script src="https://cdn.example.com/now.js"></script>
<!-- Method 2: Download and use locally -->
<script src="/path/to/Now.js"></script>Basic Usage Examples
1. Form Management
<form data-form data-action="/api/users" data-method="POST">
<input type="text" name="name" data-required>
<input type="email" name="email" data-required data-validate="email">
<button type="submit">Save</button>
</form>Automatic features:
- ✅ Validation
- ✅ AJAX Submission
- ✅ Error Handling
- ✅ Loading States
2. DataTable
<table data-table
data-source="/api/users"
data-pagination="true"
data-search="true">
<thead>
<tr>
<th data-sort="name">Name</th>
<th data-sort="email">Email</th>
<th data-field="actions">Actions</th>
</tr>
</thead>
</table>Automatic features:
- ✅ Data Loading
- ✅ Sorting
- ✅ Filtering
- ✅ Pagination
- ✅ Search
3. Animation
<div data-show="fadeIn" data-hide="fadeOut">
Animated content
</div>
<button data-on-click="toggle" data-target="#myElement">
Toggle Display
</button>4. Component System
<div data-component="UserProfile" data-user-id="123">
<h2 data-bind="user.name"></h2>
<p data-bind="user.email"></p>
<ul data-for="post in user.posts">
<li data-bind="post.title"></li>
</ul>
</div>Documentation
Core Modules
Form & Input
- FormManager - Automatic form management
- FormError - Form error handling
- ElementFactory - Custom form element creation
Data & API
- ApiComponent - API-connected components
- ApiService - API request management
- HttpClient - Basic HTTP client
- ResponseHandler - Response handling
Table & Data Display
- TableManager - DataTable management
- GraphComponent - Charts and graphs
Routing & Navigation
- RouterManager - SPA Router System
- ScrollManager - Scroll management
Authentication
- AuthManager - Authentication system
- AuthGuard - Route protection
- AuthErrorHandler - Auth error handling
- AuthLoadingManager - Loading states
- TokenService - Token management
Events & Interactions
- EventManager - Core event system
- EventSystemManager - Event system management
Internationalization
- I18nManager - Multi-language system
Progressive Web App
- ServiceWorkerManager - PWA Support
Guides
- HTTP & API Guide - HTTP and API usage guide
- Authentication Guide - Authentication system guide
Real-World Examples
Example 1: CRUD Form
<form data-form
data-action="/api/products"
data-method="POST"
data-on-success="redirect:/products">
<input type="text"
name="name"
data-required
data-min-length="3"
placeholder="Product Name">
<input type="number"
name="price"
data-required
data-min="0"
placeholder="Price">
<select name="category" data-required>
<option value="">Select Category</option>
<option value="1">Electronics</option>
<option value="2">Clothing</option>
</select>
<textarea name="description"
data-required
placeholder="Description"></textarea>
<button type="submit">Save</button>
</form>Example 2: Interactive DataTable
<table data-table
data-source="/api/products"
data-pagination="true"
data-page-size="10"
data-search="true"
data-row-actions="edit,delete">
<thead>
<tr>
<th data-sort="name" data-field="name">Product Name</th>
<th data-sort="price" data-field="price">Price</th>
<th data-field="category">Category</th>
<th data-field="actions">Actions</th>
</tr>
</thead>
</table>Example 3: Reactive Component
<div data-component="ProductList" data-source="/api/products">
<!-- Search -->
<input type="text"
data-model="search"
placeholder="Search products">
<!-- Product List -->
<div data-for="product in filteredProducts">
<div class="product-card">
<h3 data-bind="product.name"></h3>
<p data-bind="product.price" data-format="currency"></p>
<button data-on-click="addToCart(product.id)">
Add to Cart
</button>
</div>
</div>
<!-- Empty State -->
<div data-if="filteredProducts.length === 0">
<p>No products found</p>
</div>
</div>Architecture
Framework Workflow
graph TD
A[HTML with Data Attributes] --> B[Now.js Core]
B --> C[Auto-Initialize Components]
C --> D[Form Manager]
C --> E[Table Manager]
C --> F[Component Manager]
C --> G[Router Manager]
C --> H[Event Manager]
D --> I[Automatic Validation]
D --> J[AJAX Submission]
E --> K[Data Loading]
E --> L[Sorting & Filtering]
F --> M[Reactive Binding]
F --> N[State Management]
G --> O[SPA Navigation]
H --> P[Event Handling]Execution Steps
- Load Now.js - Framework loads and becomes ready
- Scan DOM - Find elements with Data Attributes
- Auto-Initialize - Create Components and Managers automatically
- Bind Events - Attach Event Handlers based on Attributes
- Ready - Ready to use without additional code
Core Concepts
1. Declarative Programming
Use HTML Attributes to declare what you want instead of coding how to do it
2. Convention over Configuration
Use sensible defaults, reduce complex configuration
3. Progressive Enhancement
Start with basics, add features as needed
4. Zero Configuration
Works immediately without setup
Important Data Attributes
Form Attributes
data-form- Define as managed formdata-action- URL for data submissiondata-method- HTTP Method (GET, POST, PUT, DELETE)data-required- Required fielddata-validate- Validation rulesdata-on-success- Action on successdata-on-error- Action on error
Table Attributes
data-table- Define as managed tabledata-source- URL for data loadingdata-pagination- Enable/disable paginationdata-search- Enable/disable searchdata-sort- Sortable columndata-row-actions- Actions for each row
Component Attributes
data-component- Component namedata-bind- Data bindingdata-model- Two-way data bindingdata-for- Loop templatedata-if- Conditional renderingdata-show- Show animationdata-hide- Hide animation
Event Attributes
data-on-click- Click eventdata-on-change- Change eventdata-on-submit- Submit eventdata-target- Target element
Advantages of Now.js
For Developers
- ✅ Write less code - Reduce development time
- ✅ Easy to read - Code is easy to understand and maintain
- ✅ No build required - No Webpack, Babel, etc.
- ✅ Easy to learn - Low learning curve
- ✅ Flexible - Works with other libraries
For Projects
- ✅ Performance - Fast loading, fast execution
- ✅ Maintainable - Easy to maintain
- ✅ Scalable - Scales as needed
- ✅ SEO Friendly - SEO support
- ✅ Accessible - Accessibility support
When to Use Now.js
Ideal For
- ✅ General web applications
- ✅ Admin Panels / Dashboards
- ✅ CRUD Applications
- ✅ Forms-heavy Applications
- ✅ Data-intensive Applications
- ✅ Single Page Applications (SPA)
- ✅ Progressive Web Apps (PWA)
May Not Be Ideal For
- ❌ Games requiring very high performance
- ❌ Very complex real-time applications
- ❌ 3D Graphics Applications
Learning Path
Recommended Steps
-
Start with Basics
- Read FormManager to learn form management
- Try creating a simple form
-
Understand Data Attributes
- Study commonly used attributes
- Try them in a small project
-
Learn Components
- Read ApiComponent
- Create your first component
-
Study Advanced Features
- RouterManager for SPA
- AuthManager for authentication
- TableManager for DataTable
-
Build Real Projects
- Apply knowledge to real projects
- Experiment with different features
License
Now.js is released under the MIT License.
Ready to Get Started?
Start using Now.js today and experience web development where you write less code and achieve more!
<!-- That's all you need! -->
<script src="Now.js"></script>