PageSourceSearch

https://ssir.org/site/functions?v=2026-07-29-2

js ssir.org collected 2026-10-01 07:07:29 UTC 12,028 bytes, 311 lines download raw bytes

1;(function($, window, document, undefined) {
2    var $win = $(window);
3    var $doc = $(document);
4
5    $doc.ready(function() {
6        // bind a listener to the body for the dynamically created
7        // form sign in modal
8        $("body").on("submit", ".form-signin form", function()
9        {
10            // Update the return value to return the user to the current page
11            $(".form-signin form").find(".hiddenFields input[name='RET']").val(window.location.href);
12        });
13
14        // Legacy .social-stream and .form-subscribe handlers were removed; their markup is no longer in use.
15        $(document).on('click', '.popup__btn, .popup-track-close, .close-popup, .popup-track-login', function () {
16            Cookies.set('ssir_popup_closed', 1, { expires: 1 });
17        });
18
19        // Search Lightbox
20        function openSearchLightbox() {
21            $('#search-lightbox').addClass('show').attr('aria-hidden', 'false');
22            $('body').addClass('search-lightbox-open');
23            setTimeout(function() {
24                $('#search-lightbox input.gsc-input').focus();
25            }, 300);
26        }
27
28        function closeSearchLightbox() {
29            $('#search-lightbox').removeClass('show').attr('aria-hidden', 'true');
30            $('body').removeClass('search-lightbox-open');
31        }
32
33        $('.btn-search').on('click', function(event) {
34            event.preventDefault();
35            event.stopPropagation();
36            openSearchLightbox();
37        });
38
39        $('.search-lightbox-close').on('click', function(event) {
40            event.stopPropagation();
41            closeSearchLightbox();
42        });
43
44        $('.search-lightbox-backdrop').on('click', function() {closeSearchLightbox();});
45
46        $(document).on('keydown', function(e) {
47            if (e.key === 'Escape' && $('#search-lightbox').hasClass('show')) {closeSearchLightbox();}
48        });
49
50        //JS Smooth scroll to block
51        $('.js-scroll-to').on('click', function(event){
52            if ($('#'+$(this).data('block-id')).length)
53            {
54                $('html, body').animate({
55                    scrollTop: $('#'+$(this).data('block-id')).offset().top
56                }, 2000);
57            }
58            return false;
59        });
60
61        // Open Comments
62        $('#comment').on('focus', function() {$('.hiddenFields').siblings().slideDown();});
63
64        // Show Tablet Navigation
65        $('.nav-trigger').on('click', function(event) {
66            event.preventDefault();
67            $('body, html').addClass('no-scroll');
68            $('.offset-nav').addClass('slideIn');
69        });
70
71        // Hide Tablet Navigation
72        $('.offset-nav .close, .offset-nav-dropdown .close').on('click', function(event) {
73            event.preventDefault();
74
75            $('body, html').removeClass('no-scroll');
76            $('body, .offset-nav').removeClass('overflow');
77            $('.offset-nav, .offset-nav-dropdown').removeClass('slideIn');
78        });
79
80        // set nav menu height based on current window size
81        function setNavHeight() {
82            $('.offset-nav-body').css({
83                height: function() {
84                    return $win.height() - 70;
85                }
86            });
87
88            $('.offset-nav-dropdown-body').css({
89                height: function() {
90                    return $win.height() - 70;
91                }
92            });
93        }
94
95        setNavHeight();
96        window.addEventListener('orientationchange', setNavHeight );
97        window.addEventListener('resize', setNavHeight );
98
99
100        function setCaptionWidth() {
101            $('.wp-caption').css({
102                width: function() {
103                    return $(this).find('img').width('100%'); // should fix problem caused when resizing page
104                }
105            });
106        }
107
108        setCaptionWidth();
109        window.addEventListener('resize', setCaptionWidth );
110
111        // moves series boxes to the bottom when the window is too small
112        function moveArticleBoxes() {
113            box = $('.seriesbox, .innerbox').not('.no-move');
114            if ( box.length > 0) {
115                if($win.width() < 479) {
116                    $(box).each(function( index ) {
117                        if (! $.hasData(this) ) {
118                            $( this ).data('movedFrom',$( this ).prevAll().length);
119                            $( this ).appendTo('.article-entry:first');
120                        }
121                    })
122                } else {
123                    $(box).each(function( index ) {
124                        if ($.hasData(this) ) {
125                            moveTo = $('.article-entry:first').children().eq( $( this ).data('movedFrom') );
126                            $( this ).removeData();
127                            $( this ).appendTo(moveTo);
128                        }
129                    })
130                }
131            }		
132        }
133
134        moveArticleBoxes();
135        window.addEventListener('resize', moveArticleBoxes );
136
137
138        // Open Secondary Mobile Navigation (fix +'>')
139        $('.has-submenu > a').on('click', function(event) {
140            event.preventDefault();
141
142            $('body, html').animate({
143                'scrollTop': 0
144            }, 300);
145            $('body').addClass('overflow');
146            $('.offset-nav').addClass('overflow');
147            $(this).next().addClass('slideIn');
148        });
149
150        $('.offset-nav-dropdown .back').on('click', function(event) {
151            event.preventDefault();
152
153            $('body').removeClass('overflow');
154            $('.offset-nav').removeClass('overflow');
155            $(this).closest('.offset-nav-dropdown').removeClass('slideIn');
156        });
157
158        $.fn.doPlaceholders = function() {
159            if ($.support.placeholder) {
160                return this;
161            }
162
163            var $fields = this.filter(function () {
164                // Don't re-initialize
165                return !$(this).data('didPlaceholders');
166            });
167
168            $fields.on('focus blur', function(event) {
169                var placeholder = this.getAttribute('placeholder');
170
171                if (event.type === 'focus' && placeholder === this.value) {
172                    this.value = '';
173                } else if (event.type === 'blur' && this.value === '') {
174                    this.value = placeholder;
175                }
176            });
177
178            // Set the initial value to the title
179            $fields.each(function() {
180                if (this.value === '') {
181                    this.value = this.getAttribute('placeholder');
182                }
183            });
184
185            // Mark the fields as initialized
186            $fields.data('didPlaceholders', true);
187
188            return $fields;
189        };
190
191        $.support.placeholder = (function() {
192            return 'placeholder' in document.createElement('input');
193        })();
194
195        /* Don't select elements if placeholder is natively supported*/
196        if (!$.support.placeholder) {
197            $('input[placeholder], textarea[placeholder]').doPlaceholders();
198        }
199
200        $('.blink').focus(function () {
201            if ($(this).val() == $(this).attr('title')) {$(this).val('');}
202        }).blur(function () {
203            if ($(this).val() == '') {$(this).val($(this).attr('title'));}
204        });
205
206        $('.print').click(function() {
207            window.print();
208            return false;
209        });
210
211        // Both admin cookie-reset buttons currently clear the same popup cookies.
212        $('#reset-popup-cookies, #reset-popup-cookies-all').click(function() {
213            Cookies.remove('ssir_popup_closed');
214            Cookies.remove('ssir_pages');
215        });
216
217        $doc.on('click', '.citation-block__copy', function () {
218            $('.citation-copied').remove();
219            let target_id = $(this).data('target');
220            let range = document.createRange();
221            range.selectNode(document.getElementById(target_id));
222            window.getSelection().removeAllRanges(); // clear current selection
223            window.getSelection().addRange(range); // to select text
224            document.execCommand("copy");
225            window.getSelection().removeAllRanges();// to deselect
226            $('#' + target_id).append('<svg class="citation-copied" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>');
227        }).on('click', '.btn-cite', function () {$('#citation-popup').removeClass('hidden');}).on('click', '.citation-close', function () {$('#citation-popup').addClass('hidden');}).on('click', '.citation-backdrop', function (e) {
228            if (e.target.id == 'citation-popup') {$('#citation-popup').addClass('hidden');}
229        }).on('change', '#citation-selector', function () {
230            let citation_style = $(this).val();
231            $('#citation-content').html(citations[citation_style]);
232        });
233
234        $('.ico-close').click(function () {
235            $('.hovertext').removeClass('show');
236            $('.arrowblock').removeClass('show');
237        });
238
239        $('.hoverlink').click(function (e) {
240            if (!$(e.target).is('.ico-close'))
241            {
242                $('.hovertext', this).toggleClass('show');
243                $('.arrowblock', this).toggleClass('show');
244            }
245        });
246        
247        $( ".hoverlink" ).hover(
248            function() {
249                $('.hovertext', this).addClass('show');
250                $('.arrowblock', this).addClass('show');
251            }, function() {
252                $('.hovertext', this).removeClass('show');
253                $('.arrowblock', this).removeClass('show');
254            }
255         );
256        
257        if($win.width() < 480) {
258            $('.presenters .hoverlink').click(function () {
259                $('.arrowblock', this).hide();
260                $('.hovertext', this).css({
261                    'position': 'absolute',
262                    'top': $win.scrollTop(),
263                    'width' : $win.width(),
264                    'left' : '0px',
265                    'right' : '0px',
266                    'margin': '0'
267                });
268                
269            });
270        }
271        
272        $('.js-collapse-if-empty').each(function() {
273            var this_html = $(this).html().trim();
274            if (this_html.length == 0) {$(this).hide();}
275        });
276
277        // Ads
278        var moving_ads = 0;
279        var google_ads_at = 'desktop';
280
281        function moveGoogleAds() {
282            if ($(window).width() < 768 && google_ads_at == 'desktop') {
283                $('.desktop-ad-container').each(function () {
284                    var ad_zone_id = $(this).data('ad-key');
285
286                    if ($('.mobile-ad-container[data-ad-key="' + ad_zone_id + '"]').length > 0) {
287                        var ad_unit = $(this).children().detach();
288                        ad_unit.appendTo('.mobile-ad-container[data-ad-key="' + ad_zone_id + '"]');
289                    }
290                });
291                google_ads_at = 'mobile';
292            } else if ($(window).width() > 767 && google_ads_at == 'mobile') {
293                $('.mobile-ad-container').each(function () {
294                    var ad_zone_id = $(this).data('ad-key');
295                    var ad_unit = $(this).children().detach();
296
297                    if ($('.desktop-ad-container[data-ad-key="' + ad_zone_id + '"]').length > 0) {
298                        ad_unit.appendTo('.desktop-ad-container[data-ad-key="' + ad_zone_id + '"]');
299                    }
300                });
301                google_ads_at = 'desktop';
302            }
303        }
304
305        moveGoogleAds();
306        $(window).resize(function () {
307            clearTimeout(moving_ads);
308            moving_ads = setTimeout(function () {moveGoogleAds();}, 500);
309        });
310    });
311})(jQuery, window, document);

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.