PageSourceSearch

https://psling.net/wp-content/themes/twentytwentyfive-child/assets/js/guide-how-to-use.js?ver=1788163727

js psling.net collected 2026-10-09 22:59:50 UTC 26,598 bytes, 419 lines download raw bytes

1var pslingGuideAssetBase = new URL('../images/guide/', document.currentScript.src).href;
2        document.addEventListener('DOMContentLoaded', function () {
3            var toc = document.querySelector('.wp-block-group.wp-block-hidden-desktop.wp-block-group-is-layout-grid');
4            if (!toc || toc.querySelectorAll(':scope > .ps-guide-toc-link').length !== 9) return;
5            toc.id = 'ps-guide-toc';
6            var isEnglish = (document.documentElement.lang || '').toLowerCase().indexOf('en') === 0;
7
8            var tocGroups = [];
9            document.querySelectorAll('.ps-guide-toc-link').forEach(function (link) {
10                var group = link.parentElement;
11                if (group && group.querySelectorAll(':scope > .ps-guide-toc-link').length === 9 && tocGroups.indexOf(group) === -1) {
12                    tocGroups.push(group);
13                }
14            });
15            tocGroups.forEach(function (group) {
16                group.classList.add('ps-guide-toc-grid');
17                if (group.parentElement) {
18                    group.parentElement.classList.add('ps-guide-toc-panel');
19                    var heading = group.previousElementSibling;
20                    if (heading) heading.classList.add('ps-guide-toc-heading');
21                }
22            });
23
24            var guideImageReplacements = [
25                {
26                    selector: 'img.wp-image-946',
27                    src: '/wp-content/uploads/2026/08/jyunbi2s.png',
28                    alt: isEnglish ? 'Spread the sling tail wide and hold both fabric edges' : 'スリングのテール部分を大きく広げ、布の両端を両手で持つイラスト'
29                },
30                {
31                    selector: 'img.wp-image-947',
32                    src: '/wp-content/uploads/2026/08/jyunbi3s.png',
33                    alt: isEnglish ? 'Gather the sling fabric from the edges toward the centre and arrange the folds' : 'スリングの生地を端から中央へたぐり寄せ、ひだを整えるイラスト'
34                }
35            ];
36            guideImageReplacements.forEach(function (replacement) {
37                document.querySelectorAll(replacement.selector).forEach(function (image) {
38                    image.src = replacement.src;
39                    image.removeAttribute('srcset');
40                    image.removeAttribute('sizes');
41                    image.alt = replacement.alt;
42                });
43            });
44
45            function updateCradleCompleteCard() {
46                var cradleMirrorImage = document.querySelector('img.wp-image-1053');
47                var cradleMirrorCard = cradleMirrorImage && cradleMirrorImage.closest('.wp-block-column');
48                if (cradleMirrorCard) {
49                    var cradleMirrorTitle = cradleMirrorCard.querySelector('.wp-block-heading');
50                    var cradleMirrorText = cradleMirrorCard.querySelector('.wp-block-paragraph');
51                    if (cradleMirrorTitle) cradleMirrorTitle.textContent = '05 鏡で仕上がりを確認';
52                    if (cradleMirrorText) {
53                        cradleMirrorText.textContent = '鏡を見ると、赤ちゃんの顔と抱っこの形を確認しやすいです。';
54                    }
55                    cradleMirrorImage.alt = '鏡を見ながら、ピースリングのヨコ抱っこの仕上がりと赤ちゃんの姿勢を確認している状態';
56                }
57                var cradleCompleteImage = document.querySelector('img.wp-image-1054');
58                var cradleCompleteCard = cradleCompleteImage && cradleCompleteImage.closest('.wp-block-column');
59                if (!cradleCompleteCard) return;
60                var cradleCompleteTitle = cradleCompleteCard.querySelector('.wp-block-heading');
61                var cradleCompleteText = cradleCompleteCard.querySelector('.wp-block-paragraph');
62                if (cradleCompleteTitle) cradleCompleteTitle.textContent = '06 ヨコ抱っこ完成';
63                if (cradleCompleteText) {
64                    cradleCompleteText.textContent = '赤ちゃんの顔が見えて、やさしく密着できれば完成です。';
65                }
66                cradleCompleteImage.alt = 'ピースリングでヨコ抱っこが正しく完成し、赤ちゃんの顔と気道が見え、頭からお尻まで布で支えられている状態';
67            }
68            if (!isEnglish) {
69                updateCradleCompleteCard();
70                window.addEventListener('load', updateCradleCompleteCard, { once: true });
71            }
72
73            var gatherSubstepNumbers = {
74                'a. 全体をゆるめる': '01 全体をゆるめる',
75                'b. 両端を整える': '02 両端を整える',
76                'c. 布全体を整える': '03 布全体を整える'
77            };
78            document.querySelectorAll('.wp-block-heading').forEach(function (heading) {
79                var gatherTitle = heading.textContent.trim();
80                if (gatherSubstepNumbers[gatherTitle]) heading.textContent = gatherSubstepNumbers[gatherTitle];
81            });
82
83            var button = document.createElement('a');
84            button.className = 'ps-guide-toc-return';
85            button.href = '#ps-guide-toc';
86            button.textContent = isEnglish ? '≡ Contents' : '≡ 目次';
87            button.setAttribute('aria-label', isEnglish ? 'Return to the guide contents' : '使い方目次へ戻る');
88            button.setAttribute('data-track-id', 'toc_return_01--button_01--toc');
89            document.body.appendChild(button);
90
91            var faqHeading = document.querySelector('#faq');
92            var faqSection = faqHeading && faqHeading.parentElement ? faqHeading.parentElement.nextElementSibling : null;
93            if (!isEnglish && faqSection && !faqSection.querySelector('.ps-guide-faq-more')) {
94                var faqWrap = document.createElement('p');
95                faqWrap.className = 'ps-guide-faq-more-wrap';
96                var faqLink = document.createElement('a');
97                faqLink.className = 'ps-guide-faq-more';
98                faqLink.href = '/guide/faq/';
99                faqLink.textContent = 'よくある質問をもっと見る →';
100                faqLink.setAttribute('data-track-id', 'faq_01--link_01--faq');
101                faqWrap.appendChild(faqLink);
102                var faqCard = Array.prototype.find.call(faqSection.children, function (child) {
103                    return child.querySelector && child.querySelector('.psl-faq-container');
104                }) || faqSection;
105                faqCard.appendChild(faqWrap);
106            }
107
108            var chapterIds = [
109                'preparation',
110                'how-to-wear',
111                'cradle',
112                'vertical',
113                'universal-care',
114                'safety-principles',
115                'video-guide',
116                'faq',
117                'media-voice'
118            ];
119            chapterIds.forEach(function (chapterId) {
120                var chapterHeading = document.querySelector('#' + chapterId);
121                var chapterHeader = chapterHeading && chapterHeading.parentElement;
122                var chapterSection = chapterHeader && chapterHeader.nextElementSibling;
123                if (!chapterHeader || !chapterSection) return;
124
125                chapterHeader.classList.add('ps-guide-chapter-trial-heading');
126                chapterSection.classList.add('ps-guide-chapter-trial');
127                if (chapterId === 'video-guide') {
128                    chapterSection.classList.add('ps-guide-video-section');
129                }
130                if (chapterId === 'faq') {
131                    chapterSection.classList.add('ps-guide-faq-section');
132                }
133                Array.prototype.forEach.call(chapterSection.children, function (child) {
134                    if (child.classList.contains('wp-block-spacer')) {
135                        child.classList.add('ps-guide-chapter-gap');
136                    } else if (child.classList.contains('has-custom-color-3-gradient-background')) {
137                        child.classList.add('ps-guide-chapter-cta');
138                    } else if (!child.classList.contains('ps-guide-faq-more-wrap')) {
139                        child.classList.add('ps-guide-chapter-card');
140                        if (chapterId === 'preparation' && child.textContent.indexOf('Threading Fundamentals') !== -1) {
141                            child.classList.add('ps-guide-threading-card');
142                        }
143                        if (chapterId === 'safety-principles' && child.textContent.indexOf('Point 05') !== -1) {
144                            child.classList.add('ps-guide-avoid-intro');
145                        }
146                        if (chapterId === 'safety-principles' && child.textContent.indexOf('Threading Fundamentals') !== -1) {
147                            child.classList.add('ps-guide-avoid-grid');
148                        }
149                    }
150                });
151                if (['how-to-wear', 'cradle', 'vertical', 'universal-care'].indexOf(chapterId) !== -1) {
152                    var sectionLead = chapterSection.querySelector(':scope > .ps-guide-chapter-card');
153                    if (sectionLead) {
154                        sectionLead.classList.add('ps-guide-section-lead');
155                        if (sectionLead.previousElementSibling && sectionLead.previousElementSibling.classList.contains('ps-guide-chapter-gap')) {
156                            sectionLead.previousElementSibling.classList.add('ps-guide-section-lead-gap');
157                        }
158                    }
159                }
160            });
161
162            var avoidGrid = document.querySelector('.ps-guide-avoid-grid');
163            if (avoidGrid) {
164                avoidGrid.querySelectorAll('.wp-block-heading.has-accent-1-color').forEach(function (title) {
165                    title.textContent = title.textContent.replace(/^\s*\d{2}\s*/, '× ');
166                });
167            }
168
169            document.querySelectorAll('.ps-step-badge').forEach(function (badge) {
170                if (!/^Point 0[1-4]$/.test(badge.textContent.trim())) return;
171                var pointColumn = badge.closest('.wp-block-column');
172                var pointPair = pointColumn && pointColumn.parentElement;
173                if (pointColumn) {
174                    pointColumn.classList.add('ps-guide-safety-point-card');
175                    var pointLabel = pointColumn.querySelector('.ps-step-label');
176                    var pointTitle = pointColumn.querySelector('.ps-step-title');
177                    if (pointLabel && pointTitle && !pointColumn.querySelector(':scope > .ps-guide-safety-point-heading')) {
178                        var pointHeading = document.createElement('div');
179                        pointHeading.className = 'ps-guide-safety-point-heading';
180                        pointColumn.insertBefore(pointHeading, badge.nextSibling);
181                        pointHeading.appendChild(pointLabel);
182                        pointHeading.appendChild(pointTitle);
183                    }
184                }
185                if (pointPair) pointPair.classList.add('ps-guide-safety-pair');
186            });
187            var threadingCard = document.querySelector('.ps-guide-threading-card');
188            if (threadingCard) {
189                var threadingHeading = Array.prototype.find.call(threadingCard.children, function (child) {
190                    return child.textContent && child.textContent.trim().toUpperCase() === 'THREADING FUNDAMENTALS';
191                });
192                if (threadingHeading) threadingHeading.textContent = 'THREADING THE SLING';
193            }
194            var avoidIntro = document.querySelector('.ps-guide-avoid-intro');
195            if (avoidIntro) {
196                var avoidBadge = avoidIntro.querySelector(':scope > .ps-step-badge');
197                var avoidLabel = avoidIntro.querySelector(':scope > .ps-step-label');
198                var avoidTitle = avoidIntro.querySelector(':scope > .ps-step-title');
199                if (avoidBadge) avoidBadge.style.display = 'none';
200                if (avoidLabel && avoidTitle && !avoidIntro.querySelector(':scope > .ps-guide-safety-point-heading')) {
201                    var avoidHeading = document.createElement('div');
202                    avoidHeading.className = 'ps-guide-safety-point-heading';
203                    avoidIntro.insertBefore(avoidHeading, avoidBadge ? avoidBadge.nextSibling : avoidIntro.firstChild);
204                    avoidHeading.appendChild(avoidLabel);
205                    avoidHeading.appendChild(avoidTitle);
206                }
207            }
208
209            var mediaHeading = document.querySelector('#media-voice');
210            var mediaHeader = mediaHeading && mediaHeading.parentElement;
211            var mediaSection = mediaHeader && mediaHeader.nextElementSibling;
212            if (!isEnglish && mediaHeader && mediaSection && !document.querySelector('#moms-voice')) {
213                var mediaEnglish = mediaHeader.querySelector('p');
214                if (mediaEnglish) mediaEnglish.textContent = 'All About Guide';
215                mediaHeading.id = 'all-about-guide';
216                mediaHeading.textContent = 'オールアバウトでの解説';
217
218                var momsHeader = mediaHeader.cloneNode(true);
219                var momsEnglish = momsHeader.querySelector('p');
220                var momsHeading = momsHeader.querySelector('.wp-block-heading');
221                if (momsEnglish) momsEnglish.textContent = 'Mothers’ Voice';
222                if (momsHeading) {
223                    momsHeading.id = 'moms-voice';
224                    momsHeading.textContent = '先輩ママの使い方';
225                }
226
227                var momsSection = mediaSection.cloneNode(false);
228                var firstSpacer = mediaSection.querySelector(':scope > .ps-guide-chapter-gap');
229                if (firstSpacer) momsSection.appendChild(firstSpacer.cloneNode(true));
230                var mediaChildren = Array.prototype.slice.call(mediaSection.children);
231                mediaChildren.forEach(function (child) {
232                    if (child.textContent.indexOf('Moms’ Voices') !== -1 ||
233                        (child.classList.contains('ps-guide-chapter-gap') && child !== firstSpacer)) {
234                        if (child.textContent.indexOf('Moms’ Voices') !== -1) child.classList.add('ps-guide-moms-card');
235                        momsSection.appendChild(child);
236                    }
237                });
238                mediaSection.after(momsHeader, momsSection);
239
240                document.querySelectorAll('.ps-guide-toc-grid').forEach(function (grid, gridIndex) {
241                    var oldItem = Array.prototype.find.call(grid.children, function (item) {
242                        return item.textContent.indexOf('09.') !== -1;
243                    });
244                    if (!oldItem) return;
245                    var oldLink = oldItem.querySelector('a');
246                    oldLink.href = '#all-about-guide';
247                    oldLink.textContent = '09. オールアバウトでの解説';
248                    oldLink.setAttribute('data-track-id', 'toc--link_01_09--all_about');
249
250                    var newItem = oldItem.cloneNode(true);
251                    var newLink = newItem.querySelector('a');
252                    newLink.href = '#moms-voice';
253                    newLink.textContent = '10. 先輩ママの使い方';
254                    newLink.setAttribute('data-track-id', 'toc--link_01_' + (gridIndex ? '20' : '10') + '--moms_voice');
255                    grid.appendChild(newItem);
256                });
257            }
258
259            var allAboutCard = document.querySelector('#all-about-guide') &&
260                document.querySelector('#all-about-guide').parentElement.nextElementSibling.querySelector('.ps-guide-chapter-card');
261            if (!isEnglish && allAboutCard && !allAboutCard.querySelector('.ps-guide-allabout-button')) {
262                allAboutCard.classList.add('ps-guide-split-chapter-card', 'ps-guide-allabout-card');
263                var allAboutUrl = 'https://allabout.co.jp/gm/gc/198081/';
264                var allAboutImage = allAboutCard.querySelector('img.wp-image-1047');
265                if (allAboutImage && !allAboutImage.parentElement.matches('a')) {
266                    var imageLink = document.createElement('a');
267                    imageLink.className = 'ps-guide-allabout-image-link';
268                    imageLink.href = allAboutUrl;
269                    imageLink.target = '_blank';
270                    imageLink.rel = 'noopener noreferrer';
271                    imageLink.setAttribute('aria-label', 'All Aboutの記事を新しいタブで開く');
272                    allAboutImage.parentNode.insertBefore(imageLink, allAboutImage);
273                    imageLink.appendChild(allAboutImage);
274                }
275                allAboutCard.querySelectorAll('.ps-step-title').forEach(function (title) {
276                    var titleLink = document.createElement('a');
277                    titleLink.className = 'ps-guide-allabout-link';
278                    titleLink.href = allAboutUrl;
279                    titleLink.target = '_blank';
280                    titleLink.rel = 'noopener noreferrer';
281                    var allAboutTitleText = title.textContent.trim();
282                    if (allAboutTitleText === 'オールアバウトでの使い方解説') {
283                        titleLink.innerHTML = 'オールアバウトでの<br>使い方解説';
284                    } else {
285                        titleLink.textContent = allAboutTitleText;
286                    }
287                    title.textContent = '';
288                    title.appendChild(titleLink);
289                });
290                var allAboutTextColumn = allAboutCard.querySelector('.ps-2column-text-control');
291                if (allAboutTextColumn) {
292                    var allAboutButton = document.createElement('a');
293                    allAboutButton.className = 'ps-guide-allabout-button';
294                    allAboutButton.href = allAboutUrl;
295                    allAboutButton.target = '_blank';
296                    allAboutButton.rel = 'noopener noreferrer';
297                    allAboutButton.setAttribute('aria-label', 'All Aboutの記事を見る(外部サイトを新しいタブで開きます)');
298                    allAboutButton.innerHTML = 'All Aboutの記事を見る<span class="ps-guide-allabout-button__external" aria-hidden="true">↗</span>';
299                    allAboutTextColumn.appendChild(allAboutButton);
300                }
301            }
302            var momsVoiceSection = document.querySelector('#moms-voice') &&
303                document.querySelector('#moms-voice').parentElement.nextElementSibling;
304            var momsVoiceIntroCard = momsVoiceSection && momsVoiceSection.querySelector(':scope > .ps-guide-chapter-card');
305            if (momsVoiceIntroCard) momsVoiceIntroCard.classList.add('ps-guide-split-chapter-card', 'ps-guide-moms-card');
306
307            var shoulderReference = document.querySelector('.ps-shoulder-specification');
308            if (shoulderReference) {
309                shoulderReference.classList.add('ps-guide-reference-set');
310                shoulderReference.id = 'shoulder-specification';
311                var shoulderImageData = {
312                    left: pslingGuideAssetBase + 'shoulder-left-en-760.jpg',
313                    right: pslingGuideAssetBase + 'shoulder-right-en-760.jpg'
314                };
315                var shoulderCards = shoulderReference.querySelectorAll('.wp-block-column');
316                [1, 2].forEach(function (index) {
317                    var image = shoulderCards[index] && shoulderCards[index].querySelector('img');
318                    if (!image) return;
319                    image.src = index === 1 ? shoulderImageData.left : shoulderImageData.right;
320                    image.removeAttribute('srcset');
321                    image.removeAttribute('sizes');
322                    image.alt = isEnglish
323                        ? (index === 1 ? 'Left-shoulder setup' : 'Right-shoulder setup')
324                        : (index === 1 ? 'Left shoulder(左肩仕様)' : 'Right shoulder(右肩仕様)');
325                });
326                if (!isEnglish) {
327                    shoulderReference.querySelectorAll('.wp-block-heading').forEach(function (heading) {
328                        heading.textContent = heading.textContent.trim().replace(/^(?:Check|Left|Right)\s+/, '');
329                    });
330                }
331            }
332            var finalCheckTitle = Array.prototype.find.call(document.querySelectorAll('.ps-illust-grid .wp-block-heading'), function (heading) {
333                return heading.textContent.indexOf('07 姿勢と呼吸を確認') !== -1;
334            });
335            var finalCheckGrid = finalCheckTitle && finalCheckTitle.closest('.ps-illust-grid');
336            if (finalCheckGrid) {
337                finalCheckGrid.querySelectorAll('.wp-block-heading').forEach(function (heading) {
338                    heading.textContent = heading.textContent.replace(/^0[789]\s*/, '');
339                });
340                var finalCheckWrap = finalCheckGrid.parentElement && finalCheckGrid.parentElement.classList.contains('ps-guide-final-check-wrap')
341                    ? finalCheckGrid.parentElement
342                    : null;
343                if (!finalCheckWrap) {
344                    finalCheckWrap = document.createElement('div');
345                    finalCheckWrap.className = 'ps-guide-final-check-wrap ps-guide-reference-set';
346                    finalCheckGrid.parentNode.insertBefore(finalCheckWrap, finalCheckGrid);
347                    finalCheckWrap.appendChild(finalCheckGrid);
348                }
349                finalCheckGrid.classList.remove('ps-guide-reference-set');
350                if (!finalCheckWrap.querySelector(':scope > .ps-guide-reference-heading')) {
351                    var finalCheckHeading = document.createElement('p');
352                    finalCheckHeading.className = 'ps-guide-reference-heading';
353                    finalCheckHeading.textContent = 'ヨコだっこの確認ポイント';
354                    finalCheckWrap.insertBefore(finalCheckHeading, finalCheckGrid);
355                }
356            }
357
358            if (shoulderReference) {
359                var shoulderLinkTargets = [];
360                var firstThreadingText = document.querySelector('.ps-guide-threading-card .ps-illust-grid .wp-block-paragraph');
361                if (firstThreadingText) shoulderLinkTargets.push(firstThreadingText);
362                document.querySelectorAll('.ps-pc-text-only.wp-block-paragraph, .ps-sp-text-only.wp-block-paragraph').forEach(function (paragraph) {
363                    if (paragraph.textContent.indexOf('本マニュアルは左肩仕様を基準') !== -1) shoulderLinkTargets.push(paragraph);
364                });
365                shoulderLinkTargets.forEach(function (element) {
366                    if (element.querySelector('.ps-guide-shoulder-link')) return;
367                    var html = element.innerHTML;
368                    html = html.replace(/(左肩仕様|右肩仕様)/g, '<a class="ps-guide-shoulder-link" href="#shoulder-specification">$1</a>');
369                    element.innerHTML = html;
370                });
371            }
372
373            document.querySelectorAll('.psl-colors-cta__title').forEach(function (title) {
374                var text = title.textContent.trim();
375                if (text === 'はじめての一枚に、ピースリング・カラーズ') {
376                    title.innerHTML = 'はじめての一枚に、<br class="psl-cta-mobile-break">ピースリング・カラーズ';
377                } else if (text === '使い方を知ったら、自分に合う色を見つける') {
378                    title.innerHTML = '使い方を知ったら、<br class="psl-cta-mobile-break">自分に合う色を見つける';
379                }
380            });
381
382            var guideLineCta = document.querySelector('.ps-cta-line');
383            if (guideLineCta && !isEnglish) {
384                guideLineCta.classList.add('ps-guide-line-cta');
385                var guideLineTitle = guideLineCta.querySelector('.ps-cta-title');
386                if (guideLineTitle) guideLineTitle.textContent = '使い方に迷ったら';
387                if (guideLineTitle && !guideLineCta.querySelector('.ps-guide-line-subtitle')) {
388                    var guideLineSubtitle = document.createElement('p');
389                    guideLineSubtitle.className = 'ps-guide-line-subtitle';
390                    guideLineSubtitle.textContent = '';
391                    guideLineTitle.after(guideLineSubtitle);
392                }
393                var guideLineText = guideLineCta.querySelector('.ps-cta-text');
394                if (guideLineText) {
395                    guideLineText.innerHTML = '<p><span class="ps-guide-line-pc-copy">写真を送りながら、リングの位置や抱き方をスタッフにご相談いただけます。</span><span class="ps-guide-line-sp-copy">写真を送りながら、<br>リングの位置や抱き方を<br>スタッフにご相談いただけます。</span></p>';
396                    if (!guideLineCta.querySelector('.ps-guide-line-assurance')) {
397                        var guideLineAssurance = document.createElement('p');
398                        guideLineAssurance.className = 'ps-guide-line-assurance';
399                        guideLineAssurance.textContent = '';
400                        guideLineText.after(guideLineAssurance);
401                    }
402                }
403                var guideLineButton = guideLineCta.querySelector('.ps-btn-line');
404                if (guideLineButton) {
405                    guideLineButton.setAttribute('aria-label', 'LINEで使い方を相談する(外部サイトを新しいタブで開きます)');
406                    guideLineButton.innerHTML = '<img class="ps-guide-line-button-icon" src="'
407                        + pslingGuideAssetBase + 'line-brand-icon.png" alt="" aria-hidden="true"><span>LINEで相談する ↗</span>';
408                }
409            }
410
411            function updateVisibility() {
412                var pastToc = window.scrollY > toc.offsetTop + toc.offsetHeight;
413                button.classList.toggle('is-visible', pastToc && window.matchMedia('(max-width: 900px)').matches);
414            }
415
416            window.addEventListener('scroll', updateVisibility, { passive: true });
417            window.addEventListener('resize', updateVisibility);
418            updateVisibility();
419        });

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.