PageSourceSearch

https://www.paramountpictures.com/themes/custom/paramount/js/news-search.js?v=11.1.2

js paramountpictures.com collected 2026-10-02 03:53:06 UTC 4,447 bytes, 95 lines download raw bytes

1(function($, Drupal, once) {
2  'use strict';
3
4  // News type tabs and selector
5  Drupal.behaviors.paramountNewsSearchType = {
6    attach: function (context, settings) {
7      $(document).ready(function() {
8        const newsSearchView = document.querySelector('.view-news-search');
9        if (newsSearchView) {
10          const filterSelector = document.querySelector('[data-drupal-selector="edit-type"]');
11          const newsTypeSelector = document.querySelector('#news-type-selector');
12
13          // News type tabs listener on desktop
14          once('news-search-view-filters', '.news-type-button', context).forEach(button => {
15            button.addEventListener("click", function (event) {
16              event.preventDefault();
17              if (filterSelector.value !== this.getAttribute("data-key")) {
18                filterSelector.value = this.getAttribute("data-key");
19                filterSelector.dispatchEvent(new Event("change", { bubbles: true }));
20              }
21            });
22          });
23
24          // News type selector listener on mobile
25          once('news-search-view-filters', '#news-type-selector', context).forEach(selector => {
26            selector.addEventListener("change", function () {
27              if (filterSelector.value !== newsTypeSelector.value) {
28                filterSelector.value = newsTypeSelector.value;
29                filterSelector.dispatchEvent(new Event("change", { bubbles: true }));
30              }
31            });
32          });
33
34          // Update news type selector
35          newsTypeSelector.value = filterSelector.value;
36
37          // Update news type tabs
38          document.querySelectorAll('.news-type-button').forEach(button => {
39            button.classList.toggle('active', filterSelector.value === button.getAttribute("data-key"));
40          });
41        }
42      });
43    }
44  }
45
46  // Year selector and month selector
47  Drupal.behaviors.paramountNewsSearchDateSelector = {
48    attach: function (context, settings) {
49      $(document).ready(function () {
50        const newsSearchView = document.querySelector('.view-news-search');
51        if (newsSearchView) {
52          const yearSelector = document.getElementById("year-selector");
53          const monthSelector = document.getElementById("month-selector");
54          const createdFrom = $('[data-drupal-selector="edit-created-from"]').val();
55          const createdTo = $('[data-drupal-selector="edit-created-to"]').val();
56          const submitBtn = $('.view-news-search .views-exposed-form button[type="submit"]');
57
58          // Date selector listener
59          once('news-search-view-filters', '.date__selector', context).forEach(selector => {
60            selector.addEventListener("change", function () {
61              const selectedYear = yearSelector.value;
62              const selectedMonth = monthSelector.value;
63              const daysInMonth = new Date(parseInt(selectedYear, 10), parseInt(selectedMonth, 10), 0).getDate();
64
65              if (selectedYear !== 'All') {
66                // condition 1 - select year and select month
67                // condition 2 - select month only => will display all, year must be selected if month was selected
68                // condition 3 - select year only  => will display January 01 to December 31 by years
69                // condition 4 - no selection      => will display all
70                const dateFrom = `${selectedYear}-${selectedMonth === 'All' ? '01' : selectedMonth}-01`;
71                const dateTo = `${selectedYear}-${selectedMonth === 'All' ? '12' : selectedMonth}-${daysInMonth ? daysInMonth : '31'}`;
72                $('[data-drupal-selector="edit-created-from"]').val(dateFrom);
73                $('[data-drupal-selector="edit-created-to"]').val(dateTo);
74                if (submitBtn.length) {
75                  submitBtn.trigger('click');
76                }
77              }
78            });
79          });
80
81          // Update Date selector
82          if (createdFrom !== '') {
83            const yearFrom = createdFrom.match(/^(\d{4})/);
84            yearSelector.value = yearFrom ? yearFrom[1] : null;
85            const monthFrom = createdFrom.match(/^\d{4}-(\d{1,2})-.*/);
86            const monthTo = createdTo.match(/^\d{4}-(\d{1,2})-.*/);
87            if (!(monthFrom[1] === '01' && monthTo[1] === '12'))  {
88              monthSelector.value = monthFrom ? monthFrom[1] : null;
89            }
90          }
91        }
92      });
93    }
94  }
95})(jQuery, Drupal, once);

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.