$(document).ready(function() { window.Preshow = Spine.Class.create({ init: function() { this.element = $(arguments[0]); this.secondsToRun = parseFloat(arguments[1] * 60); $.subscribe("presentation:preshow:toggle",$.proxy(function() { this.toggle(); },this)); }, preshowRunning: false, start: function() { if (this.preshowIntervalReference) { return; } this.preservePresentationSpace(); this.load(); this.images = this.element.children("img"); this.currentImageIndex = 0; this.totalImages = this.images.size(); this.preshowRunning = true; $.publish("presentation:preshow:start"); this.currentRunTime = 0; this.currentRemainingTime = this.secondsToRun; this.nextImage(); this.preshowIntervalReference = setInterval($.proxy(this.perform,this),1000); }, preservePresentationSpace: function() { this.storedPresentationSpace = this.element.html(); }, restorePresentationSpace: function() { this.element.empty(); this.element.html(this.storedPresentationSpace); }, displayImagesInterval: 5, perform: function() { this.currentRunTime ++; this.currentRemainingTime --; time = this.secondsToTime(this.currentRemainingTime); $('#preshow_timer').text(time + ' to go-time') var description = this.preshowDescription && this.preshowDescription[tmpImg.attr("ref")] if(description) { $('#tips').show(); $('#tips').text(description); } else { $('#tips').hide(); } if ((this.currentRunTime % this.displayImagesInterval) == 0) { this.nextImage(); } this.preshowTip(); if (this.currentRemainingTime <= 0) { this.stop(); } }, stop: function() { if (!this.preshowIntervalReference) { return; } this.preshowRunning = false; window.clearInterval(this.preshowIntervalReference); this.preshowIntervalReference = undefined; $('#preshow').remove(); $('#tips').remove(); $('#preshow_timer').remove(); this.restorePresentationSpace(); $.publish("presentation:preshow:stop"); }, toggle: function() { if (this.preshowIntervalReference) { this.stop(); } else { this.start(); } }, preshowPath: "preshow", load: function() { $.getJSON(this.preshowPath, false, $.proxy(function(data) { this.element.after("
") $.each(data, $.proxy(function(i, n) { if(n == "preshow.json") { // has a descriptions file $.getJSON("/file/preshow/preshow.json", false, function(data) { this.preshowDescription = data; }) } else { $('#preshow').append(''); this.images = $("#preshow > img"); this.totalImages = this.images.size(); } },this)); },this)); }, nextImage: function() { this.currentImageIndex ++; if((this.currentImageIndex + 1) > this.totalImages) { this.currentImageIndex = 0; } this.element.empty(); tmpImg = this.images.eq(this.currentImageIndex).clone(); $(tmpImg).attr('width', '1020'); this.element.html(tmpImg); }, preshowTip: function() { }, secondsToTime: function(seconds) { minutes = Math.floor(seconds / 60) seconds = seconds - (minutes * 60) if(seconds < 10) { seconds = "0" + seconds } return minutes + ":" + seconds } }); window.ToggleView = Spine.Class.create({ init: function () { this.element = $(arguments[0]) var eventPrefix = arguments[1] $.subscribe( eventPrefix + ":show",$.proxy(function() { this.show() },this)); $.subscribe( eventPrefix + ":hide",$.proxy(function() { this.hide() },this)); $.subscribe( eventPrefix + ":toggle",$.proxy(function() { this.toggle() },this)); }, show: function() { this.element.show() }, hide: function() { this.element.hide() }, toggle: function() { this.element.toggle() } }); window.Footer = ToggleView.sub({ init: function() { this.constructor.__super__.init.apply(this, arguments); this.progressView = $("#slideInfo") $.subscribe("presentation:slide:didChange",$.proxy(this.updateProgress,this)); }, progressPercentage: function (slideIndex,slideCount) { return Math.ceil(((slideIndex + 1) / slideCount) * 100) }, updateProgress: function(event,slideIndex,slideCount) { percent = this.progressPercentage(slideIndex,slideCount); this.progressView.text((slideIndex + 1) + '/' + slideCount + ' - ' + percent + '%') } }); window.HelpMenu = ToggleView.sub(); window.PauseScreen = ToggleView.sub(); window.SpeakerNotes = ToggleView.sub({ init: function() { this.constructor.__super__.init.apply(this, arguments) $.subscribe("presentation:slide:didChange",$.proxy(this.updateNotes,this)); }, updateNotes: function(event,slide) { // Update the text from the slide's notes } }); window.DebugView = ToggleView.sub({ log: function(text) { this.element.text(text); } }); window.Slide = Spine.Class.create({ index: 0, maxSlides: 0, init: function() { this.htmlContent = arguments[0]; this.index = arguments[1]; this.maxSlides = arguments[2]; this.transition = this.htmlContent.attr('data-transition'); this.sequence = parseInt(this.htmlContent.attr('data-sequence')); this.title = this.htmlContent.attr('data-title'); if (this.title === undefined) { this.title = this.htmlContent.text().trim().split("\n")[0]; if (this.title.length > 20) { this.title = this.title.substr(0,15) + "..."; } } this.sections = []; if (this.htmlContent.attr('data-sections') != undefined) { this.sections = this.htmlContent.attr('data-sections').split(','); } this.increments = this.htmlContent.find(".incremental > ul > li"); this.currentIncrement = 0; if (this.increments.size() == 0) { this.increments = this.htmlContent.find(".incremental pre pre") this.codeIncremental = true; } this.increments.each(function(index, increment) { $(increment).css('visibility', 'hidden'); }); }, currentIncrement: 0, increment: function(incrementIndex) { var increment = this.increments.eq(incrementIndex); if (this.codeIncremental && increment.hasClass('command')) { var typeInputOverDuration = increment.find('.input').text().length / 24; increment.find('.prompt').css('visibility', 'visible'); increment.find('.input').css('visibility', 'visible').jTypeWriter({duration:typeInputOverDuration}); } else { increment.css('visibility', 'visible'); } }, nextIncrement: function() { this.increment(this.currentIncrement); this.trigger("parade:incr"); this.currentIncrement ++; }, hasIncrement: function() { return (this.currentIncrement < this.increments.size()); }, showAllIncrements: function() { this.increments.each(function(index, increment) { $(increment).css('visibility', 'visible'); }); this.currentIncrement = this.increments.size(); }, isFullPage: function() { return this.htmlContent.find(".content").is('.full-page'); }, notes: function() { return this.htmlContent.find("p.notes").text(); }, goFullPage: function() { this.htmlContent.css({'width' : '100%', 'text-align' : 'center', 'overflow' : 'visible'}); }, trigger: function(eventName) { var event = jQuery.Event(eventName); this.htmlContent.find(".content").trigger(event,this); return event; } }); window.Slides = Spine.Class.create({ init: function() { this.element = $("#slides"); this.slides = $("#slides > .slide"); }, show: function() { this.element.show() }, hide: function() { this.element.hide() }, load: function() { // $("#slides img").batchImageLoad({ // loadingCompleteCallback: presentation.initialize() // }); // $("#slides").load("/slides",function() { // console.log("loading slides complete"); // $("#slides img").batchImageLoad({ // loadingCompleteCallback: presentation.initialize() // }); // }); }, size: function() { return this.slides.size(); }, at: function(index) { return new Slide($(this.slides.eq(index)),index,this.size()); }, find: function(query) { var regexQuery = new RegExp(query,"i"); var matchedSlideNumbers = []; for (var index = 0; index < this.size(); index++) { var slide = this.at(index); // console.log(slide.title + " " + regexQuery); if (regexQuery.exec(slide.title)) { matchedSlideNumbers.push(slide.sequence); } } console.log("Found: " + matchedSlideNumbers); return matchedSlideNumbers; }, findClosestToQuery: function(position,query) { console.log('Finding the query `' + query + '` next to position ' + position); var matchingSlides = this.find(query); var closestPosition = matchingSlides[0]; console.log('Defaulting to ' + closestPosition); for (var mI = 0; mI < matchingSlides.length; mI++) { if (matchingSlides[mI] > position) { console.log('Setting movement to ' + matchingSlides[mI]); closestPosition = matchingSlides[mI]; break; } } return closestPosition; } }); window.NavigationMenu = ToggleView.sub({ init: function() { this.constructor.__super__.init.apply(this,arguments); this.menuView = $("#navigation"); }, populate: function(slides) { var menu = new ListMenu(); for (var i = 0; i < slides.size(); i++) { var slide = slides.at(i); var sectionsMinusRoot = slide.sections.slice(1,slide.sections.length); sectionsMinusRoot.push(slide.sequence); menu.addItem(sectionsMinusRoot, slide.title, slide.sequence); } this.menuView.html(menu.getList()); this.element.menu({ content: this.menuView.html(), flyOut: true, width: 200 }); }, toggle: function() { this.constructor.__super__.toggle.apply(this,arguments); this.open(); }, show: function() { this.constructor.__super__.show.apply(this,arguments); this.open(); }, open: function() { this.element.trigger('click'); }, createMenu: function(slide) { console.log(this); function menu(slide) { console.log(this); } } }); function ListMenu(slide) { this.slide = slide this.typeName = 'ListMenu' this.itemLength = 0; this.items = new Array(); this.addItem = function (key, text, slide) { if (key.length > 1) { thisKey = key.shift() if (!this.items[thisKey]) { this.items[thisKey] = new ListMenu(slide) } this.items[thisKey].addItem(key, text, slide) } else { thisKey = key.shift() this.items[thisKey] = new ListMenuItem(text, slide) } } this.getList = function() { var newMenu = $("