Apr
05
Posted on 05-04-2008
Filed Under (ajax, hack, javascript, sviluppo, web 2.0) by Mat on 05-04-2008

If you’re using a Mootools Accordion on Internet Explorer 7, sometimes it doesn’t open on item specified in show property.
You can simply fix this bug without using show property but calling Accordion.display method immediately after accordion creation, so you’ll get open item also in IE.

View Accordion documentation

(1) Comment    Read More   
Feb
04
Posted on 04-02-2008
Filed Under (ajax, css, hack, javascript, validazione) by Mat on 04-02-2008

19/7/2008 UPDATE
The code isn’t valid anymore. Read the comments.

In Thickbox css code there are some hacks that doesn’t validate the code (only css, rather xhtml is valid).
Invalid code is javascript inline css document. So, I changed invalid code with a js function call. Take an example:

* html #TB_overlay { /* ie6 hack */
position: absolute;
/*height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + ‘px’); NOT VALID*/
height: expression(fixHeight(document.body.scrollHeight, document.body.offsetHeight)); //VALID
}* html #TB_window { /* ie6 hack */
position: absolute;
/* margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + ‘px’); NOT VALID */
margin-top:expression(fixMarginTop(this.offsetHeight,document.documentElement,document.body.scrollTop)); //VALID
}

So substitute expression inline in css file with calls to fuctions externally defined, and load the following file whenever you’re using thickbox in your site:

expressions.js:

function fixHeight(scrollHeight, offsetHeight)
{
return (scrollHeight > offsetHeight ? scrollHeight : offsetHeight + ‘px’);
}
function fixMarginTop(offsetHeight,documentElement,scrollTop)
{
return (0 - parseInt(offsetHeight / 2) + (TBWindowMargin = documentElement && documentElement.scrollTop || scrollTop) + ‘px’);
}

To use Thickbox now you need these loadings:

<script src="/lib/thickbox/jquery.js" type="text/javascript"></script>
<script src="/lib/thickbox/thickbox.js" type="text/javascript"></script>
<script src="/lib/thickbox/expressions.js" type="text/javascript"></script>
<style type="text/css"> @import "/lib/thickbox/thickbox.css"; </style>

Download Thickbox 3.1 editated sources:
thickbox.css (editated)
expressions.js (added)

(13) Comments    Read More