diff --git a/js/base.js b/js/base.js index 5eacc3db..e165902a 100644 --- a/js/base.js +++ b/js/base.js @@ -7,201 +7,201 @@ "use strict" function addEvent(a, b, c) { -// Attach event to a DOM node. -// Ex. addEvent(node,'click',function); -return (a.addEventListener) ? a.addEventListener(b, c, false) : (a.attachEvent) ? a.attachEvent('on' + b, c) : false; + // Attach event to a DOM node. + // Ex. addEvent(node,'click',function); + return (a.addEventListener) ? a.addEventListener(b, c, false) : (a.attachEvent) ? a.attachEvent('on' + b, c) : false; } function removeEvent(a, b, c) { -// Detach event from a DOM node. -// Ex. removeEvent(node,'click',function); -return (a.removeEventListener) ? a.removeEventListener(b, c, false) : (a.detachEvent) ? a.detachEvent('on' + b, c) : false; + // Detach event from a DOM node. + // Ex. removeEvent(node,'click',function); + return (a.removeEventListener) ? a.removeEventListener(b, c, false) : (a.detachEvent) ? a.detachEvent('on' + b, c) : false; } function cancelEvent(e) { -// Cancel current event. -// Ex. cancelEvent(event); -if (!e) var e = window.event; -(e.preventDefault) ? e.preventDefault() : e.returnValue = false; + // Cancel current event. + // Ex. cancelEvent(event); + if (!e) var e = window.event; + (e.preventDefault) ? e.preventDefault(): e.returnValue = false; } function getEvent(e, a) { -// Return requested event property. -// Ex. var target = getEvent(event, 'target'); -e = (e) ? e : window.event; -switch (a) { + // Return requested event property. + // Ex. var target = getEvent(event, 'target'); + e = (e) ? e : window.event; + switch (a) { case 'type': - return e.type; + return e.type; case 'target': - return (e.target && e.target.nodeType == 3) ? e.target.parentNode : (e.target) ? e.target : e.srcElement; -} + return (e.target && e.target.nodeType == 3) ? e.target.parentNode : (e.target) ? e.target : e.srcElement; + } } function getStyle(a, b) { -// Return the value of the computed style on a DOM node. -// Ex. getStyle(node,'padding-bottom'); -if (window.getComputedStyle) return document.defaultView.getComputedStyle(a, null).getPropertyValue(b); -var n = b.indexOf('-'); -if (n !== -1) b = b.substr(0, n) + b.substr(n + 1, 1).toUpperCase() + b.substr(n + 2); -return a.currentStyle[b]; + // Return the value of the computed style on a DOM node. + // Ex. getStyle(node,'padding-bottom'); + if (window.getComputedStyle) return document.defaultView.getComputedStyle(a, null).getPropertyValue(b); + var n = b.indexOf('-'); + if (n !== -1) b = b.substr(0, n) + b.substr(n + 1, 1).toUpperCase() + b.substr(n + 2); + return a.currentStyle[b]; } function addClass(node, data) { -// Add class to node. -var cl = node.className.split(' '); -for (var i = 0, n = cl.length; i < n; i++) { - if (cl[i] == data) return; -} -cl.push(data); -node.className = cl.join(' '); + // Add class to node. + var cl = node.className.split(' '); + for (var i = 0, n = cl.length; i < n; i++) { + if (cl[i] == data) return; + } + cl.push(data); + node.className = cl.join(' '); } function removeClass(node, data) { -// Remove class from node. -var ocl = node.className.split(' '); -var ncl = []; -for (var i = 0, n = ocl.length; i < n; i++) { - if (ocl[i] != data) ncl.push(ocl[i]); -} -node.className = ncl.join(' '); + // Remove class from node. + var ocl = node.className.split(' '); + var ncl = []; + for (var i = 0, n = ocl.length; i < n; i++) { + if (ocl[i] != data) ncl.push(ocl[i]); + } + node.className = ncl.join(' '); } function supportsSVG() { -// Return true if the browser supports SVG. -// Ex. if(!supportsSVG()){..apply png fallback..} -// Old FF 3.5 and Safari 3 versions have svg support, but a very poor one -// http://www.w3.org/TR/SVG11/feature#Image Defeat FF 3.5 only -// http://www.w3.org/TR/SVG11/feature#Animation Defeat Saf 3 but also returns false in IE9 -// http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute Defeat Saf 3 but also returns false in Chrome and safari4 -// http://www.w3.org/TR/SVG11/feature#Text Defeat Saf 3 but also returns false in FF and safari4 -if (!document.createElementNS || !document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect) return false; -if (!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")) return false; -if (!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute", "1.1") && !document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Animation", "1.1") && !document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Text", "1.1")) return false; -return true; + // Return true if the browser supports SVG. + // Ex. if(!supportsSVG()){..apply png fallback..} + // Old FF 3.5 and Safari 3 versions have svg support, but a very poor one + // http://www.w3.org/TR/SVG11/feature#Image Defeat FF 3.5 only + // http://www.w3.org/TR/SVG11/feature#Animation Defeat Saf 3 but also returns false in IE9 + // http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute Defeat Saf 3 but also returns false in Chrome and safari4 + // http://www.w3.org/TR/SVG11/feature#Text Defeat Saf 3 but also returns false in FF and safari4 + if (!document.createElementNS || !document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect) return false; + if (!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")) return false; + if (!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute", "1.1") && !document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Animation", "1.1") && !document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Text", "1.1")) return false; + return true; } function fallbackSVG() { -// Replace all images extensions from .svg to .png if browser doesn't support SVG files. -if (supportsSVG()) return; -for (var i = 0, nd = document.getElementsByTagName('*'), n = nd.length; i < n; i++) { - if (nd[i].nodeName == 'IMG' && /.*\.svg$/.test(nd[i].src)) nd[i].src = nd[i].src.slice(0, -3) + 'png'; - if (/\.svg/.test(getStyle(nd[i], 'background-image'))) nd[i].style.backgroundImage = getStyle(nd[i], 'background-image').replace('.svg', '.png'); - if (/\.svg/.test(getStyle(nd[i], 'background'))) nd[i].style.background = getStyle(nd[i], 'background').replace('.svg', '.png'); -} + // Replace all images extensions from .svg to .png if browser doesn't support SVG files. + if (supportsSVG()) return; + for (var i = 0, nd = document.getElementsByTagName('*'), n = nd.length; i < n; i++) { + if (nd[i].nodeName == 'IMG' && /.*\.svg$/.test(nd[i].src)) nd[i].src = nd[i].src.slice(0, -3) + 'png'; + if (/\.svg/.test(getStyle(nd[i], 'background-image'))) nd[i].style.backgroundImage = getStyle(nd[i], 'background-image').replace('.svg', '.png'); + if (/\.svg/.test(getStyle(nd[i], 'background'))) nd[i].style.background = getStyle(nd[i], 'background').replace('.svg', '.png'); + } } function onTouchClick(e, callback, callbackClick) { -// Detect and handle clicks using click and touch events while preventing accidental or ghost clicks. -var timeout = 1000, + // Detect and handle clicks using click and touch events while preventing accidental or ghost clicks. + var timeout = 1000, srcEvent = e, touchEndListener = function(e) { - // Call callback if touch events match the patterns of a click. - removeEvent(t, 'touchend', touchEndListener); - setClickTimeout(); - if (Math.abs(e.changedTouches[0].pageX - x) > 20 || Math.abs(e.changedTouches[0].pageY - y) > 20) return; - callback(srcEvent); + // Call callback if touch events match the patterns of a click. + removeEvent(t, 'touchend', touchEndListener); + setClickTimeout(); + if (Math.abs(e.changedTouches[0].pageX - x) > 20 || Math.abs(e.changedTouches[0].pageY - y) > 20) return; + callback(srcEvent); }, wrongClickListener = function(e) { - // Cancel click events on different targets within timeframe. - // This avoids accidental clicks when the page is scrolled or updated due to the 300ms click event delay on mobiles. - removeEvent(document.body, 'click', wrongClickListener); - if (!clickReady() && getEvent(e, 'target') != t) cancelEvent(e); + // Cancel click events on different targets within timeframe. + // This avoids accidental clicks when the page is scrolled or updated due to the 300ms click event delay on mobiles. + removeEvent(document.body, 'click', wrongClickListener); + if (!clickReady() && getEvent(e, 'target') != t) cancelEvent(e); }, setClickTimeout = function() { - // Update timeout during which click events will be blocked. - document.body.setAttribute('data-touchtimeout', new Date().getTime() + timeout); + // Update timeout during which click events will be blocked. + document.body.setAttribute('data-touchtimeout', new Date().getTime() + timeout); }, clickReady = function() { - // Check if timeout during click events are blocked has expired. - var ti = document.body.getAttribute('data-touchtimeout'); - return (ti === null || ti === '' || parseInt(ti, 10) < new Date().getTime()); + // Check if timeout during click events are blocked has expired. + var ti = document.body.getAttribute('data-touchtimeout'); + return (ti === null || ti === '' || parseInt(ti, 10) < new Date().getTime()); }; -if (callbackClick === undefined) callbackClick = function() {}; -// Apply appropriate actions according to each event type. -switch (getEvent(e, 'type')) { - case 'touchstart': - // Save initial touchstart coordinates and listen for touchend events and accidental click events. - var x = e.changedTouches[0].pageX, - y = e.changedTouches[0].pageY, - t = e.changedTouches[0].target; - setClickTimeout(); - addEvent(t, 'touchend', touchEndListener); - addEvent(document.body, 'click', wrongClickListener); - setTimeout(function() { - removeEvent(document.body, 'click', wrongClickListener); - }, timeout); - break; - case 'click': - // Call callback on click in the absence of a recent touchstart event to prevent ghost clicks. - // Always call callbackClick to let it cancel click events on links. - callbackClick(srcEvent); - if (!clickReady()) return; - callback(srcEvent); - break; -} + if (callbackClick === undefined) callbackClick = function() {}; + // Apply appropriate actions according to each event type. + switch (getEvent(e, 'type')) { + case 'touchstart': + // Save initial touchstart coordinates and listen for touchend events and accidental click events. + var x = e.changedTouches[0].pageX, + y = e.changedTouches[0].pageY, + t = e.changedTouches[0].target; + setClickTimeout(); + addEvent(t, 'touchend', touchEndListener); + addEvent(document.body, 'click', wrongClickListener); + setTimeout(function() { + removeEvent(document.body, 'click', wrongClickListener); + }, timeout); + break; + case 'click': + // Call callback on click in the absence of a recent touchstart event to prevent ghost clicks. + // Always call callbackClick to let it cancel click events on links. + callbackClick(srcEvent); + if (!clickReady()) return; + callback(srcEvent); + break; + } } function mobileMenuShow(e) { -// Show the mobile menu when the visitors touch the menu icon. -var show = function() { - var mm = document.getElementById('menusimple'); - var ml = document.getElementById('langselect'); - mm.style.display = ml.style.display = (mm.style.display == 'block') ? '' : 'block'; - addClass(mm, 'menutap'); - cancelEvent(e); - }; -onTouchClick(e, show); + // Show the mobile menu when the visitors touch the menu icon. + var show = function() { + var mm = document.getElementById('menusimple'); + var ml = document.getElementById('langselect'); + mm.style.display = ml.style.display = (mm.style.display == 'block') ? '' : 'block'; + addClass(mm, 'menutap'); + cancelEvent(e); + }; + onTouchClick(e, show); } function mobileMenuHover(e) { -// Prevent mobile menu to shrink on hover to prevent accidental clicks on other entries. -var t = getEvent(e, 'target'), + // Prevent mobile menu to shrink on hover to prevent accidental clicks on other entries. + var t = getEvent(e, 'target'), fn = (t.parentNode.className.indexOf('hover') === -1) ? addClass : removeClass, initHover = function() { - if (t.nodeName != 'A') return; - if (fn == removeClass && !hasSubItems(t)) return; - var p = t; - while (p.parentNode.nodeName == 'UL' || p.parentNode.nodeName == 'LI') p = p.parentNode; - for (var i = 0, nds = p.getElementsByTagName('LI'), n = nds.length; i < n; i++) { - if (nds[i] == t.parentNode) continue; - removeClass(nds[i], 'active'); - if (hasSubItems(nds[i])) continue; - removeClass(nds[i], 'hover'); - } - while (t != p) { - if (t.nodeName == 'LI') { - fn(t, 'hover'); - fn(t, 'active'); - } - t = t.parentNode; - } + if (t.nodeName != 'A') return; + if (fn == removeClass && !hasSubItems(t)) return; + var p = t; + while (p.parentNode.nodeName == 'UL' || p.parentNode.nodeName == 'LI') p = p.parentNode; + for (var i = 0, nds = p.getElementsByTagName('LI'), n = nds.length; i < n; i++) { + if (nds[i] == t.parentNode) continue; + removeClass(nds[i], 'active'); + if (hasSubItems(nds[i])) continue; + removeClass(nds[i], 'hover'); + } + while (t != p) { + if (t.nodeName == 'LI') { + fn(t, 'hover'); + fn(t, 'active'); + } + t = t.parentNode; + } }, hasSubItems = function(t) { - while (t.nodeName != 'LI') t = t.parentNode; - return (t.getElementsByTagName('UL').length > 0); + while (t.nodeName != 'LI') t = t.parentNode; + return (t.getElementsByTagName('UL').length > 0); }, // Prevent clicks on parent element links in the menu. filterClick = function(e) { - var t = getEvent(e, 'target'); - if (t.nodeName != 'A') return; - if (hasSubItems(t)) cancelEvent(e); + var t = getEvent(e, 'target'); + if (t.nodeName != 'A') return; + if (hasSubItems(t)) cancelEvent(e); }; -onTouchClick(e, initHover, filterClick); + onTouchClick(e, initHover, filterClick); } function addAnchorLinks() { -// Apply anchor links icon on each title displayed on CSS hover. -var nodes = []; -var tags = ['H2', 'H3', 'H4', 'H5', 'H6']; -for (var i = 0, n = tags.length; i < n; i++) { - for (var ii = 0, t = document.getElementsByTagName(tags[i]), nn = t.length; ii < nn; ii++) nodes.push(t[ii]); -} -for (var i = 0, n = nodes.length; i < n; i++) { - if (!nodes[i].id) continue; - if (nodes[i].getElementsByTagName('A').length > 0 && nodes[i].getElementsByTagName('A')[0].innerHTML == '') return; - addClass(nodes[i], 'anchorAf'); - var anc = document.createElement('A'); - anc.href = '#' + nodes[i].id; - nodes[i].insertBefore(anc, nodes[i].firstChild); -} + // Apply anchor links icon on each title displayed on CSS hover. + var nodes = []; + var tags = ['H2', 'H3', 'H4', 'H5', 'H6']; + for (var i = 0, n = tags.length; i < n; i++) { + for (var ii = 0, t = document.getElementsByTagName(tags[i]), nn = t.length; ii < nn; ii++) nodes.push(t[ii]); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (!nodes[i].id) continue; + if (nodes[i].getElementsByTagName('A').length > 0 && nodes[i].getElementsByTagName('A')[0].innerHTML == '') return; + addClass(nodes[i], 'anchorAf'); + var anc = document.createElement('A'); + anc.href = '#' + nodes[i].id; + nodes[i].insertBefore(anc, nodes[i].firstChild); + } } diff --git a/js/devsearch.js b/js/devsearch.js index 56462eb5..2d3490a9 100644 --- a/js/devsearch.js +++ b/js/devsearch.js @@ -38,36 +38,36 @@ category: "{{category_name}}" // code adapted from http://jqueryui.com/autocomplete/#categories // MIT license: https://jquery.org/license/ -$.widget( "custom.catcomplete", $.ui.autocomplete, { - _create: function() { - this._super(); - this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" ); - }, - _renderMenu: function( ul, items ) { - var that = this, - currentCategory = ""; - $.each( items, function( index, item ) { - var li; - if ( item.category != currentCategory ) { - ul.append( "
  • " + item.category + "
  • " ); - currentCategory = item.category; - } - li = that._renderItemData( ul, item ); - if ( item.category ) { - li.attr( "aria-label", item.category + " : " + item.label ); - } - }); - } +$.widget("custom.catcomplete", $.ui.autocomplete, { + _create: function() { + this._super(); + this.widget().menu("option", "items", "> :not(.ui-autocomplete-category)"); + }, + _renderMenu: function(ul, items) { + var that = this, + currentCategory = ""; + $.each(items, function(index, item) { + var li; + if (item.category != currentCategory) { + ul.append("
  • " + item.category + "
  • "); + currentCategory = item.category; + } + li = that._renderItemData(ul, item); + if (item.category) { + li.attr("aria-label", item.category + " : " + item.label); + } + }); + } }); $(function() { - $( "#glossary_term" ).catcomplete({ - source: search_data, - delay: 0, - minLength: 2, - autoFocus: true, - select: function( event, ui ) { - location.href = ui.item.uri; - } - }); + $("#glossary_term").catcomplete({ + source: search_data, + delay: 0, + minLength: 2, + autoFocus: true, + select: function(event, ui) { + location.href = ui.item.uri; + } + }); }); {% endraw %} diff --git a/js/events.js b/js/events.js index bf21ef25..ce8d6837 100644 --- a/js/events.js +++ b/js/events.js @@ -7,18 +7,25 @@ layout: null "use strict" -var zoom=2; -var minzoom=1; -if(isMobile())var zoom=minzoom=0; -var map = L.map('eventmap',{ 'zoom': zoom, 'minZoom': minzoom, 'center': [20.00, 10.00]}); +var zoom = 2; +var minzoom = 1; +if (isMobile()) var zoom = minzoom = 0; +var map = L.map('eventmap', { + 'zoom': zoom, + 'minZoom': minzoom, + 'center': [20.00, 10.00] +}); L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: 'Data © by OpenStreetMap contributors.', - maxZoom: 18 + attribution: 'Data © by OpenStreetMap contributors.', + maxZoom: 18 }).addTo(map); -var markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 40}); -for (var i=0, nds=document.getElementById('eventdata').getElementsByTagName('DIV'), n=nds.length; i < n; i++) { - L.marker([parseFloat(nds[i].getAttribute('data-lat')), parseFloat(nds[i].getAttribute('data-lon'))]).bindPopup(nds[i].innerHTML).addTo(markers); +var markers = new L.MarkerClusterGroup({ + showCoverageOnHover: false, + maxClusterRadius: 40 +}); +for (var i = 0, nds = document.getElementById('eventdata').getElementsByTagName('DIV'), n = nds.length; i < n; i++) { + L.marker([parseFloat(nds[i].getAttribute('data-lat')), parseFloat(nds[i].getAttribute('data-lon'))]).bindPopup(nds[i].innerHTML).addTo(markers); } map.addLayer(markers); diff --git a/js/ie.js b/js/ie.js index deb13a57..209a1a66 100644 --- a/js/ie.js +++ b/js/ie.js @@ -3,44 +3,44 @@ "use strict" -function pngfix(){ -//Allows IE6 to render transparent png -var arVersion = navigator.appVersion.split("MSIE") -var version = parseFloat(arVersion[1]) -if ((version >= 5.5) && (document.body.filters)) -{ - for(var i=0; i= 5.5) && (document.body.filters)) + { + for (var i = 0; i < document.images.length; i++) + { var img = document.images[i] var imgName = img.src.toUpperCase() - if (imgName.substring(imgName.length-3, imgName.length) == "PNG") + if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") { - //Workaround to skip github icons - if(img.src.indexOf('gravatar.com')!==-1)continue; - var imgID = (img.id) ? "id='" + img.id + "' " : "" - var imgClass = (img.className) ? "class='" + img.className + " ieimg' " : "class='ieimg' " - var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " - var imgStyle = "display:inline-block;" + img.style.cssText - var imgWidth = img.width; - var imgHeight = img.height; - //Workaround for hidden img to prevent 0px width and height - if(img.src.indexOf('/img/clients/')!==-1){imgWidth='72';imgHeight='72';} - if (img.align == "left") imgStyle = "float:left;" + imgStyle - if (img.align == "right") imgStyle = "float:right;" + imgStyle - if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle - var strNewHTML = "" - img.outerHTML = strNewHTML - i = i-1 + //Workaround to skip github icons + if (img.src.indexOf('gravatar.com') !== -1) continue; + var imgID = (img.id) ? "id='" + img.id + "' " : "" + var imgClass = (img.className) ? "class='" + img.className + " ieimg' " : "class='ieimg' " + var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " + var imgStyle = "display:inline-block;" + img.style.cssText + var imgWidth = img.width; + var imgHeight = img.height; + //Workaround for hidden img to prevent 0px width and height + if (img.src.indexOf('/img/clients/') !== -1) { + imgWidth = '72'; + imgHeight = '72'; + } + if (img.align == "left") imgStyle = "float:left;" + imgStyle + if (img.align == "right") imgStyle = "float:right;" + imgStyle + if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle + var strNewHTML = "" + img.outerHTML = strNewHTML + i = i - 1 } - } -} + } + } } //Let other scripts know browser is IE6-7 -var legacyIE=true; +var legacyIE = true; //Render all transparent pngs -window.onload=pngfix; +window.onload = pngfix; diff --git a/js/main.js b/js/main.js index a72563be..d84bccd2 100644 --- a/js/main.js +++ b/js/main.js @@ -7,316 +7,316 @@ "use strict" function getWidth(a) { -// Return the integer value of the computed width of a DOM node. -// Ex. getWidth(node); -var w = getStyle(a, 'width'); -if (w.indexOf('px') !== -1) return parseInt(w.replace('px', '')); -var p = [getStyle(a, 'padding-top'), getStyle(a, 'padding-right'), getStyle(a, 'padding-bottom'), getStyle(a, 'padding-left')]; -for (var i = 0; i < 4; i++) { - p[i] = (p[i].indexOf('px') !== -1) ? parseInt(p[i]) : 0; -} -return Math.max(0, a.offsetWidth - p[1] - p[3]); + // Return the integer value of the computed width of a DOM node. + // Ex. getWidth(node); + var w = getStyle(a, 'width'); + if (w.indexOf('px') !== -1) return parseInt(w.replace('px', '')); + var p = [getStyle(a, 'padding-top'), getStyle(a, 'padding-right'), getStyle(a, 'padding-bottom'), getStyle(a, 'padding-left')]; + for (var i = 0; i < 4; i++) { + p[i] = (p[i].indexOf('px') !== -1) ? parseInt(p[i]) : 0; + } + return Math.max(0, a.offsetWidth - p[1] - p[3]); } function getHeight(a) { -// Return the integer value of the computed height of a DOM node. -// Ex. getHeight(node); -var h = getStyle(a, 'height'); -if (h.indexOf('px') !== -1) return parseInt(h.replace('px', '')); -var p = [getStyle(a, 'padding-top'), getStyle(a, 'padding-right'), getStyle(a, 'padding-bottom'), getStyle(a, 'padding-left')]; -for (var i = 0; i < 4; i++) { - p[i] = (p[i].indexOf('px') !== -1) ? parseInt(p[i]) : 0; -} -return Math.max(0, a.offsetHeight - p[0] - p[2]); + // Return the integer value of the computed height of a DOM node. + // Ex. getHeight(node); + var h = getStyle(a, 'height'); + if (h.indexOf('px') !== -1) return parseInt(h.replace('px', '')); + var p = [getStyle(a, 'padding-top'), getStyle(a, 'padding-right'), getStyle(a, 'padding-bottom'), getStyle(a, 'padding-left')]; + for (var i = 0; i < 4; i++) { + p[i] = (p[i].indexOf('px') !== -1) ? parseInt(p[i]) : 0; + } + return Math.max(0, a.offsetHeight - p[0] - p[2]); } function getLeft(a) { -// Return the integer value of the computed distance between given node and the browser window. -// Ex. getLeft(node); -var b = a.offsetLeft; -while (a.offsetParent) { - a = a.offsetParent; - b += a.offsetLeft; -} -return b; + // Return the integer value of the computed distance between given node and the browser window. + // Ex. getLeft(node); + var b = a.offsetLeft; + while (a.offsetParent) { + a = a.offsetParent; + b += a.offsetLeft; + } + return b; } -function getTop (a) { -// Return the integer value of the computed distance between given node and the browser window. -// Ex. getTop(node); -var b = a.offsetTop; -while (a.offsetParent) { - a = a.offsetParent; - b += a.offsetTop; -} -return b; +function getTop(a) { + // Return the integer value of the computed distance between given node and the browser window. + // Ex. getTop(node); + var b = a.offsetTop; + while (a.offsetParent) { + a = a.offsetParent; + b += a.offsetTop; + } + return b; } function getPageYOffset() { -// Return the integer value for the vertical position of the scroll bar. -return window.pageYOffset || document.documentElement.scrollTop; + // Return the integer value for the vertical position of the scroll bar. + return window.pageYOffset || document.documentElement.scrollTop; } function getPageXOffset() { -// Return the integer value for the horizontal position of the scroll bar. -return window.pageXOffset || document.documentElement.scrollLeft; + // Return the integer value for the horizontal position of the scroll bar. + return window.pageXOffset || document.documentElement.scrollLeft; } function getWindowY() { -// Return the integer value for the browser window height. -return window.innerHeight || document.documentElement.clientHeight; + // Return the integer value for the browser window height. + return window.innerHeight || document.documentElement.clientHeight; } function getWindowX() { -// Return the integer value for the browser window width. -return window.innerWidth || document.documentElement.clientWidth; + // Return the integer value for the browser window width. + return window.innerWidth || document.documentElement.clientWidth; } function isMobile() { -// Return true if the mobile CSS stylesheet is used. -if (getStyle(document.getElementById('detectmobile'), 'display') != 'none') return true; -return false; + // Return true if the mobile CSS stylesheet is used. + if (getStyle(document.getElementById('detectmobile'), 'display') != 'none') return true; + return false; } function scrollToNode(t) { -// Scroll to any node on the page. -if (document.body.getAttribute('data-scrollstatus') != null) { - clearInterval(document.body.getAttribute('data-scrollstatus')); - document.body.removeAttribute('data-scrollstatus'); -} -var delay = 800; -var py = getPageYOffset(); -var fy = getTop(t) -var dy = fy - py; -var x = getPageXOffset(); -var oti = new Date().getTime(); -document.body.setAttribute('data-scrollstatus', setInterval(function() { - var nti = new Date().getTime() - oti; - if (nti >= delay) { - window.scrollTo(x, fy); - clearInterval(document.body.getAttribute('data-scrollstatus')); - document.body.removeAttribute('data-scrollstatus'); - return; - } - var p = nti / delay; - p = p * (1 + (0.5 * (1 - p))); - window.scrollTo(x, (py + (dy * p)).toFixed(0)); -}, 10)); + // Scroll to any node on the page. + if (document.body.getAttribute('data-scrollstatus') != null) { + clearInterval(document.body.getAttribute('data-scrollstatus')); + document.body.removeAttribute('data-scrollstatus'); + } + var delay = 800; + var py = getPageYOffset(); + var fy = getTop(t) + var dy = fy - py; + var x = getPageXOffset(); + var oti = new Date().getTime(); + document.body.setAttribute('data-scrollstatus', setInterval(function() { + var nti = new Date().getTime() - oti; + if (nti >= delay) { + window.scrollTo(x, fy); + clearInterval(document.body.getAttribute('data-scrollstatus')); + document.body.removeAttribute('data-scrollstatus'); + return; + } + var p = nti / delay; + p = p * (1 + (0.5 * (1 - p))); + window.scrollTo(x, (py + (dy * p)).toFixed(0)); + }, 10)); } function supportCSS(id) { -// Return true if the browser supports given CSS feature. -var domPrefixes = 'Webkit Moz ms O'.split(' '); -var nd = document.createElement('DIV'); -id = id.toLowerCase(); -if (nd.style[id] !== undefined) return true; -idc = id.charAt(0).toUpperCase() + id.substr(1); -for (var i = 0, n = domPrefixes.length; i < n; i++) { - if (nd.style[domPrefixes[i] + idc] !== undefined) return true; -} -return false; + // Return true if the browser supports given CSS feature. + var domPrefixes = 'Webkit Moz ms O'.split(' '); + var nd = document.createElement('DIV'); + id = id.toLowerCase(); + if (nd.style[id] !== undefined) return true; + idc = id.charAt(0).toUpperCase() + id.substr(1); + for (var i = 0, n = domPrefixes.length; i < n; i++) { + if (nd.style[domPrefixes[i] + idc] !== undefined) return true; + } + return false; } function loadYoutubeVideo(e) { -// Load Youtube video on target node on click. -function init(e) { - var t = getEvent(e, 'target'), - nd = document.createElement('IFRAME'); - while (t.getAttribute('data-youtubeurl') === null || t.getAttribute('data-youtubeurl') === '') t = t.parentNode; - nd.src = t.getAttribute('data-youtubeurl'); - nd.setAttribute('frameborder', 0); - nd.setAttribute('allowfullscreen', true); - t.innerHTML = ''; - t.appendChild(nd); - t.onclick = ''; -} -onTouchClick(e, init); + // Load Youtube video on target node on click. + function init(e) { + var t = getEvent(e, 'target'), + nd = document.createElement('IFRAME'); + while (t.getAttribute('data-youtubeurl') === null || t.getAttribute('data-youtubeurl') === '') t = t.parentNode; + nd.src = t.getAttribute('data-youtubeurl'); + nd.setAttribute('frameborder', 0); + nd.setAttribute('allowfullscreen', true); + t.innerHTML = ''; + t.appendChild(nd); + t.onclick = ''; + } + onTouchClick(e, init); } function expandBox(t) { -// Expand or shrink box. -var phe = getHeight(t); -t.style.transition = t.style.MozTransition = t.style.WebkitTransition = 'all 0s ease 0s'; -if (t.className.indexOf('expanded') === -1) addClass(t, 'expanded'); -else removeClass(t, 'expanded'); -t.style.height = ''; -var nhe = getHeight(t); -t.style.height = phe + 'px'; -// Async call to prevent transition from applying on last style.height statement. -setTimeout(function() { - t.style.transition = t.style.MozTransition = t.style.WebkitTransition = ''; - t.style.height = nhe + 'px'; -}, 20); + // Expand or shrink box. + var phe = getHeight(t); + t.style.transition = t.style.MozTransition = t.style.WebkitTransition = 'all 0s ease 0s'; + if (t.className.indexOf('expanded') === -1) addClass(t, 'expanded'); + else removeClass(t, 'expanded'); + t.style.height = ''; + var nhe = getHeight(t); + t.style.height = phe + 'px'; + // Async call to prevent transition from applying on last style.height statement. + setTimeout(function() { + t.style.transition = t.style.MozTransition = t.style.WebkitTransition = ''; + t.style.height = nhe + 'px'; + }, 20); } function boxShow(e) { -// Display the box content when the user click a box on the "Secure your wallet" page. -function init(e) { - var t = getEvent(e, 'target'); - while (t.nodeName != 'DIV') t = t.parentNode; - expandBox(t); - cancelEvent(e); -} -onTouchClick(e, init); + // Display the box content when the user click a box on the "Secure your wallet" page. + function init(e) { + var t = getEvent(e, 'target'); + while (t.nodeName != 'DIV') t = t.parentNode; + expandBox(t); + cancelEvent(e); + } + onTouchClick(e, init); } function faqShow(e) { -// Display the content of a question in the FAQ at user request. -function init(e) { - var t = getEvent(e, 'target'); - while (t.nodeType != 1 || t.nodeName != 'DIV') t = t.nextSibling; - expandBox(t); - cancelEvent(e); -} -onTouchClick(e, init); + // Display the content of a question in the FAQ at user request. + function init(e) { + var t = getEvent(e, 'target'); + while (t.nodeType != 1 || t.nodeName != 'DIV') t = t.nextSibling; + expandBox(t); + cancelEvent(e); + } + onTouchClick(e, init); } function materialShow(e) { -// Display more materials on the "Press center" page at user request. -function init(e) { - var t = getEvent(e, 'target'), - p = t; - while (p.nodeType != 1 || p.nodeName != 'DIV') p = p.parentNode; - expandBox(p); - cancelEvent(e); -} -onTouchClick(e, init); + // Display more materials on the "Press center" page at user request. + function init(e) { + var t = getEvent(e, 'target'), + p = t; + while (p.nodeType != 1 || p.nodeName != 'DIV') p = p.parentNode; + expandBox(p); + cancelEvent(e); + } + onTouchClick(e, init); } function librariesShow(e) { -// Display more open source projects on the "Development" page at user request. -function init(e) { - var t = getEvent(e, 'target'), - p = t; - while (p.nodeType != 1 || p.nodeName != 'UL') p = p.parentNode; - expandBox(p); - cancelEvent(e); -} -onTouchClick(e, init); + // Display more open source projects on the "Development" page at user request. + function init(e) { + var t = getEvent(e, 'target'), + p = t; + while (p.nodeType != 1 || p.nodeName != 'UL') p = p.parentNode; + expandBox(p); + cancelEvent(e); + } + onTouchClick(e, init); } function freenodeShow(e) { -// Display freenode chat window on the "Development" page at user request. -document.getElementById('chatbox').innerHTML = '