1 // minmax.js - written by Andrew Clover <and@doxdesk.com>
2 // Adapted for FluxBB by Rickard Andersson and Paul Sullivan
5 @if (@_win32 && @_jscript_version>4)
9 function minmax_bind(el) {
11 var st= el.style, cs= el.currentStyle;
13 if (minmax_elements==window.undefined) {
14 if (!document.body || !document.body.currentStyle) return;
15 minmax_elements= new Array();
16 window.attachEvent('onresize', minmax_delayout);
20 st['maxWidth']= cs['max-width'];
23 if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') {
24 st.minmaxWidth= cs.width;
25 minmax_elements[minmax_elements.length]= el;
30 var minmax_delaying= false;
31 function minmax_delayout() {
32 if (minmax_delaying) return;
33 minmax_delaying= true;
34 window.setTimeout(minmax_layout, 0);
37 function minmax_stopdelaying() {
38 minmax_delaying= false;
41 function minmax_layout() {
42 window.setTimeout(minmax_stopdelaying, 100);
43 var i, el, st, cs, optimal, inrange;
44 for (i= minmax_elements.length; i-->0;) {
45 el= minmax_elements[i]; st= el.style; cs= el.currentStyle;
47 st.width= st.minmaxWidth; optimal= el.offsetWidth;
49 if (inrange && cs.minWidth && cs.minWidth!='0' && cs.minWidth!='auto' && cs.minWidth!='') {
50 st.width= cs.minWidth;
51 inrange= (el.offsetWidth<optimal);
53 if (inrange && cs.maxWidth && cs.maxWidth!='none' && cs.maxWidth!='auto' && cs.maxWidth!='') {
54 st.width= cs.maxWidth;
55 inrange= (el.offsetWidth>optimal);
57 if (inrange) st.width= st.minmaxWidth;
61 var minmax_SCANDELAY= 500;
63 function minmax_scan() {
65 for (var i= 0; i<document.all.length; i++) {
67 if (!el.minmax_bound) {
68 el.minmax_bound= true;
75 function minmax_stop() {
76 window.clearInterval(minmax_scanner);
81 minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);
82 window.attachEvent('onload', minmax_stop);