var loadChart; var callPlayer; (function($){ loadChart = function(selector,width,height){ var radius = Math.min(width, height) / 2; var color = d3.scale.category20(); var pie = d3.layout.pie() .value(function(d) { return d.terze; }) .sort(null); var arc = d3.svg.arc() .innerRadius(radius - 100) .outerRadius(radius - 20); var svg = d3.select(selector).append("svg") .attr("width", width) .attr("height", height) .append("g") .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); d3.csv("../../data/data.csv", type, function(error, data) { var path = svg.datum(data).selectAll("path") .data(pie) .enter().append("path") .attr("fill", function(d, i) { return color(i); }) .attr("d", arc) .each(function(d) { this._current = d; }); // store the initial angles d3.selectAll("input.chart") .on("change", change); var timeout = setTimeout(function() { d3.select("input.chart[value=\"terze\"]").property("checked", true).each(change); }, 2000); function change() { var value = this.value; clearTimeout(timeout); pie.value(function(d) { return d[value]; }); // change the value function path = path.data(pie); // compute the new angles path.transition().duration(750).attrTween("d", arcTween); // redraw the arcs } }); function type(d) { d.terze = +d.terze; d.quarte = +d.quarte; d.quinte = +d.quinte; return d; } // Store the displayed angles in _current. // Then, interpolate from _current to the new angles. // During the transition, _current is updated in-place by d3.interpolate. function arcTween(a) { var i = d3.interpolate(this._current, a); this._current = i(0); return function(t) { return arc(i(t)); }; } } /* * @author Rob W * @website http://stackoverflow.com/a/7513356/938089 * @version 20131010 * @description Executes function on a framed YouTube video (see website link) * For a full list of possible functions, see: * https://developers.google.com/youtube/js_api_reference * @param String frame_id The id of (the div containing) the frame * @param String func Desired function to call, eg. "playVideo" * (Function) Function to call when the player is ready. * @param Array args (optional) List of arguments to pass to function func */ callPlayer = function(frame_id, func, args) { if (window.jQuery && frame_id instanceof jQuery) frame_id = frame_id.get(0).id; var iframe = document.getElementById(frame_id); if (iframe && iframe.tagName.toUpperCase() != 'IFRAME') { iframe = iframe.getElementsByTagName('iframe')[0]; } // When the player is not ready yet, add the event to a queue // Each frame_id is associated with an own queue. // Each queue has three possible states: // undefined = uninitialised / array = queue / 0 = ready if (!callPlayer.queue) callPlayer.queue = {}; var queue = callPlayer.queue[frame_id], domReady = document.readyState == 'complete'; if (domReady && !iframe) { // DOM is ready and iframe does not exist. Log a message window.console && console.log('callPlayer: Frame not found; id=' + frame_id); if (queue) clearInterval(queue.poller); } else if (func === 'listening') { // Sending the "listener" message to the frame, to request status updates if (iframe && iframe.contentWindow) { func = '{"event":"listening","id":' + JSON.stringify(''+frame_id) + '}'; iframe.contentWindow.postMessage(func, '*'); } } else if (!domReady || iframe && (!iframe.contentWindow || queue && !queue.ready) || (!queue || !queue.ready) && typeof func === 'function') { if (!queue) queue = callPlayer.queue[frame_id] = []; queue.push([func, args]); if (!('poller' in queue)) { // keep polling until the document and frame is ready queue.poller = setInterval(function() { callPlayer(frame_id, 'listening'); }, 250); // Add a global "message" event listener, to catch status updates: messageEvent(1, function runOnceReady(e) { if (!iframe) { iframe = document.getElementById(frame_id); if (!iframe) return; if (iframe.tagName.toUpperCase() != 'IFRAME') { iframe = iframe.getElementsByTagName('iframe')[0]; if (!iframe) return; } } if (e.source === iframe.contentWindow) { // Assume that the player is ready if we receive a // message from the iframe clearInterval(queue.poller); queue.ready = true; messageEvent(0, runOnceReady); // .. and release the queue: while (tmp = queue.shift()) { callPlayer(frame_id, tmp[0], tmp[1]); } } }, false); } } else if (iframe && iframe.contentWindow) { // When a function is supplied, just call it (like "onYouTubePlayerReady") if (func.call) return func(); // Frame exists, send message iframe.contentWindow.postMessage(JSON.stringify({ "event": "command", "func": func, "args": args || [], "id": frame_id }), "*"); } /* IE8 does not support addEventListener... */ function messageEvent(add, listener) { var w3 = add ? window.addEventListener : window.removeEventListener; w3 ? w3('message', listener, !1) : (add ? window.attachEvent : window.detachEvent)('onmessage', listener); } } $(function(){ var fixCell = function(element, event){ element.addClass('withevent') .find('.fc-day-number').wrapInner( $('').attr('href', event.url) ); if(event['title']) element.qtip({ content: event.title, style: 'qtip-light' }); }; $('.calendari').each(function(i,e){ var mycal = $(e); mycal.fullCalendar({ 'header':{ left: 'prev', center: 'title', right: 'next' }, 'allDayText' : calendar_lang.allDayText, 'timeFormat' : calendar_lang.timeFormat, 'columnFormat' : calendar_lang.columnFormat, 'titleFormat' : calendar_lang.titleFormat, 'buttonText' : calendar_lang.buttonText, 'monthNames' : calendar_lang.monthNames, 'monthNamesShort' : calendar_lang.monthNamesShort, 'dayNames' : calendar_lang.dayNames, 'dayNamesShort' : calendar_lang.dayNamesShort, 'weekNumberTitle' : calendar_lang.weekNumberTitle, dayClick: function(date, allDay, jsEvent, view) { location.replace('?sede_codice='+sede_codice+'&calendar_date='+$.fullCalendar.formatDate(date,'yyyy-M-d')+'&tipologia='+mycal.attr('data-tipologia')); }, 'eventSources': [ // your event source { url: 'pvw_sito.php?page=calendar_feed&ope=m&sede_codice='+sede_codice+'&tipologia='+mycal.attr('data-tipologia') } ], 'eventRender': function(event, element) { if(event.end){ var dates = moment().range(event.start, event.end); dates.by('days',function(date){ fixCell(mycal.find('.fc-day[data-date="' + date.format('YYYY-MM-DD') + '"]'), event); }); }else{ var date = moment(event.start).format('YYYY-MM-DD'); fixCell($( mycal.find('.fc-day[data-date="' + date + '"]')), event); } return false; } }); }); $('.debug').click(function(e){ e.preventDefault(); $('body').toggleClass('debug'); }) $('a[href="#"]').click(function(e){ e.preventDefault(); }); // Init Chart //loadChart('#chartwidget', 265, 265); /* DEBUG */ var changeCss = function(name){ $('#cssseason').attr('href', '/julian/liceoulivi/tpl/css/liceoulivi.' + name + '.css'); $('.widgets .season, .footer .season').hide(); $('.widgets .season.'+name+', .footer .season.'+name).show(); }; $('.btn-season').click(function(e){ var season = $(this).data('season'); changeCss(season); }); $('.btn-season.autumn').triggerHandler('click'); }) })(jQuery);