1 /**
2 * Gumby Init
3 */
4 
5 !function($) {
6 
7 	'use strict';
8 
9 	// not touch device or no touch events required so auto initialize here
10 	if((!Gumby.touchDevice || !Gumby.touchEvents) && Gumby.autoInit) {
11 		window.Gumby.init();
12 
13 	// load jQuery mobile touch events
14 	} else if(Gumby.touchEvents && Gumby.touchDevice) {
15 		Gumby.debug('Loading jQuery mobile touch events');
16 		// set timeout to 2sec
17 		yepnope.errorTimeout = 2000;
18 		Modernizr.load({
19 			test: Modernizr.touch,
20 			yep: Gumby.touchEvents+'/jquery.mobile.custom.min.js',
21 			complete: function() {
22 				// error loading jQuery mobile
23 				if(!$.mobile) {
24 					Gumby.error('Error loading jQuery mobile touch events');
25 				}
26 
27 				// if not auto initializing
28 				// this will allow helpers to fire when initialized
29 				Gumby.touchEventsLoaded = true;
30 
31 				// auto initialize
32 				if(Gumby.autoInit) {
33 					window.Gumby.init();
34 
35 				// if already manually initialized then fire helpers
36 				} else if(Gumby.uiModulesReady) {
37 					Gumby.helpers();
38 				}
39 			}
40 		});
41 	}
42 
43 	// if AMD return Gumby object to define
44 	if(typeof define == "function" && define.amd) {
45 		define(window.Gumby);
46 	}
47 }(jQuery);
48