PageSourceSearch

https://usen.com/js/common/header.js

js usen.com collected 2026-09-24 08:47:54 UTC 16,251 bytes, 466 lines download raw bytes

1function App() { }
2var app = new App();
3
4App.prototype.CommonClass = function () {
5  //------------------------------------------------------------------
6  //CONFIG
7  //------------------------------------------------------------------
8  this.IS_SP = true;
9  $body = $("body");
10
11  //------------------------------------------------------------------
12  // カスタムプロパティ
13  //------------------------------------------------------------------
14  var height = window.innerHeight;
15  document.documentElement.style.setProperty("--vh", height / 100 + "px");
16
17  //------------------------------------------------------------------
18  //ウィンドウ幅でSP・PC判別
19  //------------------------------------------------------------------
20  this.MediaQuery = function () {
21    var _breakpoint = 1023;
22    var _width = window.innerWidth ? window.innerWidth : $(window).width();
23    app.IS_SP = _width <= _breakpoint ? true : false;
24  };
25  this.MediaQuery();
26
27  //------------------------------------------------------------------
28  //リサイズイベント
29  //------------------------------------------------------------------
30  var _self = this;
31  window.onresize = function () {
32    //ブラウザ判別
33    _self.MediaQuery();
34  };
35
36  //------------------------------------------------------------------
37  //ヘッダー current
38  //------------------------------------------------------------------
39  //    var link1 = $(".header-level2-right-nav > li > a");
40  //    var link1url = link1.attr('href');
41  var Dx = "dx";
42  var Company = "company";
43  var Contact = "contact";
44  var Service = "service";
45  var Csr = "csr";
46  var Legal = "legal";
47  var News = "news";
48  var Newsrelease = "newsrelease";
49  var Newsrelease2025 = "newsrelease_2025";
50  var Case = "case";
51  var Portal = "portal";
52  var Column = "column";
53  var Pos = "pos";
54
55  // header level1
56  this.headerCurrentLevel1 = function () {
57    var href = location.pathname.split("/")[1];
58    var level1link1 = $(".header-level1-right-nav > li:nth-child(1)");
59    var level1link2 = $(".header-level1-right-nav > li:nth-child(2)");
60    var level1link3 = $(".header-level1-right-nav > li:nth-child(3)");
61    var level1link4 = $(".header-level1-right-nav > li:nth-child(4)");
62    var level1link5 = $(".header-level1-right-nav > li:nth-child(5)");
63    if (href === Service || location.pathname.includes("portal/support")) {
64      level1link1.addClass("current");
65    } else if (href === Company || href === Csr) {
66      level1link2.addClass("current");
67    } else if (href === News || href === Newsrelease || href === Newsrelease2025) {
68      level1link3.addClass("current");
69    } else if (href === Case) {
70      level1link4.addClass("current");
71    }
72
73  };
74  this.headerCurrentLevel1();
75
76  // header level2
77  // this.headerCurrentLevel2 = function () {
78  // if ($(location).attr("href").match(Portal)) {
79  //   $(".header-level2-right-nav > li:nth-child(1)").addClass("current");
80  // } else if ($(location).attr("href").match(Company)) {
81  //   $(".header-level2-right-nav > li:nth-child(1)").addClass("current");
82  //   $(".js-companylist").addClass("is-active");
83  //   $(".js-nav-pulldown-title").addClass("is-active");
84  // } else if ($(location).attr("href").match(Case)) {
85  //   $(".header-level2-right-nav > li:nth-child(2)").addClass("current");
86  // } else if ($(location).attr("href").match(News)) {
87  //   if ($(location).attr("href").match(Pos)) {
88  //     $(".header-level2-right-nav > li:nth-child(1)").addClass("current");
89  //   } else {
90  //     $(".header-level2-right-nav > li:nth-child(2)").addClass("current");
91  //   }
92  // } else if ($(location).attr("href").match(Dx)) {
93  //   $(".header-level2-right-nav > li:nth-child(4)").addClass("current");
94  // } else if ($(location).attr("href").match(Contact)) {
95  //   $(".header-level2-right-nav > li:nth-child(5)").addClass("current");
96  // } else if ($(location).attr("href").match(Csr)) {
97  //   $(".header-level2-right-nav > li:nth-child(3)").addClass("current");
98  // } else if ($(location).attr("href").match(Service)) {
99  // $(".header-level2-right-nav > li:nth-child(1)").addClass("current");
100  // }
101  // };
102  // this.headerCurrentLevel2();
103
104  // header level3
105  //ヘッダー上カレントアンダーライン設定
106  this.headerCurrentLevel3 = function () {
107    var href = location.href;
108    var url = href.split("#")[0];
109
110    // srevice配下 current
111    var link2 = $(".header-nav-list-menu a,.header-nav-list-menu span");
112    // console.log("link2.length"+link2.length);
113    var parent2 = $(".header-level3-right-nav li");
114    if (!parent2.length) return false;
115    if (url.includes("/service/payment/")) {
116      var link2 = $(".header-nav-list-menu a");
117    }
118
119    let current;
120    if (url.includes("/service/pos/case/")) {
121      current = 22; //TODO:とりあえずマジックナンバーでしのぐ。CMS化のタイミングで修正
122    } else if (url.endsWith("/service/pos/")) {
123      current = 0;
124    } else if (url.includes("/service/bgm/u-music/")) {
125      for (var i = 0; i < link2.length; i++) {
126        if (url.includes(link2[i].href)) {
127          current = i;
128          if (current > 8) {
129            current = current - 1;
130          }
131        }
132        if (url.includes("/u-music/faq/")) {
133          current = 26;
134        }
135      }
136    } else {
137      for (var i = 0; i < link2.length; i++) {
138        if (url.includes(link2[i].href)) {
139          current = i;
140        }
141        // if (link2[i].href == url) {
142        // 	parent2[current].classList.add("current");
143        // 	parent2[current].closest(".header-nav-list-menu").classList.add("current");
144        // }
145      }
146    }
147    if (!parent2[current]) return false;
148    if (url.includes("/service/pos/")) {
149      if (current > 0 && current > 13) current = current + 2;
150      if (url.includes("/service/pos/faq/")) current = 25;
151      if (url.includes("/service/pos/tab/uregibeauty/function/") ||
152        url.includes("/service/pos/tab/uregistore/function/") ||
153        url.includes("/service/pos/tab/uregihealthcare/function/")) {
154        $(".header-level3-right-nav > li:nth-child(1)").addClass("current");
155
156      }
157      if (current > 10 && current < 19) current = current - 2;
158      if (parent2[current].closest(".gnav-service-col")) return false;
159    }
160    parent2[current].classList.add("current");
161    parent2[current].closest(".header-nav-list-menu").classList.add("current");
162
163    // company配下 current
164    var link3 = $(".body-localnav-lists > li a");
165    var parent3 = $(".body-localnav-lists > li");
166    for (var i = 0; i < link3.length; i++) {
167      if (link3[i].href == url) {
168        if (!parent3[i]) return false;
169        parent3[i].classList.add("current");
170      }
171    }
172
173
174  };
175  this.headerCurrentLevel3();
176
177  // header level4
178  this.headerCurrentLevel4 = function () {
179    var href = location.href;
180    var link4 = $(".header-level4-right-menu > li > a");
181    var parent4 = $(".header-level4-right-menu > li");
182    let current;
183    for (var i = 0; i < link4.length; i++) {
184      if (current === undefined && link4[i].href.includes(href)) {
185        current = i;
186      }
187      // if (link4[i].href == href) {
188      //   if(!parent4[i]) return false;
189      //   parent4[i].classList.add("current");
190      //   parent4[i].closest(".header-level4-right-menu li").classList.add("current");
191      //   $(".header-level3-right-nav > li:nth-child(2)").addClass('current');
192      // }
193    }
194    if (!parent4[current]) return false;
195    parent4[current].classList.add("current");
196    parent4[current]
197      .closest(".header-level4-right-menu li")
198      .classList.add("current");
199
200    if (!href.includes("/service/pos/")) {
201      $(".header-level3-right-nav > li:nth-child(2)").addClass("current");
202    }
203  };
204  this.headerCurrentLevel4();
205
206  // gnav-service
207  //グロナビプルダウン内各ページ網掛けの設定
208  this.headerProductlist = function () {
209    var href = location.href;
210    var link5 = $(".gnav-service-col a");
211    for (var i = 0; i < link5.length; i++) {
212      if (link5[i].href == href) {
213        // console.log(href);
214        link5[i].closest(".gnav-service-col").classList.add("current");
215        link5[i].closest(".gnav-service").classList.add("current");
216      } else if (href.includes("/service/pos/guide/")) {
217        if (link5[i].href.includes("/service/pos/guide/")) {
218          link5[i].closest(".gnav-service-col").classList.add("current");
219          link5[i].closest(".gnav-service").classList.add("current");
220        }
221
222      } else if (href.includes("/service/pos/tab/uregibeauty/")) {
223        if (link5[i].href.includes("/service/pos/uregibeauty/")) {
224          link5[i].closest(".gnav-service-col").classList.add("current");
225          link5[i].closest(".gnav-service").classList.add("current");
226        }
227
228      } else if (href.includes("/service/pos/tab/uregistore/")) {
229        if (link5[i].href.includes("/service/pos/uregistore/")) {
230          link5[i].closest(".gnav-service-col").classList.add("current");
231          link5[i].closest(".gnav-service").classList.add("current");
232        }
233
234      } else if (href.includes("/service/pos/tab/uregihealthcare/")) {
235        if (link5[i].href.includes("/service/pos/uregihealthcare/")) {
236          link5[i].closest(".gnav-service-col").classList.add("current");
237          link5[i].closest(".gnav-service").classList.add("current");
238        }
239
240      }
241    }
242  };
243  this.headerProductlist();
244
245
246  // gnav-service
247  this.robotHeaderProductlist = function () {
248    var href = location.href;
249    if (href.includes("/robot/")) {
250      var robotLink = $(".robot-list-sub a");
251      for (var i = 0; i < robotLink.length; i++) {
252        if (robotLink[i].href == href) {
253          robotLink[i].closest(".robot-list-sub-item").classList.add("current");
254        }
255      }
256
257    }
258
259  }
260  this.robotHeaderProductlist();
261
262  //------------------------------------------------------------------
263  //サービス一覧
264  //------------------------------------------------------------------
265  this.toggleServicelist = function () {
266    var ClassName = "is-active";
267    var ClassName2 = "is-open";
268    var $targetPc = $(".js-nav-pulldown-title");
269    var $targetSp = $(".js-nav-pulldown-title");
270    if (app.IS_SP) {
271      // SP版
272      $targetSp.click(function () {
273        $(this).toggleClass(ClassName);
274        $targetPc.toggleClass("active");
275      });
276    } else {
277      // PC版
278      $targetPc.click(function () {
279        $(this).parent().toggleClass(ClassName);
280        $("header").toggleClass(ClassName2);
281      });
282    }
283  };
284  this.toggleServicelist();
285
286  //------------------------------------------------------------------
287  // ローカルナビの開閉
288  //------------------------------------------------------------------
289  this.toggleLocalNav = function () {
290    var ClassName = "is-active";
291    var $target = $(".nav-servicelist");
292    if (app.IS_SP) {
293      // SP版
294      $target.click(function () {
295        $(this).toggleClass(ClassName);
296      });
297    } else {
298      $target.on("click", function () {
299        $(this).addClass(ClassName);
300        $(this).children(".body-localnav-body").fadeIn();
301      });
302      $target.mouseleave(function () {
303        $(this).removeClass(ClassName);
304        $(this).children(".body-localnav-body").fadeOut(0);
305      });
306    }
307  };
308  this.toggleLocalNav();
309
310  //------------------------------------------------------------------
311  // ローカルナビの開閉
312  //------------------------------------------------------------------
313  this.kaigyoNav = function () {
314    var ClassName = "is-active";
315    var $target = $(".list-0");
316    if (app.IS_SP) {
317      // SP版
318      $target.click(function () {
319        $(this).toggleClass(ClassName);
320      });
321    } else {
322      $target.click(function () {
323        $(this).toggleClass(ClassName);
324        $(this).children(".body-localnav-body").fadeToggle();
325      });
326      $target.mouseleave(function () {
327        $(this).removeClass(ClassName);
328        $(this).children(".body-localnav-body").fadeOut(0);
329      });
330    }
331  };
332  this.kaigyoNav();
333
334  //------------------------------------------------------------------
335  //ヘッダープルダウンメニュー
336  //------------------------------------------------------------------
337  this.headerPulldown = function () {
338    var ClassName = "is-active";
339    var $target = $(".js-pulldownmenu");
340    if (app.IS_SP) {
341      // SP版
342      $target.click(function () {
343        $(this).toggleClass(ClassName);
344      });
345    } else {
346      // PC版
347      $target.hover(function () {
348        $(this).addClass(ClassName);
349        $(".js-pulldownmenu.is-active").mouseleave(function () {
350          $(this).removeClass(ClassName);
351          $(".body-localnav-head").removeClass(ClassName);
352        });
353      });
354    }
355  };
356  this.headerPulldown();
357
358  //------------------------------------------------------------------
359  //SP版ハンバーガーボタンクリック
360  //------------------------------------------------------------------
361  this.toggleHumberger = function () {
362    var className = "is-active";
363    var $target = app.IS_SP
364      ? $(".hamburger, .header-nav-list-menu a")
365      : $(".hamburger");
366    function action() {
367      $target.click(function () {
368        $(".hamburger").toggleClass(className);
369      });
370    }
371    action();
372  };
373  this.toggleHumberger();
374
375  //------------------------------------------------------------------
376  // プロダクト
377  //------------------------------------------------------------------
378  this.toggleProductlist = function () {
379    var ClassName = "is-active";
380    var $target = $(".gnav-service-title");
381    var $targetSub = $(".gnav-service-col");
382    if (app.IS_SP) {
383      // SP版
384      $target.click(function () {
385        $(this).parent().toggleClass(ClassName);
386        //                $target.toggleClass('active');
387      });
388      $targetSub.click(function () {
389        $(this).toggleClass(ClassName);
390        //                $targetSub.toggleClass('active');
391      });
392    } else {
393      // PC版
394      $target.hover(function () {
395        $(this).parent().addClass(ClassName);
396        $(".gnav-service.is-active").mouseleave(function () {
397          $(this).removeClass(ClassName);
398        });
399      });
400    }
401    // var href = location.href;
402    // var url = href.split("#")[0];
403    // console.log(url);
404    // if (url.includes("/service/pos/")) {
405    //   var $target = $(".pos-pulldown");
406    //   $target.click(function () {
407    // console.log(url);
408    //     $(this).toggleClass(ClassName);
409    //     //                $target.toggleClass('active');
410    //   });
411    // }
412  };
413  this.toggleProductlist();
414
415
416  //------------------------------------------------------------------
417  // TOP POSレジ・決済タブ モーダル
418  //------------------------------------------------------------------
419  const modalBtns = document.querySelectorAll(".modalOpen");
420  modalBtns.forEach(function (btn) {
421    btn.onclick = function () {
422      var modal = btn.getAttribute('data-modal');
423      document.getElementById(modal).style.display = "block";
424    };
425  });
426  const closeBtns = document.querySelectorAll(".modalClose");
427  closeBtns.forEach(function (btn) {
428    btn.onclick = function () {
429      var modal = btn.closest('.modal01');
430      modal.style.display = "none";
431    };
432  });
433
434  window.onclick = function (event) {
435    if (event.target.className === "modal01") {
436      event.target.style.display = "none";
437    }
438  };
439
440  //------------------------------------------------------------------
441  // ヘッダー FIX
442  //------------------------------------------------------------------
443  this.headerFixed = function () {
444    var $win = $(window),
445      $content = $(".content"),
446      $nav = $(".header"),
447      $info = $(".infomation"),
448      navHeight = $nav.outerHeight(),
449      navPos = $nav.offset().top,
450      fixedClass = "is-fixed",
451      scrollSize = 44;
452
453    $win.on("load scroll", function () {
454      var value = $(this).scrollTop();
455      if (value > scrollSize) {
456        $nav.addClass(fixedClass);
457        // $content.css('margin-top', navHeight);
458      } else {
459        $nav.removeClass(fixedClass);
460        // $content.css('margin-top', '0');
461      }
462    });
463  };
464  this.headerFixed();
465};
466app.CommonClass();

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.