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/SBogers45/smuldersinterieurprojecten.nl/wwwroot/admin/js/main.js
// JavaScript Document

var hoverBool = false;
var divOut = Array();
var thumbOut = Array();

var newDiv;

var me; //mouse event

$(document).ready(function(){
	checkSubheight(0);
	setTimeout(function(){
		checkSubheight(1);
	 },500);
	 
	 //get browser	
	var browser = getBrowser();
	
	//get mouse choords
	if(browser[0] == 'gek'){
		 $(document).mousemove(function(e) {
			 me = e;
		 });
	}
});

function checkSubheight(bool){
	//sub
	var $sub = $('#sub-nav');
	var $lib = $('#small-lib-con');
	var $con = $('#triple-column-container');
	
	var h = $('#triple-column-container').css('height');
	var subH = $sub.css('height').substring(0, $sub.css('height').lenght - 2); 
	
	if(Number(subH) < 450){
		bool == 1 ? $sub.animate({height: h},100) : $sub.css('height', h);
		if($lib){
			bool == 1 ? $lib.animate({height: h},100) : $lib.css('height', h);
		}
	}
}

function slideObj(id, dir, target){
	$('#' + id).animate( {top:  + target + 'px'} ,300);
}

function empty(input){
	var e = false;
	if(input == null || input == 'undefined' || input == 'nann' || input == ''){
		e = true;
	}
	return e;
}

function pageControl(sessionName, nr){
	$('#jsbox').load('./php/fromjs/pageControl.php?sessionName=' + sessionName + '&nr=' + nr , function() {
		window.location.reload()
	});
}

function updateSession(session, value){
	$('#jsbox').load('./php/fromjs/updateSession.php?sessionName=' + session + '&value=' + value,function() {
		window.location.reload()
	});
}

function checkSmallLib(value,page){
	switch(value){
		case 'media' :	$('#small-lib-con').load('./php/smallMedia.php?page='+page);
		break;
		case 'documents' :  $('#small-lib-con').load('./php/smallDocs.php?page='+page);
		break;
		default :  $('#small-lib-con').load('./php/smallMedia.php?page='+page);
	}
}

//update session within a div
function updateSessionInner(target, page, session, value){
	$('#jsbox').load('./php/fromjs/updateSession.php?sessionName=' + session + '&value=' + value,function() {
		$('#'+target).load(page);
	});
}

function mediaOver(id,innerStr, type){
	if (typeof type == "undefined") {
		type = "";
	}
	
	
	thumbOut[id] = false;
	//the div hovered
	var divid = 'med-img-' +id;

	//get x and y position from the thumb div related to the body (to position the hover div)
	var x=0, y=0;
	var obj = (typeof divid == "string") ? document.getElementById(divid) : divid;
	if (obj) {
		x = obj.offsetLeft;
		y = obj.offsetTop;
		var body = document.getElementsByTagName('body')[0];
		while (obj.offsetParent && obj!=body){
			x += obj.offsetParent.offsetLeft;
			y += obj.offsetParent.offsetTop;
			obj = obj.offsetParent;
		}
	}
	
	//reset obj and get its width and height
	var obj = document.getElementById(divid)
	var width = obj.width;
	var height = obj.height;
	
	
	//get browser	
	var browser = getBrowser();
	
	//get mouse choords
	if(browser[0] != 'gek'){
		var mouseOffsetX = event.clientX + document.body.scrollLeft;
		var mouseOffsetY = event.clientY + document.body.scrollTop;
	}
	else{
		var mouseOffsetX = me.clientX + document.body.scrollLeft;
		var mouseOffsetY = me.clientY + document.body.scrollTop;	
	}
	
	
	//so you don't make a new screen every time	
	if(hoverBool == false){		
		hoverBool = true;
		newDiv = document.createElement('div');
		newDiv.setAttribute('id','hover'+divid);
		document.body.appendChild(newDiv);
		
			newDiv.innerHTML = innerStr;
			
			if(type == "small"){
				$('#hover'+divid).addClass('small-lib-hover'); 
			}
			else{
				$('#hover'+divid).addClass('med-hover'); 
			}
			
			
			newDiv.onmouseout = function(){ hoverDivMouseOut(id); } 
	}
	if(type == "small"){
		$('#hover'+divid).css('left', Number(x - 120) + 'px'); 
		$('#hover'+divid).css('top', Number(y - 120) + 'px'); 
	}
	else{
		$('#hover'+divid).css('left', Number(x + 30) + 'px'); 
		$('#hover'+divid).css('top', Number(y + 90) + 'px'); 
	}
}


