<commit_before>define(['text', 'jquery', 'htmlEntites', 'buttonHandler', 'slide-template', 'settings', 'canvas'], function(textStyle, $, htmlEntites, bHandler, slideTemplate, settings, canvas){

	var Kreator = (function (options) {
		var slideX = 0, // to keep track of the current slide we're on
			slideY = 0, // to keep track of the current slide we're on
			$ = options.jquery,
			Reveal = options.reveal,
			$span,
			hljs = options.hljs;

		var init = function() {

			options.right = $('<div data-direction="right">+</div>')
					.addClass('add-slide add-right')
					.on('click', function(){
						Kreator.addSlideRight();
						Reveal.navigateRight();
					});
			
			options.down = $('<div data-direction="bottom">+</div>')
					.addClass('add-slide add-down')
					.on('click', function(){
						Kreator.addSlideDown();
						Reveal.navigateDown();
					});
			
			settings.clear();

			$('body').append(options.right).append(options.down);

			$('section').on('click', addContentToSlide);

			$('#download').on('click', function(){
				var s = $('.slides>section');
				var slides = {};
				
				s.each(function(idx, slide){
					slide = $(slide);
					if($('section', slide).length) {
						slides['slide'+idx] = [];
						$('section', slide).each(function(i, sl){
							sl = $(sl);
							content = sl.html();
							content = htmlEntites.convertTags(content);
							slides['slide'+idx].push(content);
						});
					} else {
						content = slide.html();
						content = htmlEntites.convertTags(content);
						slides['slide'+idx] = '<section>' + content + '</section>';
					}
				});
		
				var html = document.querySelector('html'),
					theme;
				if(html.classList.length) {
					theme = html.classList[0];
					if(theme.length>12) {
						theme = 'head';
					}
				} else {
					theme = 'head';
				}

				var webfonts = '';
				var fonts = settings.get('webfont');
				if(Array.isArray(fonts)) webfonts = fonts.map(function (font) {
					return "<link href='http://fonts.googleapis.com/css?family="+font+"' rel='stylesheet' type='text/css'>"
				}).join('');
					else webfonts = "<link href='http://fonts.googleapis.com/css?family="+fonts+"' rel='stylesheet' type='text/css'>";

				var title = settings.get('title') || 'kreator.js presentation';
				var description = settings.get('description') || 'kreator.js presentation';
				var author = settings.get('author') || 'kreator.js presentation';
				
				$.ajax({
					  type: 'POST'
					, url : '.'
					, dataType : 'jsonpi'
					, params : {
						slides : slides,
						params: settings.get(),
						theme: theme,
						webfont: webfonts,
						title: title,
						description: description,
						author: author
					}
				});
			});

			$('#settings-btn').on('click', function(){
				slideTemplate.showSettings.call($('.reveal'));
			});

			$('.btn-group a').on('click', function(e){
				e.preventDefault();
				var tag = $(this).data('textstyle');
				$(this).toggleClass('active');
				if(tag === 'li') {
					if($(this).hasClass('active'))
						$span = $('<span contentEditable><li></li></span>')
							.on('click', editSpan)
							.appendTo(Kreator.getCurrentSlide())
							.trigger('click').focus();
				}
				if(['b', 'i'].indexOf(tag)>=0) {
					$(this).toggleClass('active');
					$span.html(textStyle.format(tag, $span));
				} else if(['blockquote'].indexOf(tag)>=0) {
					$(this).toggleClass('active');
					textStyle.paragraph(tag, $span);
				} else if(['left', 'center', 'right'].indexOf(tag)>=0) {
					$(this).toggleClass('active');
					textStyle.align(tag, $span);
				} else if(tag === 'a') {
					$(this).toggleClass('active');
					textStyle.insertHiperlink(this, $span);
				} else if(tag === 'move') {
					$(this).toggleClass('btn-info');
					var section = $('.reveal section');
					if(!$(this).hasClass('active') && $('span', $('.present')).length ) {
						$('.present span').off('mousedown', bHandler.moveSpan)
								.attr('contentEditable', true);
						var className = $span.attr('class') || $span.addClass(Kreator.generateClassName(1)) && $span.attr('class');
						settings.set(['.'+className, 'position:absolute;top:'+$span.css('top')+';left:'+$span.css('left')]);
						
					} else {
						$('.present span').on('mousedown', bHandler.moveSpan)
								.attr('contentEditable', false);
					}
					$('.present').toggleClass('crosshair');
				} else if(tag === 'grid') {
		
					if($(this).hasClass('active')) {
						canvas.init();
					} else {
						canvas.remove();
					}
				} else if(tag === 'remove') {
					
					$(this).toggleClass('btn-info');
					$('.present').toggleClass('crosshair');
					
					if($(this).hasClass('active')) {
						$('span').on('click', bHandler.removeSpan);
					} else {
						$('span').off('click', bHandler.removeSpan);
					}
				} else if(tag === 'grid-clear') {
					$(this).toggleClass('active');
					settings.remove(['canvasPoints']);
				} else if(tag === 'upload') {
					slideTemplate.uploadImages.call($(this));
				} else if(tag === 'images') {
					$('.thumbnails').toggle();
				} else if(tag === 'resize') {
					$('.present').toggleClass('resize');
					var img = document.querySelector('.present img');
					if (img) bHandler.imageResize(img);
					if ( ! $(this).hasClass('active') ) {
						var x = Kreator.getSlideX() + 1;
						var y = Kreator.getSlideY() + 1;
						if (y==1) {
							settings.set(['.slides:nth-child('+x+') section img', 'width :' + img.style.width]);
						} else {
							settings.set(['.slides section:nth-child('+x+') section:nth-child('+y+') img', 'width :' + img.style.width]);
						}
					}
				} else if (tag === 'textcolor') {
					var that = $(this);
					if($('input[type=color]').length) {
						$('input[type=color]').remove();
					}
					if (that.hasClass('active')) {
						var input = $('<input type="color">');
						that.append(input);
						input.on('click', function(e){
							e.stopPropagation();
						}).on('change', function(){
							console.log('change triggered');
							var color = $(this).val();
							var className = $span.attr('class') || Kreator.generateClassName(1);
							$span.html(textStyle.format('span', $span));
							var coloredText = $('span:not([style])', $span);
							coloredText.css('color', color).addClass(className);
							settings.set(['.' + className, 'color:' + color]);
							$(this).remove();
							that.trigger('click');
						});
					}
				} else if (tag === 'fullscreen' || tag === 'settings') {
					$(this).removeClass('active');
				}
			});

			$('.thumbnails img').live('click', function () {
				var el = $('<img>').attr('src', $(this).attr('src'))
					.css('width', '200px')
					.attr('data-path', $(this).attr('data-path'));
				var s = $('<span/>').append(el).appendTo('.present');
				s.on('click', function (e) {
					editSpan(e, this);
				});
			});

			$('#select-dimensions').on('change', function () {
				// create H headings
				var h = $(this).val();
				var html = textStyle.removeHeadings($span.html());
				$span.html('<' + h + '>' + html + '</' + h + '>');
			});

			$('#cl-dimensions').on('change', function(){
				var tag = $(this).val(),
				string = textStyle.paragraph(tag, $span);
				if(string) $span.html(string);
			});

			$('.fullscreen').on('click', function(){<commit_msg>text and background color for content<commit_after>define(['text', 'jquery', 'htmlEntites', 'buttonHandler', 'slide-template', 'settings', 'canvas'], function(textStyle, $, htmlEntites, bHandler, slideTemplate, settings, canvas){

	var Kreator = (function (options) {
		var slideX = 0, // to keep track of the current slide we're on
			slideY = 0, // to keep track of the current slide we're on
			$ = options.jquery,
			Reveal = options.reveal,
			$span,
			hljs = options.hljs;

		var init = function() {

			options.right = $('<div data-direction="right">+</div>')
					.addClass('add-slide add-right')
					.on('click', function(){
						Kreator.addSlideRight();
						Reveal.navigateRight();
					});
			
			options.down = $('<div data-direction="bottom">+</div>')
					.addClass('add-slide add-down')
					.on('click', function(){
						Kreator.addSlideDown();
						Reveal.navigateDown();
					});
			
			settings.clear();

			$('body').append(options.right).append(options.down);

			$('section').on('click', addContentToSlide);

			$('#download').on('click', function(){
				var s = $('.slides>section');
				var slides = {};
				
				s.each(function(idx, slide){
					slide = $(slide);
					if($('section', slide).length) {
						slides['slide'+idx] = [];
						$('section', slide).each(function(i, sl){
							sl = $(sl);
							content = sl.html();
							content = htmlEntites.convertTags(content);
							slides['slide'+idx].push(content);
						});
					} else {
						content = slide.html();
						content = htmlEntites.convertTags(content);
						slides['slide'+idx] = '<section>' + content + '</section>';
					}
				});
		
				var html = document.querySelector('html'),
					theme;
				if(html.classList.length) {
					theme = html.classList[0];
					if(theme.length>12) {
						theme = 'head';
					}
				} else {
					theme = 'head';
				}

				var webfonts = '';
				var fonts = settings.get('webfont');
				if(Array.isArray(fonts)) webfonts = fonts.map(function (font) {
					return "<link href='http://fonts.googleapis.com/css?family="+font+"' rel='stylesheet' type='text/css'>"
				}).join('');
					else webfonts = "<link href='http://fonts.googleapis.com/css?family="+fonts+"' rel='stylesheet' type='text/css'>";

				var title = settings.get('title') || 'kreator.js presentation';
				var description = settings.get('description') || 'kreator.js presentation';
				var author = settings.get('author') || 'kreator.js presentation';
				
				$.ajax({
					  type: 'POST'
					, url : '.'
					, dataType : 'jsonpi'
					, params : {
						slides : slides,
						params: settings.get(),
						theme: theme,
						webfont: webfonts,
						title: title,
						description: description,
						author: author
					}
				});
			});

			$('#settings-btn').on('click', function(){
				slideTemplate.showSettings.call($('.reveal'));
			});

			$('.btn-group a').on('click', function(e){
				e.preventDefault();
				var tag = $(this).data('textstyle');
				$(this).toggleClass('active');
				if(tag === 'li') {
					if($(this).hasClass('active'))
						$span = $('<span contentEditable><li></li></span>')
							.on('click', editSpan)
							.appendTo(Kreator.getCurrentSlide())
							.trigger('click').focus();
				}
				if(['b', 'i'].indexOf(tag)>=0) {
					$(this).toggleClass('active');
					$span.html(textStyle.format(tag, $span));
				} else if(['blockquote'].indexOf(tag)>=0) {
					$(this).toggleClass('active');
					textStyle.paragraph(tag, $span);
				} else if(['left', 'center', 'right'].indexOf(tag)>=0) {
					$(this).toggleClass('active');
					textStyle.align(tag, $span);
				} else if(tag === 'a') {
					$(this).toggleClass('active');
					textStyle.insertHiperlink(this, $span);
				} else if(tag === 'move') {
					$(this).toggleClass('btn-info');
					var section = $('.reveal section');
					if(!$(this).hasClass('active') && $('span', $('.present')).length ) {
						$('.present span').off('mousedown', bHandler.moveSpan)
								.attr('contentEditable', true);
						var className = $span.attr('class') || $span.addClass(Kreator.generateClassName(1)) && $span.attr('class');
						settings.set(['.'+className, 'position:absolute;top:'+$span.css('top')+';left:'+$span.css('left')]);
						
					} else {
						$('.present span').on('mousedown', bHandler.moveSpan)
								.attr('contentEditable', false);
					}
					$('.present').toggleClass('crosshair');
				} else if(tag === 'grid') {
		
					if($(this).hasClass('active')) {
						canvas.init();
					} else {
						canvas.remove();
					}
				} else if(tag === 'remove') {
					
					$(this).toggleClass('btn-info');
					$('.present').toggleClass('crosshair');
					
					if($(this).hasClass('active')) {
						$('span').on('click', bHandler.removeSpan);
					} else {
						$('span').off('click', bHandler.removeSpan);
					}
				} else if(tag === 'grid-clear') {
					$(this).toggleClass('active');
					settings.remove(['canvasPoints']);
				} else if(tag === 'upload') {
					slideTemplate.uploadImages.call($(this));
				} else if(tag === 'images') {
					$('.thumbnails').toggle();
				} else if(tag === 'resize') {
					$('.present').toggleClass('resize');
					var img = document.querySelector('.present img');
					if (img) bHandler.imageResize(img);
					if ( ! $(this).hasClass('active') ) {
						var x = Kreator.getSlideX() + 1;
						var y = Kreator.getSlideY() + 1;
						if (y==1) {
							settings.set(['.slides:nth-child('+x+') section img', 'width :' + img.style.width]);
						} else {
							settings.set(['.slides section:nth-child('+x+') section:nth-child('+y+') img', 'width :' + img.style.width]);
						}
					}
				} else if (tag === 'textcolor') {
					var that = $(this);
					if($('input[type=color]').length) {
						$('input[type=color]').remove();
					}
					if (that.hasClass('active')) {
						var input = $('<input type="color">');
						that.append(input);
						input.on('click', function(e){
							e.stopPropagation();
						}).on('change', function(){
							var color = $(this).val();
							$span.html(textStyle.format('span', $span));
							var coloredText = $('span:not([style])', $span);
							var className = coloredText.attr('class') || Kreator.generateClassName(1);
							console.log(className);
							coloredText.css('color', color).addClass(className);
							settings.set(['.' + className, 'color:' + color]);
							$(this).remove();
							that.trigger('click');
						});
					}
				} else if (tag === 'fullscreen' || tag === 'settings') {
					$(this).removeClass('active');
				} else if (tag === 'bgcolor') {
					var that = $(this);
					if($('input[type=color]').length) {
						$('input[type=color]').remove();
					}
					var input = $('<input type="color">');
						that.append(input);
						input.on('click', function(e){
							e.stopPropagation();
						}).on('change', function(){
							var color = $(this).val();
							var className = $span.attr('class') || Kreator.generateClassName(1);
							console.log(className);
							$span.css('background', color);
							if (!$span.attr('class')) {
								$span.addClass(className);
							}
							settings.set(['.' + className, 'background:' + color]);
							$(this).remove();
							that.trigger('click');
						});

				}
			});

			$('.thumbnails img').live('click', function () {
				var el = $('<img>').attr('src', $(this).attr('src'))
					.css('width', '200px')
					.attr('data-path', $(this).attr('data-path'));
				var s = $('<span/>').append(el).appendTo('.present');
				s.on('click', function (e) {
					editSpan(e, this);
				});
			});

			$('#select-dimensions').on('change', function () {
				// create H headings
				var h = $(this).val();
				var html = textStyle.removeHeadings($span.html());
				$span.html('<' + h + '>' + html + '</' + h + '>');
			});

			$('#cl-dimensions').on('change', function(){
				var tag = $(this).val(),
				string = textStyle.paragraph(tag, $span);
				if(string) $span.html(string);
			});

			$('.fullscreen').on('click', function(){
{'fraction_non_alphanumeric': 0.22406801831262263, 'fraction_numerical': 0.002158273381294964, 'mean_word_length': 2.9470831182240578, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '468820', 'n_tokens_mistral': 6649, 'n_tokens_neox': 4880, 'n_words': 863}