/* -------------------------------------------------------------------------- */ /* * @fileoverview * Common Script Libraries. * * @version rev 0.1.3 2008-08-12 */ /* -------------------------------------------------------------------------- */ /* * yuga.js 0.6.3 - 優雅ãªWeb制作ã®ãŸã‚ã®JS * * Copyright (c) 2007 Kyosuke Nakamura (kyosuke.jp) * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * Since: 2006-10-30 * Modified: 2008-07-07 * * jQuery 1.2.6 * ThickBox 3.1 */ (function($) { $(function() { //$.yuga.selflink(); $.yuga.rollover(); $.yuga.externalLink(); //$.yuga.thickbox(); $.yuga.scroll(); $.yuga.tab(); $.yuga.stripe(); //$.yuga.css3class(); }); //--------------------------------------------------------------------- $.yuga = { // URIを解æžã—ãŸã‚ªãƒ–ジェクトを返ã™function Uri: function(path){ this.originalPath = path; //絶対パスをå–å¾— this.absolutePath = (function(){ var e = document.createElement('span'); e.innerHTML = '<a href="' + path + '" />'; return e.firstChild.href; })(); //絶対パスを分解 var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11}; var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath); for (var field in fields) { this[field] = r[fields[field]]; } }, //ç¾åœ¨ã®ãƒšãƒ¼ã‚¸ã¨è¦ªãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¸ã®ãƒªãƒ³ã‚¯ selflink: function (options) { var c = $.extend({ selfLinkClass:'current', parentsLinkClass:'parentsLink', postfix: '_cr' }, options); $('a[href]').each(function(){ var href = new $.yuga.Uri(this.getAttribute('href')); var setImgFlg = false; if ((href.absolutePath == location.href) && !href.fragment) { //åŒã˜æ–‡æ›¸ã«ãƒªãƒ³ã‚¯ $(this).addClass(c.selfLinkClass); setImgFlg = true; } else if (0 <= location.href.search(href.absolutePath)) { //親ディレクトリリンク $(this).addClass(c.parentsLinkClass); setImgFlg = false; //Select true or false } if (setImgFlg){ //imgè¦ç´ ãŒå«ã¾ã‚Œã¦ã„ãŸã‚‰ç¾åœ¨ç”¨ç”»åƒï¼ˆ_cr)ã«è¨å®š $(this).find('img').each(function(){ this.originalSrc = $(this).attr('src'); this.currentSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, c.postfix+"$1"); $(this).attr('src',this.currentSrc); }); } }); }, //ãƒãƒ¼ãƒ«ã‚ªãƒ¼ãƒãƒ¼ rollover: function(options) { var c = $.extend({ hoverSelector: '.imgover', groupSelector: '.btngroup', postfix: '_on' }, options); //ãƒãƒ¼ãƒ«ã‚ªãƒ¼ãƒãƒ¼ã™ã‚‹ãƒŽãƒ¼ãƒ‰ã®åˆæœŸåŒ– $(c.hoverSelector).filter(isNotCurrent).each(function(){ this.originalSrc = $(this).attr('src'); this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)$/, c.postfix+"$1"); this.rolloverImg = new Image; this.rolloverImg.src = this.rolloverSrc; }); //グループ内ã®imgè¦ç´ を指定ã™ã‚‹ã‚»ãƒ¬ã‚¯ã‚¿ç”Ÿæˆ var inGroup = new Array(); $.each(c.groupSelector.split(/,\s?/g), function(i, n){ inGroup.push(n + ' ' + c.hoverSelector.replace(/,\s?/g, ', '+ n +' ')); }); var inGroupSelector = $(inGroup.join(', ')); //通常ãƒãƒ¼ãƒ«ã‚ªãƒ¼ãƒãƒ¼ $(c.hoverSelector).not(inGroupSelector).filter(isNotCurrent).hover(function(){ $(this).attr('src',this.rolloverSrc); },function(){ $(this).attr('src',this.originalSrc); }); //グループ化ã•ã‚ŒãŸãƒãƒ¼ãƒ«ã‚ªãƒ¼ãƒãƒ¼ $(c.groupSelector).hover(function(){ $(this).find('img').filter(c.hoverSelector).filter(isNotCurrent).each(function(){ $(this).attr('src',this.rolloverSrc); }); },function(){ $(this).find('img').filter(c.hoverSelector).filter(isNotCurrent).each(function(){ $(this).attr('src',this.originalSrc); }); }); //フィルタ用function function isNotCurrent(i){ return Boolean(!this.currentSrc); } }, //外部リンクã¯åˆ¥ã‚¦ã‚¤ãƒ³ãƒ‰ã‚¦ã‚’è¨å®š externalLink: function(options) { var c = $.extend({ windowOpen:true, externalClass: 'externalLink' }, options); //var e = $('a[href^="http://"]'); if (c.windowOpen) { //e.click(function(){ $('.'+c.externalClass).click(function(){ //externalClassをトリガã«å¤‰æ›´ window.open(this.href, '_blank'); return false; }); } //e.addClass(c.externalClass); }, //ç”»åƒã¸ç›´ãƒªãƒ³ã‚¯ã™ã‚‹ã¨thickboxã§è¡¨ç¤º(thickbox.js利用) thickbox: function() { try { tb_init('a[@href$=".jpg"]:not(.thickbox), a[@href$=".gif"]:not(.thickbox), a[@href$=".png"]:not(.thickbox)'); } catch(e) { } }, //ページ内リンクã¯ã™ã‚‹ã™ã‚‹ã‚¹ã‚¯ãƒãƒ¼ãƒ« scroll: function(options) { //ドã‚ュメントã®ã‚¹ã‚¯ãƒãƒ¼ãƒ«ã‚’制御ã™ã‚‹ã‚ªãƒ–ジェクト var scroller = (function() { var c = $.extend({ easing:100, step:30, fps:60 }, options); c.ms = Math.floor(1000/c.fps); var timerId; var param = { stepCount:0, startY:0, endY:0, lastY:0 }; //スクãƒãƒ¼ãƒ«ä¸ã«å®Ÿè¡Œã•ã‚Œã‚‹function function move() { if (param.stepCount == c.step) { //スクãƒãƒ¼ãƒ«çµ‚了時 window.scrollTo(getCurrentX(), param.endY); } else if (param.lastY == getCurrentY()) { //通常スクãƒãƒ¼ãƒ«æ™‚ param.stepCount++; window.scrollTo(getCurrentX(), getEasingY()); param.lastY = getEasingY(); timerId = setTimeout(move, c.ms); } } function getCurrentY() { return document.body.scrollTop || document.documentElement.scrollTop; } function getCurrentX() { return document.body.scrollLeft || document.documentElement.scrollLeft; } function getEasingY() { return Math.floor(getEasing(param.startY, param.endY, param.stepCount, c.step, c.easing)); } function getEasing(start, end, stepCount, step, easing) { var s = stepCount / step; return (end - start) * (s + easing / (100 * Math.PI) * Math.sin(Math.PI * s)) + start; } return { set: function(options) { this.stop(); if (options.startY == undefined) options.startY = getCurrentY(); param = $.extend(param, options); param.lastY = param.startY; timerId = setTimeout(move, c.ms); }, stop: function(){ clearTimeout(timerId); param.stepCount = 0; } }; })(); $('a[href^=#], area[href^=#]').not('a[href=#], area[href=#]').each(function(){ this.hrefdata = new $.yuga.Uri(this.getAttribute('href')); }).click(function(){ var target = $('#'+this.hrefdata.fragment); if (target.length) { scroller.set({ endY: target.offset().top }); return false; } }); }, //タブ機能 tab: function(options) { var c = $.extend({ tabNavSelector:'.tabNav', activeTabClass:'active' }, options); $(c.tabNavSelector).each(function(){ var tabNavList = $(this).find('a[href^=#], area[href^=#]'); var tabBodyList; tabNavList.each(function(){ this.hrefdata = new $.yuga.Uri(this.getAttribute('href')); var selecter = '#'+this.hrefdata.fragment; if (tabBodyList) { tabBodyList = tabBodyList.add(selecter); } else { tabBodyList = $(selecter); } $(this).unbind('click'); $(this).click(function(){ tabNavList.removeClass(c.activeTabClass); $(this).addClass(c.activeTabClass); tabBodyList.hide(); $(selecter).show(); return false; }); }); tabBodyList.hide() tabNavList.filter(':first').trigger('click'); }); }, //奇数ã€å¶æ•°ã‚’è‡ªå‹•è¿½åŠ stripe: function(options) { var c = $.extend({ oddClass:'odd', evenClass:'even' }, options); $('ul, ol').each(function(){ //JSã§ã¯0ã‹ã‚‰æ•°ãˆã‚‹ã®ã§evenã¨addを逆ã«æŒ‡å®š $(this).children('li:odd').addClass(c.evenClass); $(this).children('li:even').addClass(c.oddClass); }); $('table, tbody').each(function(){ $(this).children('tr:odd').addClass(c.evenClass); $(this).children('tr:even').addClass(c.oddClass); }); }, //css3ã®ã‚¯ãƒ©ã‚¹ã‚’è¿½åŠ css3class: function() { //:first-child, :last-childをクラスã¨ã—ã¦è¿½åŠ $('body :first-child').addClass('firstChild'); $('body :last-child').addClass('lastChild'); //css3ã®:emptyをクラスã¨ã—ã¦è¿½åŠ $('body :empty').addClass('empty'); } }; })(jQuery); /* * eCommon Script Libraries.(Original) * * Copyright (c) 2007 Yasuhiro Hamaguchi * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ (function($) { $(function() { $.eco.autoModifyDate(); //$.eco.initFlatheights(); //$.eco.initSWFObject(); }); //--------------------------------------------------------------------- $.eco = { //Auto Modify Date autoModifyDate: function(options) { var c = $.extend({ begunDateSelector: '.copyrightDate' }, options); $(c.begunDateSelector).each(function(){ //Get begun date var begunYearStr = $(c.begunDateSelector).text(); //Get currently date var dateObj = new Date(); var currentYearStr = dateObj.getFullYear(); //Compare dates if(begunYearStr != currentYearStr) { //Add currently date $(c.begunDateSelector).append('-'+currentYearStr); } return false; }); }, initFlatheights: function(options) { var c = $.extend({ flatheightsSelector: '#main .sectionX01' }, options); $(c.flatheightsSelector).each(function(){ $(c.flatheightsSelector).flatHeights(); }); }, initSWFObject: function(options) { var c = $.extend({ SWFObjectSelector: '#homoMovie' }, options); $(c.SWFObjectSelector).each(function(){ var so = new SWFObject("swf/movie_top.swf", "eq-k", "268", "439", "7"); so.addParam("quality", "high"); so.addParam("wmode", "opaque"); so.write("homeMovie"); }); } }; })(jQuery);