diff --git a/assets/_src/js/_dnt.js b/assets/_src/js/_dnt.js new file mode 100644 index 0000000..abf646b --- /dev/null +++ b/assets/_src/js/_dnt.js @@ -0,0 +1,46 @@ +/** + * Returns true or false based on whether doNotTack is enabled. It also takes into account the + * anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles + * IE versions on Windows 7, 8 and 8.1, where the DNT implementation does not honor the spec. + * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details + * @params {string} [dnt] - An optional mock doNotTrack string to ease unit testing. + * @params {string} [userAgent] - An optional mock userAgent string to ease unit testing. + * @returns {boolean} true if enabled else false + */ +function _dntEnabled(dnt, userAgent) { + + 'use strict'; + + // for old version of IE we need to use the msDoNotTrack property of navigator + // on newer versions, and newer platforms, this is doNotTrack but, on the window object + // Safari also exposes the property on the window object. + var dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack; + var ua = userAgent || navigator.userAgent; + + // List of Windows versions known to not implement DNT according to the standard. + var anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3']; + + var fxMatch = ua.match(/Firefox\/(\d+)/); + var ieRegEx = /MSIE|Trident/i; + var isIE = ieRegEx.test(ua); + // Matches from Windows up to the first occurance of ; un-greedily + // http://www.regexr.com/3c2el + var platform = ua.match(/Windows.+?(?=;)/g); + + // With old versions of IE, DNT did not exist so we simply return false; + if (isIE && typeof Array.prototype.indexOf !== 'function') { + return false; + } else if (fxMatch && parseInt(fxMatch[1], 10) < 32) { + // Can't say for sure if it is 1 or 0, due to Fx bug 887703 + dntStatus = 'Unspecified'; + } else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) { + // default is on, which does not honor the specification + dntStatus = 'Unspecified'; + } else { + // sets dntStatus to Disabled or Enabled based on the value returned by the browser. + // If dntStatus is undefined, it will be set to Unspecified + dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified'; + } + + return dntStatus === 'Enabled' ? true : false; +} diff --git a/assets/_src/js/ascribe.js b/assets/_src/js/ascribe.js index 66ff5b2..8e34ac2 100644 --- a/assets/_src/js/ascribe.js +++ b/assets/_src/js/ascribe.js @@ -1,9 +1,12 @@ +//=include _dnt.js //=include _faq.js $(document).ready(function(){ - Faq.init(); + if ( $('.subtemplate--faq').length ) { + Faq.init(); + } slider(); marketplaces(); diff --git a/assets/dist/js/ascribe.js b/assets/dist/js/ascribe.js index ea1462a..b3ee68c 100644 --- a/assets/dist/js/ascribe.js +++ b/assets/dist/js/ascribe.js @@ -8,4 +8,4 @@ ** ** https://github.com/ascribe/wp-theme.git **/ -function stickyNav(){var t=$(".sticky");$(window).on("load resize scroll",function(){$(window).width()>768&&($(window).scrollTop()>100?t.addClass("stuck"):t.removeClass("stuck"))})}function mobileNav(){var t=$(".hamburger"),e=$(".mobile-nav");t.click(function(o){o.preventDefault(),e.toggleClass("active"),t.toggleClass("open"),$(document).bind("click.hidepopup",function(){e.removeClass("active"),t.removeClass("open"),$(document).unbind("click.hidepopup")}),e.on("click",function(t){t.stopPropagation()}),o.stopPropagation()})}!function(t){t.fn.smoothScroller=function(e){e=t.extend({},t.fn.smoothScroller.defaults,e);var o=t(this);return t(e.scrollEl).animate({scrollTop:o.offset().top-t(e.scrollEl).offset().top-e.offset},e.speed,e.ease,function(){var t=o.attr("id");t.length&&(document.location.hash=t),o.trigger("smoothScrollerComplete")}),this},t.fn.smoothScroller.defaults={speed:400,ease:"swing",scrollEl:"body,html",offset:0},t("body").on("click","[data-smoothscroller]",function(e){e.preventDefault();var o=t(this).attr("href");0===o.indexOf("#")&&t(o).smoothScroller()})}(jQuery),function(t){var e={};t.fn.toc=function(e){var o,i=this,n=t.extend({},jQuery.fn.toc.defaults,e),s=t(n.container),a=t(n.selectors,s),f=n.activeClass,r=function(){var e=[];return a.each(function(o,i){var s=t(i);e.push(s.offset().top-n.highlightOffset)}),e},l=function(e,o){if(n.smoothScrolling&&"function"==typeof n.smoothScrolling){e.preventDefault();var s=t(e.target).attr("href");n.smoothScrolling(s,n,o)}t("li",i).removeClass(f),t(e.target).parent().addClass(f)},c=function(e){o&&clearTimeout(o),o=setTimeout(function(){var e,o=t(window).scrollTop(),s=Number.MAX_VALUE,a=0;offsets=r();for(var l=0,c=offsets.length;c>l;l++){var h=Math.abs(offsets[l]-o);s>h&&(a=l,s=h)}t("li",i).removeClass(f),e=t("li:eq("+a+")",i).addClass(f),n.onHighlight(e)},50)};return n.highlightOnScroll&&(t(window).bind("scroll",c),c()),this.each(function(){var e=t(this),o=t(n.listType);a.each(function(i,s){var a=t(s),f=n.anchorName(i,s,n.prefix);if(s.id!==f){t("").attr("id",f).insertBefore(a)}var r=t("").text(n.headerText(i,s,a)).attr("href","#"+f).bind("click",function(o){t(window).unbind("scroll",c),l(o,function(){t(window).bind("scroll",c)}),e.trigger("selected",t(this).attr("href"))}),h=t("
  • ").addClass(n.itemClass(i,s,a,n.prefix)).append(r);o.append(h)}),e.html(o)})},jQuery.fn.toc.defaults={container:"body",listType:"