(function() { 'use strict'; // Создаем элемент style const styleElement = document.createElement('style'); styleElement.id = 'holiday-widget-styles'; // Добавляем CSS styleElement.textContent = ` /* Стили для десктопной версии виджета */ #holidayWidgetDesktop { position: fixed; top: 20px; right: 20px; z-index: 10000; background: white; border-radius: 15px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12); width: 280px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; overflow: hidden; border: 1px solid #e1e8ed; transition: all 0.3s ease; cursor: pointer; animation: slideInRight 0.4s ease-out; } #holidayWidgetDesktop:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); } #widgetHeaderDesktop { padding: 15px 20px; text-align: center; position: relative; } .widget-header-content { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; width: 100% !important; } #holidayIconDesktop { display: none; font-size: 24px; margin-right: 10px; min-width: 24px; } #eventTextDesktop { margin: 10px auto 0; max-width: 150px; font-size: 16px; line-height: 1; font-weight: 600; color: #fff; flex-grow: 1; text-align: center !important; } .days-container { display: flex; align-items: baseline; justify-content: center; } #daysCountDesktop { font-size: 48px; font-weight: 800; line-height: 1; color: #fff; } #daysLabelDesktop { font-size: 16px; color: #fff; margin-left: 5px; } .widget-body { padding: 0 20px 15px 20px; border-top: 1px solid #f0f0f0; } #motivationQuoteDesktop { color: #5d6d7e; font-size: 12px; line-height: 1.4; margin-top: 12px; font-style: italic; text-align: center; padding: 8px; background: #f8f9fa; border-radius: 6px; transition: opacity 0.3s ease; } /* Стили для мобильной версии виджета */ #holidayWidgetMobile { position: fixed; bottom: 20px; right: 20px; z-index: 10000; background: white; border-radius: 12px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15); min-width: 100px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; overflow: hidden; border: 1px solid #e1e8ed; cursor: pointer; transition: all 0.3s ease; animation: slideInUp 0.4s ease-out; } #holidayWidgetMobile:active { transform: scale(0.95); } .mobile-widget-content { display: flex; align-items: center; padding: 10px 15px; justify-content: center; } #holidayIconMobile { font-size: 20px; margin-right: 10px; min-width: 20px; } .mobile-days-container { text-align: center; } #daysCountMobile { font-size: 28px; font-weight: 800; line-height: 1; color: #fff; } #daysLabelMobile { font-size: 12px; color: #fff; margin-top: 2px; } /* Цветовые темы для разных периодов */ .new-year-theme { background: linear-gradient(135deg, #ff1d1d 0%, #d01a1a 100%) !important; color: white !important; } .holidays-theme { background: linear-gradient(135deg, #4ecd5a 0%, #45a045 100%) !important; color: white !important; } .work-theme { background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%) !important; color: white !important; } .future-theme { background: linear-gradient(135deg, #9b59b6 0%, #34495e 100%) !important; color: white !important; } /* Цвета текста для мобильной версии с градиентом */ .themed-text-white { color: white !important; } .themed-text-light { color: rgba(255, 255, 255, 0.9) !important; } /* Модальное окно */ #holidayModal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10001; display: none; animation: fadeIn 0.3s ease-out; } .modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(3px); } .modal-content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; border-radius: 20px; width: 90%; max-width: 400px; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); animation: modalSlideUp 0.4s ease-out; } .modal-header { padding: 25px 25px 15px; text-align: center; border-bottom: 1px solid #f0f0f0; } .modal-title { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 5px; } .modal-subtitle { font-size: 14px; color: #fff; } .modal-body { padding: 20px 25px; } .modal-icon { font-size: 48px; text-align: center; margin-bottom: 20px; } .modal-days-container { text-align: center; margin-bottom: 25px; } .modal-days-count { font-size: 64px; font-weight: 800; line-height: 1; color: #fff; } .modal-days-label { font-size: 20px; color: #fff; margin-top: 5px; } .modal-event-text { font-size: 18px; font-weight: 600; color: #fff; text-align: center; margin-bottom: 20px; } .modal-quote { color: #5d6d7e; font-size: 15px; line-height: 1.5; font-style: italic; text-align: center; padding: 15px; background: #f8f9fa; border-radius: 10px; margin-bottom: 20px; border-left: 4px solid #4ECDC4; } .modal-close-btn { position: absolute; top: 15px; right: 15px; background: none; border: none; font-size: 24px; color: #fff; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; } .modal-close-btn:hover { background: #000; color: #fff; } .modal-footer { padding: 15px 25px 25px; text-align: center; border-top: 1px solid #f0f0f0; color: #fff; font-size: 13px; } /* Анимации */ @keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideInUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes modalSlideUp { from { transform: translate(-50%, -40%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } } /* Адаптивные медиа-запросы */ @media (max-width: 1200px) { #holidayWidgetDesktop { display: none !important; } #holidayWidgetMobile { display: block !important; } } @media (min-width: 1201px) { #holidayWidgetDesktop { display: block !important; } #holidayWidgetMobile { display: none !important; } } @media (max-width: 768px) { #holidayWidgetMobile { bottom: 15px; right: 15px; border-radius: 10px; } .modal-content { width: 95%; max-height: 85vh; } } @media (max-width: 480px) { #holidayWidgetMobile { bottom: 10px; right: 10px; min-width: 70px; } .mobile-widget-content { padding: 10px 12px; } #daysCountMobile { font-size: 20px; } #daysLabelMobile { font-size: 10px; } .modal-content { border-radius: 15px; } .modal-days-count { font-size: 56px; } } `; // Добавляем стили в head документа function addStyles() { // Проверяем, не добавлены ли уже стили if (document.getElementById('holiday-widget-styles')) { console.log('Стили виджета уже добавлены'); return; } // Добавляем стили в head document.head.appendChild(styleElement); console.log('Стили виджета успешно добавлены'); } // Добавляем стили при загрузке страницы if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', addStyles); } else { addStyles(); } // Экспортируем функцию для ручного добавления стилей window.addHolidayWidgetStyles = addStyles; // Конфигурация виджета const CONFIG = { NEW_YEAR: new Date('2026-01-01'), HOLIDAYS_END: new Date('2026-01-09'), WORK_START: new Date('2026-01-12'), CURRENT_YEAR: 2026 }; // База мотивирующих цитат const MOTIVATION_QUOTES = [ "Образование — это самое мощное оружие, которое вы можете использовать, чтобы изменить мир.", "Учитесь так, будто вы будете жить вечно. Живите так, будто вы умрете завтра.", "Знания, которые не пополняются ежедневно, убывают с каждым днем.", "Ваше будущее создается тем, что вы делаете сегодня, а не завтра.", "Каждый эксперт когда-то был новичком.", "Инвестиции в знания всегда дают наибольшую прибыль.", "Не бойтесь совершенствоваться медленно, бойтесь оставаться на месте.", "Образование — это пропуск в будущее, ибо завтра принадлежит тем, кто готовится к нему сегодня.", "Лучшее время, чтобы посадить дерево, было 20 лет назад. Следующее лучшее время — сейчас.", "Чем больше я узнаю, тем больше понимаю, как мало я знаю.", "Успех — это сумма небольших усилий, повторяющихся изо дня в день.", "Ваши мечты не работают, пока вы не работаете над ними.", "Сегодняшний читатель — завтрашний лидер.", "Никогда не прекращайте учиться, потому что жизнь никогда не прекращает преподавать.", "Единственное, что стоит между вами и вашей целью — это история, которую вы продолжаете рассказывать себе о том, почему вы не можете ее достичь.", "Каждый день — это новая возможность изменить свою жизнь.", "Не ждите идеальных условий, они никогда не наступят. Начинайте сейчас с того, что у вас есть.", "Знания — это единственный актив, который невозможно отнять.", "Маленькие ежедневные улучшения со временем приводят к ошеломляющим результатам.", "Будущее принадлежит тем, кто верит в красоту своей мечты." ]; // Состояние приложения const state = { currentPeriod: null, isMobile: window.innerWidth < 1200, modalOpen: false, currentQuoteIndex: 0 }; // DOM элементы const elements = {}; // Утилиты const utils = { // Получить случайную цитату getRandomQuote() { const randomIndex = Math.floor(Math.random() * MOTIVATION_QUOTES.length); state.currentQuoteIndex = randomIndex; return MOTIVATION_QUOTES[randomIndex]; }, // Получить следующую цитату getNextQuote() { state.currentQuoteIndex = (state.currentQuoteIndex + 1) % MOTIVATION_QUOTES.length; return MOTIVATION_QUOTES[state.currentQuoteIndex]; }, // Расчет разницы в днях getDaysDiff(targetDate) { const today = new Date(); today.setHours(0, 0, 0, 0); const target = new Date(targetDate); target.setHours(0, 0, 0, 0); const diff = target - today; return Math.max(0, Math.ceil(diff / (1000 * 60 * 60 * 24))); }, // Правильное склонение слова "день" getDaysLabel(days) { const lastDigit = days % 10; const lastTwoDigits = days % 100; if (lastTwoDigits >= 11 && lastTwoDigits <= 19) return 'дней'; if (lastDigit === 1) return 'день'; if (lastDigit >= 2 && lastDigit <= 4) return 'дня'; return 'дней'; }, // Определение текущего периода getCurrentPeriod() { const today = new Date(); let periodData; if (today < CONFIG.NEW_YEAR) { periodData = { days: utils.getDaysDiff(CONFIG.NEW_YEAR), event: 'до Нового 2026 года', icon: '', theme: 'new-year-theme', description: 'Время готовиться к празднику!' }; } else if (today < CONFIG.HOLIDAYS_END) { periodData = { days: utils.getDaysDiff(CONFIG.HOLIDAYS_END), event: 'до конца праздников', icon: '', theme: 'holidays-theme', description: 'Наслаждайтесь праздничными днями!' }; } else if (today < CONFIG.WORK_START) { periodData = { days: utils.getDaysDiff(CONFIG.WORK_START), event: 'до выхода на работу', icon: '', theme: 'work-theme', description: 'Последние дни отдыха перед работой' }; } else { const nextNewYear = new Date(`${CONFIG.CURRENT_YEAR + 1}-01-01`); periodData = { days: utils.getDaysDiff(nextNewYear), event: 'до следующего Нового года', icon: '', theme: 'future-theme', description: 'Время строить планы на будущий год!' }; } state.currentPeriod = periodData; return periodData; } }; // Создание элементов const domBuilder = { // Создать десктопный виджет createDesktopWidget() { return `