|
1 if(typeof(oldIE) == 'undefined') var oldIE = false; |
|
2 |
|
3 $(document).ready(function() { |
|
4 // detect browser |
|
5 var browser = (navigator.userAgent) ? navigator.userAgent : ''; |
|
6 if(typeof(clrIE) == 'boolean') |
|
7 { |
|
8 browser = 'ie'; |
|
9 } |
|
10 else |
|
11 { |
|
12 browser = (browser.indexOf('Opera') >= 0) ? ( |
|
13 (browser.indexOf('Opera Mini/') > 0) ? 'opera-mini' : 'opera') : ( |
|
14 (browser.indexOf('Gecko/') > 0) ? 'mozilla' : ( |
|
15 (browser.indexOf('WebKit/') > 0) ? 'webkit' : ( |
|
16 (browser.indexOf('MSIE') > 0) ? 'ie' : 'unknown' |
|
17 ) |
|
18 ) |
|
19 ); |
|
20 } |
|
21 $('body').addClass('browser-' + browser + ((oldIE) ? ' old-ie transform' : '')); |
|
22 |
|
23 // transformations and test browser |
|
24 if(!oldIE) |
|
25 { |
|
26 var test = document.createElement('canvas'), |
|
27 found = false, |
|
28 list = new Array('MozTransform', 'webkitTransform', 'OTransform', 'transform', 'msTransform'); |
|
29 for(var i=0; i<list.length; i++) |
|
30 { |
|
31 if(typeof(test.style[list[i]]) != 'undefined') found = true; |
|
32 } |
|
33 if(found) $('body').addClass('can-transform'); |
|
34 if(test.style['textShadow'] != 'undefined') $('body').addClass('has-shadows'); |
|
35 delete test; |
|
36 |
|
37 setTimeout("$('body').addClass('transform');", 500); |
|
38 $(window).load(function() { $('body').addClass('transform'); }); |
|
39 } |
|
40 |
|
41 // navigation |
|
42 $('div.nav-extra').not('div.nav-extra-footer').each(function() |
|
43 { |
|
44 var count = 0; |
|
45 $(this).find('a').each(function() { |
|
46 if(count > 0) $(this).before(' • '); |
|
47 count ++; |
|
48 }); |
|
49 if(!count) $(this).css('display', 'none'); |
|
50 }); |
|
51 |
|
52 $('#footer div.nav-links > a').each(function(i) |
|
53 { |
|
54 if(i > 0) $(this).before(' • '); |
|
55 }); |
|
56 |
|
57 // clear divs |
|
58 $('#page-body, #footer').append('<div class="clear"></div>'); |
|
59 $('.cp-mini:last').after('<div class="clear"></div>'); |
|
60 |
|
61 // remove extra lines |
|
62 $('#page-body > hr, #cp-main > hr, #page-body > form > hr').remove(); |
|
63 |
|
64 // unread posts |
|
65 $('dl.icon').each(function() |
|
66 { |
|
67 var bg = $(this).css('background-image'); |
|
68 if(bg.length && bg.indexOf('_unread') > 0) |
|
69 { |
|
70 $(this).parents('li:first').addClass('unread'); |
|
71 } |
|
72 else if(bg.length && bg.indexOf('forum_link') > 0) |
|
73 { |
|
74 $(this).parents('li:first').addClass('forum-link'); |
|
75 } |
|
76 }); |
|
77 |
|
78 // topic title |
|
79 $('body.section-viewtopic #page-body > h2:first').addClass('title'); |
|
80 |
|
81 // index: reported/unapproved topics |
|
82 $('li.row a img').each(function() |
|
83 { |
|
84 if(this.src.indexOf('icon_topic_unapproved') > 0) |
|
85 { |
|
86 $(this).parents('li.row:first').addClass('unapproved'); |
|
87 } |
|
88 }); |
|
89 $('dd.lastpost a img').each(function() |
|
90 { |
|
91 if(this.src.indexOf('icon_topic_unapproved') > 0 || this.src.indexOf('icon_topic_reported') > 0) |
|
92 { |
|
93 var prev = $(this).parents('dl.icon:first').find('dt'); |
|
94 if(!prev.length) return; |
|
95 if(!prev.find('div.extra').length) |
|
96 { |
|
97 prev.prepend('<div class="extra"></div>'); |
|
98 } |
|
99 prev = prev.find('div.extra'); |
|
100 $(this).parent('a').appendTo(prev); |
|
101 } |
|
102 }); |
|
103 |
|
104 // remove rounded block within rounded block |
|
105 $('div.panel div.post, div.panel ul.topiclist, div.panel table.table1, div.panel dl.panel').parents('div.panel').addClass('panel-wrapper'); |
|
106 |
|
107 // tabs |
|
108 $('#tabs, #navigation, #minitabs').each(function() |
|
109 { |
|
110 var last = false, |
|
111 count = 0; |
|
112 $('li', $(this)).each(function(i) |
|
113 { |
|
114 if(i == 0) $(this).addClass('first'); |
|
115 last = $(this); |
|
116 count ++; |
|
117 }); |
|
118 if(count < 2) |
|
119 { |
|
120 $(this).hide(); |
|
121 } |
|
122 else |
|
123 { |
|
124 if(last !== false) last.addClass('last'); |
|
125 $(this).find('hr').remove(); |
|
126 $(this).parents('form').css('display', 'inline'); |
|
127 $(this).append('<div class="clear"></div>'); |
|
128 $(this).find('a').each(function() |
|
129 { |
|
130 if(!$('span', this).length) |
|
131 { |
|
132 $(this).html('<span>' + $(this).html() + '</span>'); |
|
133 } |
|
134 }); |
|
135 } |
|
136 }); |
|
137 $('#navigation').parents('.panel').removeClass('panel').addClass('cp-panel'); |
|
138 |
|
139 // control panel: remove empty boxes |
|
140 $('#cp-main .panel').each(function() |
|
141 { |
|
142 var inner = $(this).find('.inner:first'); |
|
143 if(!inner.length) return; |
|
144 if(inner.children().length < 2) |
|
145 { |
|
146 $(this).hide(); |
|
147 } |
|
148 }); |
|
149 |
|
150 // fix right side margin |
|
151 $('#page-body > p.rightside').each(function() |
|
152 { |
|
153 var next = $(this).next(); |
|
154 if(next.is('p') && !next.hasClass('rightside')) next.css('margin-top', 0); |
|
155 }); |
|
156 |
|
157 // pm post |
|
158 $('.post > div, .panel > div').addClass('inner'); |
|
159 |
|
160 // emulate multiple backgrounds |
|
161 if(oldIE) |
|
162 { |
|
163 $('#header, #footer').wrapInner('<div class="hdr1"><div class="hdr2"><div class="hdr3"><div class="hdr4"><div class="hdr5"><div class="hdr6"></div></div></div></div></div></div>'); |
|
164 $('#footer').wrapInner('<div class="hdr1"><div class="hdr2"></div></div>'); |
|
165 $('div.panel > .inner').addClass('inner-panel'); |
|
166 $('div.forabg, div.forumbg, div.panel-wrapper').not('.cp-panel').addClass('old-ie-wrap-1').wrapInner('<div class="hdr1-1"><div class="hdr1-2"><div class="hdr1-3"><div class="hdr1-4"><div class="hdr1-5"></div></div></div></div></div>'); |
|
167 $('div.post, .panel, .cp-mini, ul.topiclist li').not('.header, .panel-wrapper').addClass('old-ie-wrap-2').wrapInner('<div class="hdr2-1"><div class="hdr2-2"><div class="hdr2-3"><div class="hdr2-4"><div class="hdr2-5"><div class="hdr2-6"><div class="hdr2-last"></div></div></div></div></div></div></div>'); |
|
168 } |
|
169 |
|
170 // search box |
|
171 $('div.search-box input').focus(function() { $(this).parents('.search-box').addClass('focus'); }).blur(function() { $(this).parents('.search-box').removeClass('focus'); }) |
|
172 |
|
173 // header search box |
|
174 $('#search-box form').submit(function() { var value = $('#search-box input:text').val(); return (value == laSearchMini || value == '') ? false : true; }); |
|
175 $('#search-box input:text').focus(function() { |
|
176 if(this.value == laSearchMini) this.value = ''; |
|
177 $('#search-box').addClass('focused'); |
|
178 }).blur(function() { |
|
179 if(this.value == '') this.value = laSearchMini; |
|
180 $('#search-box').removeClass('focused'); |
|
181 }); |
|
182 |
|
183 // old browser warning |
|
184 function hasCookie(search) |
|
185 { |
|
186 var cookie = document.cookie.split(';'); |
|
187 search += '='; |
|
188 for(var i=0; i<cookie.length; i++) |
|
189 { |
|
190 var c = cookie[i]; |
|
191 while (c.charAt(0)==' ') c = c.substring(1,c.length); |
|
192 if (c.indexOf(search) == 0) return true; |
|
193 } |
|
194 return false; |
|
195 } |
|
196 if(oldIE && imagesetLang && !hasCookie('oldie')) |
|
197 { |
|
198 $('body').prepend('<div id="old-browser" style="display: none;"></div>'); |
|
199 $('#old-browser').load(imagesetLang + '/oldie.txt', function() { $('#old-browser').slideDown(); }); |
|
200 } |
|
201 }); |
|
202 |
|
203 $(window).load(function() { |
|
204 // set min width |
|
205 var min = 40; |
|
206 $('#nav-header a, #search-adv, #search-box').each(function() |
|
207 { |
|
208 min += $(this).width() + 20; |
|
209 }); |
|
210 $('body').css('min-width', Math.min( |
|
211 Math.floor(min), |
|
212 Math.floor($('body').width()) |
|
213 ) + 'px'); |
|
214 }); |