PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/ajax/libs/outdated-browser/1.0.1/outdatedBrowser.js

https://gitlab.com/Blueprint-Marketing/cdnjs
JavaScript | 138 lines | 101 code | 20 blank | 17 comment | 36 complexity | ca6c010dc13372eb0943891a13a84c5c MD5 | raw file
  1. /*!--------------------------------------------------------------------
  2. JAVASCRIPT "Outdated Browser"
  3. Version: 1.0.1 - 2014
  4. author: Burocratik
  5. website: http://www.burocratik.com
  6. * @preserve
  7. -----------------------------------------------------------------------*/
  8. var outdatedBrowser = function(options) {
  9. //Variable definition
  10. var outdated = document.getElementById("outdated");
  11. var btnClose = document.getElementById("btnCloseUpdateBrowser");
  12. var btnUpdate = document.getElementById("btnUpdateBrowser");
  13. // Default settings
  14. this.defaultOpts = {
  15. bgColor: '#F25648',
  16. color: '#ffffff',
  17. lowerThan: 'transform'
  18. }
  19. if (options) {
  20. this.defaultOpts.bgColor = options.bgColor,
  21. this.defaultOpts.color = options.color;
  22. //assign css3 property to IE browser version
  23. if(options.lowerThan == 'IE8' || options.lowerThan == 'borderSpacing') {
  24. options.lowerThan = 'borderSpacing';
  25. } else if (options.lowerThan == 'IE9' || options.lowerThan == 'boxShadow') {
  26. options.lowerThan = 'boxShadow';
  27. } else if (options.lowerThan == 'IE10' || options.lowerThan == 'transform' || options.lowerThan == '' || typeof options.lowerThan === "undefined") {
  28. options.lowerThan = 'transform';
  29. } else if (options.lowerThan == 'IE11' || options.lowerThan == 'borderImage') {
  30. options.lowerThan = 'borderImage';
  31. }
  32. this.defaultOpts.lowerThan = options.lowerThan;
  33. bkgColor = this.defaultOpts.bgColor;
  34. txtColor = this.defaultOpts.color;
  35. cssProp = this.defaultOpts.lowerThan;
  36. } else {
  37. bkgColor = this.defaultOpts.bgColor;
  38. txtColor = this.defaultOpts.color;
  39. cssProp = this.defaultOpts.lowerThan;
  40. }
  41. //Define opacity and fadeIn/fadeOut functions
  42. var done = true;
  43. function function_opacity(opacity_value) {
  44. outdated.style.opacity = opacity_value / 100;
  45. outdated.style.filter = 'alpha(opacity=' + opacity_value + ')';
  46. }
  47. function function_fade_out(opacity_value) {
  48. function_opacity(opacity_value);
  49. if (opacity_value == 1) {
  50. outdated.style.display = 'none';
  51. done = true;
  52. }
  53. }
  54. function function_fade_in(opacity_value) {
  55. function_opacity(opacity_value);
  56. if (opacity_value == 1) {
  57. outdated.style.display = 'block';
  58. }
  59. if (opacity_value == 100) {
  60. done = true;
  61. }
  62. }
  63. //check if element has a particular class
  64. function hasClass(element, cls) {
  65. return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
  66. }
  67. var supports = (function() {
  68. var div = document.createElement('div'),
  69. vendors = 'Khtml Ms O Moz Webkit'.split(' '),
  70. len = vendors.length;
  71. return function(prop) {
  72. if ( prop in div.style ) return true;
  73. prop = prop.replace(/^[a-z]/, function(val) {
  74. return val.toUpperCase();
  75. });
  76. while(len--) {
  77. if ( vendors[len] + prop in div.style ) {
  78. return true;
  79. }
  80. }
  81. return false;
  82. };
  83. })();
  84. //check for css3 property support (transform=default)
  85. if ( !supports(''+ cssProp +'') ) {
  86. if (done && outdated.style.opacity !== '1') {
  87. done = false;
  88. for (var i = 1; i <= 100; i++) {
  89. setTimeout((function (x) {
  90. return function () {
  91. function_fade_in(x)
  92. };
  93. })(i), i * 10);
  94. }
  95. }
  96. //close button
  97. btnClose.onmousedown = function() {
  98. outdated.style.display = 'none';
  99. return false;
  100. };
  101. }
  102. //check settings attributes
  103. outdated.style.backgroundColor = bkgColor;
  104. outdated.style.color = txtColor;
  105. //check settings attributes
  106. btnUpdate.style.color = txtColor;
  107. btnUpdate.style.borderColor = txtColor;
  108. btnClose.style.color = txtColor;
  109. //Override the update button color to match the background color
  110. btnUpdate.onmouseover = function() {
  111. this.style.color = bkgColor;
  112. this.style.backgroundColor = txtColor;
  113. };
  114. btnUpdate.onmouseout = function() {
  115. this.style.color = txtColor;
  116. this.style.backgroundColor = bkgColor;
  117. };
  118. }//end of function