//engines 初期化 var engines = new Function(); engines.openingSpeed = 175; engines.lang = ( "ja" == "en" )? "en" : "ja"; engines.loadError = "

データを読み込めませんでした。

Not found.

"; engines.url = location.hash.substring(1); engines.hash = engines.url.split("/")[0]; engines.openingChars = { "!" : "exs", "?" : "ques", " " : "space", "." : "dot", "+" : "rabit", "<" : "spaceship", "*" : "invader", "$" : "human", "#" : "hart", "&" : "hiyoko", "[" : "sl01", "]" : "sl02", "^" : "slime", "~" : "ufo" } //オープニングメッセージ /* */ engines.openingMessage = "we are engines!".match(/[a-z\!\?\.\+\-\*\/<\&#\[\] ]/g); //バックグラウンド engines.background = "http://engines.co.jp/files/2009/11/bg091217.png"; //全体非表示 document.write(""); document.write(""); document.write(""); window.onload = function() { //スクロール時のヘッダー if(jQuery.browser.msie) { engines.IEsetHeaderTopTimer = setInterval(_setHeaderTop, 200); } else { $(window).bind("scroll", setHeaderTop); } //アーティクル初期化 initArticles(); //オープニング $('html').css({overflow: "hidden"}); //$("

>skip

").appendTo($('body')); $("

>skip

