/* Copyright (c) 2007 OFFIBA, Inc. (http://offiba.com) * * KOMPOSITION.ORG UI * vertion: 1 beta R2 20080116 * * Requires: jQuery 1.2+ */ /* -------------------- jQuery コンフリクト回避 ---------------------*/ jQuery.noConflict(); var j$ = jQuery; /* -------------------- main 実行部分 ---------------------*/ j$(document).ready(function() { if (jQuery.browser.safari && jQuery.browser.version < 500) { j$('#cover').animate({opacity:0}, 1000, function(){j$('#cover').hide();}); } else { this.windowHeight = function(){return window.innerHeight}; komUI = new komUIClass(); komUI.colorTranceMotionObj.insert(); komUI.colorTranceMotionObj.motion(); //komUI.checkLocation(); } }); /* -------------------- オブジェクト ---------------------*/ /* 基本オブジェクト */ var OffibaClass = { create: function() { return function() { this.initialize.apply(this, arguments); } } } /* komUIクラス */ komUIClass = OffibaClass.create(); komUIClass.prototype = { option: { _ajaxTimeout: 20000 //AJAXタイムアウト値 }, bodyHeight: function(){ return j$('body').height() + 210; }, bodyWidth: function(){ if(jQuery.browser.firefox) { return document.documentElement.clientWidth; } else if(jQuery.browser.safari && jQuery.browser.version < 500) { return window.innerWidth; } else { return j$(window).width(); } }, initialize: function(option) { if (typeof(option) == "object") this.option = option; this.locationHash = window.location.hash; this.urlReg = new RegExp('^'+'http://komposition.org'); this.mainHeight = j$('#main').height(); this.mainWidth = j$('#main').width(); this._draggFlg = false; this._windowFlg = false; this._mapFlg = true; this._startFlg = true; this.banner = j$('#banner'); var _this = this; //colorTranceMotion 設定 var _colorDiv = 10;//traceMotionの分割数 var _gWidth = 200;//グラデーションの幅 var _sec = 500;//変化時間 this.colorTranceMotionObj = new colorTranceMotionClass(_colorDiv,_gWidth,_sec); //headerType 作成 /*this.headerType = new Array; var j = 0; j$('#main_menu_list *').each(function(){ if(typeof j$(this).children().get(0) == 'undefined') { _this.headerType[j] = new motionTypeClass(this,j); j++; } });*/ //footerType 作成 /*this.footerType = new Array; var j = 0; j$('#footer *').each(function(){ if(typeof j$(this).children().get(0) == 'undefined') { _this.footerType[j] = new motionTypeClass(this,j); j++; } });*/ //contentsWindow 作成 this.contentsWindow = new contentsWindowClass(this); this.contentsWindow.create(); this.contentsWindow.bgResize(); j$(window).resize(function(){ if(typeof komUI == 'object')komUI.contentsWindow.bgResize(); j$('#main_image').width(j$(window).width()); //j$('#footer').css({'position':'fixed','top':_height-100}); }); j$('h1 a').attr({href: '#'}).click(function(){ _this.contentsWindow.close(); //return false; }); //ハッシュ処理 var url = this.locationHash.replace(/#/,''); if(url!=''){ this.contentsWindow.open('http://'+url,j$('#site_title')); } //メニュー j$('#main_menu a').each(function(){ var _url = j$(this).attr('href'); //j$(this).attr({href: '#' + _url.replace('http://','')}); j$(this).click(function(){ _this.contentsWindow.open(_url,this); j$(this).attr({href: '#' + _url.replace('http://','')}); }); }); j$('#sub_menu a').each(function(){ var _url = j$(this).attr('href'); j$(this).attr({href: '#' + _url.replace('http://','')}); j$(this).click(function(){ _this.contentsWindow.open(_url,this); }); }); //bannerリンク j$('#banner a').each(function(){ var _url = j$(this).attr('href'); if(_url.match(_this.urlReg)) { j$(this).attr({href: '#' + _url.replace('http://','')}); j$(this).click(function(){ _this.contentsWindow.open(_url,this); return false; }); } }); //init 完了 j$(document).trigger('onKomUI'); }, checkLocation: function() { if(this.locationHash != window.location.hash) { this.locationHash = window.location.hash; var url = this.locationHash.replace(/#/,''); if(console.log) console.log('HOGE!:' + url + 'window:' + this._windowFlg); if(this._windowFlg) { (url=='')? this.contentsWindow.close() : this.contentsWindow.ajaxLoad('http://'+url); } else if(url!='') { this.contentsWindow.open('http://'+url); } } var _this = this; setTimeout(function(){_this.checkLocation();}, 500); }, startUp: function() { //this.headerTypeMotion(); }, headerTypeMotion: function() { this.headerTypeCnt = 0; var _this = this; this.headerType[0].motion(function(){_this.headerTypeMotionNext();},false); }, headerTypeMotionNext: function(){ this.headerTypeCnt ++; var _this = this; if(this.headerType[this.headerTypeCnt]) { this.headerType[this.headerTypeCnt].motion(function(){_this.headerTypeMotionNext();},false); } else { this.footerTypeMotion(); this._mapFlg = false; } }, footerTypeMotion: function() { this.footerTypeCnt = 0; var _this = this; this.footerType[0].motion(function(){_this.footerTypeMotionNext();},false); }, footerTypeMotionNext: function() { this.footerTypeCnt ++; var _this = this; if(this.footerType[this.footerTypeCnt]) { this.footerType[this.footerTypeCnt].motion(function(){_this.footerTypeMotionNext();},false); } } } /* colorTranceMotionクラス */ colorTranceMotionClass = OffibaClass.create(); colorTranceMotionClass.prototype = { /*colorSet: [ { //morning L: { R:193, G:223, B:149 }, C: { R:241, G:148, B:100 }, R: { R:238, G:150, B:189} }, { //noon L: { R:136, G:206, B:218 }, C: { R:214, G:108, B:166 }, R: { R:247, G:200, B:201 } }, { //night L: { R:240, G:148, B:149 }, C: { R:130, G:151, B:198 }, R: { R:153, G:196, B:233 } } ],*/ colorSet: [ { //morning L: { R:193, G:216, B:146 }, C: { R:244, G:161, B:66 }, R: { R:233, G:92, B:138 } }, { //noon L: { R:102, G:204, B:255 }, C: { R:230, G:30, B:37 }, R: { R:235, G:235, B:107 } }, { //night L: { R:194, G:102, B:204 }, C: { R:233, G:92, B:153 }, R: { R:126, G:225, B:153 } } ], initialize: function(colorDiv, gWidth, msec) { j$('body').prepend('
'); this.node = j$('#colorTranceBg'); this.node.css({'z-index': '0'}); this.transFlg = true; this.create(gWidth); this.colorDiv = (colorDiv)? colorDiv : 10; this.msec = (msec)? msec : 500; this.gL = this.node.find('#gDivL'); this.gR = this.node.find('#gDivR'); this.gX = this.node.find('#gDivX'); this.gLDiv = j$(this.gL.find('div')); this.gRDiv = j$(this.gR.find('div')); this.gXDiv = j$(this.gX.find('div')); this.white = { R:255, G:255, B:255 }; this.setColor(this.gX,this.white); this.cnt = 0; this.divCnt = 0; this.color = this.colorSet[0]; this.setGColor(this.color); }, create: function(gWidth) { var pageWidth = j$('body').width(); var pageHeight = j$('body').height(); //(pageHeight > j$(window).height())? this.node.height(pageHeight) : this.node.height(j$(window).height);// もしくは resize イベントを発生させる。 j$(window).trigger('resize'); if(!gWidth || gWidth <= 0) var gWidth = 40; //グラデーションの幅 var bgDiv = Math.floor((pageWidth / gWidth)/2); var op = 90/bgDiv; var bgWidth = (bgDiv+2)*gWidth*3; this.node.append('
'); j$('#bg').css({width: bgWidth}) .append('
'); for (var i=0; i <= bgDiv; i++) { var _op = Math.round( ( (100) - (i * op) ) ); j$('
 
').appendTo('#bg .gDiv'); //j$('
 
').appendTo('#bg .gDiv'); //this.node.find('.bg' + i).css({opacity: _op/100, width: gWidth}); } }, insert: function(fnc) { var cover = j$('#cover'); var pageWidth = j$('body').width(); var pageHeight = j$('body').height(); if(this.node.height() < pageHeight ) { this.node.height(pageHeight); } else { pageHeight = this.node.height(); } var _this = this; this.node.find('#bg').css({'left': -2000}); this.node.find('#bg').animate({left: '0'}, 500, function(){ //cover.hide(); _this.node.css('z-index','0'); //j$('#header').css('z-index', '1000'); //j$('#footer').css('z-index', '1100'); //fnc(); setTimeout(function(){komUI.startUp();}, 300); }); }, setGColor: function(color) { this.setColor(this.gLDiv,color.L); this.setColor(this.gL,color.C); this.setColor(this.gRDiv,color.C); this.setColor(this.gR,color.R); this.setColor(this.gXDiv,color.R); //if(console.log)console.log(this.color.R.R); //if(console.log)console.log(this.gR.css('background-color')); }, setColor: function(node,color) { var _rgb = 'rgb(' + Math.round(color.R) + ',' + Math.round(color.G) + ',' + Math.round(color.B) + ')'; j$(node).css({'background-color': _rgb}); }, getGColor: function(cnt) { var start = this.colorSet[cnt]; var end = (this.colorSet[cnt+1])? this.colorSet[cnt+1] : this.colorSet[0]; var colors = { L: this.getColors(this.color.L,start.L,end.L), C: this.getColors(this.color.C,start.C,end.C), R: this.getColors(this.color.R,start.R,end.R) } return colors; }, getColors: function(now,start,end) { var colors = { R: this.getColor(now.R, start.R, end.R), G: this.getColor(now.G, start.G, end.G), B: this.getColor(now.B, start.B, end.B) } //console.log('end.R:' + end.R + ', colors.R:' + colors.R); return colors; }, getColor: function(now,start,end) { var color = now + ( (end - start) / this.colorDiv); //console.log(color); return color; }, motion: function() { if(this.transFlg) { clearTimeout(this.mov); this.color = this.getGColor(this.cnt); this.setGColor(this.color); var _thisMotion = this; //setTimeout(function(){_this.motion();}, 1000); //if(console.log)console.log(this.divCnt + ',' + this.cnt); if(this.divCnt < this.colorDiv ) { this.divCnt++; } else { this.cnt = (this.cnt == this.colorSet.length -1) ? 0 : this.cnt + 1 ; //if(console.log)console.log('this.cnt=' + this.cnt + ',this.colorSet.length' + this.colorSet.length); this.divCnt = 0; this.setGColor(this.colorSet[this.cnt]); } this.mov = setTimeout(function(){_thisMotion.motion();}, this.msec); } }, start: function() { this.transFlg = true; this.motion(); }, stop: function() { this.transFlg = false; clearTimeout(this.mov); } } /* contentsWindowクラス */ contentsWindowClass = OffibaClass.create(); contentsWindowClass.prototype = { initialize: function(komUI) { this.komUI = komUI; this.node = {}; this.callNode = j$('#main'); this.errMes = "

指定されたページが見つかりません。

サイトマップよりご覧になりたいページをお探しください。

"; j$.ajaxSetup({timeout: this.komUI.option._ajaxTimeout}); if(jQuery.browser.firefox) { this.windowHeight = function(){return document.documentElement.clientHeight}; } else { this.windowHeight = j$(window).height; } }, create: function() { //contentsWindow 作成 j$('body').append('

loading...

  CLOSE x

 

'); this.node = j$('#contents_wrapper'); this.maxFlg = false; var obj = this; this.node.click(function(e){ if(e.target.id == this.id) obj.close(); }); j$('#closewindow').click(function(){ obj.close(); return false; }); this.contentWin = j$('#contents_window'); this.bg = j$('#contents_window_bg'); this.contentWinWidthOrig = '100%'; this.contentWinWidth = this.contentWinWidthOrig; this.contentWinHeightOrig = 50; this.contentWinHeight = this.contentWinHeightOrig; this.contentWin.css({top: 100, left: 0}); this.contentWin.hide(); this.bg.hide(); this.chapter = j$(this.contentWin.find('> .chapter').get[0]); j$('#cover').animate({opacity:0}, 1000, function(){j$('#cover').remove();}); this.bgResize(); }, bgResize: function() { var _contentWinHeight = this.contentWin.height() + 110 + 60; var _bodyHeight = this.komUI.bodyHeight(); //var _bodyHeight = j$('body').height() + 210; //var _windowHeight = j$(window).heiÏght(); /*if(jQuery.browser.opera) { //Opera (document.documentElement.clientHeightが存在するため先に処理) var _windowHeight = document.body.clientHeight; } else if(typeof document.documentElement.clientHeight == 'number') { //Firefox IE Safari3 var _windowHeight = document.documentElement.clientHeight; } else if(typeof window.innerHeight == 'number') { //Safari2 var _windowHeight = window.innerHeight; } else { //その他のブラウザの場合 var _windowHeight = _bodyHeight; }*/ //var _windowHeight = this.windowHeight(); if(jQuery.browser.firefox) { var _windowHeight = document.documentElement.clientHeight; } else if(jQuery.browser.safari && jQuery.browser.version < 500) { var _windowHeight = window.innerHeight; } else { var _windowHeight = j$(window).height(); } var _height = new Array(_contentWinHeight,_windowHeight); _height.sort(function(a,b){return b - a ;}); j$('#colorTranceBg').height(_height[0]); j$('#main').height(_height[0]-210); j$('#main_image p').width(j$('#header').width()); j$('#banner').css({position:'absolute',top: _height[0]-210-120}); j$('#contents_window_bg').height(_height[0]); //(_height[0] == _windowHeight)? j$('#footer').css({top: _height[0] - j$('#footer').height()/2}) : j$('#footer').css({top:_height[0]}); j$('#footer').css({top: _height[0] - j$('#footer').height()}); }, open: function(url,node) { this.komUI.colorTranceMotionObj.stop(); j$('#main').css({opacity:0.1}); if (this.komUI._windowFlg) { this.ajaxLoad(url); } else { //this.komUI.banner.hide(); //j$('#main_image').hide(); this.komUI._windowFlg = true; //this.callNode = (node)? j$(node) : j$('#site_title'); //this.callNode = j$('#main'); var offset = this.callNode.offset(); j$('#wrapper').addClass('unprintable');//#wrapper をプリント禁止に var obj = this; /*if (this.maxFlg) { var _width = j$('#colorTranceBg').width(); var _height = j$('#colorTranceBg').height(); var _top = 0; var _left = 0; } else { var _width = this.contentWinWidthOrig; var _height = this.contentWinHeightOrig; var _top = this.contentWinTop; var _left = this.contentWinLeft; }*/ //var _height = (this.maxFlg)? j$('#background').height() : this.contentWinHeightOrig; //var _top = (this.mxFlg)? 0 : this.contentWinTop; //var _left = (this.mxFlg)? 0 : this.contentWinTop; var _top = 0; var _left = 0; var _width = this.contentWinWidthOrig; var _height = j$(window).height() - this.contentWin.offset().top; this.bg.css({height: _height, top: 0, left: 0}); this.contentWin.css({height: _height, top: 0, left: 0}); this.bg.show('fast',function(){ obj.bg.animate({opacity: .7},500); //obj.bg.animate({opacity: 1},1000); /*obj.bg.show().animate({ top: _top, left: _left, width: _width, height: _height, opacity: .70 }, 500);*/ }); this.node.show('fast',function(){ obj.contentWin.show(); obj.ajaxLoad(url); //obj.contentWin.show().animate({opacity: 1}, 500,function(){obj.ajaxLoad(url)}); /*obj.contentWin.show().animate({ top: _top, left: _left, width: _width, height: _height, opacity: 1 }, 500, function(){ //if(!obj.maxFlg) obj.contentWin.css({height: 'auto'}); obj.ajaxLoad(url); });*/ }); } }, close: function() { if(this.komUI._windowFlg){ this.komUI._windowFlg = false; j$('#wrapper').removeClass('unprintable').css({opacity:1});//#wrapper のプリント禁止解除 //this.node.hide('slow',function(){j$('#ajaxContents').html('

loading...

');}); j$('#ajaxContents').html('

loading...

'); if(!this.maxFlg) { this.contentWinTop = this.contentWin.css('top'); this.contentWinLeft = this.contentWin.css('left'); } var offset = this.callNode.offset(); var obj = this; //this.bg.animate({opacity: 1}, 1000, function(){ obj.bg.animate({opacity: 0}, 1500, function(){ obj.bg.hide();obj.node.hide(); //obj.komUI.banner.show(); //j$('#main_image').show(); //setTimeout(function(){obj.komUI.banner.show();},500); //setTimeout(function(){j$('#main_image').hide();},1500); }); //}); this.contentWin.animate({opacity: 0}, 500, function(){ obj.contentWin.hide(); }); this.komUI.locationHash = ""; window.location.hash = "#"; j$('#main').css({opacity:1}); this.komUI.colorTranceMotionObj.start(); j$(document).trigger('conWinClose'); j$(window).trigger('resize'); } }, ajaxLoad: function(url,data) { pageTracker._trackPageview(url.replace('http://komposition.org','')); //Google j$(document).trigger('conWinClose'); var obj = this; //j$('#ajaxContents').html("

loading...

").css({'height':'auto'}); //this.bg.animate({opacity:1},500); j$('#ajaxContents').css({'height':'auto'}); this.contentWin.animate({opacity:.3}, 500); if(!url || !url.match(this.komUI.urlReg)) { j$('#ajaxContents').html(this.errMes).css({opacity:1}); j$('#contents_window').stop().css({opacity:1}); return false; } var newHash = '#' + url.replace('http://',''); this.komUI.locationHash = newHash; window.location.hash = newHash; if(typeof data != 'object') data = {}; url.indexOf("?",0) == -1 ? url += "?ajax=true" : url += "&ajax=true"; j$('#ajaxContents').ajaxError(function(date,status){ if(status.status == 404) { j$('#ajaxContents').html(obj.errMes).css({opacity:1}); } else { j$('#ajaxContents').html("

サーバに負荷がかかっているため表示できません。

しばらくたってから、アクセスしてください。

").css({opacity:1}); } j$('#contents_window').css({opacity:1}); }); j$.post(url,data,function(_html){ j$('#ajaxContents').html(_html); /*j$('#ajaxContents .item img').each(function(){ this.onload = function(){ j$('#ajaxContents').css({height:''}); setTimeout(function(){j$(window).trigger('resize');},100); } });*/ if(j$('#ajaxContents').height() < 250) j$('#ajaxContents').height(250); j$('#ajaxContents .close').click(function(){ j$(this).attr({href: '#'}); obj.close(); //return false; }); j$('#ajaxContents .text').each(function(){ var newHTML = j$(this).html(); while(newHTML.indexOf('' + j$(this).html() + '') }); //img loaded j$('#ajaxContents .item img').load(function(){ j$('#ajaxContents').css({height:''}); setTimeout(function(){j$(window).trigger('resize');},100); }); var _action = j$("#mail_form").attr('action'); j$('#ajaxContents #mail_form :submit').each(function(){ j$(this).click(function(){ var _data = {}; j$('#ajaxContents :input').each(function(){ if(j$(this).attr('type')!='radio') { var _val = (j$(this).val()) ? j$(this).val() : '' ; } _data[j$(this).attr('name')] = _val; }); j$('#ajaxContents :checked').each(function(){ var _val = (j$(this).val()) ? j$(this).val() : '' ; _data[j$(this).attr('name')] = _val; }); if(j$(this).attr('name') == 'editFlg') _data.submit = ''; obj.ajaxLoad(_action, _data); return false; }); }); j$('#ajaxContents #contents_window_menu a,#ajaxContents a.komlink,#ajaxContents a[@href^="http://komposition.org"],#ajaxContents a[@href^="/"]').each(function(){ var _url = (typeof j$(this).attr('href') == 'undefined')? '' : j$(this).attr('href'); if(!_url.match("\.pdf$")) { if(_url.match("\.jpg$") || _url.match("\.JPG$") || _url.match("\.jpeg$") || _url.match("\.JPEG$") || _url.match("\.gif$") || _url.match("\.GIF$") || _url.match("\.PNG$") || _url.match("\.png$")){ //var _rel = (typeof j$(this).attr('rel') == 'undefined')? '' : j$(this).attr('rel').match("^lightbox"); //if(_rel!="") { // lightBox j$(this).lightBox(); } else { j$(this).click(function(){ obj.ajaxLoad(_url); //j$(this).attr({href: '#' + j$(this).attr('href').replace('http://','')}); return false; }); } } else { j$(this).before('pdf '); } }); j$('#ajaxContents a[@href^="http://blog.komposition.org"]').each(function(){ j$(this).click(function(){ Widget.komblog.open(this.href); return false; }); }); j$('#ajaxContents a[title="TOP"]').each(function(){ j$(this).click(function(){ obj.close(); j$(this).attr({href: '#'}); }); }); obj.contentWin.css({height: 'auto'}) obj.node.height(obj.node.height()); obj.bg.animate({opacity:.7},500); obj.contentWin.animate({opacity:1},1000); //j$('#ajaxContents').css({opacity:.8}); obj.bgResize(); //j$('#edit'); }); } } /* motionTypeクラス */ motionTypeClass = OffibaClass.create(); motionTypeClass.prototype = { initialize: function(node,i,html,fps) { this.node = j$(node); this.i = (i) ? i : 0; this.width = 0; this.origWidth = this.node.width(); this.node.css({display:'block',width:0,height:this.node.height(),overflow:'hidden'}).hide(); /*this.htmlOrig = (html) ? html : this.node.html(); this.htmlTmp = this.htmlOrig; this.fps = (fps) ? fps : 10; this.node.html('');*/ this.flg = false; this.mov = ''; // モーションタイポグラフィ this.triggerMov = ''; // トリガー }, motion: function(fnc,flg) { this.node.show(); this.show(fnc); //this.node.animate({width: this.origWidth},500,function(){if(fnc)fnc()}); /*if(!this.htmlTmp) if(fnc) { fnc(); return;} if(this.htmlTmp.length > 0) { this.node.html( this.node.html() + this.htmlTmp.slice(0,1)); this.htmlTmp = this.htmlTmp.slice(1); var _this = this; this.mov = setTimeout(function() {_this.motion(fnc,true);}, this.fps); } else { this.reset(); if (fnc) fnc(); }*/ }, show: function(fnc) { this.width+=50; if(this.width>=this.origWidth) { this.width = this.origWidth; this.flg = true; } this.node.css({width: this.width}); if(!this.flg){ var _this = this; this.mov = setTimeout(function(){_this.show(fnc);},100); } else { if(fnc) fnc(); } } }