App-SlideServer
view release on metacpan or search on metacpan
share/public/slides.js view on Meta::CPAN
if (self.cur_slide == num)
self._show_slide(num, old_slide.cur_step);
else
self.slides[num-1].hide();
} else {
// Should never happen, but will prevent even more bizarre errors...
while (this.slides.length -1 < num) {
var placeholder= self.wrapSlideEl($('<div class="slide">Slide Missing?</div>')[0], this.slides.length+1);
self.root.append(placeholder.el)
self.slides.push(placeholder);
}
self.root.append(new_slide_el);
self.slides.push(slide);
}
new_slide_el.style.visibility= '';
},
resizeSlides: function() {
var viewport_w= $(window).width();
var viewport_h= $(window).height();
for (var i= 0; i < this.slides.length; i++) {
var slide= this.slides[i];
slide.showStep(slide.max_step)
slide.scaleTo(viewport_w, viewport_h);
}
},
// Remove leading whitespace, and convert tabs to spaces, and remove
// the largest common indent of all lines.
_fixup_code_block: function(code_el) {
var text= $(code_el).text();
text= text.replace(/\t/g, ' '); // tabs to spaces
text= text.replace(/^\s*\n/g, ''); // remove leading blank line
text= text.replace(/\n\s*$/g, ''); // remove blank trailing line
// find the shortest match of whitespace at the start of any line
var lead_ws_re= new RegExp('^( *)','mg');
var indent= null;
while ((matches= lead_ws_re.exec(text)) !== null)
if (indent === null || matches[1].length < indent) {
indent= matches[1].length;
if (indent == 0) break;
}
if (indent > 0)
text= text.replace(new RegExp('^'+(' '.repeat(indent)), 'mg'), '');
$(code_el).text(text);
// Apply syntax highlighting if available
if (this.config.code_highlight)
this.config.code_highlight(code_el);
},
_build_ui: function() {
var self= this;
self.root.prepend(this._public_ui_html);
self.root.find('button').each(function(){ this.onclick= self._button_dispatch });
self.root.find('input[type="checkbox"]').each(function(){ this.oninput= self._ckbox_dispatch });
self.root.find('.status-actions input[name="key"]').each(function(){ this.onkeydown= self._enter_dispatch });
self.root.find('.status-actions button').hide();
$(document).on('keydown', function(e) { return self._handle_key(e.originalEvent); });
self.root.find('.slide').on('click', function(e) { return self._handle_click(e) });
},
_public_ui_html: (
'<div class="slides-sidebar">'+
' <div class="slides-corner">'+
' <button class="slides-sidebar-btn" type="button" data-method="togglemenu" title="Menu">'+
' <div class="bar bar1"></div><div class="bar bar2"></div><div class="bar bar3"></div>'+
' </button>'+
' <div class="slides-notify"></div>'+
' </div>'+
' <div class="ui"><div class="ui-inner">'+
' <h5>Status</h5>'+
' <ul class="status"></ul>'+
' <div class="status-actions">'+
' <label class="login">Key : <input type="password" name="key" data-enter_method="reconnect"></label>'+
' <button class="reconnect-btn" type="button" data-method="reconnect">Reconnect</button>'+
' <label class="cb follow"><input type="checkbox" name="follow" checked data-method="enableFollow"> Follow</label>'+
' <label class="cb lead"><input type="checkbox" name="lead" data-method="enableLead"> Lead</label>'+
' <label class="cb navigate"><input type="checkbox" name="navigate" data-method="enableNavigate"> Show Nav Buttons</label>'+
' <label class="cb notes"><input type="checkbox" name="notes" data-method="enableNotes"> Show Notes</label>'+
' </div>'+
' </div></div>'+
'</div>'
),
_build_nav_ui: function() {
var self= this;
if (!self.nav_ui) {
self.root.prepend(this._nav_ui_html);
self.nav_ui= self.root.find('.navbuttons');
self.nav_ui.find('button').each(function(){ this.onclick= self._button_dispatch });
}
},
_nav_ui_html: (
'<div class="navbuttons">'+
' <button class="prev" type="button" data-method="navPrev">Prev</button>'+
' <button class="step" type="button" data-method="navStep">Step</button>'+
' <button class="next" type="button" data-method="navNext">Next</button>'+
'</div>'
),
_build_presenternotes_ui: function() {
var self= this;
if (!self.presenternotes_ui) {
self.root.prepend(this._presenternotes_ui_html);
self.presenternotes_ui= self.root.find('.presenternotes');
}
},
_presenternotes_ui_html: (
'<div class="presenternotes">'+
' <pre></pre>'+
'</div>'
),
togglemenu: function(next_slide) {
this.root.find('.slides-sidebar').toggleClass('open');
var root_top= this.root.offset().top;
if (this.root.find('.slides-sidebar').hasClass('open')) {
// if allowed to navigate, show all slides
if (this.roles.navigate) {
this.root.find('.slide').show();
// and scroll to the one we were just on
if (this.cur_slide) {
var slide= this.slides[this.cur_slide-1];
document.documentElement.scrollTop= slide.top();
}
}
} else {
if (this.following)
( run in 0.692 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )