EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
mstsc.js
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Sylvain Peyrefitte
3 *
4 * This file is part of mstsc.js.
5 *
6 * mstsc.j is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20(function() {
21
22 /**
23 * Use for domain declaration
24 */
25 Mstsc = function () {
26 }
27
28 Mstsc.prototype = {
29 // shortcut
30 $ : function (id) {
31 return document.getElementById(id);
32 },
33
34 /**
35 * Compute screen offset for a target element
36 * @param el {DOM element}
37 * @return {top : {integer}, left {integer}}
38 */
39 elementOffset : function (el) {
40 var x = 0;
41 var y = 0;
42 while (el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop )) {
43 x += el.offsetLeft - el.scrollLeft;
44 y += el.offsetTop - el.scrollTop;
45 el = el.offsetParent;
46 }
47 return { top: y, left: x };
48 },
49
50 /**
51 * Try to detect browser
52 * @returns {String} [firefox|chrome|ie]
53 */
54 browser : function () {
55 if (typeof InstallTrigger !== 'undefined') {
56 return 'firefox';
57 }
58
59 if (!!window.chrome) {
60 return 'chrome';
61 }
62
63 if (!!document.docuemntMode) {
64 return 'ie';
65 }
66
67 return null;
68 },
69
70 /**
71 * Try to detect language
72 * @returns
73 */
74 locale : function () {
75 return window.navigator.userLanguage || window.navigator.language;
76 }
77 }
78
79})();
80
81this.Mstsc = new Mstsc();