Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added iframe shim feature to allow an automatic iframe to mask select…

… elements in IE 6
  • Loading branch information...
commit 486aba191f8d394ceb4dbbfe48ace9c95e6491db 1 parent 7bff8e7
@traversal authored
Showing with 51 additions and 2 deletions.
  1. +51 −2 src/jquery.traversal.affix.js
View
53 src/jquery.traversal.affix.js
@@ -28,7 +28,50 @@ offsets
$.fn.first = function() { if (this.length > 0) return this[0]; };
-
+ $.fn.shim = function(pos) {
+ if ($.browser.msie && $.browser.version < 7.0) {
+ var z = $(this).css("z-index");
+
+ if (z <= 0) {
+ $(this).data("zeroz", true);
+ $(this).css("z-index", 1);
+ }
+
+ var ifs = $(this).data("ifs");
+
+ if (!ifs) {
+ // the iframe shim doesn't exist, so create it and store against the element
+ ifs = $('<iframe frameborder="0" scrolling="no"></iframe>')[0];
+ $(ifs).appendTo("body");
+ $(this).data("ifs", ifs);
+ }
+
+ var size = {width: $(this).outerWidth(), height: $(this).outerHeight()};
+
+ $(ifs).css({
+ "opacity" : 0.1,
+ "display" : "block",
+ "z-index" : Math.max(z - 1, 0),
+ "position" : "absolute",
+ "width" : size.width,
+ "height" : size.height,
+ "left" : pos.left,
+ "top" : pos.top
+ });
+ }
+
+ };
+
+ $.fn.unshim = function() {
+ // we won't destroy the iframe, we'll just hide it
+ var ifs = $(this).data("ifs");
+
+ if (ifs) {
+ $(ifs).hide();
+ }
+ };
+
+
$.affixPosition = function(from, to, options)
{
// "from" is an element ID, or a wrapped set. In any case, only the first matching element is regarded
@@ -162,7 +205,9 @@ offsets
classGlueFromPrefix : "glue_",
classGlueToApply : true,
- classGlueToPrefix : "glue_"
+ classGlueToPrefix : "glue_",
+
+ shim : true // if in IE 6, apply an iframe shim to the element when it is affixed to prevent any select boxes showing above it
}, options || {});
@@ -237,6 +282,10 @@ offsets
var info = $.affixPosition(from, to, options || {});
+ if (settings.shim) {
+ $(this).shim( { left: info.left, top: info.top } );
+ }
+
if (settings.animate)
{
$(from).animate( $.extend(settings.animateParams || {}, { left: info.left, top: info.top }), settings.animateOptions );
Please sign in to comment.
Something went wrong with that request. Please try again.