This post is also available in: فارسی (Persian)

There is nothing to show here!
Slider with alias شرکتی not found.
/* ========================================================= JAHAN PASHA ABOUT SECTION SCRIPT ========================================================= */ (function () { function initJahanPashaAbout() { const sections = document.querySelectorAll( '.jp-about-section' ); sections.forEach(function (section) { /* ----------------------------------------------- جلوگیری از اجرای دوباره ----------------------------------------------- */ if ( section.dataset.jpAboutInitialized === 'true' ) { return; } section.dataset.jpAboutInitialized = 'true'; /* ----------------------------------------------- تنظیمات ----------------------------------------------- */ const config = window.JP_ABOUT_CONFIG || {}; /* ----------------------------------------------- عکس اصلی ----------------------------------------------- */ const mainImage = section.querySelector( '#jp-about-main-img' ); if ( mainImage && config.mainImage ) { mainImage.src = config.mainImage; } /* ----------------------------------------------- عکس بالا ----------------------------------------------- */ const topImage = section.querySelector( '#jp-about-top-img' ); if ( topImage && config.topImage ) { topImage.src = config.topImage; } /* ----------------------------------------------- عکس پایین ----------------------------------------------- */ const bottomImage = section.querySelector( '#jp-about-bottom-img' ); if ( bottomImage && config.bottomImage ) { bottomImage.src = config.bottomImage; } /* ----------------------------------------------- لینک دکمه ----------------------------------------------- */ const button = section.querySelector( '#jp-about-button' ); if ( button && config.buttonLink ) { button.href = config.buttonLink; } /* ----------------------------------------------- متن دکمه ----------------------------------------------- */ const buttonText = section.querySelector( '#jp-about-button-text' ); if ( buttonText && config.buttonText ) { buttonText.textContent = config.buttonText; } /* ----------------------------------------------- انیمیشن هنگام ورود به صفحه ----------------------------------------------- */ const observer = new IntersectionObserver( function (entries) { entries.forEach( function (entry) { if ( entry.isIntersecting ) { section.classList.add( 'jp-about-visible' ); observer.unobserve( section ); } } ); }, { threshold: 0.18 } ); observer.observe(section); }); } /* ----------------------------------------------- اجرای معمولی ----------------------------------------------- */ if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', initJahanPashaAbout ); } else { initJahanPashaAbout(); } /* ----------------------------------------------- سازگاری با Elementor ----------------------------------------------- */ if (window.jQuery) { jQuery(window).on( 'elementor/frontend/init', function () { setTimeout( initJahanPashaAbout, 300 ); } ); } })();
/* ========================================================= JAHAN PASHA PROCESS ANIMATION ========================================================= */ (function () { function initJahanPashaProcess() { const sections = document.querySelectorAll( ".jp-process-section" ); if (!sections.length) { return; } /* اگر مرورگر IntersectionObserver داشته باشد */ if ( "IntersectionObserver" in window ) { const observer = new IntersectionObserver( function (entries) { entries.forEach( function (entry) { if ( entry.isIntersecting ) { entry.target.classList.add( "jp-process-visible" ); observer.unobserve( entry.target ); } } ); }, { threshold: 0.18 } ); sections.forEach( function (section) { observer.observe(section); } ); } else { sections.forEach( function (section) { section.classList.add( "jp-process-visible" ); } ); } } /* ======================================================= DOM ======================================================= */ if ( document.readyState === "loading" ) { document.addEventListener( "DOMContentLoaded", initJahanPashaProcess ); } else { initJahanPashaProcess(); } /* ======================================================= ELEMENTOR ======================================================= */ if (window.jQuery) { jQuery(window).on( "elementor/frontend/init", function () { setTimeout( initJahanPashaProcess, 300 ); } ); } })();
/* ========================================================= JAHAN PASHA NETWORK REVEAL ========================================================= */ (function () { function initJahanPashaNetwork() { const sections = document.querySelectorAll( ".jp-business-network" ); if (!sections.length) { return; } /* ================================================ Fallback ================================================ */ if ( !("IntersectionObserver" in window) ) { sections.forEach(function(section) { section.classList.add( "jp-network-visible" ); }); return; } /* ================================================ Observer ================================================ */ const observer = new IntersectionObserver( function(entries) { entries.forEach(function(entry) { if ( entry.isIntersecting ) { entry.target.classList.add( "jp-network-visible" ); observer.unobserve( entry.target ); } }); }, { threshold: .18 } ); sections.forEach(function(section) { observer.observe(section); }); } /* ================================================ DOM ================================================ */ if ( document.readyState === "loading" ) { document.addEventListener( "DOMContentLoaded", initJahanPashaNetwork ); } else { initJahanPashaNetwork(); } /* ================================================ Elementor ================================================ */ if (window.jQuery) { jQuery(window).on( "elementor/frontend/init", function() { setTimeout( initJahanPashaNetwork, 350 ); } ); } })();
/* ========================================================= JAHAN PASHA SMART WORDPRESS NEWS SLIDER ========================================================= */ (function () { "use strict"; /* ======================================================= ELEMENT ======================================================== */ const root = document.querySelector( "[data-jp-news]" ); if (!root) { return; } /* * جلوگیری از اجرای دوباره در Elementor */ if ( root.dataset.jpInitialized === "true" ) { return; } root.dataset.jpInitialized = "true"; /* ======================================================= CONFIG ======================================================== */ let config = {}; try { const configElement = root.querySelector( ".jp-news-config" ); config = JSON.parse( configElement.textContent ); } catch (error) { console.error( "Jahan Pasha News Config Error:", error ); return; } /* ======================================================= DEFAULTS ======================================================== */ config.blogUrl = config.blogUrl || window.location.origin + "/blog/"; config.postsPerPage = Number( config.postsPerPage ) || 9; config.desktopItems = Number( config.desktopItems ) || 3; config.tabletItems = Number( config.tabletItems ) || 2; config.mobileItems = Number( config.mobileItems ) || 1; config.autoplay = Number( config.autoplay ) || 5000; /* ======================================================= DOM ======================================================== */ const track = root.querySelector( ".jp-news__track" ); const loading = root.querySelector( ".jp-news__loading" ); const dots = root.querySelector( ".jp-news__dots" ); const prev = root.querySelector( ".jp-news__arrow--prev" ); const next = root.querySelector( ".jp-news__arrow--next" ); const allButton = root.querySelector( ".jp-news__all" ); /* ======================================================= STATE ======================================================== */ let posts = []; let current = 0; let perView = config.desktopItems; let step = 0; let timer = null; let isAnimating = false; let touchStartX = 0; let touchStartY = 0; let resizeTimer = null; /* ======================================================= URL HELPERS ======================================================== */ function cleanUrl(url) { return String(url || "") .trim(); } /* * ساخت API وردپرس * * اگر وبلاگ: * * https://jahanpasha.com/blog/ * * باشد API می‌شود: * * https://jahanpasha.com/wp-json/wp/v2/posts */ function getApiUrl() { const blog = new URL( cleanUrl( config.blogUrl ), window.location.href ); return ( blog.origin + "/wp-json/wp/v2/posts" ); } /* ======================================================= HTML SANITIZER ======================================================== */ function escapeHTML(value) { const div = document.createElement( "div" ); div.textContent = String(value || ""); return div.innerHTML; } function cleanText(html) { const div = document.createElement( "div" ); div.innerHTML = html || ""; return ( div.textContent || div.innerText || "" ) .replace(/\s+/g, " ") .trim(); } /* ======================================================= DATE ======================================================== */ function formatDate(date) { if (!date) { return ""; } const parsed = new Date(date); if ( Number.isNaN( parsed.getTime() ) ) { return ""; } return parsed.toLocaleDateString( "fa-IR", { year: "numeric", month: "long", day: "numeric" } ); } /* ======================================================= CATEGORY ======================================================== */ function getCategory(post) { try { const terms = post._embedded && post._embedded[ "wp:term" ]; if ( !terms || !Array.isArray(terms) ) { return ""; } const categories = terms.find( group => Array.isArray(group) && group.some( item => item.taxonomy === "category" ) ); if (!categories) { return ""; } const category = categories.find( item => item.taxonomy === "category" ); return category ? cleanText(category.name) : ""; } catch (error) { return ""; } } /* ======================================================= IMAGE ======================================================== */ function getImage(post) { try { const media = post._embedded && post._embedded[ "wp:featuredmedia" ] && post._embedded[ "wp:featuredmedia" ][0]; if ( media && media.source_url ) { return media.source_url; } /* * بعضی سایت‌ها * این مقدار را دارند. */ if ( post.jetpack_featured_media_url ) { return ( post.jetpack_featured_media_url ); } } catch (error) { console.warn( "Image extraction error:", error ); } return ""; } /* ======================================================= CREATE CARD ======================================================== */ function createCard( post, index ) { const article = document.createElement( "article" ); article.className = "jp-news__card"; article.dataset.realIndex = String(index); const title = cleanText( post.title?.rendered ); const excerpt = cleanText( post.excerpt?.rendered ); const link = post.link || "#"; const image = getImage(post); const category = getCategory(post); const date = formatDate( post.date ); /* ===================================================== IMAGE ====================================================== */ const imageBox = document.createElement( "div" ); imageBox.className = "jp-news__image"; if (image) { const img = document.createElement( "img" ); img.src = image; img.alt = title; img.loading = "lazy"; img.decoding = "async"; /* * اگر عکس خراب بود، * کارت همچنان سالم بماند. */ img.addEventListener( "error", function () { this.remove(); }, { once: true } ); imageBox.appendChild( img ); } /* ===================================================== CATEGORY ====================================================== */ if ( config.showCategory && category ) { const badge = document.createElement( "span" ); badge.className = "jp-news__category"; badge.textContent = category; imageBox.appendChild( badge ); } /* ===================================================== CONTENT ====================================================== */ const content = document.createElement( "div" ); content.className = "jp-news__content"; /* META */ if ( config.showDate && date ) { const meta = document.createElement( "div" ); meta.className = "jp-news__meta"; meta.innerHTML = ` ${escapeHTML(date)} جهان پاشا `; content.appendChild( meta ); } /* TITLE */ const heading = document.createElement( "h3" ); heading.className = "jp-news__card-title"; const titleLink = document.createElement( "a" ); titleLink.href = link; titleLink.textContent = title; heading.appendChild( titleLink ); content.appendChild( heading ); /* EXCERPT */ if (excerpt) { const paragraph = document.createElement( "p" ); paragraph.className = "jp-news__excerpt"; paragraph.textContent = excerpt; content.appendChild( paragraph ); } /* READ MORE */ const readMore = document.createElement( "a" ); readMore.className = "jp-news__read"; readMore.href = link; readMore.innerHTML = ` مطالعه مقاله `; content.appendChild( readMore ); /* BUILD */ article.appendChild( imageBox ); article.appendChild( content ); return article; } /* ======================================================= RESPONSIVE ITEMS ======================================================== */ function getPerView() { const width = window.innerWidth; if ( width <= 700 ) { return config.mobileItems; } if ( width <= 1050 ) { return config.tabletItems; } return config.desktopItems; } /* ======================================================= BUILD SLIDER ======================================================== */ function buildSlider( reset = true ) { perView = Math.min( getPerView(), posts.length ); if ( !perView ) { return; } /* * برای اسلایدر حلقه‌ای: * آخرین کارت‌ها قبل از ابتدا * و اولین کارت‌ها بعد از انتها */ const fragment = document.createDocumentFragment(); const cloneBefore = posts.slice( posts.length - perView ); const cloneAfter = posts.slice( 0, perView ); /* BEFORE */ cloneBefore.forEach( function(post, index) { const card = createCard( post, posts.length - perView + index ); card.dataset.clone = "before"; fragment.appendChild( card ); } ); /* REAL */ posts.forEach( function(post, index) { const card = createCard( post, index ); fragment.appendChild( card ); } ); /* AFTER */ cloneAfter.forEach( function(post, index) { const card = createCard( post, index ); card.dataset.clone = "after"; fragment.appendChild( card ); } ); track.innerHTML = ""; track.appendChild( fragment ); /* * Current starts after * cloned cards. */ current = perView; requestAnimationFrame( function() { calculateStep(); setPosition( false ); buildDots(); } ); } /* ======================================================= CALCULATE STEP ======================================================== */ function calculateStep() { const cards = track.querySelectorAll( ".jp-news__card" ); if ( !cards.length ) { return; } const first = cards[0]; const style = window.getComputedStyle( track ); const gap = parseFloat( style.columnGap || style.gap || 0 ); step = first.getBoundingClientRect() .width + gap; } /* ======================================================= POSITION ======================================================== */ function setPosition( animate = true ) { if ( !step ) { calculateStep(); } track.style.transition = animate ? "" : "none"; const offset = current * step; track.style.transform = `translate3d(-${offset}px,0,0)`; if (!animate) { requestAnimationFrame( function() { requestAnimationFrame( function() { track.style.transition = ""; } ); } ); } } /* ======================================================= MOVE ======================================================== */ function move( direction ) { if ( isAnimating || posts.length = posts.length + perView ) { current = perView; setPosition( false ); } /* * اگر به clone اول رسیدیم */ if ( current < perView ) { current = posts.length + current; setPosition( false ); } isAnimating = false; }, 680 ); } /* ======================================================= DOTS ======================================================== */ function buildDots() { dots.innerHTML = ""; if ( posts.length <= perView ) { return; } /* * یک نقطه برای هر صفحه */ const pages = Math.ceil( posts.length / perView ); for ( let i = 0; i < pages; i++ ) { const dot = document.createElement( "button" ); dot.type = "button"; dot.className = "jp-news__dot"; dot.setAttribute( "aria-label", `صفحه ${i + 1}` ); dot.addEventListener( "click", function() { current = perView + ( i * perView ); setPosition( true ); updateDots(); restartAutoplay(); } ); dots.appendChild( dot ); } updateDots(); } /* ======================================================= UPDATE DOT ======================================================== */ function updateDots() { const dotList = dots.querySelectorAll( ".jp-news__dot" ); if ( !dotList.length ) { return; } let realIndex = current - perView; if ( realIndex = posts.length ) { realIndex = 0; } const page = Math.floor( realIndex / perView ); dotList.forEach( function(dot, index) { dot.classList.toggle( "is-active", index === page ); } ); } /* ======================================================= AUTOPLAY ======================================================== */ function startAutoplay() { stopAutoplay(); if ( config.autoplay <= 0 || posts.length Math.abs(deltaX) ) { startAutoplay(); return; } if ( Math.abs(deltaX) > 45 ) { if ( deltaX < 0 ) { move(1); } else { move(-1); } } startAutoplay(); }, { passive: true } ); /* ======================================================= KEYBOARD ======================================================== */ root.addEventListener( "keydown", function(event) { if ( event.key === "ArrowLeft" ) { move(1); restartAutoplay(); } if ( event.key === "ArrowRight" ) { move(-1); restartAutoplay(); } } ); root.setAttribute( "tabindex", "0" ); /* ======================================================= RESIZE ======================================================== */ window.addEventListener( "resize", function() { clearTimeout( resizeTimer ); resizeTimer = setTimeout( function() { const newPerView = getPerView(); if ( newPerView !== perView ) { buildSlider( true ); } else { calculateStep(); setPosition( false ); } }, 180 ); } ); /* ======================================================= FETCH WORDPRESS POSTS ======================================================== */ async function loadPosts() { try { const api = getApiUrl(); /* * _embed: * تصویر شاخص + دسته‌بندی */ const requestUrl = api + "?per_page=" + encodeURIComponent( config.postsPerPage ) + "&_embed"; const response = await fetch( requestUrl, { method: "GET", headers: { "Accept": "application/json" }, cache: "no-store" } ); if ( !response.ok ) { throw new Error( "WordPress API HTTP " + response.status ); } const data = await response.json(); if ( !Array.isArray(data) || !data.length ) { throw new Error( "هیچ مقاله‌ای پیدا نشد." ); } posts = data; /* * لینک مشاهده همه */ if (allButton) { allButton.href = config.blogUrl; } /* * Loading */ loading.style.display = "none"; /* * Build */ buildSlider( true ); /* * Start */ startAutoplay(); } catch (error) { console.error( "Jahan Pasha News Error:", error ); loading.style.display = "none"; const errorBox = document.createElement( "div" ); errorBox.className = "jp-news__error"; errorBox.innerHTML = ` دریافت اخبار با مشکل مواجه شد اتصال به API وردپرس یا آدرس وبلاگ را بررسی کنید. `; const viewport = root.querySelector( ".jp-news__viewport" ); viewport.replaceWith( errorBox ); } } /* ======================================================= INIT ======================================================== */ loadPosts(); })();