// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Texy! set by Peter Kahoun
// http://kahi.cz
// ----------------------------------------------------------------------------
// Texy!
// http://texy.info
// Feel free to do anything with this.
// -------------------------------------------------------------------
onionEditorSettings = {
	onShiftEnter:	    {keepDefault:false, replaceWith:'\n\n'},
	markupSet: [
		{name:'Tučné', key:'B', closeWith:'**', openWith:'**', className:'bold', placeHolder:'Váš text tu ...'},
		{name:'Šikmé', key:'I', closeWith:'*', openWith:'*', className:'italic', placeHolder:'Váš text tu ...'},
		{separator:'---------------'},
		{name:'Zoznam', replaceWith:function(markItUp) {return texy.multiline(markItUp, '-')}, className:'list-bullet'},
		{name:'Číslovaný zoznam', replaceWith:function(markItUp) {return texy.numbered(markItUp)}, className:'list-numeric'},
		{separator:'---------------'},
		{name:'Obrázok', className:'image', replaceWith:'[* [![Adresa obrázka:!:http://]!] *]'},
		{name:'Odkaz', className:'link', replaceWith:'"[![Text odkazu:!:Odkaz]!]":[![Adresa:!:http://]!]'},
		{name:'Citácia', replaceWith:function(markItUp) {return texy.multiline(markItUp, '>')}, className:'quotes'}
	]
}

texy = {
	multiline: function (markitUp, char) {
		var selection = markitUp.selection;

		if (selection.length == 0) {
			return char + ' ';
		}

		var lines = selection.split("\n");

		var newText = '';
		$.each(lines, function(index, value) {
				newText += char + ' ' + value + "\n";
		});

		return newText;
	},
	numbered: function(markitUp) {
		var selection = markitUp.selection;

		if (selection.length == 0) {
			return char + ' ';
		}

		var lines = selection.split("\n");

		var newText = '';
		$.each(lines, function(index, value) {
				newText += (index + 1) + '. ' + value + "\n";
		});

		return newText;
	}
}

