define([ 'jquery', '/common/diffMarked.js', ],function ($, DiffMd) { var Slide = { index: 0, lastIndex: 0, content: [], changeHandlers: [], }; var ifrw; var $modal; var $content; var $pad; var placeholder; var options; var separator = '
'; var separatorReg = /
/g; var slideClass = 'slide-frame'; var Title; Slide.onChange = function (f) { if (typeof(f) === 'function') { Slide.changeHandlers.push(f); } }; var getNumberOfSlides = Slide.getNumberOfSlides = function () { return $content.find('.' + slideClass).length; }; var change = function (oldIndex, newIndex) { if (Slide.changeHandlers.length) { Slide.changeHandlers.some(function (f) { f(oldIndex, newIndex, getNumberOfSlides()); }); } }; var updateFontSize = Slide.updateFontSize = function () { // 20vh // 20 * 16 / 9vw var wbase = 20; var vh = 20; var $elem = $(window); if (!Slide.shown) { wbase = 10; vh *= $content.height()/$(window).height(); $elem = $content; } if ($elem.width() > 16/9*$elem.height()) { $content.css('font-size', vh+'vh'); // $print.css('font-size', '20vh'); return; } $content.css('font-size', (wbase*9/16)+'vw'); // $print.css('font-size', (20*9/16)+'vw'); }; var fixCSS = function (css) { var append = '.cp #print .slide-frame '; var append2 = '.cp div#modal #content .slide-frame '; return css.replace(/(\n*)([^\n}]+)\s*\{/g, '$1' + append + '$2,' + append2 + '$2 {'); }; var goTo = Slide.goTo = function (i) { i = i || 0; Slide.index = i; $content.find('.slide-container').first().css('margin-left', -(i*100)+'%'); updateFontSize(); change(Slide.lastIndex, Slide.index); $modal.find('#button_left > span').css({ opacity: Slide.index === 0? 0: 1 }); $modal.find('#button_right > span').css({ opacity: Slide.index === (getNumberOfSlides() -1)? 0: 1 }); }; var draw = Slide.draw = function (i) { if (typeof(Slide.content) !== 'string') { return; } var c = Slide.content; var m = ''+DiffMd.render(c).replace(separatorReg, '')+''; DiffMd.apply(m, $content); var length = getNumberOfSlides(); $modal.find('style.slideStyle').remove(); if (options.style && Slide.shown) { $modal.prepend($('