﻿/*****************************************************// JS-Routinen für News-Modul******************************************************//******************************************************** * Date-Picker initialisieren ********************************************************/var newsEditDiv;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 newsSortable;var newsSortableInit = function() {	newsSortable = $('#newsListe').sortable( {		items: '.sortable',		//placeholder: 'sorthelper',		axis: 'y',		distance: 2,		update: newsReorder	} );}// When an update has occurred, adjust the order for each itemvar newsReorder = function(e, sort) {		var arr = $('#newsListe').sortable('serialize');	//console.log(arr);	$.post('php/ajax/modules/news/mod.news.sort.php', arr, function(data){			});}function initEditNews(whichDiv){		newsEditDiv = whichDiv;		$.get('php/ajax/modules/news/mod.news.php', function(data){		$('#' + whichDiv).html('<div id="newsListe">' + data + '</div>');		showEditButton = false;				// initialize sortable		newsSortableInit();			});}function editNews(which, action){		if(action == "edit"){				$('body').append('<div id="divEditNews" style="display: none"></div>');				$('#divEditNews').load('php/ajax/modules/news/mod.news.edit.php?id=' + which, function(data){			centerDiv('divEditNews');			initSmallEdit($('#divEditNews beschreibung').height());			makeDatepicker();			$('#divEditNews').fadeIn();		});	}		if(action == "del"){		var msg = "Wollen Sie den Eintrag wirklich löschen?";				if(window.confirm(msg)){			$.get('php/ajax/modules/news/mod.news.delete.php?id=' + which, function(){				initEditNews(newsEditDiv);				window.alert("Eintrag wurde gelöscht");			});		}	}}function cancelEditNews(){	$.get('php/ajax/modules/news/mod.news.output.php?writeHtml=true&editDiv=' + newsEditDiv, function(data){		$('#' + newsEditDiv).load('templates/template_news_' + newsEditDiv + ".html");		showEditButton = true;	});}function closeEditNews(){	$('#divEditNews').fadeOut();}function saveNews(){	var serial = $('#frmNewsEdit').serialize();		$.post('php/ajax/modules/news/mod.news.save.php', serial, function(){		closeEditNews();		$('#newsListe').load('php/ajax/modules/news/mod.news.php');		window.alert("Eintrag gespeichert");	});}function initSmallEdit(height){	var actLang = "d";		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');	}		// Hide edit-button		$('textarea.tinymce').tinymce({		// Location of TinyMCE script		language: "de",		script_url : 'js/tiny_mce/tiny_mce.js',		height: height + 67,		// 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",				});}
