﻿/*****************************************************// JS-Routinen für Events-Modul******************************************************//******************************************************** * Date-Picker initialisieren ********************************************************/var eventsEditDiv = null;function makeDatepicker(){		$.datepicker.setDefaults($.datepicker.regional['de']);		$('.datum').each(function(){				var altID = "#alt_" + $(this).attr('id');		var d = new Date();		var jahr = d.getFullYear() + 5;				var yR = $(this).attr('rel') + ":" + jahr;				$(this).datepicker({			dateFormat: 'dd.mm.yy',			altField: altID,			altFormat: 'yy-mm-dd',			changeYear: true,			yearRange: yR,			minDate: new Date(),			defaultDate: new Date()		});	});}var sorted = new Array();var eventsSortable;var eventsSortableInit = function() {	eventsSortable = $('#eventsListe').sortable( {		items: '.sortable',		//placeholder: 'sorthelper',		axis: 'y',		distance: 2,		update: eventsReorder	} );}// When an update has occurred, adjust the order for each itemvar eventsReorder = function(e, sort) {		var arr = $('#eventsListe').sortable('serialize');	//console.log(arr);	$.post('php/ajax/modules/events/mod.events.sort.php', arr, function(data){			});}function initEditEvents(whichDiv){		eventsEditDiv = whichDiv;		$.get('php/ajax/modules/events/mod.events.php', function(data){		$('#' + whichDiv).html('<div id="eventsListe">' + data + '</div>');		showEditButton = false;				// initialize sortable		eventsSortableInit();			});}function editEvents(which, action){		if(action == "edit"){				$('body').append('<div id="divEditEvents" style="display: none"></div>');				$('#divEditEvents').load('php/ajax/modules/events/mod.events.edit.php?id=' + which, function(data){			centerDiv('divEditEvents');			initSmallEdit($('#divEditEvents beschreibung').height());			makeDatepicker();						$('#divEditEvents').fadeIn('fast',					function(){						$('#divEditEvents').css({'height': 'auto'});					}			);		});	}		if(action == "del"){		var msg = "Wollen Sie den Eintrag wirklich löschen?";				if(window.confirm(msg)){			$.get('php/ajax/modules/events/mod.events.delete.php?id=' + which, function(){				initEditEvents(eventsEditDiv);				window.alert("Eintrag wurde gelöscht");			});		}	}}function cancelEditEvents(){	$.get('php/ajax/modules/events/mod.events.output.php?writeHtml=true&editDiv='  + mainMenuDiv + '_events_' + eventsEditDiv, function(data){		$('#' + eventsEditDiv).load('templates/template_' + mainMenuDiv + '_events_' + eventsEditDiv + ".html");		showEditButton = true;	});}function closeEditEvents(){	$('#divEditEvents').fadeOut();}function saveEvents(){	var serial = $('#frmEventsEdit').serialize();		$.post('php/ajax/modules/events/mod.events.save.php', serial, function(){		closeEditEvents();		$('#eventsListe').load('php/ajax/modules/events/mod.events.php');		window.alert("Eintrag gespeichert");	});}function kfm_for_tiny_mce(field_name, url, type, win){  window.SetUrl=function(url,width,height,caption){   win.document.forms[0].elements[field_name].value = url;   if(caption){    win.document.forms[0].elements["alt"].value=caption;    win.document.forms[0].elements["title"].value=caption;   }  }  window.open('../../../KFM_ee_EXT/kfm/index.php?lang={sprache}&mode=selector&type='+type,'kfm','modal,width=800,height=600');}function initSmallEdit(height){	var actLang = "d";		// Hide edit-button		$('textarea.tinymce').tinymce({		// Location of TinyMCE script		language: "de",		script_url : 'js/tiny_mce/tiny_mce.js',		height: height + 150,		// General options		theme : "advanced",		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",		// Theme options		theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,sub,sup,|,pastetext,pasteword",		theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,table, row_props, cell_props, delete_col, delete_row, delete_table, col_after, col_before, row_after, row_before, split_cells, merge_cells",		theme_advanced_buttons3 : "undo,redo,|,link,unlink,anchor,image,cleanup,|,forecolor,backcolor,styleselect,|,code,fullscreen",		theme_advanced_text_colors : "eba3a5,afafaf,000000",		/*theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",        */		theme_advanced_toolbar_location : "top",		theme_advanced_toolbar_align : "left",		//theme_advanced_statusbar_location : "bottom",		theme_advanced_resizing : true,		file_browser_callback : kfm_for_tiny_mce,		content_css: "/css/styles_custom.css"	});}