function hoverDivMouseOut(id){
	//vars
	var current_mouse_target = null;
	var element = document.getElementById('hovermed-img-'+id); 
	var thumbElement = document.getElementById('med-img-'+id); 
	var browser = getBrowser();
	//set current target
	if(browser[0] == 'gek'){
		if( me.toElement ) {				
			current_mouse_target 			 = me.toElement;
		} else if( me.relatedTarget ) {				
			current_mouse_target 			 = me.relatedTarget;
		}
	}
	else{
		if( event.toElement ) {				
			current_mouse_target 			 = event.toElement;
		} else if( event.relatedTarget ) {				
			current_mouse_target 			 = event.relatedTarget;
		}
	}
	
	//check if target != thumbdiv or child or self
	if( !is_child_of(element, current_mouse_target) && element != current_mouse_target && element != thumbElement) {
		mediaOut('hovermed-img-'+id,id);
	}
}

function thumbDivMouseOut(id){
	//vars 
	var current_mouse_target = null;
	var element = document.getElementById('hovermed-img-'+id); 
	var browser = getBrowser();
	//set current target
	if(browser[0] == 'gek'){
		if( me.toElement ) {				
			current_mouse_target 			 = me.toElement;
		} else if( me.relatedTarget ) {				
			current_mouse_target 			 = me.relatedTarget;
		}
	}
	else{
		if( event.toElement ) {				
			current_mouse_target 			 = event.toElement;
		} else if( event.relatedTarget ) {				
			current_mouse_target 			 = event.relatedTarget;
		}
	}
	
	//check if target != hoverdiv
	if( element != current_mouse_target && browser[0] != 'gek'){	
		mediaOut('hovermed-img-'+id,id);
	}

}

function mediaOut(div,id){
	var element = document.getElementById(div);
	document.body.removeChild(element);	
	hoverBool = false;
}


function is_child_of(parent, child) {
	if( child != null ) {			
		while( child.parentNode ) {
			if( (child = child.parentNode) == parent ) {
				return true;
			}
		}
	}
	return false;
}

function updateView(page, view){
	$('#jsbox').load('./php/fromjs/updateView.php?page=' + page + '&view=' + view,function() {
		window.location.reload()
	});	
}

function initSortableList(){
	/* grab important elements */
	  var sortInput = jQuery('#sort_order');
	  var submit = jQuery('#autoSubmit');
	 // var messageBox = jQuery('#message-box');
	  var list = jQuery('#sortable-list');
	  /* create requesting function to avoid duplicate code */
	  var request = function() {
		jQuery.ajax({
		  beforeSend: function() {
			messageBox.text('Updating the sort order in the database.');
		  },
		  complete: function() {
			messageBox.text('Database has been updated.');
		  },
		  data: 'sort_order=' + sortInput[0].value + '&ajax=' + submit.checked + '&do_submit=1&byajax=1', //need [0]?
		  type: 'post',
		  url: '$_SERVER["REQUEST_URI"];'
		});
	  };
	  
	  /* worker function */
	  var fnSubmit = function(save) {
		var sortOrder = [];
		list.children('li').each(function(){
		  sortOrder.push(jQuery(this).data('id'));
		});
		sortOrder.reverse();
		sortInput.val(sortOrder.join(','));
		console.log(sortInput.val());
		if(save) {
		 // request();
			window.location.reload();
		}
	  };
	  
	  /* store values */
	  list.children('li').each(function() {
		var li = jQuery(this);
		li.data('id',li.attr('title')).attr('title','');
	  });
	  
	  /* sortables */
	  list.sortable({
		opacity: 0.7,
		update: function() {
		  fnSubmit(submit.checked);
		}
	  });
	  list.disableSelection();
	  /*
	  /* ajax form submission 
	 jQuery('#dd-form').bind('submit',function(e) {
		if(e) e.preventDefault();
		fnSubmit(true);
	  });*/
}