").appendTo($('body')); //オープニング文字生成 var l = engines.openingMessage.length; var typo = new Array(); for(var i=0;i"+char+""); } engines.typo = typo; $(typo.join('')+"
").appendTo($('#typo')); var typoWidth = 0; $('#typo .typo').each(function(){ typoWidth+=$(this).width(); }); engines.openingRight = -( $('window').width()+typoWidth); $('#typo').css({width: typoWidth}); $("#skip").css({cursor: "pointer"}).click(showWrapper); $("#skipImg").hover( function(){ this.src = 'http://engines.co.jp/wp-content/themes/engines/img/skip_on.png'; }, function(){ this.src = 'http://engines.co.jp/wp-content/themes/engines/img/skip_off.png'; } ); if( getUrlVars()['debug'] != "true" ) { engines.openingID = setInterval(function(){ engines.openingRight+=engines.openingSpeed; $("#typo").css({right: engines.openingRight}); if(engines.openingRight > 1515+500) { showWrapper(); } }, 250); $("#typo").css({position: 'absolute', right: engines.openingRight}); } //ブログリンク初期化 initBlogLink(); //ブログ内容読み込み var url = (engines.hash=="blog" && engines.url!="")? engines.url : "blog/page/1"; loadBlog("http://engines.co.jp/"+url); //メニューリンク初期化 initMenuLink(); //背景きりかえ //$("#background").change(changeBackground); } //背景きりかえ function changeBackground() { //$("html").css({backgroundImage: "url('http://engines.co.jp/wp-content/themes/engines/img/"+$("#background").val()+"')"}); $("html").css({backgroundImage: "url('"+engines.background+"')"}); } //アーティクル初期化 function initArticles() { engines.currentArticle = ""; //アーティクルズ var articles = $("#mainContents div.article"); //overflow を hidden にして section を挿入 articles.css({overflow: "hidden"}).wrapInner("
"); if($("#headerSection").length == 0) $("#header").wrapInner("
"); //iframe非表示(Firefox) $("#mainContents div.article iframe").css({visibility: "hidden"}); //Works初期化 var tabX = 0; engines.worksColumnMaxHeight = 0; if(jQuery.browser.msie) $("#works h4").css({top: -21}); $("#works h4 span").addClass("unactive"); $("#works .columns").each(function(){ engines.worksColumnMaxHeight = (engines.worksColumnMaxHeight < $(this).height())? $(this).height() : engines.worksColumnMaxHeight; }); $("#mainContents #works .tab h4").each(function(){ tabX += $(this).css({left: tabX}).find('span:first').width()+28; jQuery.data(this, "height", $(this).parent().height()); }); $("#works .columns").hide();//.height(engines.worksColumnMaxHeight); engines.currentWorksColumns = $("#works .columns").get(0); $("#works .columns:first").show().parent().find("h4 span").removeClass("unactive"); $("#works h4").click(function(){ var _this = this; var columns = $(this).parent().find(".columns").get(0); $("#works h4 span").addClass("unactive"); $(columns).height($(engines.currentWorksColumns).height()); $(this).find("span").removeClass("unactive"); $("#works .columns").stop().hide(); $(columns).show().css({opacity: .5}).animate({opacity: 1, height: jQuery.data(_this, "height")}, 800, function(){ //firefoxbug if(jQuery.browser.mozilla) fixFoxBg(); }); engines.currentWorksColumns = columns; }).css({cursor: "pointer"}); //h2要素の幅と高さを取得して保存 articles.each(function(){ jQuery.data(this, "origWidth", $(this).width()); jQuery.data(this, "origHeight", $(this).height()); var h2 = $($(this).find("h2").get(0)); jQuery.data(this, "minWidth", h2.width()+40); jQuery.data(this, "minHeight", h2.height()); h2.css({width: "auto"}); //isOpen 初期化 jQuery.data(this, "isOpen", false); }); //section を固定幅に articles.find("div.section").each(function(){ if($(this).parent().attr("class") == "article") { $(this).css({width: $(this).width()}); } }); //タイトルのみ表示(最小状態) articles.each(function(){ var article = this; $(this).css({width: jQuery.data(this, "minWidth"), height: 10}); //h2 var h2 = $( $(this).find("h2").get(0) ); //ホバー $(this).hover( //mouseon function() { var parent = article; if(! jQuery.data(parent, "isOpen")) { $(parent).stop().animate({width: $(parent).width()+Number($("#hoverW").val())}, Number($("#hoverMsec").val()), $("#easing").val()); } }, //mouseout function() { var parent = article; if(! jQuery.data(parent, "isOpen")) { $(parent).stop().animate({width: jQuery.data(parent, "minWidth")}, Number($("#hoverMsec").val()), $("#easing").val() ); } } ); $(this).click(function(){ clearAutoOpen(); openArticle(article); }).css({cursor: "pointer"}); //h2をトグルに h2.css({cursor: "pointer"}).click(function(){toggleArticle(article)}); //矢印/Closeボタン追加 $(this).append("
"); }); //カレンダー初期化 initCalLink(); } //メニューリンク初期化 function initMenuLink() { $("#mainMenu dt a").click(function(){ clearAutoOpen(); toggleArticle(this.rel, true); return false; }); $("#langSelect a").click(function(){ changeLanguage(this.rel); return false; }) } //ブログリンク初期化 function initBlogLink(parent) { if($("#blog").length != 0) { var parent = (typeof parent == "undefined")? $("#blog") : $(parent); //page parent.find("a[href^=http://engines.co.jp]").each(function(){ if($(this).parent().attr("id") != "next" && $(this).parent().attr("id") != "prev" && $(this).hasClass("more-link") == false && $(this).hasClass("read-more") == false){ $(this).click(function(){ loadBlog(this.href); return false; }); } }); //read-more parent.find(".more-link, .read-more").toggle( function(){ $(this).parent().parent().parent().find(".post-more").slideDown("slow"); //jQuery.data($(this).parent().get(0), "origHeight", $(this).parent().height()); return false; }, function(){ $(this).parent().parent().parent().find(".post-more").slideUp("slow"); //jQuery.data($(this).parent().get(0), "origHeight", $(this).parent().height()); return false; } ); } } function showWrapper(){ //オープニング停止&消去 clearInterval(engines.openingID); $("#opening").hide(); //全体表示 $("html").css({backgroundColor: "#ccc", backgroundImage: "url('"+engines.background+"')", overflow: "auto"}); /*if(jQuery.browser.mozilla) { $("#header").css({float: "left"}); $("#mainContents").css({marginLeft: 150}); } else { $("#mainContents").css({position: "absolute"}); }*/ $("#wrapper").css({opacity: 0, visibility: "visible", height: "auto",width: "auto", overflow: "visible"}).animate({opacity: 1}, 500); if(engines.hash == "") { if($("#message").length != 0) engines.openMessageTimer = setTimeout(function(){openArticle("message");}, 1000); if($("#message").length != 0) engines.closeMessageTimer = setTimeout(function(){closeArticle("message");}, 3000); if($("#blog").length != 0 && engines.lang == "ja") engines.openBlogTimer = setTimeout(function(){openArticle("blog");}, 4000); } else { var hash = engines.hash; if($("#"+hash).length != 0) engines.openHashTimer = setTimeout(function(){openArticle(hash);}, 1000); } } //アーティクルトグル function toggleArticle(article, isMenu) { var parent = (typeof article == "string")? document.getElementById(article) : article; if(jQuery.data(parent, "isOpen")) { (isMenu)? closeAndScroll(parent) : closeArticle(parent); } else { (isMenu)? openAndScroll(parent) : openArticle(parent); } } //アーティクルオープン function openArticle(article) { var parent = (typeof article == "string")? document.getElementById(article) : article; if(jQuery.data(parent, "isOpen") == false) { _openArticle(parent); } } //アーティクルクローズウォッチャー function watchAllClosed(article) { var count = 0; var articles = $("#mainContents div.article"); articles.each(function(){ if(jQuery.data(this, "isOpen") == false) count++; }); if(count == articles.length) { clearInterval(engines.watchAllClosedTimer); _openArticle(engines.openArticle); } } //アーティクルオープン本体 function _openArticle(article) { var parent = (typeof article == "string")? document.getElementById(article) : article; if(jQuery.data(parent, "isOpen") == false) { jQuery.data(parent, "isOpen", true); var _hMsec = jQuery.data(parent, "origWidth") * 0.6; var _vMsec = jQuery.data(parent, "origHeight") * 1.5; $(parent).stop().css({cursor: "default"}); //$(parent).animate({width: jQuery.data(parent, "origWidth")}, Number($("#openH").val()), $("#openHeasing").val(), function(){ $(parent).animate({width: jQuery.data(parent, "origWidth")}, _hMsec, $("#openHeasing").val(), function(){ //矢印をクローズボタンに $(parent).find(".arrow-close").css({backgroundImage: "url('http://engines.co.jp/wp-content/themes/engines/img/icon_02.gif')", cursor: "pointer"}).one("click", function(){closeArticle(parent)}); //firefox対策 //if(jQuery.browser.mozilla) engines.fixFoxBgTimer = setInterval(fixFoxBg, 50); //if(jQuery.browser.mozilla) $(parent).find("iframe").css({visibility: "visible"}); $(parent).animate({height: jQuery.data(parent, "origHeight")}, Number($("#openV").val()), $("#openVeasing").val(), function(){ //$(parent).animate({height: jQuery.data(parent, "origHeight")}, _vMsec, $("#openVeasing").val(), function(){ $(parent).css({height: ""}); if(parent.id == "works") { //$("#mainContents").animate({paddingBottom: engines.worksColumnMaxHeight}); } //firefox対策 if(jQuery.browser.mozilla) fixFoxBg(); //clearInterval(engines.fixFoxBgTimer); }); }); } } //アーティクルクローズ function closeArticle(article, isMenu) { var isMenu = (isMenu)? true : false; var parent = (typeof article == "string")? document.getElementById(article) : article; var currentArticle = engines.currentArticle; if(jQuery.data(parent, "isOpen") == true) { //高さ設定 jQuery.data(parent, "origHeight", $(parent).height()); //クローズボタンを矢印に $(parent).find(".arrow-close").css({backgroundImage: "url('http://engines.co.jp/wp-content/themes/engines/img/icon_01.gif')", cursor: "default"}); $(parent).stop().css({cursor: "pointer"}); //firefox対策 $(parent).find("iframe").css({visibility: "hidden"}); if(jQuery.browser.mozilla) { var _y = jQuery.data(parent, "origHeight")-55; var _origScrollTop = $().scrollTop(); var _scrollBottom = $().height()-$().scrollTop()-$(window).height(); if( _scrollBottom < _y ) { //$().scrollTop( $().scrollTop()-1 ); //$("#mainContents").css({paddingBottom: 40+_y}); //$().scrollTop( $().scrollTop()+1 ); } //$("#mainContents").css({paddingBottom: 40+_y}); //$.scrollTo("-="+_y+"px",Number($("#closeV").val())); } $(parent).animate({height: 15}, Number($("#closeV").val()), $("#closeHeasing").val(), function(){ $(parent).animate({width: jQuery.data(parent, "minWidth") }, Number($("#closeH").val()), $("#closeVeasing").val(), function(){ jQuery.data(parent, "isOpen", false); }); //firefox対策 if(jQuery.browser.mozilla) { //$("#mainContents").css({paddingBottom: 40}); //$().scrollTop(_origScrollTop); //$.scrollTo("-="+_y+"px"); //$("#mainContents").animate({paddingBottom: 40}, 100, function(){}); } if(isMenu && currentArticle != "" ) { $.scrollTo($(currentArticle).offset().top,0); setTimeout(function(){engines.currentArticle = currentArticle}, 1000); } if(parent.id == "works") { //$("#mainContents").animate({paddingBottom: 0}); } //firefox対策 if(jQuery.browser.mozilla) fixFoxBg(); //clearInterval(engines.fixFoxBgTimer); }); } } function fixFoxBg() { //firefox対策 $('html').css({opacity: .99}).animate({opacity: 1},1); } //Oepn & Scroll function openAndScroll(article) { article = (typeof article == "string")? document.getElementById(article) : article; openArticle(article); article = (article.id == "message")? document.getElementById("wrapper") : article ; if (jQuery.browser.msie) clearInterval(engines.IEsetHeaderTopTimer); setTimeout(function(){ $.scrollTo($(article).offset().top, { duration : 500, easing : "easeOutQuad", onAfter : function(){ engines.currentArticle = article; if(jQuery.browser.msie) engines.IEsetHeaderTopTimer = setInterval(_setHeaderTop, 200); } }); }, 1000); setTimeout(function(){ engines.currentArticle = article; }, 2000); return false; } //Close & Scroll function closeAndScroll(article) { closeArticle(article, true); return false; } //ブログロード function loadBlog(url) { if($("#blog").length != 0) { url = (url.match(/\?/) == null)? url+"?ajax=true" : (url.match(/ajax=true/))? url : url+"&ajax=true"; url = encodeURI(url); //ロード部 $.ajax({ url: url, // リクエストURL dataType: "html", cache: true, success: function(data, status) { setBlog(data); }, error: function() { setBlog(engines.loadError); } }); /*$.get(url, function(data){ //$("#ajax").html(data); $($("#blog .blogMain").get(0)).animate({opacity: 0}, 500, function(){ //Firefox対策 if(jQuery.browser.mozilla) fixFoxBg(); //$("#blog").animate({height: newHeight+20}, 0, function(){ if(jQuery.data(document.getElementById("blog"), "isOpen")) $("#blog").css({height: ""}); $("#blog").css({opacity: 0}).css({opacity: 1});//IE対策 $($("#blog .blogMain").get(0)).html(data).animate({opacity: 1}, 500); initBlogLink("#blog .blogMain"); }); });*/ } } function setBlog(data) { $($("#blog .blogMain").get(0)).animate({opacity: 0}, 500, function(){ //Firefox対策 if(jQuery.browser.mozilla) fixFoxBg(); //blog消去 if(jQuery.data(document.getElementById("blog"), "isOpen")) $("#blog").css({height: ""}); //IE対策 $("#blog").css({opacity: 0}).css({opacity: 1}); //内容入れ替え $("#blog .blogMain:first").html(data).animate({opacity: 1}, 500); //ブログリンク初期化 initBlogLink("#blog .blogMain"); }); } function initCalLink() { $("#wp-calendar #next a, #wp-calendar #prev a").click(function(){ loadCal(this.href); return false; }) } function loadCal(url) { url += "?calendar=true"; url = encodeURI(url); //ロード部 $.ajax({ url: url, // リクエストURL dataType: "html", cache: true, success: function(data, status) { setCal(data); }, error: function() { setCal(engines.loadError); } }); /*$.get(url, function(data){ $("#calendar_wrap").parent().animate({opacity: 0}, 500, function(){ $("#calendar_wrap").parent().html(data).html($("#calendar_wrap").parent().html()); initCalLink(); initBlogLink("#calendar_wrap"); $("#calendar_wrap").parent().animate({opacity: 1}, 500); }); })*/ return false; } function setCal(data) { $("#calendar_wrap").parent().animate({opacity: 0}, 500, function(){ $("#calendar_wrap").parent().html(data).html($("#calendar_wrap").parent().html()); initCalLink(); initBlogLink("#calendar_wrap"); $("#calendar_wrap").parent().animate({opacity: 1}, 500); }); } function setHeaderTop(){ //clearTimeout(engines.headerTopTimer); //engines.headerTopTimer = setTimeout(_setHeaderTop, 50); _setHeaderTop(); } function _setHeaderTop(){ var msec = Math.abs( $("#headerSection").offset().top-$(window).scrollTop()) / 300 * Number($("#sideberSpeed").val()); $("#headerSection").css({position: "absolute"}).stop().animate({top: $(window).scrollTop()+20}, msec); engines.currentArticle = "" } //言語切替 function changeLanguage(lang) { var menuUrl, mainContentsUrl, blogUrl; var siteUrl = "http://engines.co.jp/"; if(lang == "en") { menuUrl = siteUrl+"en/?menu=true"; mainContentsUrl = siteUrl+"en/?ajax=true"; blogUrl = siteUrl+"en/blog/"; } else { menuUrl = siteUrl+"?menu=true"; mainContentsUrl = siteUrl+"?ajax=true"; blogUrl = siteUrl+"blog/"; } //メインコンテンツ切替 $.ajax({ url: encodeURI(mainContentsUrl), // リクエストURL dataType: "html", cache: true, success: function(data, status) { setMainContents(data, blogUrl,lang); }, error: function() { setMainContents(engines.loadError, blogUrl,lang); } }); /*$.get(encodeURI(mainContentsUrl), function(data){ $.scrollTo(0,0); //engines.data = data; $("#mainContents").animate({opacity: 0}, 500, function(){ //全アニメーション停止 clearAutoOpen(); $("#mainContents *:animated").stop(); document.getElementById("mainContents").innerHTML = data; $("#mainContents").attr("class", lang).animate({opacity: 1}, 1000); initArticles(); initBlogLink(); loadBlog(blogUrl); }); });*/ //メニュー切替 $.ajax({ url: encodeURI(menuUrl), // リクエストURL dataType: "html", cache: true, success: function(data, status) { setMenu(data); }, error: function() { setMenu(engines.loadError); } }); /*$.get(encodeURI(menuUrl), function(data){ //スクロール時のヘッダー if(jQuery.browser.msie) { clearInterval(engines.IEsetHeaderTopTimer); } else { $(window).unbind("scroll", setHeaderTop); } $("#headerSection").stop().animate({opacity: 0}, 500, function(){ $("#headerSection").html(data).css({top: 20}).animate({opacity: 1}, 500, function(){ //スクロール時のヘッダー clearInterval(engines.IEsetHeaderTopTimer); if(jQuery.browser.msie) { engines.IEsetHeaderTopTimer = setInterval(_setHeaderTop, 200); } else { $(window).bind("scroll", setHeaderTop); } }); initMenuLink(); }); });*/ } function setMainContents(data,blogUrl,lang) { $.scrollTo(0,0); $("#mainContents").animate({opacity: 0}, 500, function(){ //全アニメーション停止 clearAutoOpen(); $("#mainContents *:animated").stop(); document.getElementById("mainContents").innerHTML = data; $("#mainContents").attr("class", lang).animate({opacity: 1}, 1000); initArticles(); initBlogLink(); loadBlog(blogUrl); }); } function setMenu(data) { //スクロール時のヘッダー if(jQuery.browser.msie) { clearInterval(engines.IEsetHeaderTopTimer); } else { $(window).unbind("scroll", setHeaderTop); } $("#headerSection").stop().animate({opacity: 0}, 500, function(){ $("#headerSection").html(data).css({top: 20}).animate({opacity: 1}, 500, function(){ //スクロール時のヘッダー clearInterval(engines.IEsetHeaderTopTimer); if(jQuery.browser.msie) { engines.IEsetHeaderTopTimer = setInterval(_setHeaderTop, 200); } else { $(window).bind("scroll", setHeaderTop); } }); initMenuLink(); }); } function clearAutoOpen() { clearTimeout(engines.openMessageTimer); clearTimeout(engines.closeMessageTimer); clearTimeout(engines.openBlogTimer); clearTimeout(engines.openHashTimer); } function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; }