If a man seeks from the good life anything beyond itself, it is not the good life that he is seekingPlotinus
Also relates to Browsers and Exploder
I have decided to re-classify some of the categories here on my weblog. Its that unfortunate tendency to have an ordered world around me seeping into my virtual world too! I have started by splitting up Browsers into separate categories for Firefox and Co. and Exploder. I feel it is an injustice to be blogging about the legacy browsers (and that includes IE6 in my oppinion now) in the same space as the standards based browsers. Since my convolutions on Opera and other browers are fairly irregular these remain in the Browsers category.
Shouldn't break any links, I hope, and if it does you should just land at the index page for that category. Right what is next…
Posted on Nov 08, 2004 at 20:53:56. [Comments for Reclassification- 0]
Also relates to CSS Design and DOM Scripting
One of the Mozilla rendering engine's few annoyances is its apparent disregard for the alignment attributes of col and colgroup elements within HTML tables. One might argue this is justified since alignment is a presentational attribute that should be defined with CSS. However, table alignment can be crucial to the visual display of data in a usable format and this should not be dependant on CSS - perhaps one reason why table alignment persists in the XHTML 1.1 Table Module.
Putting this presentation/structure debate aside, a workaround is required if alignment rules are to be defined by column in Mozilla browsers. One solution is to turn to CSS and define adjacent sibling selector rules (or direct adjacent combinators in CSS3 syntax) for table cells as demonstrated in these CSS snippets. However this will only work if the number of columns and columnar alignment is predefined.
The scenario I found myself in earlier today, working on the latest version of my PHP powered CMS, had column alignment and quantity determined on a content module basis with considerable variation. So it was once again time to call on the DOM, and to create those adjacent sibling selector rules dynamically.
function synchronizeColumns(table) {
var inline = create('style');
inline.setAttribute('type', 'text/css');
var rule = "tbody th",
rules = "",
span, halign, valign, i, temp;
(function(elem){
temp = "";
span = elem.getAttribute('span');
halign = elem.getAttribute('align');
valign = elem.getAttribute('valign');
if (halign != null) {
temp += "text-align:" + halign + ";";
}
if (valign != null) {
temp += "vertical-align:" + valign + ";";
}
i = (span != null) ? span : 1;
do {
if (temp.length > 0) {
rules += rule + "{" + temp + "}\n";
}
rule += "+td";
} while (–i > 0);
}).Iterate(table.get('col')());
inline.appendChild(create(rules,Node.TEXT_NODE));
get('head')(0).appendChild(inline);
}
The rules are declared inline (to override any default alignment rules that may be set for columns, by appending a new style node to the head element. Then it is just a case of iterating through each col element in the table, extracting the corresponding align and valign attributes and building the corresponding rule. The span attribute must also be taken into consideration to ensure the correct attribute values are assigned across each column as this document fragment demonstrates:
<colgroup>
<col align="left" width="50" />
<col span="3" align="center" width="2*" />
<col width="3*" />
<col span="2" align="right" width="1*" />
</colgroup>
So, the do..while loop takes care of appending the correct number of adjacent sibling selectors.
The function described above only loops through col elements which met my requirements. Including colgroup elements is a little more complex since the content model can contain col child nodes or be empty. Since the problem only applies to Mozilla, this would be a perfect opportunity to utilise the supported TreeWalker interface from the DOM2 Traversal and Range specification. For example:
var nodes = document.createTreeWalker(
table,
NodeFilter.SHOW_ELEMENT,
{
acceptNode : function(n) {
return (n.tagName == "COL" ||
(n.tagName == "COLGROUP" &&
n.childNodes.length == 0)
) ?
NodeFilter.FILTER_ACCEPT :
NodeFilter.FILTER_SKIP;
}
},
false);
The returned node list will contain all col and colgroup empty elements. This
assumes that a colgroup element does not define the alignment for any child nodes - to account for this the
acceptNode method would need to be extended further.
Posted on Nov 08, 2004 at 20:20:29. [Comments for Mozilla COL Alignment via DOM Scripting- 2]
Also relates to Open Source
Back in April I posted an entry on the Firefox extensions I found most useful supplemented by instruction on safely installing new extensions. Since reaching Preview Release, the Extension Manager has made the later discussion redundant. At the same time, the new Extension Room and older repository has seen the number and variety of extensions for Firefox grow extensively. With my former post the top viewed page on this weblog, I decided it was time for a quick update.
Some of the extensions I recommended in April are no longer relevant while others can now be found under new project names. So here is my list:
The last four replace some of the functionality of the Tabbrowser Extension which I chose to avoid this time round due to its resource consumption.
Feel free to recommend any other extensions you may have found useful that I have not mentioned above. And since I recommended Gmail Notifier, if anyone is still after a Gmail invite leave your email address in the comment with your recommendations and I will send you one (so long as my invites continue to top up). Just counting down the days now to the final release…
Posted on Oct 16, 2004 at 21:46:04. [Comments for Firefox Extensions in PR1- 6]
Also relates to DOM Scripting
Sometimes when visiting a site in Firefox I have found the page suddenly stops loading, is replaced by a blank screen, and, the status bar displays the text stopped. More often than not this is supplemented by an error thrown in Javascript for an undeclared variable. Well, as frustrating as this is on other sites, the same problem started occurring in the latest build I am working in. After a little code debugging, the error comes down to the use of the document.write method during page loading. I was using this method to declare some inline styles dynamically only if scripts are enabled - following the same prinicples outlined in the article I wrote on Accessible DHTML.
The fix seems to be to create the inline styles with the DOM regardless of the document being served as application/xhtml+xml mime type (in this case it was not). Since the head element is already in place when the external script is called, the inline styles can safely be appended:
if (document.getElementById && document.createElementNS) {
var elem=document.createElementNS("http://www.w3.org/1999/xhtml","style");
elem.setAttribute("type","text/css");
var text=document.createTextNode(strCSS);
elem.appendChild(text);
document.getElementsByTagName("head")[0].appendChild(elem);
} else {
strCSS = '<style type="text/css">' + strCSS + '</style>';
document.write(strCSS);
}
Posted on Oct 10, 2004 at 14:40:22. [Comments for Firefox Status: stopped- 0]
Also relates to Browsers
I now have a Social Bookmarks page on del.icio.us. As well as sharing resources, the incentive for moving my collection of bookmarks to an online repository was this excellent little tip from Simon Willison for integrating del.icio.us with Live Bookmarks, plus the additional space that is freed up on my Personal Toolbar.
The del.icio.us extension for Firefox has just been updated for the Preview Release, but currently the link seems to be broken, so I have settled for using nutr.itio.us for the time being.
The updated extension is available now and adds additional functionality to this great tool.
Posted on Sep 18, 2004 at 02:07:56. [Comments for del.icio.us- 0]