// JavaScript Document (function($){ $.fn.panelMenu=function(_label){ //ラベル var label=_label; return this.each(function(){ //パネルの開閉の設定 $(this).children().each(function(index){ var outURL=$(this).css('backgroundImage'); var overURL=outURL.replace(/.gif/,'_o.gif'); var outLabel=$(this).find('span').text(); var overLabel=_label[index]; $(this).hover( function(){//ロールオーバー時 $(this).css({cursor:'pointer',backgroundImage:overURL}).find('span').text(overLabel).end().find('div').fadeIn(200); }, function(){//ロールアウト時 $(this).css({cursor:'default',backgroundImage:outURL}).find('span').text(outLabel).end().find('div').fadeOut(50); } ).click(function(){ //サブメニューをもっていない場合 if(!$(this).is(':has(div)')){ if($(this).children('a').attr('target')=='_blank'){ //別ウィンドウで開く場合 window.open($(this).children('a').attr('href'),'blog'); return false; }else{ location.href=$(this).children('a').attr('href'); } } }); }); //サブメニューの設定 $(this).find('div').css({opacity:0.92}).find('li.sub').hover( function(){ $(this).css({cursor:'pointer',backgroundColor:'#000'}); }, function(){ $(this).css({cursor:'default',backgroundColor:'#333333'}); } ).click(function(){ location.href=$(this).children('a').attr('href'); }); //さらにスワップイメージ機能を追加する $(this).find('ul.swapImage').each(function(){ var path=$(this).parent().css('backgroundImage'); $(this).find('li.sub').each(function(index){ //プリロード //URLのフィルタリング var preURL=path.match(/url\(['"]?([^'"]+)['"]?\)/)[1]; var preImg=new Image(); preImg.src=preURL.replace(/([0-9]{2})\.(jpg|gif|png)/,'0'+(index+1)+'.$2'); $(this).mouseover(function(){ var repTex=path.replace(/([0-9]{2})\.(jpg|gif|png)/,'0'+(index+1)+'.$2'); $(this).parent().parent().css({backgroundImage:repTex}); }); }); }); }); }; })(jQuery)