globals.js

/**
 * General customization alongside the framework
 *
 * @author Deux Huit Huit <https://deuxhuithuit.com>
 * @license MIT <https://deuxhuithuit.mit-license.org>
 *
 * @requires jQuery
 * @requires App
 */
(function ($, global, undefined) {
	'use strict';

	if (!!global.App && !!global.App.device) {
		(function (h, deviceClasses) {
			deviceClasses.forEach(function (c) {
				if (!!App.device[c]) {
					h.addClass(c);
				}
			});
		})($('html'), [
			'iphone', 'ipad', 'ios',
			'android',
			'mobile', 'phone', 'tablet', 'touch',
			'chrome', 'firefox', 'safari', 'internetexplorer', 'edge'
		]);

		// easing support
		$.easing.def = (App.device.mobile ? 'linear' : 'easeOutQuad');
	}

	/**
	 * Patching console object.
	 * @see https://developers.google.com/chrome-developer-tools/docs/console-api
	 */
	var consoleFx = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'group',
		'group', 'group', 'info', 'log', 'profile', 'profile', 'time', 'time', 'time',
		'trace', 'warn'];

	/**
	 * Console support
	 * @global
	 */
	if (!global.console) {
		global.console = {};
	}

	consoleFx.forEach(function (key) {
		global.console[key] = global.console[key] || $.noop;
	});

	/**
	 * Facade to stop the propagation of events
	 * @name pd
	 * @method
	 * @param {Event} e Event object
	 * @param {Boolean} stopPropagation Flag to stop the event propagation or not
	 * @returns {Boolean} false, always.
	 * @global
	 * @public
	 */
	global.pd = function (e, stopPropagation) {
		if (!!e) {
			if ($.isFunction(e.preventDefault)) {
				e.preventDefault();
			}
			if (stopPropagation !== false && $.isFunction(e.stopPropagation)) {
				e.stopPropagation();
			}
		}
		return false;
	};
	
})(jQuery, window);