commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / packages / kcfinder / js / 029.jquery.agent.js
1 /** This file is part of KCFinder project
2 *
3 * @desc User Agent jQuery Plugin
4 * @package KCFinder
5 * @version 3.12
6 * @author Pavel Tzonkov <sunhater@sunhater.com>
7 * @copyright 2010-2014 KCFinder Project
8 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
9 * @license http://opensource.org/licenses/LGPL-3.0 LGPLv3
10 * @link http://kcfinder.sunhater.com
11 */
12
13 (function($) {
14 $.agent = {};
15
16 var agent = " " + navigator.userAgent,
17
18 patterns = [
19 {
20 expr: / [a-z]+\/[0-9a-z\.]+/ig,
21 delim: "/"
22 }, {
23 expr: / [a-z]+:[0-9a-z\.]+/ig,
24 delim: ":",
25 keys: ["rv", "version"]
26 }, {
27 expr: / [a-z]+\s+[0-9a-z\.]+/ig,
28 delim: /\s+/,
29 keys: ["opera", "msie", "firefox", "android"]
30 }, {
31 expr: /[ \/\(]([a-z0-9_]+)[ ;\)\/]/ig,
32 keys: "i386|i486|i586|i686|x86|x64|x86_64|intel|ppc|powerpc|windows|macintosh|darwin|unix|linux|sunos|android|iphone|ipad|ipod|amiga|amigaos|beos|wii|playstation|gentoo|fedora|slackware|ubuntu|archlinux|debian|mint|mageia|mandriva|freebsd|openbsd|netbsd|solaris|opensolaris|x11|mobile|phone".split('|'),
33 sub: "platform"
34 }
35 ];
36
37 $.each(patterns, function(i, pattern) {
38 var elements = agent.match(pattern.expr);
39 if (elements === null)
40 return;
41 $.each(elements, function(j, ag) {
42 ag = ag.replace(/^\s+/, "").toLowerCase();
43 var key = ag.replace(pattern.expr, "$1"),
44 val = true;
45 if (typeof pattern.delim != "undefined") {
46 ag = ag.split(pattern.delim);
47 key = ag[0];
48 val = ag[1];
49 }
50
51 if (typeof pattern.keys != "undefined") {
52 var exists = false, k = 0;
53 for (; k < pattern.keys.length; k++)
54 if (pattern.keys[k] == key) {
55 exists = true;
56 break;
57 }
58 if (!exists)
59 return;
60 }
61
62 if (typeof pattern.sub != "undefined") {
63 if (typeof $.agent[pattern.sub] != "object")
64 $.agent[pattern.sub] = {};
65 if (typeof $.agent[pattern.sub][key] == "undefined")
66 $.agent[pattern.sub][key] = val;
67
68 } else if (typeof $.agent[key] == "undefined")
69 $.agent[key] = val;
70 });
71 });
72
73 if (!$.agent.platform)
74 $.agent.platform = {};
75
76 // Check for mobile device
77 $.mobile = false;
78 var keys = "mobile|android|iphone|ipad|ipod|iemobile|phone".split('|');
79 a = $.agent;
80
81 $.each([a, a.platform], function(i, p) {
82 for (var j = 0; j < keys.length; j++) {
83 if (p[keys[j]]) {
84 $.mobile = true;
85 return false;
86 }
87 }
88 });
89 })(jQuery);