this.jQuery && (function(win, doc, $){ 'use strict'; /* ---------------------------------------------------------------- 鍏ㄤ綋瑷畾 ----------------------------------------------------------------- */ var $win = $(win), $doc = $(doc), $html = $(doc.documentElement).removeClass('state-js-off'), //IE8銇垽瀹 ie8Flg = !!doc.getElementById('state-ie-8'); /* ---------------------------------------------------------------- Plugin瀹氱京 ----------------------------------------------------------------- */ /** * jQuery set_rollover plugin * version: 1.0.0 * * Copyright (c) 2013 Mitsue-Links Co., Ltd. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ $.fn.SetRollover = function(options){ var settings = { extension : '_o', hover_extension : '_h', menu : {} }; if(options){ $.extend(settings, options); } var path = doc.location.pathname; var active = false; $.each(settings.menu, function(menu_path){ if(path.match(new RegExp("^" + menu_path))){ active = settings.menu[menu_path]; } }); return this.filter(function(){ return $(this).attr("src").match(settings.extension); }).each(function(){ var roll = new Image(); roll.src = this.src.replace(settings.extension + '.', settings.hover_extension + '.'); if(this.src.match(/[^\/]+$/)[0] === active){ this.src = this.src.replace(new RegExp(settings.extension + "(\.[a-z]+)$"), settings.hover_extension + "$1"); } else{ if(this.parentNode.nodeName.match(/a/i)){ $(this).parent().focus(function(){ $(this).find(">img").trigger("mouseover"); }).blur(function(){ $(this).find(">img").trigger("mouseout"); }); } $(this).mouseover(function(){ this.src = this.src.replace(new RegExp(settings.extension + "(\.[a-z]+)$"), settings.hover_extension + "$1"); }).mouseout(function(){ this.src = this.src.replace(settings.hover_extension, settings.extension); }); } }); }; /** * jQuery SetAdjustHeight plugin * version: 1.0.0 * required: jQuery 2++ * * Copyright (c) 2013 Mitsue-Links Co., Ltd. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ $.fn.SetAdjustHeight = function(options){ if(!this){ return false; } var o = $.extend({ 'target' : '>*', 'each' : 0, 'monitorInterval' : 0 }, options); var timer, i, task = []; var cullInterval = 100; function fontSizeMonitor(){ clearTimeout(timer); timer = setTimeout(function(){ for(i = 0; i < task.length; ++i){ task[i](); } fontSizeMonitor(); }, o.monitorInterval); } o.monitorInterval = parseInt(o.monitorInterval, 10) || 0; if(0 > o.monitorInterval){ o.monitorInterval = 0; } (o.monitorInterval) && fontSizeMonitor(); return this.each(function(){ var $root = $(this); var $targets = $root.find(o.target); var $target; var flex = 'flex' === o.each; var each = Math.floor(parseInt(o.each, 10)) || $targets.length; var height = 0; var fontSize = $root.css('fontSize'); var display, temp, i, j, k, l, cullTimer; if(!$targets.length){ return; } function adjust(){ $targets.css('height', 'auto'); if(flex){ each = Math.floor($root.eq(0).innerWidth() / $targets.eq(0).outerWidth()); } for(i = 0, l = Math.ceil($targets.length / each); i < l; ++i){ height = 0; for(j = 0; j < each; ++j){ $target = $targets.eq((i * each) + j); if($target.length){ height = Math.max(height, Math.max( getStyleNum($target, 'minHeight'), getStyleNum($target, 'height') )); } } if(height){ for(k = 0; k < each; ++k){ $target = $targets.eq((i * each) + k).css('height', height); display = $target.css('display'); // BUG: IE9鏈簚銇ф弿鐢汇亴鏇存柊銇曘倢銇亜鍫村悎銇屻亗銈嬨伄銇с儶銉曘儹銉 if((doc.uniqueID && !doc.getElementsByClassName) && ('none' !== display)){ $target.css('display', 'none').css('display', display); } } } } } function getStyleNum($elem, style){ return (parseFloat($elem.css(style)) || 0); } ($root.find('img').length) && $win.on('load', function(){ adjust(); }); $win.on('resize', function(){ clearTimeout(cullTimer); cullTimer = setTimeout(function(){ adjust(); }, cullInterval); }); adjust(); (o.monitorInterval) && task.push(function(){ temp = $root.css('fontSize'); if(temp !== fontSize){ fontSize = temp; adjust(); } }); }); }; // SetDialog // ------------------------------------------------------------------------------ (function(){ var DialogSpace = {}; DialogSpace.buildFlg = false; DialogSpace.activeObject; DialogSpace.rootContent = $('body'); var Dialog = function(element, options){ var t = this; t.o = options; t.$hook = $(element); t.$overlay = $($(t.o.overlay)[0] || t.createElement(t.o.overlay)); t.$dialogWrapper = $($(t.o.dialogWrapper)[0] || t.createElement(t.o.dialogWrapper)); t.$dialog = $($(t.o.dialog)[0] || t.createElement(t.o.dialog, t.o.dialogFooterHtml)); t.$dialogInner = $($(t.o.dialogInner)[0] || t.createElement(t.o.dialogInner)); t.targetUrl = t.$hook.attr('href'); t.tabindexSelecter = '.' + t.o.tabindexClassName; t.tabindexDataAttribute = 'data-' + t.o.tabindexClassName; t.dialogDisplay = false; }; Dialog.prototype = { // Controller // ------------------------------ init : function(){ var t = this; // 銉€銈ゃ偄銉偘銇〃绀恒仌銇涖倠瑕佺礌銇屻仾銇勫牬鍚堛伅銈广偔銉冦儣 if(!t.targetUrl) return; t.set(); }, set : function(){ var t = this; t.build(); //銉€銈ゃ偄銉偘銇〃绀恒倰瑷畾 t.$hook.on('click', function(e){ e.preventDefault(); t.show(e); }); //銉€銈ゃ偄銉偘銇潪琛ㄧず銈掕ō瀹 t.$overlay.on('click', $.proxy(function(){ t.hide(); }, t)); $doc.on('click', '.dialog-footer-link a', function(e){ e.preventDefault(); t.hide(); }); $doc.on('keyup', function(e){ if(t.dialogDisplay && e.keyCode === 27) t.hide(); }); }, // Function // ------------------------------ //銉€銈ゃ偄銉偘銇т娇鐢ㄣ仚銈嬭绱犮倰妲嬬瘔 build : function(){ var t = this; if(!DialogSpace.buildFlg){ DialogSpace.rootContent.append(t.$dialogWrapper.append(t.$overlay).append(t.$dialog.prepend(t.$dialogInner))); DialogSpace.buildFlg = true; } }, //瑕佺礌銇敓鎴 createElement : function(selecter, innerHtml){ var _element, _selecterArray = selecter.match(/^(.*)(\#|\.)(.*)$/), _tagName = _selecterArray[1], _idClass = _selecterArray[2] === '#' ? 'id' : 'class', _idClassName = _selecterArray[3]; _element = doc.createElement(_tagName); _element.setAttribute(_idClass, _idClassName); _element.innerHTML = innerHtml || ''; return _element; }, //銉€銈ゃ偄銉偘銇〃绀 show : function(){ var t = this; //鏃伀銉€銈ゃ偄銉偘銇岃〃绀恒仌銈屻仸銇勩倠鍫村悎銇嚘鐞嗐仐銇亜 if(t.dialogDisplay) return; t.$dialogInner.load(t.targetUrl + ' ' + t.o.dialogInner, null, $.proxy(function(){ t.showCallback(); }, t)); DialogSpace.rootContent.css({ 'overflow' : 'hidden' }); t.dialogDisplay = true; DialogSpace.activeObject = t; }, //銉€銈ゃ偄銉偘琛ㄧず鐩村緦銇嚘鐞 showCallback : function(){ var t = this; //浣欏垎銇 .dialog-inner 銈掓帓闄 var _innerHtml = $(t.o.dialogInner, t.$dialogInner).html(); t.$dialogInner.html(_innerHtml); //銉€銈ゃ偄銉偘銇〃绀恒仌銈屻仸銇勩倠瑕佺礌浠ュ銇嬨倝銉曘偐銉笺偒銈规ī闄愩倰濂亞 $('a, input, select, textarea, button, [tabindex]').each(function(){ var _$focusElement = $(this); if(!_$focusElement.closest(t.o.dialog)[0]){ if(_$focusElement.attr('tabindex')){ _$focusElement.attr(t.tabindexDataAttribute, _$focusElement.attr('tabindex')); } _$focusElement.attr('tabindex', '-1').addClass(t.o.tabindexClassName); } }); t.$dialogWrapper.fadeIn('nomal', function(){ var _dialogWrapperHeight = parseInt(t.$dialog.css('top')) + parseInt(t.$dialog.css('margin-bottom')) + t.$dialog.innerHeight(), _overlayHeight = (_dialogWrapperHeight > $win.innerHeight()) ? _dialogWrapperHeight : $win.innerHeight(); t.$overlay.css({'height' : _overlayHeight + 'px'}); }).scrollTop(0).scrollLeft(0); $('img', t.$dialog).SetRollover(); }, //銉€銈ゃ偄銉偘銇潪琛ㄧず hide : function(){ var t = this; //琛ㄧず涓伄銉€銈ゃ偄銉偘銇岃嚜韬伄鍫村悎銇伩鍑︾悊銇欍倠 if(t !== DialogSpace.activeObject) return; t.$dialogWrapper.fadeOut('nomal', function(){ t.$dialogInner.empty(); DialogSpace.rootContent.css({ 'overflow' : 'visible' }); }); //濂仯銇熴儠銈┿兗銈偣妯╅檺銈掑厓銇埢銇 $(t.tabindexSelecter).each(function(){ var _$dialogTabindex = $(this); var _tabindex = _$dialogTabindex.attr(t.tabindexDataAttribute); if(_tabindex) _$dialogTabindex.attr('tabindex', _tabindex).removeAttr(t.tabindexDataAttribute); else _$dialogTabindex.removeAttr('tabindex'); _$dialogTabindex.removeClass(t.o.tabindexClassName); }); t.$hook.focus(); t.dialogDisplay = false; } }; //jQuery Plugin銇敓鎴 $.fn.SetDialog = function(options){ var t = this, defaults = { 'overlay' : 'div.overlay', 'dialogWrapper' : 'div.dialog-wrapper', 'dialog' : 'div.dialog', 'dialogInner' : 'div.dialog-inner', 'dialogFooterHtml' : '', 'closeHook' : 'dialog-footer-link a', 'tabindexClassName' : 'dialog-tabindex' }; options = $.extend(defaults, options); for(var i = 0, l = t.length; i < l; i++){ t[i].SetDialog = new Dialog(t[i], options); t[i].SetDialog.init(); } return t; }; }()); // 銈广儬銉笺偣銈广偗銉兗銉紙銉氥兗銈搞儓銉冦儣銆併儦銉笺偢鍐呫儶銉炽偗锛 // ------------------------------------------------------------------------------ (function(){ var SmoothScroll = function(element, options){ var t = this; t.o = options; t.$root = $(element); t.targetUrl = t.$root.attr('href'); t.$target; t.scrollPosition; }; SmoothScroll.prototype = { // Controller // ------------------------------ init : function(){ var t = this; //銈兂銈兗銉兂銈互澶栥伅瀵捐薄澶栥仺銇欍倠 if(!t.targetUrl || !t.targetUrl.match(/^#./)) return false; t.set(); }, set : function(){ var t = this; t.$root.on('click', function(e){ e.preventDefault(); t.getPosition() && t.scroll(); }); }, // Function // ------------------------------ getPosition : function(){ var t = this; if(t.targetUrl === '#top'){ t.scrollPosition = 0; } else{ t.$target = t.$target || $(t.targetUrl); if(t.$target.length !== 0) t.scrollPosition = t.$target.offset().top; else return false; } return true; //t.scrollPosition銇ō瀹氭垚鍔熴倰鏄庣ず銇欍倠 }, scroll : function(){ var t = this; $html.add('body').animate({scrollTop : t.scrollPosition}, t.o.speed); } }; $.fn.SetSmoothScroll = function(options){ var t = this, defaults = { 'speed' : 500 }; options = $.extend(defaults, options); for(var i = 0, l = t.length; i < l; i++){ t[i].SetSmoothScroll = new SmoothScroll(t[i], options); t[i].SetSmoothScroll.init(); } return t; }; }()); /* ---------------------------------------------------------------- 銉°偆銉冲嚘鐞 ----------------------------------------------------------------- */ // GlobalNavigation // ------------------------------------------------------------------------------ (function(){ var $globalNavigationList = $('.global-navigation-list'), $secondaryList = $globalNavigationList.find('._secondary'), $primaryHook = $globalNavigationList.find('> li > a'), $secondaryHook = $secondaryList.find('a'), primaryHookHeight = 0; $primaryHook.add($secondaryList).on({ 'mouseenter' : function(e){ if(e.target.nodeName === 'A') $(this).addClass('is-active'); else $(this).prev('a').addClass('is-active'); }, 'mouseleave' : function(){ $primaryHook.removeClass('is-active'); } }); $primaryHook.add($secondaryHook).on({ 'focus' : function(){ if ($(this).closest('._secondary').length === 0) $(this).addClass('is-active'); else $(this).closest('._secondary').prev('a').addClass('is-active'); }, 'blur' : function(){ setTimeout(function(){ if($(doc.activeElement).closest('.global-navigation-list').length === 0){ $primaryHook.removeClass('is-active'); } }, 500); } }); // 銉娿儞闋呯洰銇珮銇曟弮銇堛仺._secondary銇畃osition瑾挎暣 $win.on('load resize', function(){ primaryHookHeight = 0; for(var i = 0, t = $primaryHook.length; i < t; i++){ primaryHookHeight = Math.max(primaryHookHeight, $primaryHook.eq(i).outerHeight()); } $secondaryList.css('top', primaryHookHeight); }); }()); // IE8鐢ㄣ伄class浠樹笌 // ------------------------------------------------------------------------------ function SetClassIe8(rootArray, childArray, className){ for (var i = 0, t = rootArray.length; i < t; i++) { $(rootArray[i]).children(childArray[i]).addClass(className); } } //DOM妲嬬瘔寰屽嚘鐞 $(function(){ //銉兗銉偑銉笺儛銉 $('img').SetRollover(); //楂樸仌鎻冦亪 $('.global-navigation-list').SetAdjustHeight({ 'target' : '> li > a' }); $('.layout-col2-01').SetAdjustHeight({ 'target' : '.box-01', 'each' : 2 }).SetAdjustHeight({ 'target' : '._col', 'each' : 2 }); //銉€銈ゃ偄銉偘 $('.js-dialog').SetDialog(); //銈广儬銉笺偣銈广偗銉兗銉 $('.js-smoothscroll').SetSmoothScroll(); //IE8鐢ㄣ伄鍑︾悊 if(ie8Flg){ //IE8鐢ㄣ伄class浠樹笌 var typeFirstList = { 'rootSelectorArray' : [ '.link-list-02', '.link-index-01', '.layout-col2-01', '.dialog-layout', '.product-01' ], 'childSelectorArray' : [ 'li:nth-child(3n+1)', 'li:nth-child(6n+1)', '._col:nth-child(2n+1)', '._col:nth-child(2n+1)', 'li:nth-child(3n+1)' ] }, typeLastList = { 'rootSelectorArray' : [ '.link-list-01', '.box-01', '.layout-col2-01', '.dialog-layout', '.flow-02', '.flow-03', '.voice-01', '.voice-02' ], 'childSelectorArray' : [ 'li:last-child', ':last-child', '._col > :last-child', '._col > :last-child', 'li > :last-child', 'li > :last-child', '._text > :last-child', '._text > :last-child' ] }; SetClassIe8(typeFirstList.rootSelectorArray, typeFirstList.childSelectorArray, 'type-first'); SetClassIe8(typeLastList.rootSelectorArray, typeLastList.childSelectorArray, 'type-last'); //銈般儹銉笺儛銉儕銉撶3闅庡堡銇偣銈裤偆銉鏁 var targetList = $('.global-navigation-list').find('._secondary li ul'); targetList.wrap('
').before(''); } }); //$(document).ready 绲備簡 }(this, this.document, this.jQuery));