Skip to content
Browse files

added annoying.js the iframe select ie6 z-index fixer

  • Loading branch information...
1 parent efc3cfa commit cc1979e1a929c25ed5bfb7827d82762206f42ecc @jnunemaker committed Jun 13, 2008
Showing with 63 additions and 0 deletions.
  1. +63 −0 annoying.js
View
63 annoying.js
@@ -0,0 +1,63 @@
+/**
+ * For fixing the IE6 div's can't show over selects issue.
+ *
+ * Call Annoying.fix(id or element) to put an iframe behind the element
+ * that covers selects and Annoying.unfix(id or element) to hide that
+ * iframe when hiding the element.
+ */
+var Annoying = {
+ fix: function(id_or_el) {
+ var element = $(id_or_el);
+ if (!element) { return; }
+
+ var iframe = Annoying.iFrameFor(element);
+
+ // if we don't have an iframe and it's ie create iframe
+ if(!iframe && Prototype.Browser.IE) {
+ iframe = Annoying.createIframe(element);
+ }
+
+ // now we should have an iframe so let's
+ // show it which will hide the selects
+ if(iframe) {
+ setTimeout("Annoying.finalizeFix('" + element.id + "')", 50);
+ }
+ },
+
+ // hide the iframe so the selects appear again
+ unfix: function(id_or_el) {
+ var element = $(id_or_el);
+ var iframe = Annoying.iFrameFor(element);
+ if (!element || !iframe) { return; }
+ iframe.hide();
+ },
+
+ // finds the iframe for a given element
+ iFrameFor: function(id_or_el) {
+ var element = $(id_or_el);
+ if (!element) { return; }
+ return $(element.id + '_iefix');
+ },
+
+ // adds an iframe after the element and returns the iframe
+ createIframe: function(id_or_el) {
+ var element = $(id_or_el);
+ if (!element) { return; }
+ element.insert({ after: '<iframe id="' + element.id + '_iefix" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" src="javascript:false;" frameborder="0" scrolling="no"></iframe>'});
+ return $(element.id + '_iefix');
+ },
+
+ // positions the iframe perfectly behind the element
+ // and over any selects that may be there
+ finalizeFix: function(id_or_el) {
+ var element = $(id_or_el);
+ if (!element) { return; }
+ var iframe = Annoying.iFrameFor(element);
+ if (element && iframe) {
+ iframe.clonePosition(element);
+ iframe.setStyle({zIndex: 1});
+ element.setStyle({zIndex: 2});
+ iframe.show();
+ }
+ }
+}

0 comments on commit cc1979e

Please sign in to comment.
Something went wrong with that request. Please try again.