ie6_fixer 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.markdown +256 -0
- data/Rakefile +2 -0
- data/ie6_fixer.gemspec +21 -0
- data/init.rb +2 -0
- data/lib/ie6_fixer.rb +56 -0
- data/lib/ie6_fixer/assets/ie6_fixer/PIE.htc +77 -0
- data/lib/ie6_fixer/assets/ie6_fixer/README.txt +256 -0
- data/lib/ie6_fixer/assets/ie6_fixer/fixed.js +10 -0
- data/lib/ie6_fixer/assets/ie6_fixer/fixed_active.js +354 -0
- data/lib/ie6_fixer/assets/ie6_fixer/foo +0 -0
- data/lib/ie6_fixer/assets/ie6_fixer/warning/background_browser.gif +0 -0
- data/lib/ie6_fixer/assets/ie6_fixer/warning/browser_chrome.gif +0 -0
- data/lib/ie6_fixer/assets/ie6_fixer/warning/browser_firefox.gif +0 -0
- data/lib/ie6_fixer/assets/ie6_fixer/warning/browser_ie.gif +0 -0
- data/lib/ie6_fixer/assets/ie6_fixer/warning/browser_opera.gif +0 -0
- data/lib/ie6_fixer/assets/ie6_fixer/warning/browser_safari.gif +0 -0
- data/lib/ie6_fixer/assets/ie6_fixer/warning/warning.js +16 -0
- data/lib/ie6_fixer/helpers.rb +184 -0
- data/lib/ie6_fixer/railtie.rb +13 -0
- data/lib/ie6_fixer/version.rb +3 -0
- data/lib/tasks/ie6_fixer.rake +6 -0
- metadata +85 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
function fixedIE(tl, n, el){
|
2
|
+
var sc = 'scroll'+tl;
|
3
|
+
var d = document;
|
4
|
+
var c = 'compatMode';
|
5
|
+
var b = d[c]&&d[c]=='CSS1Compat'? d.documentElement : d.body;
|
6
|
+
n = n-0;
|
7
|
+
if(typeof n!='number')return 0; if(/^(Top|Left)$/.test(tl)) return b[sc]+n+'px';
|
8
|
+
if(/^(Bottom|Right)$/.test(tl)&&typeof el=='object'){ tl = tl=='Right'? 'Left' : 'Top', sc = 'scroll'+tl; var dim = 'client' + (tl=='Top'? 'Height' : 'Width'); return b[sc]+b[dim]-el[dim]-n+'px'; }
|
9
|
+
return 0;
|
10
|
+
}
|
@@ -0,0 +1,354 @@
|
|
1
|
+
// fixed.js: fix fixed positioning and fixed backgrounds in IE/Win
|
2
|
+
// version 1.8, 08-Aug-2003
|
3
|
+
// written by Andrew Clover <and@doxdesk.com>, use freely
|
4
|
+
|
5
|
+
/*@cc_on
|
6
|
+
@if (@_win32 && @_jscript_version>4)
|
7
|
+
|
8
|
+
var fixed_positions= new Array();
|
9
|
+
var fixed_backgrounds= new Array();
|
10
|
+
var fixed_viewport;
|
11
|
+
|
12
|
+
// Initialisation. Called when the <body> tag arrives. Set up viewport so the
|
13
|
+
// rest of the script knows we're going, and add a measurer div, used to detect
|
14
|
+
// font size changes and measure image sizes for backgrounds later
|
15
|
+
|
16
|
+
function fixed_init() {
|
17
|
+
fixed_viewport= (document.compatMode=='CSS1Compat') ?
|
18
|
+
document.documentElement : document.body;
|
19
|
+
var el= document.createElement('div');
|
20
|
+
el.setAttribute('id', 'fixed-measure');
|
21
|
+
el.style.position= 'absolute';
|
22
|
+
el.style.top= '0'; el.style.left= '0';
|
23
|
+
el.style.overflow= 'hidden'; el.style.visibility= 'hidden';
|
24
|
+
el.style.fontSize= 'xx-large'; el.style.height= '5em';
|
25
|
+
el.style.setExpression('width', 'fixed_measureFont()');
|
26
|
+
document.body.insertBefore(el, document.body.firstChild);
|
27
|
+
}
|
28
|
+
|
29
|
+
// Binding. Called every time an element is added to the document, check it
|
30
|
+
// for fixed features, if found add to our lists and set initial props
|
31
|
+
|
32
|
+
function fixed_bind(el) {
|
33
|
+
var needLayout= false;
|
34
|
+
var tag= el.tagName.toLowerCase();
|
35
|
+
var st= el.style;
|
36
|
+
var cst= el.currentStyle;
|
37
|
+
var anc;
|
38
|
+
|
39
|
+
// find fixed-position elements
|
40
|
+
if (cst.position=='fixed') {
|
41
|
+
needLayout= true;
|
42
|
+
fixed_positions[fixed_positions.length]= el;
|
43
|
+
// store original positioning as we'll overwrite it
|
44
|
+
st.position= 'absolute';
|
45
|
+
st.fixedPLeft= cst.left;
|
46
|
+
st.fixedPTop= cst.top;
|
47
|
+
st.fixedPRight= cst.right;
|
48
|
+
st.fixedPBottom= cst.bottom;
|
49
|
+
st.fixedPWidth= fixed_parseLength(cst.width);
|
50
|
+
st.fixedPHeight= fixed_parseLength(cst.height);
|
51
|
+
// find element that will act as containing box, for convenience later
|
52
|
+
st.fixedCB= null;
|
53
|
+
for (anc= el; (anc= anc.parentElement).parentElement;) {
|
54
|
+
if (anc.currentStyle.position!='static') {
|
55
|
+
st.fixedCB= anc;
|
56
|
+
break;
|
57
|
+
} }
|
58
|
+
// detect nested fixed positioning (only ancestor need move)
|
59
|
+
st.fixedNest= false;
|
60
|
+
for (anc= el; anc= anc.parentElement;) {
|
61
|
+
if (anc.style.fixedNest!=null)
|
62
|
+
st.fixedNest= true;
|
63
|
+
break;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
// find fixed-background elements (not body/html which IE already gets right)
|
68
|
+
if (cst.backgroundAttachment=='fixed' && tag!='body' && tag!='html') {
|
69
|
+
needLayout= true;
|
70
|
+
fixed_backgrounds[fixed_backgrounds.length]= el;
|
71
|
+
// get background offset, converting from keyword if necessary
|
72
|
+
st.fixedBLeft= fixed_parseLength(cst.backgroundPositionX);
|
73
|
+
st.fixedBTop= fixed_parseLength(cst.backgroundPositionY);
|
74
|
+
// if it's a non-zero %age, need to know size of image for layout
|
75
|
+
if (st.fixedBLeft[1]=='%' || st.fixedBTop[1]=='%') {
|
76
|
+
st.fixedBWidth= 0; st.fixedBHeight= 0;
|
77
|
+
fixed_measureBack(el);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
if (needLayout) fixed_layout();
|
81
|
+
}
|
82
|
+
|
83
|
+
// Layout. On every window or font size change, recalculate positioning
|
84
|
+
|
85
|
+
// Request re-layout at next free moment
|
86
|
+
var fixed_delaying= false;
|
87
|
+
function fixed_delayout() {
|
88
|
+
if (fixed_delaying) return;
|
89
|
+
fixed_delaying= true;
|
90
|
+
window.setTimeout(fixed_layout, 0);
|
91
|
+
}
|
92
|
+
|
93
|
+
var fixed_ARBITRARY= 200;
|
94
|
+
|
95
|
+
function fixed_layout() {
|
96
|
+
fixed_delaying= false;
|
97
|
+
if (!fixed_viewport) return;
|
98
|
+
var i, el, st, j, pr, tmp, A= 'auto';
|
99
|
+
var cb, cbLeft, cbTop, cbRight, cbBottom, oLeft, oTop, oRight, oBottom;
|
100
|
+
var vpWidth=fixed_viewport.clientWidth, vpHeight=fixed_viewport.clientHeight;
|
101
|
+
|
102
|
+
// calculate initial position for fixed-position elements [black magic]
|
103
|
+
for (i= fixed_positions.length; i-->0;) {
|
104
|
+
el= fixed_positions[i]; st= el.style;
|
105
|
+
// find positioning of containing block
|
106
|
+
cb= st.fixedCB; if (!cb) cb= fixed_viewport;
|
107
|
+
cbLeft= fixed_pageLeft(cb); cbTop= fixed_pageTop(cb);
|
108
|
+
if (cb!=fixed_viewport) { cbLeft+= cb.clientLeft; cbTop+= cb.clientTop; }
|
109
|
+
cbRight= fixed_viewport.clientWidth-cbLeft-cb.clientWidth;
|
110
|
+
cbBottom= fixed_viewport.clientHeight-cbTop-cb.clientHeight;
|
111
|
+
// if size is in %, must recalculate relative to viewport
|
112
|
+
if (st.fixedPWidth[1]=='%')
|
113
|
+
st.width= Math.round(vpWidth*st.fixedPWidth[0]/100)+'px';
|
114
|
+
if (st.fixedPHeight[1]=='%')
|
115
|
+
st.height= Math.round(vpHeight*st.fixedPHeight[0]/100)+'px';
|
116
|
+
// find out offset values at max size, to account for margins
|
117
|
+
st.left= A; st.right= '0'; st.top= A; st.bottom= '0';
|
118
|
+
oRight= el.offsetLeft+el.offsetWidth; oBottom= el.offsetTop+el.offsetHeight;
|
119
|
+
st.left= '0'; st.right= A; st.top= '0'; st.bottom= A;
|
120
|
+
oLeft= el.offsetLeft; oTop= el.offsetTop;
|
121
|
+
// use this to convert all edges to pixels
|
122
|
+
st.left= A; st.right= st.fixedPRight;
|
123
|
+
st.top= A; st.bottom= st.fixedPBottom;
|
124
|
+
oRight-= el.offsetLeft+el.offsetWidth;
|
125
|
+
oBottom-= el.offsetTop+el.offsetHeight;
|
126
|
+
st.left= st.fixedPLeft; st.top= st.fixedPTop;
|
127
|
+
oLeft= el.offsetLeft-oLeft; oTop= el.offsetTop-oTop;
|
128
|
+
// edge positioning fix
|
129
|
+
if (st.fixedPWidth[1]==A && st.fixedPLeft!=A && st.fixedPRight!=A) {
|
130
|
+
tmp= el.offsetLeft; st.left= A; st.width= fixed_ARBITRARY+'px';
|
131
|
+
tmp= fixed_ARBITRARY+el.offsetLeft-tmp+cbLeft+cbRight;
|
132
|
+
st.left= st.fixedPLeft; st.width= ((tmp<1)?1:tmp)+'px';
|
133
|
+
}
|
134
|
+
if (st.fixedPHeight[1]==A && st.fixedPTop!=A && st.fixedPBottom!=A) {
|
135
|
+
tmp= el.offsetTop; st.top= A; st.height= fixed_ARBITRARY+'px';
|
136
|
+
tmp= fixed_ARBITRARY+el.offsetTop-tmp+cbTop+cbBottom;
|
137
|
+
st.top= st.fixedPTop; st.height= ((tmp<1)?1:tmp)+'px';
|
138
|
+
}
|
139
|
+
// move all non-auto edges relative to the viewport
|
140
|
+
st.fixedCLeft= (st.fixedPLeft=='auto') ? oLeft : oLeft-cbLeft;
|
141
|
+
st.fixedCTop= (st.fixedPTop=='auto') ? oTop : oTop-cbTop;
|
142
|
+
st.fixedCRight= (st.fixedPRight=='auto') ? oRight : oRight-cbRight;
|
143
|
+
st.fixedCBottom= (st.fixedPBottom=='auto') ? oBottom : oBottom-cbBottom;
|
144
|
+
// remove left-positioning of right-positioned elements
|
145
|
+
if (st.fixedPLeft=='auto' && st.fixedPRight!='auto') st.fixedCLeft= 'auto';
|
146
|
+
if (st.fixedPTop=='auto' && st.fixedPBottom!='auto') st.fixedCTop= 'auto';
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
// calculate initial positioning of fixed backgrounds
|
151
|
+
for (i= fixed_backgrounds.length; i-->0;) {
|
152
|
+
el= fixed_backgrounds[i]; st= el.style;
|
153
|
+
tmp= st.fixedBImage;
|
154
|
+
if (tmp) {
|
155
|
+
if (tmp.readyState!='uninitialized') {
|
156
|
+
st.fixedBWidth= tmp.offsetWidth;
|
157
|
+
st.fixedBHeight= tmp.offsetHeight;
|
158
|
+
st.fixedBImage= window.undefined;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
st.fixedBX= fixed_length(el, st.fixedBLeft, vpWidth-st.fixedBWidth);
|
162
|
+
st.fixedBY= fixed_length(el, st.fixedBTop, vpHeight-st.fixedBHeight);
|
163
|
+
}
|
164
|
+
|
165
|
+
// now call scroll() to set the positions from the values just calculated
|
166
|
+
fixed_scroll();
|
167
|
+
}
|
168
|
+
|
169
|
+
// Scrolling. Offset fixed elements relative to viewport scrollness
|
170
|
+
|
171
|
+
var fixed_lastX, fixed_lastY;
|
172
|
+
var fixed_PATCHDELAY= 300;
|
173
|
+
var fixed_patching= false;
|
174
|
+
|
175
|
+
// callback function after a scroll, because incorrect scroll position is
|
176
|
+
// often reported first go!
|
177
|
+
function fixed_patch() {
|
178
|
+
fixed_patching= false;
|
179
|
+
var scrollX= fixed_viewport.scrollLeft, scrollY= fixed_viewport.scrollTop;
|
180
|
+
if (scrollX!=fixed_lastX && scrollY!=fixed_lastY) fixed_scroll();
|
181
|
+
}
|
182
|
+
|
183
|
+
function fixed_scroll() {
|
184
|
+
if (!fixed_viewport) return;
|
185
|
+
var i, el, st, viewportX, viewportY;
|
186
|
+
var scrollX= fixed_viewport.scrollLeft, scrollY= fixed_viewport.scrollTop;
|
187
|
+
fixed_lastX= scrollX; fixed_lastY= scrollY;
|
188
|
+
|
189
|
+
// move non-nested fixed-position elements
|
190
|
+
for (i= fixed_positions.length; i-->0;) {
|
191
|
+
st= fixed_positions[i].style;
|
192
|
+
viewportX= (st.fixedNest) ? 0 : scrollX;
|
193
|
+
viewportY= (st.fixedNest) ? 0 : scrollY;
|
194
|
+
if (st.fixedCLeft!='auto') st.left= (st.fixedCLeft+viewportX)+'px';
|
195
|
+
if (st.fixedCTop!='auto') st.top= (st.fixedCTop+viewportY)+'px';
|
196
|
+
viewportX= (st.fixedCB==null || st.fixedCB==fixed_viewport) ? 0 : viewportX;
|
197
|
+
viewportY= (st.fixedCB==null || st.fixedCB==fixed_viewport) ? 0 : viewportY;
|
198
|
+
st.right= (st.fixedCRight-viewportX+1)+'px'; st.right= (st.fixedCRight-viewportX)+'px';
|
199
|
+
st.bottom= (st.fixedCBottom-viewportY+1)+'px'; st.bottom= (st.fixedCBottom-viewportY)+'px';
|
200
|
+
}
|
201
|
+
|
202
|
+
// align fixed backgrounds to viewport
|
203
|
+
for (i= fixed_backgrounds.length; i-->0;) {
|
204
|
+
el= fixed_backgrounds[i]; st= el.style;
|
205
|
+
viewportX= scrollX;
|
206
|
+
viewportY= scrollY;
|
207
|
+
while (el.offsetParent) {
|
208
|
+
viewportX-= el.offsetLeft+el.clientLeft;
|
209
|
+
viewportY-= el.offsetTop +el.clientTop;
|
210
|
+
el= el.offsetParent;
|
211
|
+
}
|
212
|
+
st.backgroundPositionX= (st.fixedBX+viewportX)+'px';
|
213
|
+
st.backgroundPositionY= (st.fixedBY+viewportY)+'px';
|
214
|
+
}
|
215
|
+
|
216
|
+
// call back again in a tic
|
217
|
+
if (!fixed_patching) {
|
218
|
+
fixed_patching= true;
|
219
|
+
window.setTimeout(fixed_patch, fixed_PATCHDELAY);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
// Measurement. Load bg-image into an invisible element on the page, when
|
224
|
+
// loaded write the width/height to an element's style for layout use; detect
|
225
|
+
// when font size changes
|
226
|
+
|
227
|
+
function fixed_measureBack(el) {
|
228
|
+
var measure= document.getElementById('fixed-measure');
|
229
|
+
var img= document.createElement('img');
|
230
|
+
img.setAttribute('src', fixed_parseURL(el.currentStyle.backgroundImage));
|
231
|
+
measure.appendChild(img);
|
232
|
+
el.style.fixedBImage= img;
|
233
|
+
if (img.readyState=='uninitialized')
|
234
|
+
img.attachEvent('onreadystatechange', fixed_measureBackImage_ready);
|
235
|
+
}
|
236
|
+
|
237
|
+
function fixed_measureBackImage_ready() {
|
238
|
+
var img= event.srcElement;
|
239
|
+
if (img && img.readyState!='uninitialized') {
|
240
|
+
img.detachEvent('onreadystatechange', fixed_measureBackImage_ready);
|
241
|
+
fixed_layout();
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
var fixed_fontsize= 0;
|
246
|
+
function fixed_measureFont() {
|
247
|
+
var fs= document.getElementById('fixed-measure').offsetHeight;
|
248
|
+
if (fixed_fontsize!=fs && fixed_fontsize!=0)
|
249
|
+
fixed_delayout();
|
250
|
+
fixed_fontsize= fs;
|
251
|
+
return '5em';
|
252
|
+
}
|
253
|
+
|
254
|
+
// Utility. General-purpose functions
|
255
|
+
|
256
|
+
// parse url() to get value inside
|
257
|
+
|
258
|
+
function fixed_parseURL(v) {
|
259
|
+
v= v.substring(4, v.length-1);
|
260
|
+
if (v.charAt(0)=='"' && v.charAt(v.length-1)=='"' ||
|
261
|
+
v.charAt(0)=="'" && v.charAt(v.length-1)=="'")
|
262
|
+
return v.substring(1, v.length-1);
|
263
|
+
else return v;
|
264
|
+
}
|
265
|
+
|
266
|
+
// parse length or auto or background-position keyword into number and unit
|
267
|
+
|
268
|
+
var fixed_numberChars= '+-0123456789.';
|
269
|
+
var fixed_ZERO= new Array(0, 'px');
|
270
|
+
var fixed_50PC= new Array(50, '%');
|
271
|
+
var fixed_100PC= new Array(100, '%');
|
272
|
+
var fixed_AUTO= new Array(0, 'auto');
|
273
|
+
|
274
|
+
function fixed_parseLength(v) {
|
275
|
+
var num, i;
|
276
|
+
if (v=='left' || v=='top') return fixed_ZERO;
|
277
|
+
if (v=='right' || v=='bottom') return fixed_100PC;
|
278
|
+
if (v=='center') return fixed_50PC;
|
279
|
+
if (v=='auto') return fixed_AUTO;
|
280
|
+
i= 0;
|
281
|
+
while (i<v.length && fixed_numberChars.indexOf(v.charAt(i))!=-1)
|
282
|
+
i++;
|
283
|
+
num= parseFloat(v.substring(0, i));
|
284
|
+
if (num==0) return fixed_ZERO;
|
285
|
+
else return new Array(num, v.substring(i));
|
286
|
+
}
|
287
|
+
|
288
|
+
// convert parsed (number, unit) into a number of pixels
|
289
|
+
|
290
|
+
function fixed_length(el, l, full) {
|
291
|
+
var tmp, x;
|
292
|
+
if (l[1]=='px') return l[0];
|
293
|
+
if (l[1]=='%') return Math.round(full*l[0]/100);
|
294
|
+
// other units - measure by setting position; this is rather inefficient
|
295
|
+
// but then these units are used for background-position so seldom...
|
296
|
+
tmp= el.currentStyle.left;
|
297
|
+
el.style.left= '0';
|
298
|
+
x= el.offsetLeft;
|
299
|
+
el.style.left= l[0]+l[1];
|
300
|
+
x= el.offsetLeft-x;
|
301
|
+
el.style.left= tmp;
|
302
|
+
return x;
|
303
|
+
}
|
304
|
+
|
305
|
+
// convert stupid IE offsetLeft/Top to page-relative values
|
306
|
+
|
307
|
+
function fixed_pageLeft(el) {
|
308
|
+
var v= 0;
|
309
|
+
while (el.offsetParent) {
|
310
|
+
v+= el.offsetLeft;
|
311
|
+
el= el.offsetParent;
|
312
|
+
}
|
313
|
+
return v;
|
314
|
+
}
|
315
|
+
function fixed_pageTop(el) {
|
316
|
+
var v= 0;
|
317
|
+
while (el.offsetParent) {
|
318
|
+
v+= el.offsetTop;
|
319
|
+
el= el.offsetParent;
|
320
|
+
}
|
321
|
+
return v;
|
322
|
+
}
|
323
|
+
|
324
|
+
// Scanning. Check document every so often until it has finished loading. Do
|
325
|
+
// nothing until <body> arrives, then call main init. Pass any new elements
|
326
|
+
// found on each scan to be bound
|
327
|
+
|
328
|
+
var fixed_SCANDELAY= 500;
|
329
|
+
|
330
|
+
function fixed_scan() {
|
331
|
+
if (!document.body) return;
|
332
|
+
if (!fixed_viewport) fixed_init();
|
333
|
+
var el;
|
334
|
+
for (var i= 0; i<document.all.length; i++) {
|
335
|
+
el= document.all[i];
|
336
|
+
if (!el.fixed_bound) {
|
337
|
+
el.fixed_bound= true;
|
338
|
+
fixed_bind(el);
|
339
|
+
} }
|
340
|
+
}
|
341
|
+
|
342
|
+
var fixed_scanner;
|
343
|
+
function fixed_stop() {
|
344
|
+
window.clearInterval(fixed_scanner);
|
345
|
+
fixed_scan();
|
346
|
+
}
|
347
|
+
|
348
|
+
fixed_scan();
|
349
|
+
fixed_scanner= window.setInterval(fixed_scan, fixed_SCANDELAY);
|
350
|
+
window.attachEvent('onload', fixed_stop);
|
351
|
+
window.attachEvent('onresize', fixed_delayout);
|
352
|
+
window.attachEvent('onscroll', fixed_scroll);
|
353
|
+
|
354
|
+
@end @*/
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var msg1 = "Did you know that your Internet Explorer is out of date?";
|
2
|
+
var msg2 = "To get the best possible experience using our website we recommend that you upgrade to a newer version or other web browser. A list of the most popular web browsers can be found below.";
|
3
|
+
var msg3 = "Just click on the icons to get to the download page";
|
4
|
+
var br1 = "Internet Explorer 8+";
|
5
|
+
var br2 = "Firefox 3+";
|
6
|
+
var br3 = "Safari 5+";
|
7
|
+
var br4 = "Opera 10+";
|
8
|
+
var br5 = "Chrome 6.0+";
|
9
|
+
var url1 = "http://www.microsoft.com/windows/Internet-explorer/default.aspx";
|
10
|
+
var url2 = "http://www.mozilla.com/firefox/";
|
11
|
+
var url3 = "http://www.apple.com/safari/download/";
|
12
|
+
var url4 = "http://www.opera.com/download/";
|
13
|
+
var url5 = "http://www.google.com/chrome";
|
14
|
+
var imgPath;
|
15
|
+
|
16
|
+
function warn_ie6(str) {imgPath = str;var _body = document.getElementsByTagName('body')[0];var _d = document.createElement('div');var _l = document.createElement('div');var _h = document.createElement('h1');var _p1 = document.createElement('p');var _p2 = document.createElement('p');var _ul = document.createElement('ul');var _li1 = document.createElement('li');var _li2 = document.createElement('li');var _li3 = document.createElement('li');var _li4 = document.createElement('li');var _li5 = document.createElement('li');var _ico1 = document.createElement('div');var _ico2 = document.createElement('div');var _ico3 = document.createElement('div');var _ico4 = document.createElement('div');var _ico5 = document.createElement('div');var _lit1 = document.createElement('div');var _lit2 = document.createElement('div');var _lit3 = document.createElement('div');var _lit4 = document.createElement('div');var _lit5 = document.createElement('div');_body.appendChild(_l);_body.appendChild(_d);_d.appendChild(_h);_d.appendChild(_p1);_d.appendChild(_p2);_d.appendChild(_ul);_ul.appendChild(_li1);_ul.appendChild(_li2);_ul.appendChild(_li3);_ul.appendChild(_li4);_ul.appendChild(_li5);_li1.appendChild(_ico1);_li2.appendChild(_ico2);_li3.appendChild(_ico3);_li4.appendChild(_ico4);_li5.appendChild(_ico5);_li1.appendChild(_lit1);_li2.appendChild(_lit2);_li3.appendChild(_lit3);_li4.appendChild(_lit4);_li5.appendChild(_lit5);_d.setAttribute('id','_d');_l.setAttribute('id','_l');_h.setAttribute('id','_h');_p1.setAttribute('id','_p1');_p2.setAttribute('id','_p2');_ul.setAttribute('id','_ul');_li1.setAttribute('id','_li1');_li2.setAttribute('id','_li2');_li3.setAttribute('id','_li3');_li4.setAttribute('id','_li4');_li5.setAttribute('id','_li5');_ico1.setAttribute('id','_ico1');_ico2.setAttribute('id','_ico2');_ico3.setAttribute('id','_ico3');_ico4.setAttribute('id','_ico4');_ico5.setAttribute('id','_ico5');_lit1.setAttribute('id','_lit1');_lit2.setAttribute('id','_lit2');_lit3.setAttribute('id','_lit3');_lit4.setAttribute('id','_lit4');_lit5.setAttribute('id','_lit5');var _width = document.body.clientWidth;var _height = document.body.clientHeight;var _dl = document.getElementById('_l');_dl.style.width = _width+"px";_dl.style.height = _height+"px";_dl.style.position = "absolute";_dl.style.top = "0px";_dl.style.left = "0px";_dl.style.filter = "alpha(opacity=50)";_dl.style.background = "#000";var _dd = document.getElementById('_d');_ddw = 730;_ddh = 260;_dd.style.width = _ddw+"px";_dd.style.height = _ddh+"px";_dd.style.position = "absolute";_dd.style.top = "20px";_dd.style.left = ((_width-_ddw)/2)+"px";_dd.style.padding = "20px";_dd.style.background = "#fff";_dd.style.border = "1px solid #ccc";_dd.style.fontFamily = "'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,sans-serif";_dd.style.listStyleType = "none";_dd.style.color = "#4F4F4F";_dd.style.fontSize = "12px";_h.appendChild(document.createTextNode(msg1));var _hd = document.getElementById('_h');_hd.style.display = "block";_hd.style.fontSize = "1.3em";_hd.style.marginBottom = "0.5em";_hd.style.color = "#333";_hd.style.fontFamily = "Helvetica,Arial,sans-serif";_hd.style.fontWeight = "bold";_p1.appendChild(document.createTextNode(msg2));var _p1d = document.getElementById('_p1');_p1d.style.marginBottom = "1em";_p2.appendChild(document.createTextNode(msg3));var _p2d = document.getElementById('_p2');_p2d.style.marginBottom = "1em";var _uld = document.getElementById('_ul');_uld.style.listStyleImage = "none";_uld.style.listStylePosition = "outside";_uld.style.listStyleType = "none";_uld.style.margin = "0 px auto";_uld.style.padding = "0px";_uld.style.paddingLeft = "10px";var _li1d = document.getElementById('_li1');var _li2d = document.getElementById('_li2');var _li3d = document.getElementById('_li3');var _li4d = document.getElementById('_li4');var _li5d = document.getElementById('_li5');var _li1ds = _li1d.style;var _li2ds = _li2d.style;var _li3ds = _li3d.style;var _li4ds = _li4d.style;var _li5ds = _li5d.style;_li1ds.background = _li2ds.background = _li3ds.background = _li4ds.background = _li5ds.background = "transparent url('"+imgPath+"background_browser.gif') no-repeat scroll left top";_li1ds.cursor = _li2ds.cursor = _li3ds.cursor = _li4ds.cursor = _li5ds.cursor = "pointer";_li1d.onclick = function() {window.location = url1 }; _li2d.onclick = function() {window.location = url2 }; _li3d.onclick = function() {window.location = url3 }; _li4d.onclick = function() {window.location = url4 }; _li5d.onclick = function() {window.location = url5 };_l.onclick = function() {_body.removeChild(_l);_body.removeChild(_d);};_li1ds.styleFloat = _li2ds.styleFloat = _li3ds.styleFloat = _li4ds.styleFloat = _li5ds.styleFloat = "left";_li1ds.width = _li2ds.width = _li3ds.width = _li4ds.width = _li5ds.width = "120px";_li1ds.height = _li2ds.height = _li3ds.height = _li4ds.height = _li5ds.height = "122px";_li1ds.margin = _li2ds.margin = _li3ds.margin = _li4ds.margin = _li5ds.margin = "0 10px 10px 0";var _ico1d = document.getElementById('_ico1');var _ico2d = document.getElementById('_ico2');var _ico3d = document.getElementById('_ico3');var _ico4d = document.getElementById('_ico4');var _ico5d = document.getElementById('_ico5');var _ico1ds = _ico1d.style;var _ico2ds = _ico2d.style;var _ico3ds = _ico3d.style;var _ico4ds = _ico4d.style;var _ico5ds = _ico5d.style;_ico1ds.width = _ico2ds.width = _ico3ds.width = _ico4ds.width = _ico5ds.width = "100px";_ico1ds.height = _ico2ds.height = _ico3ds.height = _ico4ds.height = _ico5ds.height = "100px";_ico1ds.margin = _ico2ds.margin = _ico3ds.margin = _ico4ds.margin = _ico5ds.margin = "1px auto";_ico1ds.background = "transparent url('"+imgPath+"browser_ie.gif') no-repeat scroll left top";_ico2ds.background = "transparent url('"+imgPath+"browser_firefox.gif') no-repeat scroll left top";_ico3ds.background = "transparent url('"+imgPath+"browser_safari.gif') no-repeat scroll left top";_ico4ds.background = "transparent url('"+imgPath+"browser_opera.gif') no-repeat scroll left top";_ico5ds.background = "transparent url('"+imgPath+"browser_chrome.gif') no-repeat scroll left top";_lit1.appendChild(document.createTextNode(br1));_lit2.appendChild(document.createTextNode(br2));_lit3.appendChild(document.createTextNode(br3));_lit4.appendChild(document.createTextNode(br4));_lit5.appendChild(document.createTextNode(br5));var _lit1d = document.getElementById('_lit1');var _lit2d = document.getElementById('_lit2');var _lit3d = document.getElementById('_lit3');var _lit4d = document.getElementById('_lit4');var _lit5d = document.getElementById('_lit5');var _lit1ds = _lit1d.style;var _lit2ds = _lit2d.style;var _lit3ds = _lit3d.style;var _lit4ds = _lit4d.style;var _lit5ds = _lit5d.style;_lit1ds.color = _lit2ds.color = _lit3ds.color = _lit4ds.color = _lit5ds.color = "#808080";_lit1ds.fontSize = _lit2ds.fontSize = _lit3ds.fontSize = _lit4ds.fontSize = _lit5ds.fontSize = "0.8em";_lit1ds.height = _lit2ds.height = _lit3ds.height = _lit4ds.height = _lit5ds.height = "18px";_lit1ds.lineHeight = _lit2ds.lineHeight = _lit3ds.lineHeight = _lit4ds.lineHeight = _lit5ds.lineHeight = "17px";_lit1ds.margin = _lit2ds.margin = _lit3ds.margin = _lit4ds.margin = _lit5ds.margin = "1px auto";_lit1ds.width = _lit2ds.width = _lit3ds.width = _lit4ds.width = _lit5ds.width = "118px";_lit1ds.textAlign = _lit2ds.textAlign = _lit3ds.textAlign = _lit4ds.textAlign = _lit5ds.textAlign = "center";}
|
@@ -0,0 +1,184 @@
|
|
1
|
+
module IE6Fixer
|
2
|
+
module Helpers
|
3
|
+
# See the README.txt for an explanation for all helpers.
|
4
|
+
|
5
|
+
FIXED = "ie6_fixer/fixed.js"
|
6
|
+
FIXED_ACTIVE = "ie6_fixer/fixed_active.js"
|
7
|
+
FIXED_BACKGROUND = "body {background:url(/javascripts/ie6_fixer/foo) fixed;}\n"
|
8
|
+
WARNING = "ie6_fixer/warning/warning.js"
|
9
|
+
|
10
|
+
def ie_fixer *args, &block # => A block that is only visible to IE6, IE7 and IE8.
|
11
|
+
versions = "6-8" || args.map { |arg| arg.to_s.gsub("ie", "") }
|
12
|
+
if request.user_agent[/msie\s+[#{versions}]\.\d+/i].present?
|
13
|
+
set_fixes(&block)
|
14
|
+
end
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
# USE:
|
18
|
+
# <% ie_fixer do %>
|
19
|
+
# Only IE6, IE7 and IE8 see this!
|
20
|
+
# <% end %>
|
21
|
+
|
22
|
+
def ie6_fixer &block # => A block that is only visibly to IE6.
|
23
|
+
if request.user_agent[/msie\s+6\.\d+/i].present?
|
24
|
+
set_fixes(&block)
|
25
|
+
end
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
# USE:
|
29
|
+
# <% ie6_fixer do %>
|
30
|
+
# Only IE6 sees this!
|
31
|
+
# <% end %>
|
32
|
+
|
33
|
+
|
34
|
+
def png_fix *args # => Fixes transparent PNG's with CSS3 PIE.
|
35
|
+
args.each do |arg|
|
36
|
+
@styles.push("#{arg} {-pie-png-fix: true; behavior: url(/javascripts/ie6_fixer/PIE.htc);}")
|
37
|
+
end
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
# USE:
|
41
|
+
# <% ie6_fixer do %>
|
42
|
+
# <%= png_fix "#id_name", ".class_name", "#content img" %>
|
43
|
+
# <% end %>
|
44
|
+
|
45
|
+
|
46
|
+
def css3_fix *args # => Fixes some of the CSS3 functions with PIE.htc.
|
47
|
+
args.each do |arg|
|
48
|
+
@styles.push("#{arg} {behavior: url(/javascripts/ie6_fixer/PIE.htc);}\n")
|
49
|
+
end
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
# USE:
|
53
|
+
# <% ie6_fixer do %>
|
54
|
+
# <%= css3_fix "#content", ".footer" %>
|
55
|
+
# <% end %>
|
56
|
+
|
57
|
+
|
58
|
+
def fixed_fix *args # => Allows you to easily use 'position:fixed'. Won't work in combination with css3_fix!
|
59
|
+
options = args.extract_options!
|
60
|
+
@script_sources.push(FIXED) unless @script_sources.include?(FIXED)
|
61
|
+
@styles.push(FIXED_BACKGROUND) unless @styles.include?(FIXED_BACKGROUND)
|
62
|
+
options.each_key do |key|
|
63
|
+
top = ""
|
64
|
+
left = ""
|
65
|
+
top = "top:expression(fixedIE('Top',#{options[key][:top]},this));" if options[key][:top].present?
|
66
|
+
top = "top:expression(fixedIE('Bottom',#{options[key][:bottom]},this));" if options[key][:bottom].present?
|
67
|
+
left = "left:expression(fixedIE('Left',#{options[key][:left]},this));" if options[key][:left].present?
|
68
|
+
left = "left:expression(fixedIE('Right',#{options[key][:right]},this));" if options[key][:right].present?
|
69
|
+
@styles.push("#{key} {position:absolute; #{top} #{left} }\n")
|
70
|
+
end
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
# USE:
|
74
|
+
# <% ie6_fixer do %>
|
75
|
+
# <%= fixed_fix "#header" => { :top => 10, :left => 20 }, ".footer" => { :bottom => 100, :right => 30 } %>
|
76
|
+
# <% end %>
|
77
|
+
|
78
|
+
|
79
|
+
def fixed_fix_active # => Another 'position:fixed' fix. Loads a Javascript file that runs the whole time.
|
80
|
+
@script_sources.push(FIXED_ACTIVE) unless @script_sources.include?(FIXED_ACTIVE)
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
# USE:
|
84
|
+
# <% ie6_fixer do %>
|
85
|
+
# <%= fixed_fix_active %>
|
86
|
+
# <% end %>
|
87
|
+
|
88
|
+
|
89
|
+
def max_fix *args # => Allows you to easily use max-width and max-height.
|
90
|
+
options = args.extract_options!
|
91
|
+
options.each_key do |key|
|
92
|
+
width = ""
|
93
|
+
height = ""
|
94
|
+
width = "width: expression(document.body.clientWidth > #{options[key][:width].to_i} ? '#{options[key][:width]}px' : 'auto');" if options[key][:width].present?
|
95
|
+
height = "height: expression(this.scrollHeight > #{options[key][:height].to_i} ? '#{options[key][:height]}px' : 'auto')" if options[key][:height].present?
|
96
|
+
@styles.push("#{key} {#{width}#{height}}\n")
|
97
|
+
end
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
# USE:
|
101
|
+
# <% ie6_fixer do %>
|
102
|
+
# <%= max_fix "#container" => { :width => 500, :height => 300 }, "#content" => { :height => 500 } %>
|
103
|
+
# <% end %>
|
104
|
+
|
105
|
+
|
106
|
+
def min_fix *args # => Allows you to easily use min-width and min-height.
|
107
|
+
options = args.extract_options!
|
108
|
+
options.each_key do |key|
|
109
|
+
width = ""
|
110
|
+
height = ""
|
111
|
+
width = "width: auto !important; width: #{options[key][:width]}px;" if options[key][:width].present?
|
112
|
+
height = "height: auto !important; height: #{options[key][:height]}px;" if options[key][:height].present?
|
113
|
+
@styles.push("#{key} {#{width}#{height}}\n")
|
114
|
+
end
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
# USE:
|
118
|
+
# <% ie6_fixer do %>
|
119
|
+
# <%= min_fix "#container" => { :width => 500, :height => 300 }, "#content" => { :height => 500 } %>
|
120
|
+
# <% end %>
|
121
|
+
|
122
|
+
|
123
|
+
def warn_ie6 *args # => A helper that shows the user a notification that he/she is using an outdated browser.
|
124
|
+
options = args.extract_options!
|
125
|
+
@script_sources.push(WARNING) unless @script_sources.include?(WARNING)
|
126
|
+
options.each_key do |key|
|
127
|
+
@scripts.push("\t#{key} = '#{options[key]}';\n")
|
128
|
+
end
|
129
|
+
@scripts.push("\twarn_ie6('/javascripts/ie6_fixer/warning/');\n")
|
130
|
+
nil
|
131
|
+
end
|
132
|
+
# USE:
|
133
|
+
# <% ie6_fixer do %>
|
134
|
+
# <%= warn_ie6, :msg1 => "You're using a shitty browser. Please upgrade." %>
|
135
|
+
# <% end %>
|
136
|
+
|
137
|
+
|
138
|
+
def kill_ie6 # => A helper that's just for fun: sets 'display: none' on the body tag. ;)
|
139
|
+
@styles.push("body{display:none !important;}\n")
|
140
|
+
nil
|
141
|
+
end
|
142
|
+
# USE:
|
143
|
+
# <% ie6_fixer do %>
|
144
|
+
# <%= kill_ie6 %>
|
145
|
+
# <% end %>
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def set_fixes &block
|
150
|
+
@styles = []
|
151
|
+
@script_sources = []
|
152
|
+
@scripts = []
|
153
|
+
|
154
|
+
# Set the variables
|
155
|
+
capture(&block)
|
156
|
+
|
157
|
+
if @script_sources.present?
|
158
|
+
concat javascript_include_tag(@script_sources, :cache => "ie6_fixer")
|
159
|
+
concat "\n"
|
160
|
+
end
|
161
|
+
|
162
|
+
if @scripts.present?
|
163
|
+
concat "<script type=\"text/javascript\">\n".html_safe
|
164
|
+
concat "window.onload = function() {\n".html_safe
|
165
|
+
@scripts.each do |script|
|
166
|
+
concat script.html_safe
|
167
|
+
end
|
168
|
+
concat "\n};\n".html_safe
|
169
|
+
concat "</script>\n".html_safe
|
170
|
+
end
|
171
|
+
|
172
|
+
if @styles.present?
|
173
|
+
concat "<style type=\"text/css\">\n".html_safe
|
174
|
+
@styles.each do |style|
|
175
|
+
concat style.html_safe
|
176
|
+
end
|
177
|
+
concat "\n</style>\n".html_safe
|
178
|
+
end
|
179
|
+
|
180
|
+
yield
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|