PluginProbe
AL Pack / 1.0.0
AL Pack v1.0.0
1.3.13 trunk 1.0.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.11 1.3.12
alpack / includes / scroll.php

scroll.php in AL Pack 1.0.0, at includes/scroll.php

438 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 /**
7 * Scroll functionality for PressLearn Plugin
8 */
9
10 function presslearn_is_plugin_active_for_scroll() {
11 $scroll_depth_enabled = get_option('presslearn_scroll_depth_enabled', 'no');
12 return $scroll_depth_enabled === 'yes';
13 }
14
15 /**
16 * Scroll admin styles
17 */
18 function presslearn_scroll_admin_styles() {
19 if (!is_admin()) {
20 return;
21 }
22
23 $screen = get_current_screen();
24 if (!$screen || strpos($screen->id, 'presslearn-scroll-depth') === false) {
25 return;
26 }
27
28 wp_register_style(
29 'presslearn-scroll-admin-css',
30 false,
31 array(),
32 PRESSLEARN_PLUGIN_VERSION
33 );
34 wp_enqueue_style('presslearn-scroll-admin-css');
35
36 $scroll_css = "
37 .popup-editor-overlay {
38 position: fixed;
39 top: 0;
40 left: 0;
41 width: 100%;
42 height: 100%;
43 background-color: rgba(0, 0, 0, 0.7);
44 z-index: 99999;
45 display: flex;
46 justify-content: center;
47 align-items: center;
48 }
49
50 .popup-editor-content {
51 background-color: #fff;
52 width: 80%;
53 max-width: 900px;
54 border-radius: 5px;
55 box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
56 display: flex;
57 flex-direction: column;
58 max-height: 90vh;
59 }
60
61 .popup-editor-header {
62 padding: 15px 20px;
63 border-bottom: 1px solid #ddd;
64 display: flex;
65 justify-content: space-between;
66 align-items: center;
67 }
68
69 .popup-editor-header h2 {
70 margin: 0;
71 font-size: 18px;
72 }
73
74 .close-popup-editor {
75 background: none;
76 border: none;
77 font-size: 22px;
78 cursor: pointer;
79 color: #666;
80 }
81
82 .popup-editor-body {
83 padding: 20px;
84 overflow-y: auto;
85 flex: 1;
86 }
87
88 .wp-editor-container {
89 min-height: 400px;
90 }
91
92 #wp-popup_content_editor-wrap {
93 min-height: 400px;
94 }
95
96 .mce-container iframe {
97 min-height: 350px !important;
98 }
99
100 .popup-editor-footer {
101 padding: 15px 20px;
102 border-top: 1px solid #ddd;
103 text-align: right;
104 }
105
106 .popup-content-preview {
107 margin-top: 15px;
108 padding: 10px;
109 border: 1px solid #ddd;
110 background-color: #f9f9f9;
111 border-radius: 3px;
112 max-height: 200px;
113 overflow-y: auto;
114 }
115
116 .popup-preview-content {
117 margin-top: 5px;
118 padding: 10px;
119 background-color: #fff;
120 border: 1px dashed #ccc;
121 }
122
123 .popup-preview-overlay {
124 position: fixed;
125 top: 0;
126 left: 0;
127 width: 100%;
128 height: 100%;
129 background-color: rgba(0, 0, 0, 0.7);
130 z-index: 99999;
131 display: flex;
132 justify-content: center;
133 align-items: center;
134 }
135
136 .popup-preview-container {
137 display: flex;
138 justify-content: center;
139 align-items: center;
140 width: 100%;
141 height: 100%;
142 }
143
144 .popup-preview-window {
145 background-color: #fff;
146 width: 90%;
147 max-width: 500px;
148 border-radius: 8px;
149 box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
150 display: flex;
151 flex-direction: column;
152 max-height: 80vh;
153 animation: popupFadeIn 0.3s ease-out;
154 }
155
156 @keyframes popupFadeIn {
157 from {
158 opacity: 0;
159 transform: scale(0.9);
160 }
161 to {
162 opacity: 1;
163 transform: scale(1);
164 }
165 }
166
167 @keyframes popupSlideIn {
168 from {
169 opacity: 0;
170 transform: translateY(-50px);
171 }
172 to {
173 opacity: 1;
174 transform: translateY(0);
175 }
176 }
177
178 @keyframes popupZoomIn {
179 from {
180 opacity: 0;
181 transform: scale(0.5);
182 }
183 to {
184 opacity: 1;
185 transform: scale(1);
186 }
187 }
188
189 .popup-preview-header {
190 padding: 15px 20px;
191 border-bottom: 1px solid #ddd;
192 display: flex;
193 justify-content: space-between;
194 align-items: center;
195 background-color: #f9f9f9;
196 border-radius: 8px 8px 0 0;
197 }
198
199 .popup-preview-header h2 {
200 margin: 0;
201 font-size: 18px;
202 color: #333;
203 }
204
205 .close-popup-preview {
206 position: fixed;
207 top: 20px;
208 right: 20px;
209 background: none;
210 border: none;
211 font-size: 40px;
212 cursor: pointer;
213 color: #fff;
214 z-index: 100000;
215 padding: 0;
216 line-height: 1;
217 }
218
219 .close-popup-preview:hover {
220 color: #ddd;
221 }
222
223 .popup-preview-body {
224 padding: 30px;
225 overflow-y: auto;
226 flex: 1;
227 line-height: 1.6;
228 }
229
230 .popup-preview-body img {
231 max-width: 100%;
232 height: auto;
233 display: block;
234 margin: 0 auto;
235 }
236
237 .popup-preview-footer {
238 padding: 15px 20px;
239 border-top: 1px solid #ddd;
240 text-align: center;
241 background-color: #f9f9f9;
242 border-radius: 0 0 8px 8px;
243 }
244
245 @media screen and (max-width: 768px) {
246 .popup-preview-window {
247 width: 95%;
248 max-width: 95%;
249 }
250
251 .popup-preview-body {
252 padding: 20px;
253 }
254
255 .close-popup-preview {
256 top: 10px;
257 right: 10px;
258 font-size: 32px;
259 }
260
261 .popup-editor-content {
262 width: 95%;
263 max-width: 95%;
264 }
265 }
266 ";
267
268 wp_add_inline_style('presslearn-scroll-admin-css', $scroll_css);
269 }
270
271 /**
272 * Scroll admin scripts
273 */
274 function presslearn_scroll_admin_scripts() {
275 if (!is_admin()) {
276 return;
277 }
278
279 $screen = get_current_screen();
280 if (!$screen || strpos($screen->id, 'presslearn-scroll-depth') === false) {
281 return;
282 }
283
284 wp_register_script(
285 'presslearn-scroll-popup-editor-js',
286 false,
287 array('jquery'),
288 PRESSLEARN_PLUGIN_VERSION,
289 true
290 );
291 wp_enqueue_script('presslearn-scroll-popup-editor-js');
292
293 $popup_editor_js = "
294 document.addEventListener('DOMContentLoaded', function() {
295 const openEditorBtn = document.getElementById('open-popup-editor');
296 const closeEditorBtns = document.querySelectorAll('.close-popup-editor');
297 const editorModal = document.getElementById('popup-editor-modal');
298 const saveContentBtn = document.querySelector('.save-popup-content');
299
300 if (openEditorBtn) {
301 openEditorBtn.addEventListener('click', function(e) {
302 e.preventDefault();
303 editorModal.style.display = 'flex';
304 });
305 }
306
307 closeEditorBtns.forEach(btn => {
308 btn.addEventListener('click', function() {
309 editorModal.style.display = 'none';
310 });
311 });
312
313 if (editorModal) {
314 editorModal.addEventListener('click', function(e) {
315 if (e.target === this) {
316 this.style.display = 'none';
317 }
318 });
319 }
320
321 if (saveContentBtn) {
322 saveContentBtn.addEventListener('click', function() {
323 let content = '';
324 if (typeof tinyMCE !== 'undefined' && tinyMCE.get('popup_content_editor') !== null) {
325 content = tinyMCE.get('popup_content_editor').getContent();
326 } else {
327 const editor = document.getElementById('popup_content_editor');
328 if (editor) {
329 content = editor.value;
330 }
331 }
332
333 const hiddenInput = document.getElementById('popup_content_hidden');
334 if (hiddenInput) {
335 hiddenInput.value = content;
336 }
337
338 let previewBtn = document.getElementById('preview-popup');
339 if (content.trim() === '') {
340 if (previewBtn) {
341 previewBtn.remove();
342 }
343 } else {
344 if (!previewBtn) {
345 previewBtn = document.createElement('button');
346 previewBtn.type = 'button';
347 previewBtn.id = 'preview-popup';
348 previewBtn.className = 'secondary-btn';
349 previewBtn.style.marginLeft = '5px';
350 previewBtn.textContent = '팝�
351 미리보기';
352
353 if (openEditorBtn) {
354 openEditorBtn.parentNode.insertBefore(previewBtn, openEditorBtn.nextSibling);
355 }
356
357 attachPreviewButtonEvent();
358 }
359 }
360
361 editorModal.style.display = 'none';
362 });
363 }
364
365 function attachPreviewButtonEvent() {
366 const previewBtn = document.getElementById('preview-popup');
367 if (previewBtn) {
368 previewBtn.addEventListener('click', function(e) {
369 e.preventDefault();
370 const previewModal = document.getElementById('popup-preview-modal');
371 if (previewModal) {
372 previewModal.style.display = 'flex';
373
374 const animationSelect = document.querySelector('select[name=\"popup_animation\"]');
375 const previewWindow = document.querySelector('.popup-preview-window');
376
377 if (animationSelect && previewWindow) {
378 const animation = animationSelect.value;
379 previewWindow.style.animation = '';
380
381 if (animation === 'fade') {
382 previewWindow.style.animation = 'popupFadeIn 0.3s ease-out';
383 } else if (animation === 'slide') {
384 previewWindow.style.animation = 'popupSlideIn 0.3s ease-out';
385 } else if (animation === 'zoom') {
386 previewWindow.style.animation = 'popupZoomIn 0.3s ease-out';
387 }
388 }
389 }
390 });
391 }
392 }
393
394 attachPreviewButtonEvent();
395 });
396 ";
397
398 wp_add_inline_script('presslearn-scroll-popup-editor-js', $popup_editor_js);
399
400 wp_register_script(
401 'presslearn-scroll-popup-preview-js',
402 false,
403 array('jquery'),
404 PRESSLEARN_PLUGIN_VERSION,
405 true
406 );
407 wp_enqueue_script('presslearn-scroll-popup-preview-js');
408
409 $popup_preview_js = "
410 document.addEventListener('DOMContentLoaded', function() {
411 const closePreviewBtns = document.querySelectorAll('.close-popup-preview');
412 const previewModal = document.getElementById('popup-preview-modal');
413
414 closePreviewBtns.forEach(btn => {
415 btn.addEventListener('click', function() {
416 if (previewModal) {
417 previewModal.style.display = 'none';
418 }
419 });
420 });
421
422 if (previewModal) {
423 previewModal.addEventListener('click', function(e) {
424 if (e.target === this || e.target.classList.contains('popup-preview-container')) {
425 this.style.display = 'none';
426 }
427 });
428 }
429 });
430 ";
431
432 wp_add_inline_script('presslearn-scroll-popup-preview-js', $popup_preview_js);
433 }
434
435 add_action('admin_enqueue_scripts', 'presslearn_scroll_admin_styles');
436 add_action('admin_enqueue_scripts', 'presslearn_scroll_admin_scripts');
437
438