// JavaScript Document
$(function () {
//color
bg_switch();
$("#site_bg button").click( function (){
var set_bg = $(this).attr("id");
bg_switch(set_bg);
});
function bg_switch( $bg_switch ){
if( $bg_switch == undefined ){
var $bg_switch = $.cookie( 'bg_switch' );
if( $bg_switch == undefined ){
var $bg_switch = '';
}
}
$.cookie( 'bg_switch', $bg_switch, { expires: 1, path:'/' } );
$("body").removeClass().addClass($bg_switch);
}
//fontSize
fontSize();
$('#fs_reset').click( function () {
$('html').css("font-size", "62.5%");
var now_font = $("html").css('font-size');
fontSize(now_font);
});
$('#fs_big').click( function () {
var now_font = $("html").css('font-size');
if ( now_font == "20px" ){
alert("これ以上文字のサイズを大きくできません。");
} else {
$('html').css("font-size", "+=1");
var now_font = $("html").css('font-size');
fontSize(now_font);
}
});
function fontSize( $fontSize ){
if( $fontSize == undefined ){
var $fontSize = $.cookie('fontSize');
if( $fontSize == undefined ){
var $fontSize = '62.5%';
}
}
$.cookie( 'fontSize', $fontSize, { expires: 1,path:'/' } );
$("html").css({ 'font-size': $fontSize });
}
/*colorbox*/
$(".pop_inline").colorbox({
inline: true,
innerWidth: 1000,
//innerHeight: 100,
maxWidth: "100%",
maxHeight: "100%",
opacity: "0.8",
scrolling: false,
className: "pop_inline"
});
$(".pop_search").colorbox({
inline: true,
innerWidth: 600,
innerHeight: 100,
maxWidth: "100%",
maxHeight: "100%",
opacity: "0.8",
scrolling: false,
className: "pop_search"
});
$(".pop_img").colorbox({
maxWidth: "90%",
maxHeight: "90%",
opacity: "0.8",
className: "pop_img"
});
$(".pop_youtube").colorbox({
iframe: true,
innerWidth: "80%",
innerHeight: "75%",
/*maxWidth:"100%",
maxHeight:"100%",*/
opacity: "0.8",
className: "pop_youtube"
});
/* inview.begin */
$('.js_slide_down').on('inview', function(event, isInView) {
if(isInView){
var offset = $(this).attr("data-offset");
$(this).delay(offset).animate({
top:0,
opacity:1
},1000);
}
});
$('.js_slide_up').on('inview', function(event, isInView) {
if(isInView){
var offset = $(this).attr("data-offset");
$(this).delay(offset).animate({
top:0,
opacity:1
},1000);
}
});
$('.js_slide_left').on('inview', function(event, isInView) {
if(isInView){
var offset = $(this).attr("data-offset");
$(this).delay(offset).animate({
left:0,
opacity:1
},1000);
}
});
$('.js_slide_right').on('inview', function(event, isInView) {
if(isInView){
var offset = $(this).attr("data-offset");
$(this).delay(offset).animate({
right:0,
opacity:1
},1000);
}
});
$('.js_fade').on('inview', function(event, isInView) {
if(isInView){
var offset = $(this).attr("data-offset");
$(this).delay(offset).animate({
opacity:1
},1000);
}
});
/* inview.end */
// smooth-scroll
$('a[href^="#"]').not(".not_scroll").on("click", function () {
var speed = 1000;
var href = $(this).attr("href");
var target = $(href == "#" || href == "" ? 'html' : href);
var position = target.offset().top - 110;
$('body,html').animate({
scrollTop: position
}, speed, 'swing');
return false;
});
var hash = location.hash;
if (location.hash != "") {
var hashposition = $(hash).offset().top - 110;
$("html,body").animate({
scrollTop: hashposition
});
}
$(".header_jigyosyokei #btn_site_navi").on("click",function(){
$(this).toggleClass("open");
$(".header_jigyosyokei .site_navi").toggleClass("open");
});
$(".type_select_more_btn, .type_select_close_btn").on("click",function(){
$(".type_select_more").slideToggle();
return false;
});
});
$(document).ready(function () {
//matchHeight
$("#list_index").each(function () {
$("#list_index .item a").matchHeight();
});
$(".list_5column").each(function () {
$(".list_5column .item").matchHeight();
});
$(".list_4column").each(function () {
$(".list_4column .item").matchHeight();
});
$(".list_3column").each(function () {
$(".list_3column .item").matchHeight();
});
$(".list_2column").each(function () {
$(".list_2column .item").matchHeight();
});
});
$("document").ready(function() {
//自分のサーバのファイルを取得してファイル サイズをリンク横に出力するスクリプト
//IMG タグの場合と class="noFileInfo" 指定の場合は除外
$("a[href]").not(":has('img')").not(".noIcon").not(".el_btn").not(".btn_01").each(function() {
var obj = $(this);
var href = $(this).attr('href');
if ($(this).attr('href').match(/\.(TXT|CSV|PDF|MP3|ISO|ZIP|7Z|LZH|RAR|EXE|DMG|SIT|TAR|GZ|DOC|DOCX|XLS|XLSX|XLSM|PPT|PPTX|MOV|AVI|MP4|WMV|MSI|MSP|SWF)$/i)) {
$.ajax({
type: 'GET',
url: '/api/get/filesize/?file=' + href,
dataType: 'json',
success: function(response){
if ( response.size > 0 )
{
obj.after('['+ conv_unit(response.size)+']');
}
},
error: function(response){
// console.log(response);
}
});
// var ext = RegExp.$1;
// var req = $.ajax({
// type: 'HEAD',
// url: href,
// success: function () {
// var size = req.getResponseHeader('Content-Length');
//
// console.log(href + ' ------> ' + size);
//
// if (size) {
//// var iHrefLength = href.length;
//// var iDot = href.lastIndexOf(".");
//// var sExtension = href.substring(iDot+1,iHrefLength);
//// sExtension = sExtension.toUpperCase();
//// var regExp = /PDF([?#&][\w]+[=]\d)+$/;
//// if(regExp.test(sExtension)) {
//// sExtension = '';
//// }
// obj.after('['+ conv_unit(size)+']');
// }
// }
// });
}
});
});
//関数
var number_format = function(val) {
var s = '' + val;
if (s.length > 3) {
var r = ((r = s.length % 3) == 0 ? 3 : r);
var d = s.substring(r);
s = s.substr(0, r) + d.replace(/(\d{3})/g, ",$1");
}
return s;
};
var conv_unit = function(size) {
var unit = ['KB','MB','GB','TB','PB','EB','ZB','YB'];
if (size < 1024) return size + 'B';
for (var i = 0; i < unit.length; i++) {
size /= 1024;
if (size < 1024) {
if (size >= 100)
return number_format(Math.round(size)) + unit[i];
else
return Math.round(size*10)/10 + unit[i];
}
}
return number_format(Math.round(size)) + 'YB';
};