1/* ************************************************** 2 3Name: responsive.js 4 5Description: Settings for Responsive Web Design 6 7Create: 2015.09.30 8Update: 2017.01.31 9Update: 2021.08.31 10 11Copyright 2015 Hitachi, Ltd. 12 13***************************************************** */ 14 15 16 17if (_responsiveLabel == undefined) { 18 var _responsiveLabel = { 19 "url":"http://www.hitachi.com/", 20 "close":"Close" 21 }; 22} 23var _headerScrollTop; 24 25function _checkRWD(width) { 26 27 var checkRWD = { 28 995 :$("#U995").css("display") == "block", 29 768 :$("#U768").css("display") == "block", 30 580 :$("#U580").css("display") == "block", 31 400 :$("#U400").css("display") == "block" 32 } 33 return checkRWD[width]; 34 35} 36 37 38 39(function($){ 40 41 42 43/* Append to DOM 44=========================================================================================== */ 45 46if (ua("win") || ua("mac")) $("html").addClass("PC"); 47if (ua("android")) $("html").addClass("Android"); 48$("html[class!='JS']").addClass("JS"); 49 50if ($("head meta[name=viewport]").attr("content") == "width=1024") { 51 $("head meta[name=viewport]").attr("content", "width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"); 52} 53 54var under995 = function() { 55 56 if (_checkRWD(995)) { 57 $("html[class!='Under995']").addClass("Under995"); 58 } else { 59 $("html[class*='Under995']").removeClass("Under995"); 60 } 61 62} 63 64$(document).ready(function() { 65 66 $("#UltraGlobalNavi").before('<p id="GlobalNaviTopButtonSP" class="BtnOpen ShowRWD"><a href="javascript:void(0);"><img src="/image/en/r1/icon/icon_navi_global.gif" width="21" height="21" alt="Menu" /></a></p>'); 67 $("#SiteIdentity .Title img").each(function() {$(this).after('<span class="ShowRWD">' + $(this).attr("alt") + '</span>');}); 68 $("body").append('<div id="U995"></div><div id="U768"></div><div id="U580"></div><div id="U400"></div>'); 69 under995(); 70 71 $(window).on("load resize", under995); 72 73}); 74 75 76 77/* Global Navigation 78=========================================================================================== */ 79 80$(document).ready(function() { 81 82 var gn = ''; 83 var cn = ''; 84 85 if ($("#GlobalNaviTop")[0]) { 86 gn = '<ul id="GlobalNaviTopSP">' 87 gn += $("#GlobalNaviTop").html(); 88 gn += '</ul>'; 89 } 90 91 if ($("#GlobalNavi .CourtesyNavi")[0]) { 92 var cn = '<ul id="CourtesyNaviSP">'; 93 cn += $("#GlobalNavi .CourtesyNavi").html(); 94 cn += '</ul>'; 95 } 96 97 $("#UltraGlobalNavi").prepend('<div id="GlobalNaviSP" class="ShowRWD">' + gn + cn + '</div>'); 98 99 if ($("#HorizontalLocalNavi")[0]) { 100 var hln = '<ul id="HorizontalLocalNaviSP">'; 101 hln += $("#HorizontalLocalNavi").html(); 102 hln += '</ul>'; 103 $("#GlobalNaviTopSP li.Current").append(hln); 104 } 105 106}); 107 108_headerScrollTop = function() { 109 110 var topID = (navigator.userAgent.indexOf("Safari") !== -1) ? "body" : "html"; 111 if ($(topID).scrollTop() > 100) { 112 $(topID).stop().animate({scrollTop: "0"}, 400, "swing"); 113 } 114 115} 116 117 118 119/* Link List 120=========================================================================================== */ 121 122$(document).ready(function() { 123 124 var boxLink = { 125 768 :".ResponsiveLinkListStyle dl.LinkListStyle1, .ResponsiveLinkListStyle dl.LinkListStyle2, .Re
125sponsiveLinkListStyle .ImgW60SetStyle, .ResponsiveLinkListStyle .ImgW120SetStyle, .ResponsiveLinkListStyle .ImgW180SetStyle, .ResponsiveLinkListStyle .ImgW230SetStyle, .ResponsiveLinkListStyle .ThumbW60SetStyle, .ResponsiveLinkListStyle .ThumbW120SetStyle, .ResponsiveLinkListStyle .ThumbW180SetStyle, .ResponsiveLinkListStyle .ThumbW230SetStyle", 126 580 :"", 127 400 :".ResponsivePanelStyle .Column1" 128 } 129 130 var addLink = function(width) { 131 132 $(boxLink[width]).each(function() { 133 if ($(this).find("a")[0]) { 134 135 $a = $(this).find("a"); 136 var js = $a.attr("onclick") || 0; 137 if (js) { 138 if (js.indexOf("this.href") !== -1) js = js.replace("this.href", "'" + $a.attr("href") + "'"); 139 $(this).attr("onclick", "if(_checkRWD(" + width + ")) {" + js + "}"); 140 $a.attr("onclick", "if(!_checkRWD(" + width + ")) {" + js + "}"); 141 } 142 143 $(this).addClass("LinkU" + width) 144 .removeClass("hover") // for Android 4.x 145 .on("mouseover", function() { 146 if (_checkRWD(width)) $(this).addClass("hover"); 147 }).on("mouseout", function() { 148 if (_checkRWD(width)) $(this).removeClass("hover"); 149 }).on("click", function(){ 150 if (_checkRWD(width) && !js) { 151 location.href = $(this).find("a").attr("href"); 152 return false; 153 } 154 }); 155 156 } 157 }); 158 } 159 160 $(".ResponsiveLinkListStyle .DateListStyle1 dt, .ResponsiveLinkListStyle .DateListStyle2 dt").each(function() { 161 $(this).next().find("a").prepend('<strong class="Date">' + $(this).text() + '</strong>'); 162 }); 163 164 addLink(768); 165 addLink(580); 166 addLink(400); 167 168}); 169 170 171 172/* Box 173=========================================================================================== */ 174 175$(document).ready(function() { 176 177 if (!$(".BoxPatternA .BoxImgStyle, .BoxPatternB .BoxImgStyle")[0]) return false; 178 179 $(".BoxPatternA .BoxImgStyle, .BoxPatternB .BoxImgStyle").each(function() { 180 var html = $(this).html(); 181 $(this).next(".Title, h2, h3, h4").after('<p class="BoxImgStyleRWD ShowRWD">' + html + '</p>'); 182 }); 183 184}); 185 186 187 188/* Table 189=========================================================================================== */ 190 191$(document).ready(function() { 192 193 if ($(".ResponsiveTableStyle1")[0]) { 194 195 $(".ResponsiveTableStyle1").each(function() { 196 197 var thItem = []; 198 $(this).find("tr").eq(0).find("th").each(function(i) { 199 if (i > 0) thItem[i] = $(this).text(); 200 }); 201 $(this).find("tr").each(function() { 202 $(this).find("td").each(function(i) { 203 $(this).prepend('<span class="ResponsiveTableHeading">' + thItem[i+1] + '</span>'); 204 }); 205 }); 206 207 }); 208 209 } 210 211 212 if ($(".ResponsiveTableStyle2")[0] || $(".ResponsiveTableStyle3")[0]) { 213 214 var contents = "#top, #SiteIdentity, #SiteIdentityS, #SiteIdentityL, #GlobalNavi, #TopicPath, #Contents, .Contents, .FatBanner, .FatMenu, .FatMenuWide, #Footer, #PageTopBottom"; 215 var topID = (ua("safari")) ? "body" : "html"; 216 var scrolltop = 0; 217 var android4 = navigator.userAgent.indexOf("Android 4") !== -1; // for Android 4.x 218
219 $(".ResponsiveTableStyle2, .ResponsiveTableStyle3").each(function() { 220 221 var grid = $(this).parent(".Grid4")[0] ? "Contents965" : "Contents720"; 222 223 var h = '<div class="ResponsiveTableWindow">'; 224 h += '<div class="SiteIdentityP">'; 225 h += '<p><a href="' + _responsiveLabel.url + '"><img src="/image/en/r1/corp_id.gif" alt="Hitachi" width="95" height="29" /></a></p>'; 226 h += '<ul class="CloseButtonStyle">'; 227 h += '<li><a href="javascript:void(0);">' + _responsiveLabel.close + '</a></li>'; 228 h += '</ul>'; 229 h += '</div>'; 230 h += android4 ? '<div class="ResponsiveTableContainer">' : ''; // for Android 4.x 231 h += '<div class="' + grid + '">'; 232 h += $(this).find(".TableSet").html(); 233 h += '</div>'; 234 h += android4 ? '</div>' : ''; // for Android 4.x 235 h += '</div>'; 236 237 $("body").append(h); 238 239 }); 240 241 $(".LinkSet a").on("click", function() { 242 243 scrolltop = $(topID).scrollTop(); 244 245 var index = $(".LinkSet a").index(this); 246 $("html").addClass("ResponsiveTableWindowOpen"); 247 $(contents + ", #HeaderArea").hide(); 248 $(".ResponsiveTableWindow").eq(index).show(); 249 250 $(topID).scrollTop(0); 251 252 }); 253 254 $(".CloseButtonStyle").on("click", function() { 255 256 var index = $(".CloseButtonStyle").index(this); 257 $("html").removeClass("ResponsiveTableWindowOpen"); 258 $(contents).removeAttr("style"); 259 $("#HeaderArea").show(); 260 $(".ResponsiveTableWindow").eq(index).removeAttr("style"); 261 262 $(topID).scrollTop(scrolltop); 263 264 }); 265 266 } 267 268}); 269 270 271 272/* Branding Image 273=========================================================================================== */ 274 275$(document).ready(function() { 276 277 $(".ResponsiveBrandingImgStyle").each(function() { 278 279 if ($(this).find("a")[0] && !$(this).find(".branding-image")[0]) { 280 $(this).addClass("hover").on("click", function() { 281 location.href = $(this).find("a").attr("href"); 282 }); 283 } 284 285 }); 286 287}); 288 289 290 291/* Image Box 292=========================================================================================== */ 293 294$(document).ready(function() { 295 296 $(".ImgBoxStyle1, .ImgBoxStyle2").each(function() { 297 var $img = $(this).find(".ImgOnlyStyle"); 298 var html = $img.html(); 299 $img.replaceWith('<p class="ImgOnlyStyle"><span>' + html + '</span></p>'); 300 }); 301 302}); 303 304$(window).on("load resize", function() { 305 306 if (_checkRWD(995) && !_checkRWD(580)) { 307 308 $(".ImgBoxStyle1, .ImgBoxStyle2").each(function() { 309 310 var $img = $(this).find("span"); 311 $img.removeAttr("style"); 312 var boxH = $(this).height(); 313 var imgW = $img.width(); 314 var imgH = $img.height(); 315 316 if (boxH > imgH) { 317 imgW = imgW * (boxH / imgH); 318 var imgM = ($(this).find(".ImgOnlyStyle").width() - imgW) / 2; 319 $img.width(imgW).css({marginLeft:imgM}); 320 } 321 322 }); 323 324 } 325 326}); 327 328 329 330/* Category Navigation 331=========================================================================================== */ 332 333$(document).ready(function() { 334 335 $(".CategoryNavi .Bottom").each(function() { 336 var cn = '<ul class="BottomSP ShowRWD">'; 337 cn += $(this).html(); 338 cn += '</ul>'; 339 $(this).parent().find(".Top2 .Current").append(cn); 340 }); 341 342}); 343 344 345 346/* Smooth Scroll 347=========================================================================================== */ 348 349$(document).ready(function() { 350 351 var topID = (ua("safari")) ? "html,body" : "html"; 352 353 $(".SmoothScroll").unbind().click(function(){ 354 var link = $(this).attr("href"); 355 if(link.charAt(0)=="#" && link.charAt(1)!="") { 356 var offset = $(link).offset(); 357 var tid = setTimeout(function() { 358 $(topID).stop().animate({scrollTop: offset.top}, 800, "easeInOutCubic", function() { 359 location.href = link; 360 }); 361 }, 10); 362 return false; 363 } 364 }); 365 366}); 367 368 369 370/* Page Top Button 371=========================================================================================== */ 372 373$(window).on("load", function() { 374 375 var link = navigator.userAgent.indexOf("Android 2") == -1 ? "#top" : "javascript:void(0)"; 376 if (!$("#PageTopBottom")[0]) $("body").append('<ul id="PageTopBottom" class="ShowRWD"><li><a href="' + link + '"><span>Page top</span></a></li></ul>'); 377 378 var topID = (ua("safari")) ? "html,body" : "html"; 379 380 $("#PageTopBottom a").on("click", function(){ 381 if (navigator.userAgent.indexOf("Android 2") == -1) { 382 var tid = setTimeout(function() { 383 $(topID).stop().animate({scrollTop: 0}, 800, "easeInOutCubic", function() { 384 location.href = "#top"; 385 }); 386 }, 10); 387 } else { 388 var scrolltop = $(topID).scrollTop(); 389 $(topID).scrollTop(scrolltop - 1); 390 var tid = setTimeout(function() { 391 $(topID).stop().animate({scrollTop: 1}, 800, "easeInOutCubic"); 392 }, 50); 393 } 394 return false;
395 }); 396 397}); 398 399 400 401/* for Android 2.x 402=========================================================================================== */ 403 404$(document).ready(function() { 405 406 if (navigator.userAgent.indexOf("Android 2") !== -1) { 407 408 $("a").each(function() { 409 var link = $(this).attr("href"); 410 if (typeof link !== "undefined" && link.charAt(0)=="#" && link.charAt(1)!="") { 411 if ($(this).hasClass("SmoothScroll")) { 412 $(this).attr("href", "javascript:_smoothScroll('" + link + "')") 413 .removeClass("SmoothScroll"); 414 } else { 415 $(this).attr("href", "javascript:_internalLink('" + link + "')") 416 } 417 } 418 }); 419 420 var topID = (ua("safari")) ? "body" : "html"; 421 422 _smoothScroll = function(link) { 423 var offset = $(link).offset(); 424 var offsettop = offset.top == 0 ? 1 : offset.top; 425 var scrolltop = $(topID).scrollTop(); 426 $(topID).scrollTop(scrolltop - 1); 427 var tid = setTimeout(function() { 428 $(topID).stop().animate({scrollTop: offsettop}, 800, "easeInOutCubic"); 429 }, 50); 430 return false; 431 } 432 433 _internalLink = function(link) { 434 var offset = $(link).offset(); 435 var offsettop = offset.top == 0 ? 1 : offset.top; 436 $(topID).scrollTop(offsettop); 437 return false; 438 } 439 440 } 441 442}); 443 444 445 446})(jQuery); 447 448 449 450if (navigator.userAgent.indexOf("Android 2") !== -1) { 451 452 var _smoothScroll; 453 var _internalLink; 454 455} 456 457 458 459/* Base Settings 460=========================================================================================== */ 461 462// Browser size 463 464function getBrowserWidth() { 465 return window.innerWidth || self.innerWidth || (document.documentElement&&document.documentElement.clientWidth) || document.body.clientWidth; 466} 467 468function getBrowserHeight() { 469 return window.innerHeight || self.innerHeight || (document.documentElement&&document.documentElement.clientHeight) || document.body.clientHeight; 470}
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.