Here's how we did it in Prototype UI (http://prototype-ui.com/)

var IframeShim = Class.create({

  initialize: function() {
    this.element = new Element('iframe', {
      style:
'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',
      src: 'javascript:false;'
    });
    $(document.body).insert(this.element);
    return this;
  },

  hide: function() {
    this.element.hide();
    return this;
  },

  positionUnder: function(element) {
    var element = $(element),
         offset = element.cumulativeOffset(),
         dimensions = Object.extend(element.getDimensions(), { zIndex:
element.getStyle('zIndex') }),
         position = { left: offsets[0], top: offsets[1] };

    this.element.setStyle(Object.extend(position, dimensions)).show();
    return this;
  }
})


Then this generic class is used in contextmenu, windows or any other
floated element like so:

this.iefix = new IframeShim().positionUnder('contextMenu');
...
document.observe('click', function(e) {
  if (e.isLeftClick()) {
    this.contextMenu.hide();

    // hides iframe when left click is fired on a document
    this.iefix.hide();
  }
}.bind(this))


best,
kangax


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to