HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/komma-mediadesign.nl/wwwroot/beheer/js/main.js
/*

	Javascript document // main.js
	
	Handles all javascript regarding MO-Beheer v3

*/

$(document).ready(function()
{
	
	//handle animation classes
	handleDisappear();
	handleSelectedListitem();
	
	//setup Tiny MCE
	initTinymce();
	
	//uploader
	initUploader();
	
	//datepicker
	$( "#datepicker" ).datepicker();
	
	//
	resizeMenu();
	$(window).resize(resizeMenu);
})

/**
* Handles animation for all objects with a class js-disapear
*
* @return null
*/
function handleDisappear()
{
	var time = 4000;
	var delay = 0;
	$('.js-disappear').each(function()
	{
		var _this = $(this);
		$(_this).animate({ opacity: 1 },200);
		setTimeout(function()
		{
			$(_this).animate({ opacity: 0 },400,function()
			{
				$(this).remove();
			});
		
		},time+delay);
		delay += 100;
	});
}

/**
* Handles actions regarding selecting a list-item in a selectable list
*
* @return null
*/
function handleSelectedListitem()
{
	$('ul.selectable').each(function()
	{
		$(this).children('li').children('.title').click(function()
		{
			if($(this).parent().hasClass('heading')){ /* do nothing */ }
			else
			{
				if($(this).parent().children('.cb').children('input').attr('checked'))
				{
					$(this).parent().children('.cb').children('input').attr("checked", ""); 
					$(this).parent().children('.cb').children('input').removeAttr('checked');
					$(this).parent().children('.cb').children('input').checked = false;
					$(this).parent().removeClass('sel');
				}
				else
				{
					$(this).parent().children('.cb').children('input').attr("checked", "checked");
					$(this).parent().children('.cb').children('input').checked = true;
					$(this).parent().addClass('sel');
				}			
			}		
		});
	});
	
	$('ul.selectable input[type="checkbox"]').change(function()
	{
		if($(this).parent().parent().hasClass('heading')){ /* do nothing */ }
		else
		{
			if($(this).attr('checked'))
			{
				$(this).parent().parent().addClass('sel');
			}
			else
			{
				$(this).parent().parent().removeClass('sel');
			}
		}
	});
	
	$('#check_all').click(function(){
	  	if ($('#check_all').attr("checked") )
		{
			$('ul.selectable input[type="checkbox"]').attr("checked", "checked");
			$('ul.selectable input[type="checkbox"]').checked = true;
			$('ul.selectable li:not(.heading)').addClass('sel');
		}
		else
		{
			$('ul.selectable input[type="checkbox"]').attr("checked", "");
			$('ul.selectable input[type="checkbox"]').removeAttr('checked');
			$('ul.selectable input[type="checkbox"]').checked = false;
			$('ul.selectable li:not(.heading)').removeClass('sel');
		}
	});
}

/**
* Setup for textareas with the tiny mce class
*
* @return null
*/
function initTinymce(){
	$('textarea.tinymce').tinymce({
		// General options
		mode : 	"textareas",
		theme : "motheme",
		skin : 	"mikeontwerpt",
		height : "184",
		plugins : "inlinepopups,tabfocus,paste", 
		//init_instance_callback: myCustomInitInstance, 
		
		// Theme options
		theme_motheme_buttons1 : "bold,italic,underline,|,bullist,numlist,|,link,unlink",
		theme_motheme_buttons2 : "",
		theme_motheme_buttons3 : "",
		theme_motheme_buttons4 : "",
		theme_motheme_toolbar_location : "top",
		theme_motheme_toolbar_align : "left",
		theme_motheme_statusbar_location : "bottom",
		theme_motheme_resizing : false,
	
		// Replace values for the template plugin
		/*
		template_replace_values : {
			username : "Mike Ontwerpt",
			staffid : "991234"
		}
		*/
	});	
}

/**
* Make sure we only have to click the upload button to upload files
*
* @return null
*/
function initUploader()
{
	// filemanager
 	$('#upload_file').click(function()
 	{
   		document.getElementById('my_file').click();
   	});
    $("#my_file").live('change', function()
    {
    	$('#mp_info').submit();
    	$('#loader').css({ display: 'block' });
	});
}

/**
*
* Resizes the left menu
*
*/
function resizeMenu()
{
	var currentH = $('header').height() + $('aside').height() + $('footer').height();
	var bodyH = $(window).height();
	if(currentH < bodyH)
	{
		var asideH = bodyH - $('header').height() - $('footer').height();
		$('aside').css({ height: asideH+'px' });
	}	

}