PageSourceSearch

https://www.meyer-transporte-gmbh.de/modules/wsGadgets/gadgets/megaMenu/assets/js/device.js

js meyer-transporte-gmbh.de collected 2026-10-07 04:37:19 UTC 6,605 bytes, 294 lines download raw bytes

1// Device.js
2// (c) 2014 Matthew Hudson
3// Device.js is freely distributable under the MIT license.
4// For all details and documentation:
5// http://matthewhudson.me/projects/device.js/
6
7(function() {
8
9	var device,
10		previousDevice,
11		addClass,
12		documentElement,
13		find,
14		handleOrientation,
15		hasClass,
16		orientationEvent,
17		removeClass,
18		userAgent;
19
20	// Save the previous value of the device variable.
21	previousDevice = window.device;
22
23	device = {};
24
25	// Add device as a global object.
26	window.device = device;
27
28	// The <html> element.
29	documentElement = window.document.documentElement;
30
31	// The client user agent string.
32	// Lowercase, so we can use the more efficient indexOf(), instead of Regex
33	userAgent = window.navigator.userAgent.toLowerCase();
34
35	// Main functions
36	// --------------
37
38	device.ios = function () {
39		return device.iphone() || device.ipod() || device.ipad();
40	};
41
42	device.iphone = function () {
43		return !device.windows() && find('iphone');
44	};
45
46	device.ipod = function () {
47		return find('ipod');
48	};
49
50	device.ipad = function () {
51		return find('ipad');
52	};
53
54	device.android = function () {
55		return !device.windows() && find('android');
56	};
57
58	device.androidPhone = function () {
59		return device.android() && find('mobile');
60	};
61
62	device.androidTablet = function () {
63		return device.android() && !find('mobile');
64	};
65
66	device.blackberry = function () {
67		return find('blackberry') || find('bb10') || find('rim');
68	};
69
70	device.blackberryPhone = function () {
71		return device.blackberry() && !find('tablet');
72	};
73
74	device.blackberryTablet = function () {
75		return device.blackberry() && find('tablet');
76	};
77
78	device.windows = function () {
79		return find('windows');
80	};
81
82	device.windowsPhone = function () {
83		return device.windows() && find('phone');
84	};
85
86	device.windowsTablet = function () {
87		return device.windows() && (find('touch') && !device.windowsPhone());
88	};
89
90	device.fxos = function () {
91		return (find('(mobile;') || find('(tablet;')) && find('; rv:');
92	};
93
94	device.fxosPhone = function () {
95		return device.fxos() && find('mobile');
96	};
97
98	device.fxosTablet = function () {
99		return device.fxos() && find('tablet');
100	};
101
102	device.meego = function () {
103		return find('meego');
104	};
105
106	device.cordova = function () {
107		return window.cordova && location.protocol === 'file:';
108	};
109
110	device.nodeWebkit = function () {
111		return typeof window.process === 'object';
112	};
113
114	device.mobile = function () {
115		return device.androidPhone() || device.iphone() || device.ipod() || device.windowsPhone() || device.blackberryPhone() || device.fxosPhone() || device.meego();
116	};
117
118	device.tablet = function () {
119		return device.ipad() || device.androidTablet() || device.blackberryTablet() || device.windowsTablet() || device.fxosTablet();
120	};
121
122	device.desktop = function () {
123		return !device.tablet() && !device.mobile();
124	};
125
126	device.television = function() {
127		var i, television = [
128			"googletv",
129			"viera",
130			"smarttv",
131			"internet.tv",
132			"netcast",
133			"nettv",
134			"appletv",
135			"boxee",
136			"kylo",
137			"roku",
138			"dlnadoc",
139			"roku",
140			"pov_tv",
141			"hbbtv",
142			"ce-html"
143		];
144
145		i = 0;
146		while (i < television.length) {
147			if (find(television[i])) {
148				return true;
149			}
150			i++;
151		}
152		return false;
153	};
154
155	device.portrait = function () {
156		return (window.innerHeight / window.innerWidth) > 1;
157	};
158
159	device.landscape = function () {
160		return (window.innerHeight / window.innerWidth) < 1;
161	};
162
163	// Public Utility Functions
164	// ------------------------
165
166	// Run device.js in noConflict mode,
167	// returning the device variable to its previous owner.
168	device.noConflict = function () {
169		window.device = previousDevice;
170		return this;
171	};
172
173	// Private Utility Functions
174	// -------------------------
175
176	// Simple UA string search
177	find = function (needle) {
178		return userAgent.indexOf(needle) !== -1;
179	};
180
181	// Check if documentElement already has a given class.
182	hasClass = function (className) {
183		var regex;
184		regex = new RegExp(className, 'i');
185		return documentElement.className.match(regex);
186	};
187
188	// Add one or more CSS classes to the <html> element.
189	addClass = function (className) {
190
191	};
192
193	// Remove single CSS class from the <html> element.
194	removeClass = function (className) {
195
196	};
197
198	// HTML Element Handling
199	// ---------------------
200
201	// Insert the appropriate CSS class based on the _user_agent.
202
203	if (device.ios()) {
204		if (device.ipad()) {
205			addClass("ios ipad tablet");
206		} else if (device.iphone()) {
207			addClass("ios iphone mobile");
208		} else if (device.ipod()) {
209			addClass("ios ipod mobile");
210		}
211	} else if (device.android()) {
212		if (device.androidTablet()) {
213			addClass("android tablet");
214		} else {
215			addClass("android mobile");
216		}
217	} else if (device.blackberry()) {
218		if (device.blackberryTablet()) {
219			addClass("blackberry tablet");
220		} else {
221			addClass("blackberry mobile");
222		}
223	} else if (device.windows()) {
224		if (device.windowsTablet()) {
225			addClass("windows tablet");
226		} else if (device.windowsPhone()) {
227			addClass("windows mobile");
228		} else {
229			addClass("desktop");
230		}
231	} else if (device.fxos()) {
232		if (device.fxosTablet()) {
233			addClass("fxos tablet");
234		} else {
235			addClass("fxos mobile");
236		}
237	} else if (device.meego()) {
238		addClass("meego mobile");
239	}
239 else if (device.nodeWebkit()) {
240		addClass("node-webkit");
241	} else if (device.television()) {
242		addClass("television");
243	} else if (device.desktop()) {
244		addClass("desktop");
245	}
246
247	if (device.cordova()) {
248		addClass("cordova");
249	}
250
251	// Orientation Handling
252	// --------------------
253
254	// Handle device orientation changes.
255	handleOrientation = function () {
256		if (device.landscape()) {
257			removeClass("portrait");
258			addClass("landscape");
259		} else {
260			removeClass("landscape");
261			addClass("portrait");
262		}
263	};
264
265	// Detect whether device supports orientationchange event,
266	// otherwise fall back to the resize event.
267	if (Object.prototype.hasOwnProperty.call(window, "onorientationchange")) {
268		orientationEvent = "orientationchange";
269	} else {
270		orientationEvent = "resize";
271	}
272
273	// Listen for changes in orientation.
274	if (window.addEventListener) {
275		window.addEventListener(orientationEvent, handleOrientation, false);
276	} else if (window.attachEvent) {
277		window.attachEvent(orientationEvent, handleOrientation);
278	} else {
279		window[orientationEvent] = handleOrientation;
280	}
281
282	handleOrientation();
283
284	if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
285		define(function() {
286			return device;
287		});
288	} else if (typeof module !== 'undefined' && module.exports) {
289		module.exports = device;
290	} else {
291		window.device = device;
292	}
293
294}).call(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.