Snippets code from my daily experience

April 7, 2008

How to get element style values from XUL (or HTML)

Filed under: css, table2clipboard, xul — dafi @ 8:15 pm

I’m working to my Extend Firefox 2 Runner Up winner Table2Clipboard.

Many users tell me to add a simple feature, exclude cells having style display: none.

The solution is so straightforward that I could not believe after initial implementation.

You can style an element using CSS selectors

.invisible {
display: none;
}

<span id=“invisibleSpan” class=“invisible”>I’m invisible man</span>

or using the attribute style attribute

<span id=“invisibleSpan” style=“display : none”>I’m invisible man</span>

These two ways can both simply handled using getComputedStyle

var spanElement = document.getElementById(“invisibleSpan”);
var style = spanElement.ownerDocument.defaultView.getComputedStyle(spanElement, null);
var displayValue = style.getPropertyValue(“display”);

That’s all folks!!

Obviously you can use any CSS attribute not only display.

Pay attention to ownerDocument.defaultView, you should use window.getComputedStyle() but under XUL this doesn’t return what you expect.

getComputedStyle can be used in normal unprivileged HTML code, too.

getComputedStyle is a W3C standard and is present on Internet Explorer, Opera and Safari, too.

Little things make developer life easier.

February 14, 2008

Extend Firefox 2 Contest and other surprises

Filed under: firefox, mozilla, openkomodo, table2clipboard — dafi @ 9:06 pm

January and February are very important months for my programming activites.

In January ActiveState guys gave me a KomodoIDE license for my contribution to their OpenKomodo wiki, a great unexpected surprise, the first one.

A couple of days ago Mozilla published the Extend Firefox 2 Contest and I discovered my name on “Runners up” list, a great
unexpected surprise, the second one.
I can figure out ViewSourceWith is the winner, no! The winner is Table2Clipboard my outsider extension, a great unexpected surprise, the third one.

I’m happy that other people appreciates my work.

My feed reader alerts me, LifeHacker has new contents, I take a look and found they speak about Table2Clipboard, a great unexpected surprise, the fourth one.

ActivateState gave me a KomodoIDE license, EF2 prices contain a KomodoIDE license, now I have two KomodoIDE license, another surprise the fifth :D

Mumble mumble… may I sell the unused license?

Blog at WordPress.com.