ie.js
64 lines
| 2.1 KiB
| application/javascript
|
JavascriptLexer
r2487 | // # Copyright (C) 2010-2018 RhodeCode GmbH | ||
r1 | // # | ||
// # This program is free software: you can redistribute it and/or modify | |||
// # it under the terms of the GNU Affero General Public License, version 3 | |||
// # (only), as published by the Free Software Foundation. | |||
// # | |||
// # This program is distributed in the hope that it will be useful, | |||
// # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
// # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
// # GNU General Public License for more details. | |||
// # | |||
// # You should have received a copy of the GNU Affero General Public License | |||
// # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
// # | |||
// # This program is dual-licensed. If you wish to learn more about the | |||
// # RhodeCode Enterprise Edition, including its added features, Support services, | |||
// # and proprietary license terms, please see https://rhodecode.com/licenses/ | |||
/** | |||
* detect IE | |||
* returns version of IE or false, if browser is not Internet Explorer | |||
*/ | |||
function detectIE() { | |||
var ua = window.navigator.userAgent; | |||
var msie = ua.indexOf('MSIE '); | |||
if (msie > 0) { | |||
// IE 10 or older => return version number | |||
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); | |||
} | |||
var trident = ua.indexOf('Trident/'); | |||
if (trident > 0) { | |||
// IE 11 => return version number | |||
var rv = ua.indexOf('rv:'); | |||
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); | |||
} | |||
var edge = ua.indexOf('Edge/'); | |||
if (edge > 0) { | |||
// IE 12 => return version number | |||
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); | |||
} | |||
// other browser | |||
return false; | |||
} | |||
// TODO: no usages found. Maybe it's time to remove it | |||
// IE doesn't support previousElementSibling | |||
var prevElementSibling = function( el ) { | |||
if( el.previousElementSibling ) { | |||
return el.previousElementSibling; | |||
} else { | |||
while( el === el.previousSibling ) { | |||
if( el.nodeType === 1 ) return el; | |||
} | |||
} | |||
}; | |||
// TODO: no usages found. Maybe it's time to remove it | |||
var firstElementChild = function(el) { | |||
return (el.firstElementChild||el.firstChild); | |||
}; |