bug3
[aidenligne_francais_universite.git] / fluxbb / style / imports / minmax.js
CommitLineData
c495c100
P
1// minmax.js - written by Andrew Clover <and@doxdesk.com>
2// Adapted for FluxBB by Rickard Andersson and Paul Sullivan
3
4/*@cc_on
5@if (@_win32 && @_jscript_version>4)
6
7var minmax_elements;
8
9function minmax_bind(el) {
10 var em, ms;
11 var st= el.style, cs= el.currentStyle;
12
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);
17 }
18
19 if (cs['max-width'])
20 st['maxWidth']= cs['max-width'];
21
22 ms= cs['maxWidth'];
23 if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') {
24 st.minmaxWidth= cs.width;
25 minmax_elements[minmax_elements.length]= el;
26 minmax_delayout();
27 }
28}
29
30var minmax_delaying= false;
31function minmax_delayout() {
32 if (minmax_delaying) return;
33 minmax_delaying= true;
34 window.setTimeout(minmax_layout, 0);
35}
36
37function minmax_stopdelaying() {
38 minmax_delaying= false;
39}
40
41function 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;
46
47 st.width= st.minmaxWidth; optimal= el.offsetWidth;
48 inrange= true;
49 if (inrange && cs.minWidth && cs.minWidth!='0' && cs.minWidth!='auto' && cs.minWidth!='') {
50 st.width= cs.minWidth;
51 inrange= (el.offsetWidth<optimal);
52 }
53 if (inrange && cs.maxWidth && cs.maxWidth!='none' && cs.maxWidth!='auto' && cs.maxWidth!='') {
54 st.width= cs.maxWidth;
55 inrange= (el.offsetWidth>optimal);
56 }
57 if (inrange) st.width= st.minmaxWidth;
58 }
59}
60
61var minmax_SCANDELAY= 500;
62
63function minmax_scan() {
64 var el;
65 for (var i= 0; i<document.all.length; i++) {
66 el= document.all[i];
67 if (!el.minmax_bound) {
68 el.minmax_bound= true;
69 minmax_bind(el);
70 }
71 }
72}
73
74var minmax_scanner;
75function minmax_stop() {
76 window.clearInterval(minmax_scanner);
77 minmax_scan();
78}
79
80minmax_scan();
81minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);
82window.attachEvent('onload', minmax_stop);
83
84@end @*/