| 1 |
/** |
| 2 |
* PowerPress Post Entry Point |
| 3 |
* unified ES6 module for episode editing (replaces metabox-episode.js, metabox-channel.js) |
| 4 |
*/ |
| 5 |
|
| 6 |
// ============================================ |
| 7 |
// PCI MANAGER IMPORTS |
| 8 |
// ============================================ |
| 9 |
|
| 10 |
import { initLocationManager } from './modules/pci/LocationManager.js'; |
| 11 |
import { initCreditsManager } from './modules/pci/CreditsManager.js'; |
| 12 |
import { initValueRecipientManager } from './modules/pci/ValueRecipientsManager.js'; |
| 13 |
import { initSoundbitesManager } from './modules/pci/SoundbitesManager.js'; |
| 14 |
import { initSocialInteractManager } from './modules/pci/SocialInteractManager.js'; |
| 15 |
import { initTxtTagManager } from './modules/pci/TxtTagManager.js'; |
| 16 |
import { initAlternateEnclosureManager } from './modules/pci/AlternateEnclosureManager.js'; |
| 17 |
import { initContentLinksManager } from './modules/pci/ContentLinksManager.js'; |
| 18 |
|
| 19 |
// ============================================ |
| 20 |
// UTILITY IMPORTS |
| 21 |
// ============================================ |
| 22 |
|
| 23 |
import { toggleVisibility, initCharCounter } from './utils/dom-utils.js'; |
| 24 |
import { initMediaEdit } from './modules/post-editor/EpisodeEnclosureManager.js'; |
| 25 |
|
| 26 |
// ============================================ |
| 27 |
// GLOBAL EXPORTS |
| 28 |
// ============================================ |
| 29 |
|
| 30 |
// pci managers (for PHP template init calls) |
| 31 |
window.initLocationManager = initLocationManager; |
| 32 |
window.initCreditsManager = initCreditsManager; |
| 33 |
window.initValueRecipientManager = initValueRecipientManager; |
| 34 |
window.initSoundbitesManager = initSoundbitesManager; |
| 35 |
window.initSocialInteractManager = initSocialInteractManager; |
| 36 |
window.initTxtTagManager = initTxtTagManager; |
| 37 |
window.initAlternateEnclosureManager = initAlternateEnclosureManager; |
| 38 |
window.initContentLinksManager = initContentLinksManager; |
| 39 |
|
| 40 |
// utilities |
| 41 |
window.toggleVisibility = toggleVisibility; |
| 42 |
window.initCharCounter = initCharCounter; |
| 43 |
|
| 44 |
// ============================================ |
| 45 |
// AUTO-INITIALIZATION |
| 46 |
// ============================================ |
| 47 |
|
| 48 |
// initialize character counters for any element with data-char-counter attribute |
| 49 |
// usage: <textarea data-char-counter="counterId" data-char-warn="250"> |
| 50 |
// data-char-warn is optional; omit for no warning color |
| 51 |
document.querySelectorAll('[data-char-counter]').forEach(input => { |
| 52 |
const counterId = input.dataset.charCounter; |
| 53 |
const warnAt = input.dataset.charWarn ? parseInt(input.dataset.charWarn, 10) : null; |
| 54 |
initCharCounter(input.id, counterId, warnAt); |
| 55 |
}); |
| 56 |
|
| 57 |
// Auto-Grow Text area for Show Notes in the post editor instead of allowing scroll |
| 58 |
document.querySelectorAll('[id^="powerpress_shownotes_"]').forEach(ta => { |
| 59 |
ta.style.overflow = 'hidden'; |
| 60 |
const grow = () => { |
| 61 |
ta.style.height = 'auto'; |
| 62 |
const lineHeight = parseFloat(getComputedStyle(ta).lineHeight) || 20; |
| 63 |
ta.style.height = (ta.scrollHeight + lineHeight) + 'px'; |
| 64 |
}; |
| 65 |
ta.addEventListener('input', grow); |
| 66 |
grow(); |
| 67 |
}); |
| 68 |
|
| 69 |
// ============================================ |
| 70 |
// MEDIA EDIT INIT |
| 71 |
// ============================================ |
| 72 |
|
| 73 |
initMediaEdit(); |
| 74 |
|