1.1 --- a/styles/cubometry-style/template/forum_fn.js Sat Mar 10 00:18:56 2012 +0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,443 +0,0 @@
1.4 -/**
1.5 -* phpBB3 forum functions
1.6 -*/
1.7 -
1.8 -/**
1.9 -* Window popup
1.10 -*/
1.11 -function popup(url, width, height, name)
1.12 -{
1.13 - if (!name)
1.14 - {
1.15 - name = '_popup';
1.16 - }
1.17 -
1.18 - window.open(url.replace(/&/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes, width=' + width);
1.19 - return false;
1.20 -}
1.21 -
1.22 -/**
1.23 -* Jump to page
1.24 -*/
1.25 -function jumpto()
1.26 -{
1.27 - var page = prompt(jump_page, on_page);
1.28 -
1.29 - if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0)
1.30 - {
1.31 - if (base_url.indexOf('?') == -1)
1.32 - {
1.33 - document.location.href = base_url + '?start=' + ((page - 1) * per_page);
1.34 - }
1.35 - else
1.36 - {
1.37 - document.location.href = base_url.replace(/&/g, '&') + '&start=' + ((page - 1) * per_page);
1.38 - }
1.39 - }
1.40 -}
1.41 -
1.42 -/**
1.43 -* Mark/unmark checklist
1.44 -* id = ID of parent container, name = name prefix, state = state [true/false]
1.45 -*/
1.46 -function marklist(id, name, state)
1.47 -{
1.48 - var parent = document.getElementById(id);
1.49 - if (!parent)
1.50 - {
1.51 - eval('parent = document.' + id);
1.52 - }
1.53 -
1.54 - if (!parent)
1.55 - {
1.56 - return;
1.57 - }
1.58 -
1.59 - var rb = parent.getElementsByTagName('input');
1.60 -
1.61 - for (var r = 0; r < rb.length; r++)
1.62 - {
1.63 - if (rb[r].name.substr(0, name.length) == name)
1.64 - {
1.65 - rb[r].checked = state;
1.66 - }
1.67 - }
1.68 -}
1.69 -
1.70 -/**
1.71 -* Resize viewable area for attached image or topic review panel (possibly others to come)
1.72 -* e = element
1.73 -*/
1.74 -function viewableArea(e, itself)
1.75 -{
1.76 - if (!e) return;
1.77 - if (!itself)
1.78 - {
1.79 - e = e.parentNode;
1.80 - }
1.81 -
1.82 - if (!e.vaHeight)
1.83 - {
1.84 - // Store viewable area height before changing style to auto
1.85 - e.vaHeight = e.offsetHeight;
1.86 - e.vaMaxHeight = e.style.maxHeight;
1.87 - e.style.height = 'auto';
1.88 - e.style.maxHeight = 'none';
1.89 - e.style.overflow = 'visible';
1.90 - }
1.91 - else
1.92 - {
1.93 - // Restore viewable area height to the default
1.94 - e.style.height = e.vaHeight + 'px';
1.95 - e.style.overflow = 'auto';
1.96 - e.style.maxHeight = e.vaMaxHeight;
1.97 - e.vaHeight = false;
1.98 - }
1.99 -}
1.100 -
1.101 -/**
1.102 -* Set display of page element
1.103 -* s[-1,0,1] = hide,toggle display,show
1.104 -* type = string: inline, block, inline-block or other CSS "display" type
1.105 -*/
1.106 -function dE(n, s, type)
1.107 -{
1.108 - if (!type)
1.109 - {
1.110 - type = 'block';
1.111 - }
1.112 -
1.113 - var e = document.getElementById(n);
1.114 - if (!s)
1.115 - {
1.116 - s = (e.style.display == '' || e.style.display == type) ? -1 : 1;
1.117 - }
1.118 - e.style.display = (s == 1) ? type : 'none';
1.119 -}
1.120 -
1.121 -/**
1.122 -* Alternate display of subPanels
1.123 -*/
1.124 -function subPanels(p)
1.125 -{
1.126 - var i, e, t;
1.127 -
1.128 - if (typeof(p) == 'string')
1.129 - {
1.130 - show_panel = p;
1.131 - }
1.132 -
1.133 - for (i = 0; i < panels.length; i++)
1.134 - {
1.135 - e = document.getElementById(panels[i]);
1.136 - t = document.getElementById(panels[i] + '-tab');
1.137 -
1.138 - if (e)
1.139 - {
1.140 - if (panels[i] == show_panel)
1.141 - {
1.142 - e.style.display = 'block';
1.143 - if (t)
1.144 - {
1.145 - t.className = 'activetab';
1.146 - }
1.147 - }
1.148 - else
1.149 - {
1.150 - e.style.display = 'none';
1.151 - if (t)
1.152 - {
1.153 - t.className = '';
1.154 - }
1.155 - }
1.156 - }
1.157 - }
1.158 -}
1.159 -
1.160 -/**
1.161 -* Call print preview
1.162 -*/
1.163 -function printPage()
1.164 -{
1.165 - if (is_ie)
1.166 - {
1.167 - printPreview();
1.168 - }
1.169 - else
1.170 - {
1.171 - window.print();
1.172 - }
1.173 -}
1.174 -
1.175 -/**
1.176 -* Show/hide groups of blocks
1.177 -* c = CSS style name
1.178 -* e = checkbox element
1.179 -* t = toggle dispay state (used to show 'grip-show' image in the profile block when hiding the profiles)
1.180 -*/
1.181 -function displayBlocks(c, e, t)
1.182 -{
1.183 - var s = (e.checked == true) ? 1 : -1;
1.184 -
1.185 - if (t)
1.186 - {
1.187 - s *= -1;
1.188 - }
1.189 -
1.190 - var divs = document.getElementsByTagName("DIV");
1.191 -
1.192 - for (var d = 0; d < divs.length; d++)
1.193 - {
1.194 - if (divs[d].className.indexOf(c) == 0)
1.195 - {
1.196 - divs[d].style.display = (s == 1) ? 'none' : 'block';
1.197 - }
1.198 - }
1.199 -}
1.200 -
1.201 -function selectCode(a)
1.202 -{
1.203 - // Get ID of code block
1.204 - var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
1.205 -
1.206 - // Not IE and IE9+
1.207 - if (window.getSelection)
1.208 - {
1.209 - var s = window.getSelection();
1.210 - // Safari
1.211 - if (s.setBaseAndExtent)
1.212 - {
1.213 - s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
1.214 - }
1.215 - // Firefox and Opera
1.216 - else
1.217 - {
1.218 - // workaround for bug # 42885
1.219 - if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
1.220 - {
1.221 - e.innerHTML = e.innerHTML + ' ';
1.222 - }
1.223 -
1.224 - var r = document.createRange();
1.225 - r.selectNodeContents(e);
1.226 - s.removeAllRanges();
1.227 - s.addRange(r);
1.228 - }
1.229 - }
1.230 - // Some older browsers
1.231 - else if (document.getSelection)
1.232 - {
1.233 - var s = document.getSelection();
1.234 - var r = document.createRange();
1.235 - r.selectNodeContents(e);
1.236 - s.removeAllRanges();
1.237 - s.addRange(r);
1.238 - }
1.239 - // IE
1.240 - else if (document.selection)
1.241 - {
1.242 - var r = document.body.createTextRange();
1.243 - r.moveToElementText(e);
1.244 - r.select();
1.245 - }
1.246 -}
1.247 -
1.248 -/**
1.249 -* Play quicktime file by determining it's width/height
1.250 -* from the displayed rectangle area
1.251 -*/
1.252 -function play_qt_file(obj)
1.253 -{
1.254 - var rectangle = obj.GetRectangle();
1.255 -
1.256 - if (rectangle)
1.257 - {
1.258 - rectangle = rectangle.split(',');
1.259 - var x1 = parseInt(rectangle[0]);
1.260 - var x2 = parseInt(rectangle[2]);
1.261 - var y1 = parseInt(rectangle[1]);
1.262 - var y2 = parseInt(rectangle[3]);
1.263 -
1.264 - var width = (x1 < 0) ? (x1 * -1) + x2 : x2 - x1;
1.265 - var height = (y1 < 0) ? (y1 * -1) + y2 : y2 - y1;
1.266 - }
1.267 - else
1.268 - {
1.269 - var width = 200;
1.270 - var height = 0;
1.271 - }
1.272 -
1.273 - obj.width = width;
1.274 - obj.height = height + 16;
1.275 -
1.276 - obj.SetControllerVisible(true);
1.277 - obj.Play();
1.278 -}
1.279 -
1.280 -/**
1.281 -* Check if the nodeName of elem is name
1.282 -* @author jQuery
1.283 -*/
1.284 -function is_node_name(elem, name)
1.285 -{
1.286 - return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
1.287 -}
1.288 -
1.289 -/**
1.290 -* Check if elem is in array, return position
1.291 -* @author jQuery
1.292 -*/
1.293 -function is_in_array(elem, array)
1.294 -{
1.295 - for (var i = 0, length = array.length; i < length; i++)
1.296 - // === is correct (IE)
1.297 - if (array[i] === elem)
1.298 - return i;
1.299 -
1.300 - return -1;
1.301 -}
1.302 -
1.303 -/**
1.304 -* Find Element, type and class in tree
1.305 -* Not used, but may come in handy for those not using JQuery
1.306 -* @author jQuery.find, Meik Sievertsen
1.307 -*/
1.308 -function find_in_tree(node, tag, type, class_name)
1.309 -{
1.310 - var result, element, i = 0, length = node.childNodes.length;
1.311 -
1.312 - for (element = node.childNodes[0]; i < length; element = node.childNodes[++i])
1.313 - {
1.314 - if (!element || element.nodeType != 1) continue;
1.315 -
1.316 - if ((!tag || is_node_name(element, tag)) && (!type || element.type == type) && (!class_name || is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1))
1.317 - {
1.318 - return element;
1.319 - }
1.320 -
1.321 - if (element.childNodes.length)
1.322 - result = find_in_tree(element, tag, type, class_name);
1.323 -
1.324 - if (result) return result;
1.325 - }
1.326 -}
1.327 -
1.328 -var in_autocomplete = false;
1.329 -var last_key_entered = '';
1.330 -
1.331 -/**
1.332 -* Check event key
1.333 -*/
1.334 -function phpbb_check_key(event)
1.335 -{
1.336 - // Keycode is array down or up?
1.337 - if (event.keyCode && (event.keyCode == 40 || event.keyCode == 38))
1.338 - in_autocomplete = true;
1.339 -
1.340 - // Make sure we are not within an "autocompletion" field
1.341 - if (in_autocomplete)
1.342 - {
1.343 - // If return pressed and key changed we reset the autocompletion
1.344 - if (!last_key_entered || last_key_entered == event.which)
1.345 - {
1.346 - in_autocompletion = false;
1.347 - return true;
1.348 - }
1.349 - }
1.350 -
1.351 - // Keycode is not return, then return. ;)
1.352 - if (event.which != 13)
1.353 - {
1.354 - last_key_entered = event.which;
1.355 - return true;
1.356 - }
1.357 -
1.358 - return false;
1.359 -}
1.360 -
1.361 -/**
1.362 -* Usually used for onkeypress event, to submit a form on enter
1.363 -*/
1.364 -function submit_default_button(event, selector, class_name)
1.365 -{
1.366 - // Add which for key events
1.367 - if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode))
1.368 - event.which = event.charCode || event.keyCode;
1.369 -
1.370 - if (phpbb_check_key(event))
1.371 - return true;
1.372 -
1.373 - var current = selector['parentNode'];
1.374 -
1.375 - // Search parent form element
1.376 - while (current && (!current.nodeName || current.nodeType != 1 || !is_node_name(current, 'form')) && current != document)
1.377 - current = current['parentNode'];
1.378 -
1.379 - // Find the input submit button with the class name
1.380 - //current = find_in_tree(current, 'input', 'submit', class_name);
1.381 - var input_tags = current.getElementsByTagName('input');
1.382 - current = false;
1.383 -
1.384 - for (var i = 0, element = input_tags[0]; i < input_tags.length; element = input_tags[++i])
1.385 - {
1.386 - if (element.type == 'submit' && is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1)
1.387 - current = element;
1.388 - }
1.389 -
1.390 - if (!current)
1.391 - return true;
1.392 -
1.393 - // Submit form
1.394 - current.focus();
1.395 - current.click();
1.396 - return false;
1.397 -}
1.398 -
1.399 -/**
1.400 -* Apply onkeypress event for forcing default submit button on ENTER key press
1.401 -* The jQuery snippet used is based on http://greatwebguy.com/programming/dom/default-html-button-submit-on-enter-with-jquery/
1.402 -* The non-jQuery code is a mimick of the jQuery code ;)
1.403 -*/
1.404 -function apply_onkeypress_event()
1.405 -{
1.406 - // jQuery code in case jQuery is used
1.407 - if (jquery_present)
1.408 - {
1.409 - jQuery('form input[type=text], form input[type=password]').live('keypress', function (e)
1.410 - {
1.411 - var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action');
1.412 -
1.413 - if (!default_button || default_button.length <= 0)
1.414 - return true;
1.415 -
1.416 - if (phpbb_check_key(e))
1.417 - return true;
1.418 -
1.419 - if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
1.420 - {
1.421 - default_button.click();
1.422 - return false;
1.423 - }
1.424 -
1.425 - return true;
1.426 - });
1.427 -
1.428 - return;
1.429 - }
1.430 -
1.431 - var input_tags = document.getElementsByTagName('input');
1.432 -
1.433 - for (var i = 0, element = input_tags[0]; i < input_tags.length ; element = input_tags[++i])
1.434 - {
1.435 - if (element.type == 'text' || element.type == 'password')
1.436 - {
1.437 - // onkeydown is possible too
1.438 - element.onkeypress = function (evt) { submit_default_button((evt || window.event), this, 'default-submit-action'); };
1.439 - }
1.440 - }
1.441 -}
1.442 -
1.443 -/**
1.444 -* Detect JQuery existance. We currently do not deliver it, but some styles do, so why not benefit from it. ;)
1.445 -*/
1.446 -var jquery_present = typeof jQuery == 'function';