yBox 13.0.1
A lightweight, flexible, and modern lightbox library. ספרייה קלה, גמישה ומודרנית ל-lightbox.
Installation & Filesהתקנה וקבצים
Include the CSS and JS files in your project: הוסיפו את קבצי ה-CSS וה-JS בפרויקט:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/yuvalAshkenaz/yBox/dist/css/ybox.min.css" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/yuvalAshkenaz/yBox/dist/js/ybox.min.js?lang=he"></script>
You can download the files from Github:
ניתן להוריד את הקבצים מ-Github:
Helper Classesקלאסים עיקריים
Add this class to any element with a
href or data-href to open it in the lightbox.
נדרש על כל אלמנט טריגר.הוסף קלאס זה לכל אלמנט עם
href או data-href כדי לפתוח אותו בלייטבוקס.
href / data-href link inside an iframe container.
פותח את הקישור שב-href / data-href בתוך iframe.
href / data-href attribute.
טוען תוכן באמצעות AJAX מה-href / data-href.
By default shares the current page URL.
Use
href or data-href to share a custom URL instead.
פותח מודאל שיתוף ברשתות חברתיות.כברירת מחדל משתף את כתובת הדף הנוכחי.
השתמש ב-
href או data-href לשיתוף כתובת מותאמת.
JavaScript API Parametersפרמטרי JavaScript API
yBox({ code: '<div>Hello</div>' });
הזרקת HTML ישירות.yBox({ code: '<div>שלום</div>' });
yBox({ url: 'https://example.com' });
פתיחת כתובת URL ב-iframe.yBox({ url: 'https://example.com' });
<a href="#popup" class="yBox my-link">The link</a>
<script> yBox({ self: '.my-link' }); </script>
העברת אלמנט DOM (בד"כ הכפתור שנלחץ) לירושת התכונות שלו.<a href="#popup" class="yBox my-link">הקישור</a>
<script> yBox({ self: '.my-link' }); </script>
.yBoxOverlay.yBox({ yBoxClass: 'custom-theme' });
הוספת קלאס מותאם ל-wrapper הראשי .yBoxOverlay.yBox({ yBoxClass: 'custom-theme' });
yBox({ focus: '.input-field' });
selector של אלמנט שיקבל פוקוס לאחר הפתיחה.yBox({ focus: '.input-field' });
yBox({ id: '#my-hidden-div' });
בחירת אלמנט מה-DOM (גם אם מוסתר) והצגתו.yBox({ id: '#my-hidden-div' });
HTML Attributesתכונות HTML
Both work identically — use
data-href when href is semantically incorrect (e.g. on a <div> or <button>).href="#my-popup" / data-href="#my-popup"
כתובת ה-URL או הסלקטור לפתיחה.שניהם עובדים זהה — השתמש ב-
data-href כשאין משמעות סמנטית ל-href (למשל על <div> או <button>).href="#my-popup" / data-href="#my-popup"
Use
"no-bg" to remove the default white background.
מוסיף קלאס מותאם לחלון הפופאפ.השתמש ב-
"no-bg" להסרת הרקע הלבן.
alt attribute for the opened image.
קובע את תכונת ה-alt לתמונה שנפתחת.
title attribute for iframe or image.
קובע את תכונת ה-title ל-iframe או תמונה.
<h2> headline above the content.
מוסיף כותרת <h2> מעל התוכן.
Targeting Elements (href / data-href)מיקוד אלמנטים (href / data-href)
Use href or data-href on your trigger element to target specific hidden elements or URLs. Both attributes work identically.
השתמש ב-href או data-href על אלמנט הטריגר כדי למקד אלמנטים מוסתרים או כתובות URL. שתי התכונות עובדות באופן זהה.
href="#my-popup" / data-href="#my-popup"Opens the element with the exact ID. If the ID is not found, yBox automatically falls back to searching for a class named
.my-popup.
פותח את האלמנט עם ה-ID המדויק. אם לא נמצא, yBox עובר אוטומטית לחיפוש קלאס בשם .my-popup.
href=".my-popup" / data-href=".my-popup"Opens an element by its class. Perfect for dynamic content loops (like product cards or blog posts).
- First, yBox looks for the class inside the clicked button.
- If not found, it opens the element that matches the index of the clicked button.
- תחילה yBox מחפש את הקלאס בתוך הכפתור שנלחץ.
- אם לא נמצא, פותח את האלמנט שתואם ל-אינדקס של הכפתור.
URL Parametersפרמטרי URL
You can trigger yBox automatically on page load by adding parameters to the URL query string. ניתן להפעיל את yBox אוטומטית בטעינת הדף על ידי הוספת פרמטרים ל-query string של ה-URL.
URL Example:
https://yourdomain.com/page?ybox-id=my-popupRequired HTML structure: פותח אוטומטית אלמנט ספציפי בטעינת הדף.
דוגמת URL:
https://yourdomain.com/page?ybox-id=my-popupמבנה HTML נדרש:
<div style="display:none;">
<div id="my-popup">
Content opens automatically!
</div>
</div>
JavaScript Execution Examplesדוגמאות הרצת JavaScript
Open on page loadפתיחה בטעינת הדף
<script>
yBox({
code: '<div class="p-5">Welcome to yBox!</div>'
});
</script>
Call specific hidden elementפתיחת אלמנט מוסתר ספציפי
yBox({ id: '#popup' });
Event Callbacksקולבאקים
Hook into the lifecycle of the modal. התחבר למחזור החיים של המודאל.
function beforeYboxOpen(self){ ... }
function afterYboxOpen(self){ ... }
function beforeYboxClose(self){ ... }
function afterYboxClose(self){ ... }
Nested yBox (Modal inside Modal)yBox מקונן (מודאל בתוך מודאל)
Media Embedsהטמעת מדיה
YouTube / Vimeo (Iframe)YouTube / Vimeo (Iframe)
Self-Hosted Video (MP4)סרטון מאוחסן עצמאית (MP4)
Custom Styling & AJAXעיצוב מותאם ו-AJAX
Imageתמונה
Gallery Groupsגלריות
Add data-ybox-group="groupname" to create a gallery.
הוסף data-ybox-group="groupname" ליצירת גלריה.
Social Sharingשיתוף ברשתות
There are two ways to add sharing buttons to a page: ישנן שתי דרכים להוסיף כפתורי שיתוף לדף:
Option 1: Share popup (
.yBox_share)אפשרות 1: פופאפ שיתוף (.yBox_share)A single trigger button opens a modal with all sharing options.
By default shares the current page URL.
Add
hrefordata-hrefto share a specific URL instead. כפתור טריגר אחד פותח מודאל עם כל אפשרויות השיתוף.כברירת מחדל משתף את כתובת הדף הנוכחי.
הוסף
hrefאוdata-hrefלשיתוף כתובת ספציפית.Option 2: Inline share buttonsאפשרות 2: כפתורי שיתוף מוטמעים
Place individual share buttons directly in the page — no popup involved.
Each button needs only the platform class (e.g.
ybox-facebook-share-btn).Add
hrefordata-hrefon the button itself to share a specific URL, or on the wrapping<ul>to apply the same URL to all buttons inside. מקם כפתורי שיתוף ישירות בדף ללא פופאפ.לכל כפתור נדרש רק קלאס הפלטפורמה (למשל
ybox-facebook-share-btn).הוסף
hrefאוdata-hrefעל הכפתור עצמו, או על ה-<ul>העוטף כדי שכל הכפתורים בפנים יירשו אותו.Available platform classes: קלאסי פלטפורמה זמינים:
ybox-facebook-share-btn,ybox-whatsapp-share-btn,ybox-twitter-share-btn,ybox-linkedin-share-btn,ybox-pinterest-share-btn,ybox-telegram-share-btn,ybox-copy-text-btn,ybox-print.