!function (global) { 'use strict'; function Detect() { this.isMobile = false; this.isFlash = false; this.isBasic = false; this.ua = navigator.userAgent.toLowerCase(); var UNDEF = "undefined", OBJECT = "object", SHOCKWAVE_FLASH = "Shockwave Flash", SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", FLASH_MIME_TYPE = "application/x-shockwave-flash", playerVersion = [0, 0, 0], platform = navigator.platform.toLowerCase(), UA = this.ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0]; if (typeof navigator.plugins !== UNDEF && typeof navigator.plugins[SHOCKWAVE_FLASH] === OBJECT) { var d = navigator.plugins[SHOCKWAVE_FLASH].description; if (d && !(typeof navigator.mimeTypes != UNDEF && navigator.mimeTypes[FLASH_MIME_TYPE] && !navigator.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ var plugin = true; var ie = false; // cascaded feature detection for Internet Explorer d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; } } else if (typeof window.ActiveXObject !== UNDEF) { try { var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); if (a) { // a will return null when ActiveX is disabled d = a.GetVariable("$version"); if (d) { ie = true; // cascaded feature detection for Internet Explorer d = d.split(" ")[1].split(","); playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; } } } catch (e) { } } if (playerVersion[0] === 0 && playerVersion[1] === 0 && playerVersion[2] === 0) { this.flash = false; } else { this.flash = true; } this.publisher = {}; this.publisher.isOn = typeof global.publisher !== 'undefined'; this.browser = {}; this.platform = {}; this.device = {}; //инициализация объекта browser this.browser.name = (UA[1] == 'version') ? UA[3] : UA[1];//из-за специфики юзерагента сафри идем на костыль this.browser.name = this.browser.name == 'unknown' ? 'safari' : this.browser.name; this.browser[this.browser.name] = true; var mode = UA[1] == 'ie' && document.documentMode;//ввиду специфики юзерагента IE - костыль определения версии для него this.browser.version = mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]); //инициализация объекта platform this.platform.name = this.ua.match(/ip(?:ad|od|hone)/) ? 'ios' : this.ua.match(/(?:trident)/) ? 'win' : (this.ua.match(/(?:webos|android|bada|symbian|palm|blackberry)/) || platform.match(/mac|win|linux/) || ['other'])[0]; if((('ontouchstart' in window) || (navigator.MaxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) && this.platform.name === 'win'){ this.platform.name = 'wphone'; } this.platform[this.platform.name] = true; this.platform.version = 0; if (this.platform.mac) { var regRes = this.ua.match(/os\sx\s(\d+[\._]*\d*[\._]*\d*)/); this.platform.version = (Object.prototype.toString.call(regRes) === '[object Array]') && regRes.length > 1 ? regRes[1].split(/[\._]/) : 0; } else if (this.platform.ios) { var regRes = this.ua.match(/os\s(\d+_*\d*_*\d*)/); this.platform.version = (Object.prototype.toString.call(regRes) === '[object Array]') && regRes.length > 1 ? regRes[1].split('_') : 0; } else if (this.platform.android) { var regRes = this.ua.match(/android\s(\d+\.*\d*\.*\d*)/); this.platform.version = (Object.prototype.toString.call(regRes) === '[object Array]') && regRes.length > 1 ? regRes[1].split('.') : 0; } this.platform.verCheck = function (cpVersion) { if (this.platform.version * 1 === cpVersion * 1) { return 0; } else if (cpVersion * 1 > this.platform.version * 1) { return -1; } else { return 1; } }; //инициализация объекта device this.device.name = this.ua.match(/ipad/) ? 'ipad' : this.ua.match(/ipad/) ? 'ipad' : this.ua.match(/iphone/) ? 'iphone' : this.ua.match(/android/) ? 'android' : platform.match(/mac|win|linux/) ? 'pc' : 'other'; if(this.platform.name === 'wphone'){ this.device.name = 'wphone'; } this.device[this.device.name] = true; this.device.version = this.platform.version[0]; this.device.type = this.ua.match(/(mobile\ssafari)|iphone|ipod/) ? 'mobile' : 'tablet'; this.queryString = function () { // This function is anonymous, is executed immediately and // the return value is assigned to QueryString! var query_string = {}; var query = window.location.search.substring(1); if (query === "") return query_string; var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { if (vars[i] === "") continue; var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = pair[1]; // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [query_string[pair[0]], pair[1]]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(pair[1]); } } return query_string; }(); switch (this.queryString.v) { case 'basic': this.isBasic = true; this.isMobile = this.isFlash = false; break; case 'mobile': this.isMobile = true; break; case 'flash': this.isFlash = true; break; } var isIOS = this.platform.ios, isAndroid = this.platform.android && (parseInt(this.platform.version[0], 10) > 4 || (parseInt(this.platform.version[0], 10) === 4 && parseInt(this.platform.version[1], 10) >= 1)), isIOSOnlySafari = isIOS && this.browser.safari, isAndroidOnlyChrome = isAndroid && this.browser.chrome; if (!(this.isBasic || this.isMobile || this.isFlash)) { if ((isIOS || isAndroid) && typeof COMPATIBLE === 'undefined') { this.isMobile = true; } else if (isIOSOnlySafari || isAndroidOnlyChrome) { this.isMobile = true; } else if (this.flash && this.device.pc && (playerVersion[0] > 10 || (playerVersion[0] === 10 && playerVersion[1] >= 3))) { this.isFlash = true; } else { this.isBasic = true; } } this._loadVersion(); if (this.device.android && !this.browser.chrome) { var metas = document.getElementsByTagName('meta'); for (var i = 0; i < metas.length; i++) { if (metas[i].name == "viewport") { document.head.removeChild(metas[i]); } } var andriodOld = this.platform.android && !this.browser.chrome && (parseInt(this.platform.version[0], 10) < 4 || (parseInt(this.platform.version[0], 10) === 4 && parseInt(this.platform.version[1], 10) <= 3)); var prefix = andriodOld ? 1.5 : 1; var content = ('width=device-width, height=device-height, initial-scale=' + (prefix / window.devicePixelRatio) + ', minimum-scale=' + (prefix / window.devicePixelRatio) + ', user-scalable=yes, maximum-scale=2.0' + (andriodOld ? '' : ', target-densitydpi=device-dpi')); if(this.ua.indexOf('gt')){ var content = ('width=device-width, height=device-height, initial-scale=1, minimum-scale=1, user-scalable=yes, maximum-scale=2.0' + (andriodOld ? '' : ', target-densitydpi=device-dpi')); } var meta = document.createElement('meta'); meta.name = 'viewport'; meta.content = content; document.getElementsByTagName('head')[0].appendChild(meta); } var msViewportStyle = document.createElement("style"); msViewportStyle.appendChild( document.createTextNode( "@-ms-viewport{width:" + (window.innerWidth < 640 ? 640 : window.innerWidth) + "px; zoom: 1;}" + "@-moz-viewport{width:" + (window.innerWidth < 640 ? 640 : window.innerWidth) + "px; zoom: 1;} " + " @-webkit-viewport{width:" + (window.innerWidth < 640 ? 640 : window.innerWidth) + "px; zoom: 1;} " + " @-o-viewport{width:" + (window.innerWidth < 640 ? 640 : window.innerWidth) + "px; zoom: 1;}" + " @viewport{width:" + (window.innerWidth < 640 ? 640 : window.innerWidth) + "px; zoom: 1;}" ) ); document.getElementsByTagName("head")[0]. appendChild(msViewportStyle); } Detect.prototype._loadVersion = function () { if ((this.isMobile || this.isFlash) && ((typeof global.IS_DEBUG === 'undefined') || !global.IS_DEBUG) && !this.publisher.isOn) { var mainPage = global.MAIN_PAGE || "index.html"; var url = "../../../" + mainPage; var document = global.document; if (document.domain.indexOf('publ.com') != -1 || document.domain.indexOf('cld.bz') != -1 || document.domain.indexOf('cld.mobi') != -1 || document.domain.indexOf('cld.local') != -1) { url = global.location.protocol + "//" + global.location.host + "/" + global.location.href.split('/')[4]; } var postfix = ""; if (typeof global.CURRENT_PAGE !== 'undefined' && global.CURRENT_PAGE != "1") { postfix += "#" + encodeURIComponent(global.CURRENT_PAGE); } var query = ''; if (this.queryString.v === 'mobile' || this.queryString.v === 'flash') { query = '?v'+this.queryString.v; } window.location = url + query + postfix; } if (!this.device.pc) { global.document.getElementsByTagName("html")[0].setAttribute("class", "isMobile"); } }; global.detector = new Detect(); }(this); !(function (global) { 'use strict'; function BasicPage() { this._popUp(); function getCookie(name) { try { var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)")) return matches ? decodeURIComponent(matches[1]) : undefined } catch (e) { console.log(e); } } //this.currentZoom = parseFloat(getCookie('zoom')); if (typeof this.currentZoom === 'undefined') { this.currentZoom = 1; } this.pageContainer = document.getElementById('pageContainer'); this.pageRect = this._getBoundingClientRect(this.pageContainer); this.mobileMenu = 'close'; this.lastFontSize = 0; this.offset = { right: 0.05, left: 0.05, top: 0.05, bottom: 0.05 }; this.videoFrame = false; this.currentWindowWidth = this._getWindowWidth(); this.currentWindowHeight = this._getWindowHeight(); this._setSizes(); this._fontCorrection(); if (true) { } this._parseVideos(); var that = this; this._addEvent(window, 'resize', function () { if (global.detector.device.pc) { that._setSizes.call(that); that._fontCorrection.call(that); } else { //аналог orientationChange //сделано для того что бы: //1. поддержать старые телефоны //2. в андроидах orientationChange изменения размеров, из-за чего невозможно проверить размеры окна по событию. if ((that.currentWindowWidth < that.currentWindowHeight && that._getWindowWidth.call(that) > that._getWindowHeight.call(that)) || (that.currentWindowWidth > that.currentWindowHeight && that._getWindowWidth.call(that) < that._getWindowHeight.call(that))) { that._setSizes.call(that); that._fontCorrection.call(that); } that.currentWindowWidth = that._getWindowWidth.call(that); that.currentWindowHeight = that._getWindowHeight.call(that); } }); this._zoomButtons(); this._socialButtons(); this._mobileMenu(); if (global.detector.platform.mac && document.getElementById('downloadWindows')) { document.getElementById('downloadWindows').parentNode.removeChild(document.getElementById('downloadWindows')); } else if (global.detector.platform.win && document.getElementById('downloadMac')) { document.getElementById('downloadMac').parentNode.removeChild(document.getElementById('downloadMac')); } else if (global.detector.platform.linux) { if (document.getElementById('downloadWindows')) { document.getElementById('downloadWindows').parentNode.removeChild(document.getElementById('downloadWindows')); } if (document.getElementById('downloadMac')) { document.getElementById('downloadMac').parentNode.removeChild(document.getElementById('downloadMac')); } } if (global.detector.queryString.v === 'basic') { var urls = this._getElementsByClass('internalLink'); for (var i = 0, l = urls.length; i < l; i++) { var currentUrl = urls[i]; currentUrl.href = currentUrl.href + '?v=basic'; } } } BasicPage.prototype._popUp = function () { var hide = function () { document.getElementById('infoPopUp').style.display = 'none'; document.getElementById('popUp').style.display = 'none'; }; var show = function () { document.getElementById('infoPopUp').style.display = 'block'; document.getElementById('popUp').style.display = 'block'; }; this._addEvent(document.getElementById('infoPopUp'), 'click', hide); this._addEvent(document.getElementById('closeButton'), 'click', hide); this._addEvent(document.getElementById('verContainer'), 'click', show); }; BasicPage.prototype._mobileMenu = function () { if (!document.getElementById('mobileMenuButton')) { return } var that = this; if ('ontouchstart' in document.documentElement && !(global.detector.platform.android && !global.detector.browser.chrome && !global.detector.browser.opera && !global.detector.browser.firefox)) { document.getElementById('mobileMenuButton').addEventListener('touchstart', function (event) { event.preventDefault(); event.stopPropagation(); }); document.getElementById('mobileMenuButton').addEventListener('touchend', function (event) { event.stopPropagation(); event.preventDefault(); if (that.mobileMenu === 'close') { that._mobileMenuOpen.call(that); } else { that._mobileMenuClose.call(that); } }); document.getElementById('mainFrame').addEventListener('touchend', function () { event.stopPropagation(); //event.preventDefault(); if (that.mobileMenu === 'close') { return } that._mobileMenuClose.call(that); }); } else { this._addEvent(document.getElementById('mobileMenuButton'), 'click', function () { event.stopPropagation(); event.preventDefault(); if (that.mobileMenu === 'close') { that._mobileMenuOpen.call(that); } else { that._mobileMenuClose.call(that); } }); this._addEvent(document.getElementById('mainFrame'), 'click', function () { if (that.mobileMenu === 'close') { return } that._mobileMenuClose.call(that); }); } }; BasicPage.prototype._mobileMenuOpen = function () { document.getElementById('mainFrame').className = 'mainFrame openMenu'; this.mobileMenu = 'open'; }; BasicPage.prototype._mobileMenuClose = function () { document.getElementById('mainFrame').className = 'mainFrame closeMenu'; this.mobileMenu = 'close'; }; BasicPage.prototype._socialButtons = function (url) { var filesFolder = global.FILES_FOLDER || "files"; var mainPage = global.MAIN_PAGE || "index.html"; if (!document.getElementById('facebookShare')) { return } if (typeof url === 'undefined') { url = window.location.href; var rexp = new RegExp('\/' + filesFolder + '\/.*', 'i'); url = url.replace(rexp, '/' + mainPage); } url = encodeURIComponent(url); var publicationName = encodeURIComponent(global.PUBLICATION_NAME); document.getElementById('facebookShare').setAttribute('href', '//m.facebook.com/sharer.php?u=' + url); document.getElementById('twitterShare').setAttribute('href', '//twitter.com/intent/tweet?text=' + publicationName + '&url=' + url); document.getElementById('linkedinShare').setAttribute('href', '//www.linkedin.com/shareArticle?mini=true&url=' + url + '&title=' + publicationName + '&summary=' + publicationName + '&source=' + url); document.getElementById('tumblrShare').setAttribute('href', '//www.tumblr.com/share/link?url=' + url + '&name=' + publicationName); document.getElementById('googleShare').setAttribute('href', '//plus.google.com/share?url=' + url); document.getElementById('mailShare').setAttribute('href', 'mailto:?subject=' + publicationName + '&body=' + url); document.getElementById('vkShare').setAttribute('href', '//vk.com/share.php?url=' + url + '&title=' + publicationName); }; BasicPage.prototype._zoomButtons = function () { if (!document.getElementById('zoomIn')) { return } if ((window.PointerEvent || 'ontouchstart' in window) && !global.detector.device.pc) { document.getElementById('zoomContainer').parentNode.removeChild(document.getElementById('zoomContainer')); return } var that = this, maxZoom = (this._getWindowWidth() - 100) / this._getFitScreenSizes(this.pageRect.width, this.pageRect.height).width; function setCookie(name, value, expires, domain, secure) { try { if (!name || !value) return false; var str = name + '=' + encodeURIComponent(value); str += '; path=/' if (expires) str += '; expires=' + expires.toGMTString(); if (domain) str += '; domain=' + domain; if (secure) str += '; secure'; document.cookie = str; return true; } catch (e) { console.log(e); } } var d = new Date(); d.setMonth(d.getMonth() + 6); this._addEvent(document.getElementById('zoomIn'), 'click', function () { if (that.currentZoom + 0.2 > maxZoom) { return } that.currentZoom = that.currentZoom + 0.2; that._setSizes.call(that); that._fontCorrection.call(that); //setCookie('zoom', that.currentZoom, d); }); this._addEvent(document.getElementById('zoomOut'), 'click', function () { if (that.currentZoom === 1) { return } that.currentZoom = that.currentZoom - 0.2; that._setSizes.call(that); that._fontCorrection.call(that); setCookie('zoom', that.currentZoom, d); }); }; BasicPage.prototype._getFitScreenSizes = function (origWidth, origHeight, offset) { offset = offset || this._getWindowWidth() * (this.offset.top * 2); offset = Math.round(offset); var screenWidth = this._getWindowWidth(), screenHeight = this._getWindowHeight(), screenRatio = screenWidth / screenHeight, origRatio = origWidth / origHeight, resultWidth = Math.round(screenRatio > origRatio ? origWidth * (screenHeight - offset) / origHeight : screenWidth - offset), resultHeight = Math.round(screenRatio > origRatio ? screenHeight - offset : origHeight * (screenWidth - offset) / origWidth); return { width: Math.round(resultWidth), height: Math.round(resultHeight) } }; BasicPage.prototype._getFitWidthSizes = function (origWidth, origHeight, offset) { offset = offset || this._getBoundingClientRect(document.body).width * (this.offset.top * 2); offset = Math.round(offset); var screenWidth = this._getBoundingClientRect(document.body).width, resultWidth = Math.round(screenWidth - offset), resultHeight = Math.round(origHeight * (screenWidth - offset) / origWidth); return { width: Math.round(resultWidth), height: Math.round(resultHeight) } }; BasicPage.prototype._setSizes = function () { var top = 0, left = 0; if (typeof global.TOC_BOOK_HEIGHT !== 'undefined') { this.newRect = global.detector.device.pc ? this._getFitScreenSizes(this.pageRect.width, global.TOC_BOOK_HEIGHT) : this._getFitWidthSizes(this.pageRect.width, global.TOC_BOOK_HEIGHT); this.pageContainer.style['width'] = (this.newRect.width * this.currentZoom) + 'px'; top = this._getWindowHeight() > this.pageRect.height * this.currentZoom ? (this._getWindowHeight() - this.pageRect.height * this.currentZoom) / 2 : this._getWindowHeight() * this.offset.top; left = this._getWindowWidth() - 100 > this.newRect.width * this.currentZoom ? (this._getWindowWidth() - this.newRect.width * this.currentZoom) / 2 + 'px' : this._getWindowWidth() * this.offset.left + 'px'; } else { this.newRect = global.detector.device.pc ? this._getFitScreenSizes(this.pageRect.width, this.pageRect.height) : this._getFitWidthSizes(this.pageRect.width, this.pageRect.height); this.pageContainer.style['width'] = (this.newRect.width * this.currentZoom) + 'px'; this.pageContainer.style['height'] = (this.newRect.height * this.currentZoom) + 'px'; top = this._getWindowHeight() > this.newRect.height * this.currentZoom ? (this._getWindowHeight() - this.newRect.height * this.currentZoom) / 2 : this._getWindowHeight() * this.offset.top; left = this._getWindowWidth() - 100 > this.newRect.width * this.currentZoom ? (this._getWindowWidth() - this.newRect.width * this.currentZoom) / 2 + 'px' : this._getWindowWidth() * this.offset.left + 'px'; } this.pageContainer.style['left'] = '0'; top = top - 45 > 10 ? top - 45 : 10; if (global.detector.device.type !== 'pc') { top = 20; } this.pageContainer.style['margin'] = top + 'px 0 0 ' + left; this.lastFontSize = ((this.newRect.width * this.currentZoom * 20) / this.pageRect.width).toFixed(6); document.body.style['fontSize'] = this.lastFontSize + 'px'; }; BasicPage.prototype._fontCorrection = function () { var testStrings = this._getElementsByClass('testString'); var MAX_FONT_CORRECTION = 0; for (var i = 0, l = testStrings.length; i < l; i++) { var string = testStrings[i], parent = string.parentNode, stringRect = this._getBoundingClientRect(string), parentRect = this._getBoundingClientRect(parent), docRect = this._getBoundingClientRect(document.getElementById('pageContainer')), q = parentRect.width / docRect.width; var correction = stringRect.width - parentRect.width > 0 ? (stringRect.width - parentRect.width) / parentRect.width : 0; correction = correction * q; MAX_FONT_CORRECTION = MAX_FONT_CORRECTION >= correction ? MAX_FONT_CORRECTION : correction; } //var currentFontSize = this._getComputedStyle(document.body, '').fontSize || this._getComputedStyle(document.body, '').getPropertyValue("fontSize"); document.body.style['fontSize'] = (this.lastFontSize * (1 - MAX_FONT_CORRECTION)) + 'px' }; BasicPage.prototype._parseVideos = function () { var videoArray = this._getElementsByClass('videoItem'), that = this; for (var i = 0, l = videoArray.length; i < l; i++) { var videoItem = videoArray[i], videoProvider = videoItem.getAttribute('class').split(' ')[1], videoID = videoItem.id; (function (videoID, videoProvider) { that._addEvent(videoItem, 'click', function () { that._showVideo.call(that, videoID, videoProvider); }); })(videoID, videoProvider); } this._sizeVideoIcons(); this._addEvent(window, 'resize', function (event) { that._sizeVideoIcons(); }); }; BasicPage.prototype._sizeVideoIcons = function () { var videoArray = this._getElementsByClass('videoItem'), that = this; for (var i = 0, l = videoArray.length; i < l; i++) { var videoItem = videoArray[i], rect = this._getBoundingClientRect(videoItem), icon = this._getElementsByClass("play", videoItem)[0]; if (icon) { var playSize = rect.height > 50 ? rect.height * .35 : rect.height * .8; icon.style["width"] = playSize + 'px'; icon.style["height"] = playSize + 'px'; icon.style["margin"] = (-playSize / 2) + 'px 0 0 ' + (-playSize / 2) + 'px'; } } }; BasicPage.prototype._showVideo = function (id, type) { this.videoFrame = document.createElement('iframe'); var blackout = document.createElement('div'), that = this, rect = this._getFitScreenSizes(1600, 900, (this._getWindowHeight()) / 10); blackout.setAttribute('class', 'blackoutVideo'); document.body.appendChild(blackout); this._addEvent(blackout, 'click', function (event) { event.stopPropagation(); that._hideVideo.call(that); }); if (type === 'youtube') { this.videoFrame.className = this.videoFrame.getAttribute('class') + ' youtube-player'; this.videoFrame.src = 'http://www.youtube.com/embed/' + id + '?autoplay=1&html5=1'; } else { this.videoFrame.src = "http://player.vimeo.com/video/" + id + "?title=0&byline=0&portrait=0&color=da4541"; } document.body.appendChild(this.videoFrame); this._resizeVideo(); this._addEvent(global.document, 'keyup', function (event) { event.stopPropagation(); var code = (event.keyCode ? event.keyCode : event.which); if (code === 27) { that._hideVideo.call(that); } }); this._addEvent(window, 'resize', function (event) { that._resizeVideo(); }); }; BasicPage.prototype._resizeVideo = function () { if (!this.videoFrame) { return; } var rect = this._getFitScreenSizes(1600, 900, (this._getWindowHeight()) / 10); this.videoFrame.setAttribute('class', 'videoFrame'); this.videoFrame.setAttribute('type', 'text/html'); this.videoFrame.setAttribute('width', rect.width + 'px'); this.videoFrame.setAttribute('height', rect.height + 'px'); this.videoFrame.setAttribute('frameBorder', '0'); this.videoFrame.style.top = '50%'; this.videoFrame.style.left = '50%'; this.videoFrame.style.margin = -rect.height / 2 + 'px 0 0 ' + -rect.width / 2 + 'px'; }; BasicPage.prototype._hideVideo = function () { var blackoutsArray = this._getElementsByClass('blackoutVideo'); if (this.videoFrame) { this.videoFrame.parentNode.removeChild(this.videoFrame); } for (var i = 0, l = blackoutsArray.length; i < l; i++) { var blackoutEl = blackoutsArray[i]; blackoutEl.parentNode.removeChild(blackoutEl); } this.videoFrame = false; }; BasicPage.prototype._getBoundingClientRect = function (el) { var rect = el.getBoundingClientRect(); return { width: rect.width || rect.right - rect.left, height: rect.height || rect.bottom - rect.top, left: rect.left, right: rect.right, top: rect.top, bottom: rect.bottom } }; BasicPage.prototype._getWindowWidth = function () { return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; }; BasicPage.prototype._getWindowHeight = function () { return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight }; BasicPage.prototype._getElementsByClass = function (className, parent) { if (typeof parent === 'undefined') { parent = global.document; } if (typeof parent.getElementsByClassName === 'function') { return parent.getElementsByClassName(className); } else { var resultArray = [], arrayOfElements = parent.getElementsByTagName('*'); for (var i in arrayOfElements) { if (Object.prototype.hasOwnProperty.call(arrayOfElements, i) && typeof arrayOfElements[i] === 'object') { var currClassName = arrayOfElements[i].getAttribute('className'), arrayOfClasses = currClassName === null ? [] : currClassName.split(' '); if (this._indexOf(arrayOfClasses, className) !== -1) { resultArray.push(arrayOfElements[i]); } } } return resultArray; } }; // BasicPage.prototype._getComputedStyle = function (el, pseudo) { // if (!global.getComputedStyle) { // return function (el, pseudo) { // this.el = el; // this.getPropertyValue = function (prop) { // var re = /(\-([a-z]){1})/g; // if (prop == 'float') prop = 'styleFloat'; // if (re.test(prop)) { // prop = prop.replace(re, function () { // return arguments[2].toUpperCase(); // }); // } // return el.currentStyle[prop] ? el.currentStyle[prop] : null; // } // return this; // }(el, pseudo); // } // return global.getComputedStyle(el, pseudo); // }; BasicPage.prototype._addEvent = function (el, eveName, callback) { if (window.addEventListener) { el.addEventListener(eveName, callback, true); } else { el.attachEvent('on' + eveName, callback); } }; BasicPage.prototype._indexOf = function (array, item) { if (array == null) return -1; var i, l; for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i; return -1; }; BasicPage.prototype._setFrame = function () { if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) { document.body.style['height'] = this._getWindowHeight() + 'px'; } window.scrollTo(0, 0); }; global.BasicPage = BasicPage; var callback = function () { if (typeof global.BASIC_PAGE === 'undefined') { global.BASIC_PAGE = new BasicPage(); } }; if (window.addEventListener) { global.addEventListener('load', callback, true); } else { global.attachEvent('onload', callback); } })(this);