$(function() { var that = this; // scroll bar $('#wrap-i').addClass('scroll-pane'); // resize var resize = function() { var margin = 20; var wheight = $(window).height(); if (wheight < 730) { $('#container').css('padding-top', '2px'); $('#main').css({'padding-top': '20px', 'padding-bottom': '5px'}); margin = 4; } var diff = $('#container').height() - $('#wrap-i').height() + margin; $('#wrap-i').height(wheight - diff); $('.scroll-pane').jScrollPane({showArrows: true}); $('#twitter-tweets').height(wheight - margin - 148); }; $(window).resize(resize); resize(); // twitter var setTweets = function(token) { var type = (/^[#@]/.test(token)) ? 'search' : 'profile'; var user = ''; if (/([^\/]+)\/([^\/]+)/.test(token)) { type = 'list'; token = RegExp.$1; user = RegExp.$2; } $('#twitter-tweets').empty(); var opt = { id: 'twitter-tweets', version: 2, type: type, rpp: 100, interval: 5000, width: 194, height: 1000, avatars: true, theme: { shell: { background: '#e6e6e6', color: '#000' }, tweets: { background: '#e6e6e6', color: '#000', links: '#000' } }, features: { scrollbar: false, loop: false, live: true, behavior: 'all' }, ready: loadCheck }; if (type == 'search') opt['search'] = token; var tw = new TWTR.Widget(opt).render(); if (type == 'profile') tw = tw.setUser(token); else if (type == 'list') tw.setList(token, user); function loadCheck(){ if ($('.twtr-tweet').length <= 0) { setTimeout(loadCheck, 100); } else { $(".twtr-tweets").carouFredSel({ items : { width: 195, height: "variable", filter: '.twtr-tweet' }, scroll : { items : 1, easing : 'easeInOutExpo', duration : 1000 }, direction: "up", circular: false, infinite: false, auto: false, prev: { button: "#twitter .twitter-prev", key: "up" }, next: { button: "#twitter .twitter-next", key: "down" } }) clearTimeout(loadCheck); } } tw.start(); }; $('#twitter .twitter-accounts').change(function() { var value = $(this).find(':selected').val(); setTweets(value); }); setTweets('iwakami_staff/iwj-info'); // =========================== return if it's not a top page if (!$('body').hasClass('top')) return; // grid var initSlides = function() { var g = $('#grid'); var cols = Math.max.apply(Math, $.map($('tr', g), function(n) { return $('td', n).length })); var rows = $('tr', g).length; var gw = that.gridWidth = g.width(); var gh = that.gridHeight = g.height(); var sw = that.slideWidth = gw / cols; var sh = that.slideHeight = gh / rows; $('td', g).each(function() { var cols = $(this).attr('colspan') ? $(this).attr('colspan') : 1; var rows = $(this).attr('rowspan') ? $(this).attr('rowspan') : 1; $(this).width(sw * cols).height(sh * rows); $('div', this).width(sw * cols).height(sh * rows); $('.slide', this).each(function(i) { var self = $(this); self.css({ 'width': sw * cols, 'padding': ((sh * rows - self.height()) / 2) + 'px 0', 'background-image': 'url(' + self.attr('src') + ')' }); if (self.attr('href') != 'undefined') { // self.click(function() { // location.href = self.href; // }).css('cursor', 'pointer'); } if (i == 0) self.addClass('current'); }); }); var s = that.slides = $('#grid td div'); setTimeout(slide, 5000); }; var slide = function() { var s = that.slides; var next = []; next.push(Math.floor(Math.random() * s.length)); for (var i = 0; i < next.length; i++) { var o = next[i]; var v = $('.slide', s.eq(o)); if (v.length < 2) continue; var pos = [[-138, 0], [0, 258], [138, 0], [0, -258]][Math.floor(Math.random() * 4)]; var cr, n; for (var j = 0; j < v.length; j++) { var d = v.eq(j); if (d.hasClass('current')) { cr = d; n = j + 1; } } if (n >= v.length) n = 0; var target = v.eq(n); if (cr) cr.removeClass('current'); target .css({'top': pos[0], 'left': pos[1]}) .addClass('current') .animate({'top': 0, 'left': 0}, 500); } setTimeout(slide, 5000); }; /* $.get('/base/wp-content/themes/iwj_site/src/grid.php', function(data) { */ $.get('/base/wp-content/themes/iwj_site/src/grid_dynamic.php', function(data) { $('#grid').html(data); setTimeout(initSlides, 1); }); // fetch feed var registeredCategory = ['社会', '行政', '国際', '司法', '文化']; var fetch = function(data) { var xml = (typeof(data) == 'string') ? $($.parseXML(data)) : $(data); var today = new Date($('lastBuildDate', xml).text()); $('#articles .today').html([ today.getFullYear(), ('0' + (today.getMonth() + 1)).slice(-2), ('0' + today.getDate()).slice(-2) ].join('.')); xml.find('item').each(function(i) { var html = $('.article.template').clone(); html.removeClass('template'); var title = $('title', this).text(); var link = $('link', this).text(); title = '' + title.replace(/\d{4}\/\d+\/\d+\s+/, '') + '' $('.title', html).html(title); var text = $('encoded', this).text(); if (!text) text = $(this).find('content\\:encoded').text(); text = text.replace(/