// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// BBCode tags example
// http://en.wikipedia.org/wiki/Bbcode
// ----------------------------------------------------------------------------
// Feel free to add more tags
// ----------------------------------------------------------------------------
mySettings = {
	previewParserPath:	'', // path to your BBCode parser
	markupSet: [
		{name:'Pogrubienie', key:'B', openWith:'[b]', closeWith:'[/b]'},
		{name:'Kursywa', key:'I', openWith:'[i]', closeWith:'[/i]'},
		{name:'Podkreślenie', key:'U', openWith:'[u]', closeWith:'[/u]'},
		{separator:'---------------'},
		{name:'Zdjęcie', key:'P', openWith:'[img]', closeWith:'[/img]', call: function(){

			// TODO refaktoryzacja.
			var getPhotos = function(){
				var photos = "";
				for( var i = 0; i< MyViMu.manager.upload.imageList.length; i++ ){					// rysuj wszystkie juz dodane zdjecia
					var res		= MyViMu.API.call("photo_copy_for_forum", {							// todo: optymalizacja - wszystkie zdjecia na raz
							photo : MyViMu.manager.upload.imageList[ i ].id
						});
					photos+=res.data[0];				// skladaj tekst
				}
				var editor	= jQuery("#new_post_textarea");
				editor.val( editor.val().replace(/\[img\]\[\/img\]/g, photos ));			// zamien [img][/img] na wygenerowany kod zdjec
				MyViMu.manager.upload.imageList = [];
			}

			if( MyViMu.manager.upload.uploading !== true ){							// jesli ju znie wysylam
				dialogManager.run( 'uploader', { getPhotos: getPhotos } );
			}
		}},
		{name:'Link', key:'L', openWith:'[url=[![Url]!]]', closeWith:'[/url]', placeHolder:'Your text to link here...'},
		{separator:'---------------'},
		{name:'Rozmiar tekstu', key:'S', openWith:'[size=[![Text size]!]]', closeWith:'[/size]',
		dropMenu :[
			{name:'Duży', openWith:'[size=15]', closeWith:'[/size]'},
			{name:'Normalny', openWith:'[size=11]', closeWith:'[/size]'},
			{name:'Mały', openWith:'[size=9]', closeWith:'[/size]'}
		]},
		{separator:'---------------'},
		{name:'Wypunktowanie', openWith:'[list]\n', closeWith:'\n[/list]'},
		{name:'Lista numerowana', openWith:'[list=[![Starting number]!]]\n', closeWith:'\n[/list]'}, 
		{name:'Element listy', openWith:'[*] '},
		{separator:'---------------'},
		{name:'Cytat', openWith:'[quote]', closeWith:'[/quote]'},
		{name:'Kod', openWith:'[code]', closeWith:'[/code]'}, 
		{separator:'---------------'},
		{name:'Wyczyść formatowanie', className:"clean", replaceWith:function(markitup) {return markitup.selection.replace(/\[(.*?)\]/g, "")}},
		{name:'Podgląd', className:"preview", call:'preview'}
	]
}



