@uf-onbrand/onbrand-utility-functions-tv2
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("onbrandUtilityFunctions",[],e):"object"==typeof exports?exports.onbrandUtilityFunctions=e():t.onbrandUtilityFunctions=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},o.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";e.checkPageType=function(){return document.body.classList[0]},e.blockCTAFix=function(t){var e=document.getElementById("uf-gated-cta-wrapper"),o=this.getTopNavBuffer(t);if(e){var n=e.offsetHeight/2,i=document.getElementById("uf-item-container"),r=i.getBoundingClientRect().top+document.body.scrollTop,c=i.offsetTop+i.offsetHeight,s=window.innerHeight/2,a=window.pageYOffset+s;!function(t,e){for(var o in e)t.style[o]=e[o]}(e,a-n<r?{position:"absolute",top:"0",margin:"0",transform:"translate(-50%, "+o/3+"px)"}:a+n>c?{position:"absolute",margin:"0",top:c-e.offsetHeight-n+"px",transform:"translate(-50%, -50%)"}:{position:"fixed",transform:"translate(-50%, -50%)",top:"",marginTop:o/3+"px"})}},e.fadeOutItem=function(){var t=document.getElementById("uf-prev-next-items");if("uf-item-page"===checkPageType()&&document.getElementById("uf-prev-next-items").classList.contains("uf-next-item-flyout")&&t){var e=document.getElementById("injected-footer")?document.getElementById("injected-footer").offsetHeight:0,o=document.body.scrollHeight-window.innerHeight-(e+window.innerHeight),n=document.querySelector("#uf-prev-next-items.uf-next-item-flyout .uf-next-link"),i=Math.ceil(n.getBoundingClientRect().top);document.body.classList.contains("uf-has-cta-beside")?Math.ceil(document.getElementById("uf-cta-beside").getBoundingClientRect().bottom)>i||window.scrollY>o?n.style.opacity="0":n.style.opacity="1":window.scrollY>o?n.style.opacity="0":n.style.opacity="1"}},e.devMode=function(){console.log(" "),console.log(" "),console.warn("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"),console.warn(" Hey OnBrander, we're in dev mode!"),console.warn(" Info on the utility functions can be found here: https://obdocs.herokuapp.com/ob/tools/utility-functions-tv2.html"),console.warn("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"),console.log(" "),console.log(" ")},e.recoEnginePosition=function(t){var e=document.getElementById("uf-reco-panel");if(e)try{var o=t?document.querySelector(""+t):document.getElementById("injected-footer"),n=parseInt(e.style.top),i=Math.ceil(o.getBoundingClientRect().top)-n;e.style.height=i+"px"}catch(e){console.warn("recoEnginePositioning() has failed - the error thrown was:"),console.error(e),console.warn("The bottom target used was: "+t)}},e.getTopNavBuffer=function(t){var e=void 0;if(t)e=t;else{var o=document.getElementById("injected-header"),n=document.getElementById("uf-top-nav-container"),i=getComputedStyle(o).position,r=getComputedStyle(n).position;e=("fixed"===i||"sticky"===i?o.offsetHeight:0===o.height?document.querySelector("#injected-header > *").offsetHeight:0)+("fixed"===r||"sticky"===r?n.offsetHeight:0)}return e},e.sideCtaFix=function(t){var e=this.getTopNavBuffer(t),o=document.getElementById("uf-cta-beside");if(window.innerWidth>1351&&o){var n=o.childNodes[1],i=n.offsetHeight,r=document.getElementById("main-content"),c=r.offsetHeight,s=Math.ceil(r.getBoundingClientRect().top),a=Math.ceil(r.getBoundingClientRect().bottom);document.getElementById("uf-article").style.position="static",n.style.position="static",s-e<=0&&(n.style.position="fixed",n.style.top=e+"px"),a<=i+e&&(n.style.position="relative",n.style.top=c-i+"px")}else window.innerWidth<1351&&o&&o.childNodes[1].removeAttribute("style")},e.addThisFix=function(t){var e=this.getTopNavBuffer(t);if(window.innerWidth>980){var o=window.scrollY,n=document.querySelector("#at4-share");if(n){var i=n.offsetHeight,r=window.innerHeight/2,c=document.querySelector(".uf-main-content"),s=c.getBoundingClientRect().top+o,a=c.getBoundingClientRect().top+o+c.offsetHeight;n.setAttribute("style","top: "+(s-o)+"px !important;"),o+e>s&&o+e+i<a&&n.setAttribute("style","top: "+(e+r)+"px !important"),o+e+i>a&&n.setAttribute("style","top: "+(a-i-o)+"px !important")}}},e.checkStreamID=function(t){return Number(document.body.dataset.streamId)===t},e.streamTraverse=function(t,e,o){var n=!1,i=t.map(String);return e&&o?i.forEach(function(t){document.body.dataset.sourceStreamId===t&&(n=!0)}):e&&!o?i.forEach(function(t){document.body.dataset.streamId===t&&(n=!0)}):document.body.classList.contains("uf-stream-page")&&i.forEach(function(t){document.body.dataset.streamId===t&&(n=!0)}),n},e.streamCustomization=function(t,e){t.map(String).forEach(function(t){document.body.dataset.streamId===t&&e()})},e.createElem=function(t,e,o){var n=document.createElement(t);return void 0!==e&&Object.keys(e).forEach(function(t){n.setAttribute(t,e[t])}),void 0!==o&&(n.innerHTML=o),n}}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("onbrandUtilityFunctions",[],e):"object"==typeof exports?exports.onbrandUtilityFunctions=e():t.onbrandUtilityFunctions=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},o.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";e.checkPageType=function(){return document.body.classList[0]},e.blockCTAFix=function(t){var e=document.getElementById("uf-gated-cta-wrapper"),o=this.getTopNavBuffer(t);if(e){var n=e.offsetHeight/2,i=document.getElementById("uf-item-container"),r=i.getBoundingClientRect().top+document.body.scrollTop,c=i.offsetTop+i.offsetHeight,s=window.innerHeight/2,a=window.pageYOffset+s;!function(t,e){for(var o in e)t.style[o]=e[o]}(e,a-n<r?{position:"absolute",top:"0",margin:"0",transform:"translate(-50%, "+o/3+"px)"}:a+n>c?{position:"absolute",margin:"0",top:c-e.offsetHeight-n+"px",transform:"translate(-50%, -50%)"}:{position:"fixed",transform:"translate(-50%, -50%)",top:"",marginTop:o/3+"px"})}},e.fadeOutItem=function(){var t=document.getElementById("uf-prev-next-items");if("uf-item-page"===this.checkPageType()&&document.getElementById("uf-prev-next-items").classList.contains("uf-next-item-flyout")&&t){var e=document.getElementById("injected-footer")?document.getElementById("injected-footer").offsetHeight:0,o=document.body.scrollHeight-window.innerHeight-(e+window.innerHeight),n=document.querySelector("#uf-prev-next-items.uf-next-item-flyout .uf-next-link"),i=Math.ceil(n.getBoundingClientRect().top);document.body.classList.contains("uf-has-cta-beside")?Math.ceil(document.getElementById("uf-cta-beside").getBoundingClientRect().bottom)>i||window.scrollY>o?n.style.opacity="0":n.style.opacity="1":window.scrollY>o?n.style.opacity="0":n.style.opacity="1"}},e.devMode=function(){console.log(" "),console.log(" "),console.warn("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"),console.warn(" Hey OnBrander, we're in dev mode!"),console.warn(" Info on the utility functions can be found here: https://obdocs.herokuapp.com/ob/tools/utility-functions-tv2.html"),console.warn("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"),console.log(" "),console.log(" ")},e.recoEnginePosition=function(t){var e=document.getElementById("uf-reco-panel");if(e)try{var o=t?document.querySelector(""+t):document.getElementById("injected-footer"),n=parseInt(e.style.top),i=Math.ceil(o.getBoundingClientRect().top)-n;e.style.height=i+"px"}catch(e){console.warn("recoEnginePositioning() has failed - the error thrown was:"),console.error(e),console.warn("The bottom target used was: "+t)}},e.getTopNavBuffer=function(t){var e=void 0;if(t)e=t;else{var o=document.getElementById("injected-header"),n=document.getElementById("uf-top-nav-container"),i=getComputedStyle(o).position,r=getComputedStyle(n).position;e=("fixed"===i||"sticky"===i?o.offsetHeight:0===o.height?document.querySelector("#injected-header > *").offsetHeight:0)+("fixed"===r||"sticky"===r?n.offsetHeight:0)}return e},e.sideCtaFix=function(t){var e=this.getTopNavBuffer(t),o=document.getElementById("uf-cta-beside");if(window.innerWidth>1351&&o){var n=o.childNodes[1],i=n.offsetHeight,r=document.getElementById("main-content"),c=r.offsetHeight,s=Math.ceil(r.getBoundingClientRect().top),a=Math.ceil(r.getBoundingClientRect().bottom);document.getElementById("uf-article").style.position="static",n.style.position="static",s-e<=0&&(n.style.position="fixed",n.style.top=e+"px"),a<=i+e&&(n.style.position="relative",n.style.top=c-i+"px")}else window.innerWidth<1351&&o&&o.childNodes[1].removeAttribute("style")},e.addThisFix=function(t){var e=this.getTopNavBuffer(t);if(window.innerWidth>980){var o=window.scrollY,n=document.querySelector("#at4-share");if(n){var i=n.offsetHeight,r=window.innerHeight/2,c=document.querySelector(".uf-main-content"),s=c.getBoundingClientRect().top+o,a=c.getBoundingClientRect().top+o+c.offsetHeight;n.setAttribute("style","top: "+(s-o)+"px !important;"),o+e>s&&o+e+i<a&&n.setAttribute("style","top: "+(e+r)+"px !important"),o+e+i>a&&n.setAttribute("style","top: "+(a-i-o)+"px !important")}}},e.checkStreamID=function(t){return Number(document.body.dataset.streamId)===t},e.streamTraverse=function(t,e,o){var n=!1,i=t.map(String);return e&&o?i.forEach(function(t){document.body.dataset.sourceStreamId===t&&(n=!0)}):e&&!o?i.forEach(function(t){document.body.dataset.streamId===t&&(n=!0)}):document.body.classList.contains("uf-stream-page")&&i.forEach(function(t){document.body.dataset.streamId===t&&(n=!0)}),n},e.streamCustomization=function(t,e){t.map(String).forEach(function(t){document.body.dataset.streamId===t&&e()})},e.createElem=function(t,e,o){var n=document.createElement(t);return void 0!==e&&Object.keys(e).forEach(function(t){n.setAttribute(t,e[t])}),void 0!==o&&(n.innerHTML=o),n}}])}); | ||
//# sourceMappingURL=onbrandUtilityFunctions.bundle.js.map |
{ | ||
"name": "@uf-onbrand/onbrand-utility-functions-tv2", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "A collection of useful reusable functions for working with uberflip TV2 hubs, to be included on an as-needed basis.", | ||
@@ -5,0 +5,0 @@ "main": "build/onbrandUtilityFunctions.bundle.js", |
@@ -13,9 +13,9 @@ # The Onbrand Utility Function Library for Themes V2 | ||
This library depends on jQuery. At the time of writing this, jQuery is included in all Uberflip Hubs, and so this module should be usable without importing jQuery separately. | ||
The utility functions for TV2 no longer rely on jQuery. They are all written in vanilla Javscript and come packaged with a babel-polyfill bundle for maximum browser compatability. | ||
Typically, this library would be automatically included when generating a new onbrand project. The library is to be installed via npm `npm install @uf-onbrand/onbrand-utility-functions-tv2`, then refferenced in your scripts via import. Here is a simple example: | ||
Typically, this library would be automatically included when generating a new onbrand project. In any existing TV2 project ensure that `"@uf-onbrand/onbrand-utility-functions-tv2":` exists within the dependencies object in the project's `package.json` file. Ensure it is the most up-to-date version as well. | ||
import onbrandutilityfunctions from '@uf-onbrand/onbrand-utility-functions-tv2'; | ||
onbrandutilityfunctions.doIfTag('someTag', someFunc); | ||
Once dependencies are made for the project, referenced the functions in your scripts via import. Here is a simple example: | ||
These functions should be run through babel.js to ensure maximum compatibility. | ||
require('./node_modules/@uf-onbrand/onbrand-utility-functions-tv2/build/conditional-babel-polyfill.bundle'); | ||
const onbrandUtilityFunctions = require('./node_modules/@uf-onbrand/onbrand-utility-functions-tv2/build/onbrandUtilityFunctions.bundle'); |
Sorry, the diff of this file is not supported yet
559491