/**
 * clearFusionCMS script to trigger form save on ctl+s or cmd+s.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS
 * @copyright Copyright (c) 2015 - 2016 clearFusionCMS. All rights reserved.
 * @link http://clearFusionCMS.com
 */

$fl(document).ready(function() {
	$fl(document).bind('keydown', function(event) {
		if(!(String.fromCharCode(event.which).toLowerCase() == 's' && (event.ctrlKey || event.metaKey)) && !(event.which == 19)) return true;

		var f = $fl('form.metaSSubmit');
		if(f.length) {
			document.activeElement.blur();
			$fl(window).unbind('beforeunload');
			f.submit();
			event.preventDefault();
			return false;
		}
	});
});
