views:

1474

answers:

3

I know its possible to integrate jQuery within mozilla addons, but are we able to manipulate (animate, move, adjust transparency, etc) xul elements themselves?

From what I understand, the mozilla addon can use jquery to manipulate html/dom elements, but not sure about xul elements.

All links and tips are appreciated, -=Vin

+4  A: 

I was wondering this myself recently. Obviously the DHTML doesn't make sense, but the basic syntactic sugar and things are rumored to work.

  • There is this jQuery on XUL discussion from the jQuery group which indicates that it loads up with some exceptions.
  • Also see this slightly more recent blog post about jQuery and DHTML in XUL. That person is going after the HTML within the XUL which is not exactly what you need but he does have good information.
jhs
+4  A: 
Senthil
Thanks for the info
+1  A: 

XUL and HTML actually deal with opacity the exact same way, and it is jQuery that incorrectly detects what the browser can do. jQuery thinks it's in a different browser when it's living inside XUL, and so opacity effects are handled differently - by jQuery. Since it IS in Firefox, and it should deal with opacity normally, you can override this like so:

jQuery.support.opacity = true

Do this right after jQuery is loaded.

There is probably a whole category of similar fixes that can be post-applied to jQuery to make it behave better, but I haven't looked in to it.

Daniel
It seems to me that you could find out what exactly happens to make jQuery think it's not in Firefox, and then override that so that it will think it IS in Firefox. If that's possible, I would think you could solve all such problems in one step.
MatrixFrog
I looked in to this - opacity and other things are not detected using browser-specific methods. They are detected directly (search for "jQuery.support = {" in the 1.4.2 source) - by creating a div element and manipulating it in various ways. Short of patching jQuery, which I leave as an exercise to the reader, the method I described is the quickest way to do it and should be done on a case-by-case basis - because the XUL DOM is not the same as the HTML DOM.
Daniel
Thanks for the feedback. Much appreciated