Sha256: da130516e53faa7296eea4e012b4bd5af5f1515e9d4c00700be968c4b400e37d

Contents?: true

Size: 1.47 KB

Versions: 21

Compression:

Stored size: 1.47 KB

Contents

/*!
Deck JS - deck.split
Copyright (c) 2012 Qingping Hou <dave2008713@gmail.com>
                   about.houqp.me
Dual licensed under the MIT license and GPL license.
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt
*/

/*
This module splits a long slide into multiple slides.
*/
(function($, deck, undefined) {
	var $d = $(document);

	createEmptySlide = function(title_el) {
		slide = $(document.createElement('section'));
		slide.addClass('slide').append(title_el.clone());
		return slide;
	};

	$d.bind('deck.beforeInit', function() {
		$(".slide").each( function(i, slide) {
			/* each slide */
			var is_split = false,
			prev_slide = $(slide),
			/* extract title which will be added to each new slides */
			title_el = prev_slide.children('h2'),
			tmp_slide = createEmptySlide(title_el);

			$(slide).children().each(function() {
				/* for each element inside original slide */
				var el = $(this);

				if (el.css('page-break-after') == 'always') {
					if (is_split) {
						tmp_slide.insertAfter(prev_slide);
						prev_slide = tmp_slide;
						tmp_slide = createEmptySlide(title_el);
					}
					else {
						/* find the first page break */
						is_split = true;
					}
				}
				else {
					if (is_split) {
						tmp_slide.append(el);
					}
				}
			})
			/* add remaining elements to a new slides */
			if (is_split) {
				tmp_slide.insertAfter(prev_slide);
			}
		});
	})
})(jQuery, 'deck');

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hyla-1.0.1 lib/resources/deck.js/extensions/split/deck.split.js