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