PageSourceSearch

https://www.workit.jp/themes/custom/workit/custom/js/workit.node.js?tmcumf

js workit.jp collected 2026-10-04 02:15:50 UTC 5,334 bytes, 172 lines download raw bytes

1/**
2 * @file
3 * Contains js for the search.
4 */
5
6(function ($, Drupal, drupalSettings, once, cookies) {
7
8  'use strict';
9
10  /**
11   * Add job_id to keep_list.
12   */
13  Drupal.behaviors.jobs_keep = {
14    attach: function (context, settings) {
15      $(once('jobs_keep', '#wrap', context)).each(function () {
16        var options = $.extend({
17          total: ['.header_icolist-item__keep span','span.header-btn__keep-num','.footer-follow-nav_list-item__keep .keep_number'],
18          btn_keep: '.keep-job',
19          max_keep: 20,
20          cookie_name: 'keep_jobs_list',
21          cookie_settings: {
22            path: '/',
23            domain  : drupalSettings.subdomain,
24            expires : 365,
25            secure: true,
26          },
27          cls: 'is-end is-active',
28        }, settings.jobs_keep);
29        var $wrap = $(this);
30        var keep_list = cookies.get(options.cookie_name) ? JSON.parse(cookies.get(options.cookie_name)) : [];
31        var keep_text = 'キープする';
32
33        var getKeepText = function ($btn) {
34          if ($(window).width() <= g_breakpoints) {
35            return 'キープする';
36          }
37          return keep_text;
38        };
39
40        var setKeep = function(id) {
41          keep_list = cookies.get(options.cookie_name) ? JSON.parse(cookies.get(options.cookie_name)) : [];
42          if (inKeep(id)) {
43            keep_list.splice(keep_list.indexOf(id), 1);
44          } else {
45            keep_list.push(id);
46            if (keep_list.length > options.max_keep) {
47              check_keep_full();
48              return false;
49            }
50          }
51          cookies.set(options.cookie_name, JSON.stringify(keep_list), options.cookie_settings);
52          toogleBtnKeep(id);
53        }; // End keeps.
54
55        var inKeep = function(id) {
56          // var list = getKeeps();
57          return ($.inArray(id, keep_list) == -1) ? false : true;
58        } // Check id in keeps.
59
60        var getId = function($elm) {
61          return parseInt($elm.attr('id'));
62        }
63
64        var updateTotal = function() {
65          // var list = getKeeps();
66          $.each(options.total, function (key,value) {
67            $wrap.find(value).text(keep_list.length);
68          })
69        }
70
71        var toogleBtnKeep = function(id) {
72          var $btn = $(options.btn_keep + '[id=' + id + ']');
73          if (inKeep(id)) {
74            $btn.addClass(options.cls)
75              .find('span.keep-btn-hidden').text('キープ済み');
76          } else {
77            $btn.removeClass(options.cls);
78            $btn.each(function() {
79              $(this).find('span.keep-btn-hidden').text(getKeepText($(this)));
80            });
81          }
82          updateTotal();
83        }
84
85        // Toogle button keeps when init page.
86        $(options.btn_keep).each(function(index, el) {
87          var id = getId($(this));
88          toogleBtnKeep(id);
89        });
90
91        // Add or remove cookie when clicked button.
92        $(context).on('click', options.btn_keep, function(event) {
93          var id = getId($(this));
94          setKeep(id);
95        });
96
97        // Remove cookie when clicked button delete on '/keep' page.
98        $(context).on('click', 'div.c-job-panel_delete', function(event) {
99          var id = getId($(this));
100          $('li.delete_cookie').attr('id', id);
101        });
102        $(context).on('click', 'li.delete_cookie', function(event) {
103          var id = getId($(this));
104          keep_list.splice(keep_list.indexOf(id), 1);
105          cookies.set(options.cookie_name, JSON.stringify(keep_list), options.cookie_settings);
106          location.reload();
107        });
108        updateTotal();
109
110      }); // End once.
111
112    } // End attach.
113  } // End behaviors jobs_keep.
114
115  /**
116   * Add nid to cookie recent_views.
117   */
118  Drupal.behaviors.recent_view = {
119    attach: function (context, settings) {
120      $(once('recent_view', '#wrap', context)).each(function () {
121        var options = $.extend({
122          cookie_name: 'recent_views',
123          cookie_settings: {
124            path: '/',
125            domain  : drupalSettings.subdomain,
126            secure: true,
127          },
128          max: 4,
129        }, settings.recent_views);
130        var list = cookies.get(options.cookie_name) ? JSON.parse(cookies.get(options.cookie_name)) : [];
131
132        if (settings.recent_views) {
133          var id = parseInt(settings.recent_views);
134          if ($.inArray(id, list) == -1) {
135            list.push(id);
136          }
137          if (list.length > options.max) {
138            list.splice(0, 1);
139          }
140          cookies.set(options.cookie_name, JSON.stringify(list), options.cookie_settings);
141        }
142      });
143    } // End attach.
144  } // End behaviors recent_view.
145
146  function check_keep_full() {
147
148    if (window.innerWidth > g_breakpoints) {
149      parent.$.colorbox({
150        inline: true,
151        maxWidth: '620px',
152        innerWidth: '620px',
153        top: '30%',
154        reposition: false,
155        scrolling: false,
156        opacity: 0.7,
157        href: '#js-keepfull-content'
158      });
159    } else {
160      parent.$.colorbox({
161        inline: true,
162        maxWidth: '92%',
163        innerWidth: '92%',
164        top: '60px',
165        reposition: false,
166        scrolling: false,
167        opacity: 0.7,
168        href: '#js-keepfull-content'
169      });
170    }
171  }
172})(jQuery, Drupal, drupalSettings, once, window.Cookies);

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.