define([ 'jquery', '/common/diffMarked.js', ],function ($, DiffMd) { var Slide = { index: 0, lastIndex: 0, content: [], changeHandlers: [], }; var ifrw; var $modal; var $content; var placeholder; var options; var separator = '
'; var separatorReg = /
/g; var slideClass = 'cp-app-slide-frame'; var Title; var Common; 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 goTo = Slide.goTo = function (i) { i = i || 0; Slide.index = i; $content.find('.cp-app-slide-container').first().css('margin-left', -(i*100)+'%'); updateFontSize(); change(Slide.lastIndex, Slide.index); $modal.find('#cp-app-slide-modal-left > span').css({ opacity: Slide.index === 0? 0: 1 }); $modal.find('#cp-app-slide-modal-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.cp-app-slide-style').remove(); if (options.style) { $modal.prepend($('