Requires

Provides

IframeShim.js

Defines IframeShim, a class for obscuring select lists and flash objects in IE.

License:
MIT-style license
Authors:
Aaron Newton
  1. 29
  2. 30
  3. 31
  4. 32
  5. 33
  6. 34
  7. 35
  8. 36
  9. 37
  10. 38
  11. 39
  12. 40
  13. 41
  14. 42
  15. 43
  16. 44
  17. 45
  18. 46
  19. 47
  20. 48
  21. 49
  22. 50
  23. 51
  24. 52
  25. 53
  26. 54
  27. 55
  28. 56
  29. 57
  30. 58
  31. 59
  32. 60
  33. 61
  34. 62
  35. 63
  36. 64
  37. 65
  38. 66
  39. 67
  40. 68
  41. 69
  42. 70
  43. 71
  44. 72
  45. 73
  46. 74
  47. 75
  48. 76
  49. 77
  50. 78
  51. 79
  52. 80
  53. 81
  54. 82
  55. 83
  56. 84
  57. 85
  58. 86
  59. 87
  60. 88
  61. 89
  62. 90
  63. 91
  64. 92
  65. 93
  66. 94
  67. 95
  68. 96
  69. 97
  70. 98
  71. 99
  72. 100
  73. 101
  74. 102
  75. 103
  76. 104
  77. 105
  78. 106
  79. 107
  80. 108
  81. 109
  82. 110
  83. 111
  84. 112
  85. 113
  86. 114
  87. 115
  88. 116
  89. 117
  90. 118
  91. 119
  92. 120
  93. 121
  94. 122
  95. 123
  96. 124
  97. 125
  98. 126
  99. 127
  100. 128
  101. 129
  102. 130
  103. 131
var IframeShim = new Class({ Implements: [Options, Events, Class.Occlude], options: { className: 'iframeShim', src: 'javascript:false;document.write("");', display: false, zIndex: null, margin: 0, offset: {x: 0, y: 0}, browsers: ((Browser.ie && Browser.version == 6) || (Browser.firefox && Browser.version < 3 && Browser.Platform.mac)) }, property: 'IframeShim', initialize: function(element, options){ this.element = document.id(element); if (this.occlude()) return this.occluded; this.setOptions(options); this.makeShim(); return this; }, makeShim: function(){ if (this.options.browsers){ var zIndex = this.element.getStyle('zIndex').toInt(); if (!zIndex){ zIndex = 1; var pos = this.element.getStyle('position'); if (pos == 'static' || !pos) this.element.setStyle('position', 'relative'); this.element.setStyle('zIndex', zIndex); } zIndex = ((this.options.zIndex != null || this.options.zIndex === 0) && zIndex > this.options.zIndex) ? this.options.zIndex : zIndex - 1; if (zIndex < 0) zIndex = 1; this.shim = new Element('iframe', { src: this.options.src, scrolling: 'no', frameborder: 0, styles: { zIndex: zIndex, position: 'absolute', border: 'none', filter: 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)' }, 'class': this.options.className }).store('IframeShim', this); var inject = (function(){ this.shim.inject(this.element, 'after'); this[this.options.display ? 'show' : 'hide'](); this.fireEvent('inject'); }).bind(this); if (!IframeShim.ready) window.addEvent('load', inject); else inject(); } else { this.position = this.hide = this.show = this.dispose = Function.from(this); } }, position: function(){ if (!IframeShim.ready || !this.shim) return this; var size = this.element.measure(function(){ return this.getSize(); }); if (this.options.margin != undefined){ size.x = size.x - (this.options.margin * 2); size.y = size.y - (this.options.margin * 2); this.options.offset.x += this.options.margin; this.options.offset.y += this.options.margin; } this.shim.set({width: size.x, height: size.y}).position({ relativeTo: this.element, offset: this.options.offset }); return this; }, hide: function(){ if (this.shim) this.shim.setStyle('display', 'none'); return this; }, show: function(){ if (this.shim) this.shim.setStyle('display', 'block'); return this.position(); }, dispose: function(){ if (this.shim) this.shim.dispose(); return this; }, destroy: function(){ if (this.shim) this.shim.destroy(); return this; } }); window.addEvent('load', function(){ IframeShim.ready = true; });