/*****************************************************************************
 * Copyright (C) 2019
 *   
 * Michiel Broek <mbroek at mbse dot eu>
 *
 * This file is part of ThermFerm
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * ThermFerm is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with ThermFerm; see the file COPYING.  If not, write to the Free
 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *****************************************************************************/

var phi = 0, flipped = 0, mirrored = 0;

function setXformClass () {
	$('.xform').each(function(idx,el) {
		el.className = "xform x" +(flipped ? "-flipped":"") + (mirrored ? "-mirrored" : "") + "-rotated-" + phi;
	});
}



$(document).ready(function () {

	// set rotation angle phi and toggle rotate class
	$("#rotate").jqxButton({ template: "info", width: 50, height: 50, theme: theme, imgWidth: 32, imgHeight: 32, imgSrc:"images/object-rotate-right.png" });
	$('#rotate').click(function() {
		phi = (phi + 90) % 360;
		setXformClass();
		if (phi % 180) {
			$('.xform-p').addClass('rotated');
		} else {
			$('.xform-p').removeClass('rotated');
		}
	});
	// toggle mirror class component
	$("#mirror").jqxButton({ template: "info", width: 50, height: 50, theme: theme, imgWidth: 32, imgHeight: 32, imgSrc:"images/object-flip-horizontal.png" });
	$('#mirror').click(function() {
		mirrored = ! mirrored;
		setXformClass();
	});
	// toggle flip class componen
	$("#flip").jqxButton({ template: "info", width: 50, height: 50, theme: theme, imgWidth: 32, imgHeight: 32, imgSrc:"images/object-flip-vertical.png" });
	$('#flip').click(function() {
		flipped = ! flipped;
		setXformClass();
	});

	$("#Close").jqxButton({ template: "success", width: 125, theme: theme });
	$("#Close").click(function () {
		window.close();
	});

});
