Changeset 3334620
- Timestamp:
- 07/26/2025 05:21:07 PM (7 months ago)
- Location:
- sk-epaper-manager/trunk
- Files:
-
- 5 edited
-
assets/admin/epaper-admin.css (modified) (2 diffs)
-
assets/epaper-script.js (modified) (1 diff)
-
assets/epaper-style.css (modified) (6 diffs)
-
sk-epaper-manager.php (modified) (2 diffs)
-
templates/single-epaper.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sk-epaper-manager/trunk/assets/admin/epaper-admin.css
r3325982 r3334620 14 14 position: relative; 15 15 flex: 1 1 calc(33.33% - 10px); 16 max-width: calc(33.33% - 10px); 16 17 border: 1px solid #ccc; 17 18 border-radius: 5px; … … 21 22 .sk-epaper-image-list img { 22 23 width: 100%; 23 height: auto; 24 height: 250px; 25 object-fit: cover; 24 26 display: block; 25 27 border-radius: 4px; -
sk-epaper-manager/trunk/assets/epaper-script.js
r3325982 r3334620 5 5 const slides = document.querySelectorAll('.image-slide'); 6 6 7 const zoomInBtn = document.getElementById('zoom-in'); 8 const zoomOutBtn = document.getElementById('zoom-out'); 9 const downloadBtn = document.getElementById('download-btn'); 10 const printBtn = document.getElementById('print-btn'); 11 const printAllBtn = document.getElementById('print-all-btn'); 12 7 13 let currentIndex = 0; 8 14 const numImages = slides.length; 15 let zoomLevel = 1; 9 16 10 17 if (currentPageDisplay) { 18 currentPageDisplay.textContent = currentIndex + 1; 19 } 20 21 function updateSlider() { 22 const translateX = -currentIndex * 100; 23 imageSlider.style.transform = `translateX(${translateX}%)`; 24 if (currentPageDisplay) { 11 25 currentPageDisplay.textContent = currentIndex + 1; 12 } 13 14 function updateSlider() { 15 const translateX = -currentIndex * 100; 16 imageSlider.style.transform = `translateX(${translateX}%)`; 17 if (currentPageDisplay) { 18 currentPageDisplay.textContent = currentIndex + 1; 19 } 26 } 27 updateDownloadLink(); 28 resetZoom(); 29 } 30 31 function resetZoom() { 32 zoomLevel = 1; 33 slides.forEach(slide => { 34 const img = slide.querySelector('img'); 35 img.style.transform = 'scale(1)'; 36 }); 37 } 38 39 function zoomImage(factor) { 40 zoomLevel += factor; 41 if (zoomLevel < 1) zoomLevel = 1; 42 if (zoomLevel > 5) zoomLevel = 5; 43 44 const currentContainer = slides[currentIndex].querySelector('.zoom-container img'); 45 currentContainer.style.transform = `scale(${zoomLevel})`; 46 } 47 48 function updateDownloadLink() { 49 const img = slides[currentIndex].querySelector('img'); 50 downloadBtn.href = img.src; 20 51 } 21 52 22 53 if (nextButton && prevButton && imageSlider && slides.length > 0) { 23 nextButton.addEventListener('click', () => { 24 currentIndex = (currentIndex + 1) % numImages; 25 updateSlider(); 54 nextButton.addEventListener('click', () => { 55 currentIndex = (currentIndex + 1) % numImages; 56 updateSlider(); 57 }); 58 59 prevButton.addEventListener('click', () => { 60 currentIndex = (currentIndex - 1 + numImages) % numImages; 61 updateSlider(); 62 }); 63 64 zoomInBtn.addEventListener('click', () => { 65 zoomImage(0.5); 66 }); 67 68 zoomOutBtn.addEventListener('click', () => { 69 zoomImage(-0.5); 70 }); 71 72 updateSlider(); 73 } else { 74 console.warn('Slider elements not found.'); 75 } 76 77 // Drag-to-pan 78 slides.forEach(slide => { 79 const container = slide.querySelector('.zoom-container'); 80 let isDown = false; 81 let startX, startY, scrollLeft, scrollTop; 82 83 container.addEventListener('mousedown', e => { 84 const img = container.querySelector('img'); 85 if (zoomLevel <= 1) return; 86 isDown = true; 87 container.classList.add('dragging'); 88 startX = e.pageX - container.offsetLeft; 89 startY = e.pageY - container.offsetTop; 90 scrollLeft = container.scrollLeft; 91 scrollTop = container.scrollTop; 92 }); 93 94 container.addEventListener('mouseleave', () => { 95 isDown = false; 96 container.classList.remove('dragging'); 97 }); 98 99 container.addEventListener('mouseup', () => { 100 isDown = false; 101 container.classList.remove('dragging'); 102 }); 103 104 container.addEventListener('mousemove', e => { 105 if (!isDown) return; 106 e.preventDefault(); 107 const x = e.pageX - container.offsetLeft; 108 const y = e.pageY - container.offsetTop; 109 const walkX = (x - startX) * 1; 110 const walkY = (y - startY) * 1; 111 container.scrollLeft = scrollLeft - walkX; 112 container.scrollTop = scrollTop - walkY; 113 }); 114 }); 115 116 // ✅ Print Button Functionality 117 if (printBtn) { 118 printBtn.addEventListener('click', () => { 119 const currentSlide = slides[currentIndex]; 120 const img = currentSlide.querySelector('img'); 121 if (!img) return; 122 123 const iframe = document.createElement('iframe'); 124 iframe.style.position = 'fixed'; 125 iframe.style.width = '0'; 126 iframe.style.height = '0'; 127 iframe.style.border = '0'; 128 document.body.appendChild(iframe); 129 130 const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document; 131 if (!iframeDoc) return; 132 133 iframeDoc.open(); 134 iframeDoc.write(` 135 <html> 136 <head> 137 <title>Print Page</title> 138 <style> 139 @page { 140 size: A4 portrait; 141 margin: 0; 142 } 143 html, body { 144 margin: 0; 145 padding: 0; 146 height: 100%; 147 width: 100%; 148 display: flex; 149 justify-content: center; 150 align-items: center; 151 background: white; 152 } 153 img { 154 width: 100%; 155 height: auto; 156 max-height: 100%; 157 object-fit: contain; 158 page-break-after: avoid; 159 } 160 </style> 161 </head> 162 <body> 163 <img src="${img.src}" onload="window.focus(); window.print(); setTimeout(() => window.close(), 100);" /> 164 </body> 165 </html> 166 `); 167 iframeDoc.close(); 168 }); 169 } 170 171 if(printAllBtn) { 172 printAllBtn.addEventListener('click', () => { 173 const iframe = document.createElement('iframe'); 174 iframe.style.position = 'fixed'; 175 iframe.style.width = '0'; 176 iframe.style.height = '0'; 177 iframe.style.border = 'none'; 178 document.body.appendChild(iframe); 179 180 const doc = iframe.contentDocument || iframe.contentWindow.document; 181 182 doc.open(); 183 doc.write('<html><head><title>Print All</title><style>'); 184 doc.write(` 185 @media print { 186 @page { 187 size: A4; 188 margin: 0; 189 } 190 body { 191 margin: 0; 192 text-align: center; 193 } 194 img { 195 page-break-after: always; 196 max-width: 100%; 197 max-height: 100vh; 198 } 199 } 200 `); 201 doc.write('</style></head><body>'); 202 203 slides.forEach(slide => { 204 const img = slide.querySelector('img'); 205 if (img) { 206 doc.write(`<img src="${img.src}" alt="Slide" />`); 207 } 26 208 }); 27 209 28 prevButton.addEventListener('click', () => { 29 currentIndex = (currentIndex - 1 + numImages) % numImages; 30 updateSlider(); 31 }); 32 33 updateSlider(); 34 } else { 35 console.warn('Slider elements not found.'); 36 } 210 doc.write('</body></html>'); 211 doc.close(); 212 213 iframe.onload = () => { 214 iframe.contentWindow.focus(); 215 iframe.contentWindow.print(); 216 setTimeout(() => document.body.removeChild(iframe), 1000); 217 }; 218 }); 219 } -
sk-epaper-manager/trunk/assets/epaper-style.css
r3325982 r3334620 2 2 .single-epaper .slider-container { 3 3 position: relative; 4 /* width: 80%; */5 4 margin: 0 auto; 6 5 overflow: hidden; … … 22 21 width: 100%; 23 22 height: auto; 24 border-radius: 5px; /* Adds rounded corners to images */25 box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2); /* Adds a subtle box shadow to images */23 border-radius: 5px; 24 box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2); 26 25 } 27 26 … … 40 39 62%, 41 40 1 42 ); /* Adds a semi-transparent background to the arrows */43 color: #fff; /* Sets the arrow color to white */44 border-radius: 50%; /* Makes the arrows round */41 ); 42 color: #fff; 43 border-radius: 50%; 45 44 width: 40px; 46 45 height: 40px; … … 70 69 .epaper-top-header .epaper-col { 71 70 display: flex; 71 flex-wrap: wrap; 72 72 justify-content: space-between; 73 73 align-items: center; … … 85 85 /* Styles for each epaper-item */ 86 86 .epaper-item { 87 width: calc(33% - 10px); /* Adjust as needed for your layout */ 88 /* margin-bottom: 20px; */ 87 width: calc(33% - 10px); 89 88 border: 1px solid #e0e0e0; 90 89 box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); 91 90 background-color: #fff; 92 /* padding: 15px;*/93 91 } 94 92 … … 114 112 text-align: center; 115 113 } 114 .epaper-content h2 a { 115 text-decoration: none; 116 } 117 118 .zoom-container { 119 overflow: auto; 120 width: 100%; 121 height: 100%; 122 } 123 124 .zoom-container img { 125 display: block; 126 margin: 0 auto; 127 max-width: 100%; 128 transition: transform 0.3s ease; 129 } 130 131 .dragging { 132 cursor: grabbing !important; 133 } 134 135 /* Zoom & Download Button Group Styling */ 136 .epaper-center { 137 display: flex; 138 align-items: center; 139 justify-content: center; 140 padding: 10px 0; 141 } 142 143 .epaper-center .sk-control-button { 144 background-color: #fff; 145 border: none; 146 color: #000; 147 padding: 7px 8px; 148 margin: 0 5px; 149 font-size: 16px; 150 border-radius: 6px; 151 cursor: pointer; 152 display: inline-flex; 153 align-items: center; 154 justify-content: center; 155 transition: background-color 0.3s ease, transform 0.2s ease; 156 } 157 158 .epaper-center .sk-control-button i { 159 font-size: 18px; 160 pointer-events: none; 161 } 162 163 .epaper-center .sk-control-button:hover { 164 opacity: 0.8 165 } -
sk-epaper-manager/trunk/sk-epaper-manager.php
r3325982 r3334620 84 84 add_action( 'wp_enqueue_scripts', SK_EPAPER_PREFIX . 'enqueue_styles' ); 85 85 86 function sk_epaper_enqueue_fontawesome() { 87 wp_enqueue_style( 88 SK_EPAPER_PREFIX .'fontawesome', 89 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css', 90 array(), 91 '6.5.0', 92 'all' 93 ); 94 } 95 add_action( 'wp_enqueue_scripts', SK_EPAPER_PREFIX . 'enqueue_fontawesome' ); 96 86 97 function sk_epaper_enqueue_scripts() { 87 98 wp_enqueue_script( … … 146 157 ?> 147 158 <div> 148 <label for="<?php echo SK_EPAPER_PREFIX . 'images'; ?>">ePaper Images</label>149 159 <ul class="sk-epaper-image-list"> 150 160 <?php foreach ( $image_ids as $id ) : ?> 151 161 <li data-id="<?php echo esc_attr( $id ); ?>"> 152 <?php echo wp_get_attachment_image( $id, ' thumbnail' ); ?>162 <?php echo wp_get_attachment_image( $id, 'full' ); ?> 153 163 <span class="remove-image"><span class="text-remove-btn hidden">Remove</span></span> 154 164 </li> -
sk-epaper-manager/trunk/templates/single-epaper.php
r3325982 r3334620 9 9 // Get stored attachment IDs 10 10 $epaper_images = get_post_meta(get_the_ID(), 'sk_epaper_images', true); 11 12 11 if (!is_array($epaper_images)) { 13 12 $epaper_images = array_filter(explode(',', $epaper_images)); … … 27 26 <?php single_post_title('ePaper: '); ?> 28 27 </span> 28 </div> 29 </div> 30 <div class="epaper-center"> 31 <div> 32 <div> 33 <button id="zoom-in" class="zoom-btn sk-control-button" title="Zoom In"> 34 <i class="fas fa-search-plus"></i> 35 </button> 36 <button id="zoom-out" class="zoom-btn sk-control-button" title="Zoom Out"> 37 <i class="fas fa-search-minus"></i> 38 </button> 39 <button id="print-btn" class="sk-control-button" title="Print"> 40 <i class="fas fa-print"></i> 41 </button> 42 <button id="print-all-btn" title="Print All Pages" class="sk-control-button"> 43 <i class="fa-solid fa-print"></i> 44 </button> 45 <a id="download-btn" href="#" download class="sk-control-button" title="Download"> 46 <i class="fas fa-download"></i> 47 </a> 48 </div> 29 49 </div> 30 50 </div> … … 50 70 <div class="epaper-col"> 51 71 <div class="slider-container"> 52 <div class="arrow left-arrow" id="prev"> <</div>72 <div class="arrow left-arrow" id="prev"><i class="fas fa-chevron-left"></i></div> 53 73 <div class="image-slider"> 54 74 <?php … … 57 77 $attachment_id = absint($attachment_id); 58 78 echo '<div class="image-slide">'; 59 echo wp_get_attachment_image( 60 $attachment_id, 61 'full', 62 false, 63 array('alt' => get_the_title($attachment_id)) 64 ); 65 echo '</div>'; 79 echo '<div class="zoom-container">'; 80 echo wp_get_attachment_image( 81 $attachment_id, 82 'full', 83 false, 84 array('alt' => get_the_title($attachment_id)) 85 ); 86 echo '</div>'; 87 echo '</div>'; 66 88 } 67 89 } 68 90 ?> 69 91 </div> 70 <div class="arrow right-arrow" id="next"> ></div>92 <div class="arrow right-arrow" id="next"><i class="fas fa-chevron-right"></i></div> 71 93 </div> 72 94 </div>
Note: See TracChangeset
for help on using the changeset viewer.