审查机器

This commit is contained in:
tls 2022-07-06 17:32:53 +08:00
parent cd5529065b
commit 52e0383360
82 changed files with 13517 additions and 0 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
kenengba/审查机器/审查机器 _ 可能吧_files/1.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
kenengba/审查机器/审查机器 _ 可能吧_files/2.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,28 @@
.arpw-ul {
list-style: none;
padding-left: 40px;
padding-right: 14px;
}
.arpw-li {
margin-bottom: 10px;
}
.arpw-time {
display: block;
color: #aaa;
}
.arpw-clearfix:before,
.arpw-clearfix:after {
content: "";
display: table;
}
.arpw-clearfix:after {
clear:both;
}
.arpw-clearfix {
zoom:1;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,51 @@
.recent-comment {
list-style-type: none;
margin-top: 10px;
/*ie fix*/ zoom: 1;
}
.recent-comment:after { content: "."; display: block; height: 0; font-size: 0; line-height: 0; clear: both; visibility: hidden; }
.recent-comment .recent-comment-avatar {
display: none;
}
.recent-comment .avatar {
display: none;
}
.recent-comment .icon-comment {
vertical-align: text-top;
}
.recent-comment-single {
display: block;
margin-left: 0px;
}
.recent-comment-tb .recent-comment-single {
display: inline;
margin-left: 0px;
}
.recent-comment-credit {
font-size: 0.8em;
color: #aaaaaa;
}
.recent-comment-author {
font-weight: bold;
padding-right: 0px;
overflow: hidden;
}
.recent-comment-text {
overflow: hidden;
}
/* ajax nav */
.bwp-rc-ajax-nav {
list-style-type: none;
list-style-position: inside;
text-align: left;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,2 @@
/*! This file is auto-generated */
window.addComment=function(v){var I,C,h,E=v.document,b={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=v.MutationObserver||v.WebKitMutationObserver||v.MozMutationObserver,r="querySelector"in E&&"addEventListener"in v,n=!!E.documentElement.dataset;function t(){d(),e&&new e(o).observe(E.body,{childList:!0,subtree:!0})}function d(e){if(r&&(I=g(b.cancelReplyId),C=g(b.commentFormId),I)){I.addEventListener("touchstart",l),I.addEventListener("click",l);function t(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode)return C.removeEventListener("keydown",t),e.preventDefault(),C.submit.click(),!1}C&&C.addEventListener("keydown",t);for(var n,d=function(e){var t=b.commentReplyClass;e&&e.childNodes||(e=E);e=E.getElementsByClassName?e.getElementsByClassName(t):e.querySelectorAll("."+t);return e}(e),o=0,i=d.length;o<i;o++)(n=d[o]).addEventListener("touchstart",a),n.addEventListener("click",a)}}function l(e){var t,n,d=g(b.temporaryFormId);d&&h&&(g(b.parentIdFieldId).value="0",t=d.textContent,d.parentNode.replaceChild(h,d),this.style.display="none",n=(d=(d=g(b.commentReplyTitleId))&&d.firstChild)&&d.nextSibling,d&&d.nodeType===Node.TEXT_NODE&&t&&(n&&"A"===n.nodeName&&n.id!==b.cancelReplyId&&(n.style.display=""),d.textContent=t),e.preventDefault())}function a(e){var t=g(b.commentReplyTitleId),t=t&&t.firstChild.textContent,n=this,d=m(n,"belowelement"),o=m(n,"commentid"),i=m(n,"respondelement"),r=m(n,"postid"),n=m(n,"replyto")||t;d&&o&&i&&r&&!1===v.addComment.moveForm(d,o,i,r,n)&&e.preventDefault()}function o(e){for(var t=e.length;t--;)if(e[t].addedNodes.length)return void d()}function m(e,t){return n?e.dataset[t]:e.getAttribute("data-"+t)}function g(e){return E.getElementById(e)}return r&&"loading"!==E.readyState?t():r&&v.addEventListener("DOMContentLoaded",t,!1),{init:d,moveForm:function(e,t,n,d,o){var i,r,l,a,m,c,s,e=g(e),n=(h=g(n),g(b.parentIdFieldId)),y=g(b.postIdFieldId),p=g(b.commentReplyTitleId),u=(p=p&&p.firstChild)&&p.nextSibling;if(e&&h&&n){void 0===o&&(o=p&&p.textContent),a=h,m=b.temporaryFormId,c=g(m),s=(s=g(b.commentReplyTitleId))?s.firstChild.textContent:"",c||((c=E.createElement("div")).id=m,c.style.display="none",c.textContent=s,a.parentNode.insertBefore(c,a)),d&&y&&(y.value=d),n.value=t,I.style.display="",e.parentNode.insertBefore(h,e.nextSibling),p&&p.nodeType===Node.TEXT_NODE&&(u&&"A"===u.nodeName&&u.id!==b.cancelReplyId&&(u.style.display="none"),p.textContent=o),I.onclick=function(){return!1};try{for(var f=0;f<C.elements.length;f++)if(i=C.elements[f],r=!1,"getComputedStyle"in v?l=v.getComputedStyle(i):E.documentElement.currentStyle&&(l=i.currentStyle),(i.offsetWidth<=0&&i.offsetHeight<=0||"hidden"===l.visibility)&&(r=!0),"hidden"!==i.type&&!i.disabled&&!r){i.focus();break}}catch(e){}return!1}}}}(window);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
/* HiDPI Gravatar Loader © 2012-2015 by Robert Chapin, license: GPL */
if ((window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI) > 1.4) {
if (document.cookie.indexOf('miqro_srcset=') < 0) {
miqro_srcset_detection();
} else if (document.cookie.indexOf('miqro_srcset=no') >= 0) {
miqro_hidpi_gravatars();
}
document.cookie = 'miqro_hidpi=yes';
}
function miqro_hidpi_gravatars() {
avatars = document.getElementsByClassName('avatar');
for (var i = 0; i < avatars.length; i++) {
if (avatars[i].tagName != 'IMG') continue;
lodpi = avatars[i].src;
if (lodpi.indexOf('.gravatar.com') < 1) continue;
temp = lodpi.indexOf('&s=');
if (temp < 9) temp = lodpi.indexOf('?s=');
if (temp < 9) continue;
temp += 3;
size = parseInt(lodpi.substr(temp));
hidpi = lodpi.substr(0, temp) + size * 2 + lodpi.substr(temp + String(size).length);
temp = hidpi.indexOf('%3Fs%3D');
if (temp < 9) temp = hidpi.indexOf('%26s%3D');
if (temp > 9) {
temp += 7;
size = parseInt(hidpi.substr(temp));
hidpi = hidpi.substr(0, temp) + size * 2 + hidpi.substr(temp + String(size).length);
}
avatars[i].src = hidpi;
}
}
function miqro_srcset_detection() {
testimg = document.createElement("IMG");
supported = '' == testimg.srcset;
if ( supported ) {
document.cookie = 'miqro_srcset=yes';
} else {
miqro_hidpi_gravatars();
document.cookie = 'miqro_srcset=no';
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,18 @@
.rpbt-post-date {
display: block;
font-size: smaller;
}
.rpbt-screen-reader-text {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */
}

View File

@ -0,0 +1,44 @@
( function( $ ) {
// Responsive videos
var all_videos = $( '.entry-content' ).find( 'iframe[src*="player.vimeo.com"], iframe[src*="youtube.com"], iframe[src*="youtube-nocookie.com"], iframe[src*="dailymotion.com"],iframe[src*="kickstarter.com"][src*="video.html"], object, embed' ),
f_height;
all_videos = all_videos.not( 'object object' );
all_videos.each( function() {
var video = $(this);
if ( video.parents( 'object' ).length )
return;
if ( ! video.prop( 'id' ) )
video.attr( 'id', 'rvw' + Math.floor( Math.random() * 999999 ) );
video
.wrap( '<div class="responsive-video-wrapper" style="padding-top: ' + ( video.attr( 'height' ) / video.attr( 'width' ) * 100 ) + '%" />' )
.removeAttr( 'height' )
.removeAttr( 'width' );
} );
// Footer height
$(window)
.resize( function() {
footer_height();
} )
.load( function() {
footer_height();
} );
function footer_height() {
f_height = $( '#footer-content' ).outerHeight() + 1;
$( '#footer' ).css( { height: f_height + 'px' } );
$( '#page' ).css( { marginBottom: -f_height + 'px', paddingBottom: f_height + 'px' } );
}
// Image anchor
$( 'a:has(img)' ).addClass('image-anchor');
$( 'a[href="#"]' ).click( function(e) {
e.preventDefault();
});
} )( jQuery );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
#wpfront-scroll-top-container{display:none;position:fixed;cursor:pointer;z-index:9999}#wpfront-scroll-top-container div.text-holder{padding:3px 10px;border-radius:3px;-webkit-border-radius:3px;-webkit-box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5);-moz-box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5);box-shadow:4px 4px 5px 0 rgba(50,50,50,0.5)}#wpfront-scroll-top-container a{outline-style:none;box-shadow:none;text-decoration:none}

View File

@ -0,0 +1,4 @@
(function(){window.wpfront_scroll_top=function(a){var d=jQuery,c=d("#wpfront-scroll-top-container").css("opacity",0),b={};switch(a.location){case 1:b.right=a.marginX+"px";b.bottom=a.marginY+"px";break;case 2:b.left=a.marginX+"px";b.bottom=a.marginY+"px";break;case 3:b.right=a.marginX+"px";b.top=a.marginY+"px";break;case 4:b.left=a.marginX+"px",b.top=a.marginY+"px"}c.css(b);a.button_width=0==a.button_width?"auto":a.button_width+"px";a.button_height=0==a.button_height?"auto":a.button_height+"px";c.children("img").css({width:a.button_width,
height:a.button_height});if(!a.hide_iframe||d(window).attr("self")===d(window).attr("top")){var e=!1,f=0,h=function(){clearTimeout(f);c.is(":visible")&&c.stop().fadeTo(a.button_fade_duration,0,function(){c.hide();e=!1})},k=function(){a.auto_hide&&(clearTimeout(f),f=setTimeout(function(){h()},1E3*a.auto_hide_after))},g=!1;b=function(){g||(g=!0,d(window).scrollTop()>a.scroll_offset?(c.stop().css("opacity",e?1:a.button_opacity).show(),e||k()):h(),g=!1)};d(window).on("scroll",b);d(document).on("scroll",
b);c.on("mouseenter",function(){clearTimeout(f);e=!0;d(this).css("opacity",1)}).on("mouseleave",function(){d(this).css("opacity",a.button_opacity);e=!1;k()}).on("click",function(b){if("url"===a.button_action)return!0;if("element"===a.button_action){b.preventDefault();var c=d(a.button_action_element_selector).first();b=d(a.button_action_container_selector);c=c.offset();if(null==c)return!1;var e=b.last().offset();if(null==e)return!1;a.button_action_element_offset=parseInt(a.button_action_element_offset);
isNaN(a.button_action_element_offset)&&(a.button_action_element_offset=0);b.animate({scrollTop:c.top-e.top-a.button_action_element_offset},a.scroll_duration);return!1}b.preventDefault();d("html, body").animate({scrollTop:0},a.scroll_duration);return!1})}}})();

View File

@ -0,0 +1,133 @@
/* worth the read styles */
#wtr-progress {
position:fixed;
z-index:99999;
overflow:hidden;
transition:opacity 1s;
opacity:1;
-moz-box-shadow: 0px 0px 2px 3px rgba(0,0,0,.12);
-webkit-box-shadow: 0px 0px 2px 3px rgba(0,0,0,.12);
box-shadow: 0px 0px 2px 3px rgba(0,0,0,.12);
}
#wtr-progress.transparent,
#wtr-progress.noshadow {
-moz-box-shadow:none;
-webkit-box-shadow:none;
box-shadow:none;
}
#wtr-slider {
position:relative;
width:100%;
height:100%;
z-index:2;
transition:background-color .8s;
}
#wtr-progress.mute {
opacity:.5;
}
#wtr-progress-comments {
position:absolute;
width:100%;
height:100%;
z-index:1;
}
#wtr-comments-end {
position:relative;
z-index:-999;
top:-500px;
}
/* placement top */
#wtr-progress.top {
left:0;
width:100%;
}
#wtr-progress.top.wtr-rtl {
left:auto;
right:0;
}
#wtr-progress.top.shown {
top:0!important;
}
.admin-bar #wtr-progress.top.shown {
top:32px!important;
}
@media (max-width: 782px) {
.admin-bar #wtr-progress.top.shown {
top:46px!important;
}
}
@media (max-width: 600px) {
.admin-bar #wtr-progress.top.shown {
top:0px!important;
}
}
#wtr-progress.top #wtr-slider {
top:0;
left:-100%;
}
#wtr-progress.top.wtr-rtl #wtr-slider {
left:auto;
right:-100%;
}
/* placement bottom */
#wtr-progress.bottom {
left:0;
width:100%;
}
#wtr-progress.bottom.wtr-rtl {
left:auto;
right:0;
}
#wtr-progress.bottom.shown {
bottom:0!important;
}
#wtr-progress.bottom #wtr-slider {
bottom:0;
left:-100%;
}
#wtr-progress.bottom.wtr-rtl #wtr-slider {
left:auto;
right:-100%;
}
/* placement left */
#wtr-progress.left {
top:0;
height:100%;
}
#wtr-progress.left.shown {
left:0!important;
}
#wtr-progress.left #wtr-slider {
left:0;
top:-100%;
}
/* placement right */
#wtr-progress.right {
top:0;
height:100%;
}
#wtr-progress.right.shown {
right:0!important;
}
#wtr-progress.right #wtr-slider {
right:0;
top:-100%;
}
/* time commitment */
.wtr-time-wrap {
display:inline-block;
margin:0 10px;
}
.wtr-time-wrap.block,
.wtr-time-wrap.before-content {
display:block;
margin:5px 0;
}
.wtr-time-number {
/* style of the number specifically */
}

View File

@ -0,0 +1,272 @@
jQuery(document).ready(function($) {
//get variables
var $wrap = $('#wtr-content');
if($wrap.length > 0) {
wtrDebug('#wtr-content found');
var $touch = $wrap.data('touch');
var $non_touch = $wrap.data('non-touch');
if((!isTouchDevice() && $non_touch) || (isTouchDevice() && $touch)) {
wtrDebug('touch device check passed');
var $fg = $wrap.data('fg'),
$bg = $wrap.data('bg'),
$placement = $wrap.data('placement'),
$placement_offset = $wrap.data('placement-offset'),
$content_offset = $wrap.data('content-offset'),
$placement_touch = $wrap.data('placement-touch'),
$placement_offset_touch = $wrap.data('placement-offset-touch'),
$width = $wrap.data('width'),
$transparent = $wrap.data('transparent'),
$shadow = $wrap.data('shadow'),
$comments = $wrap.data('comments'),
$comments_bg = $wrap.data('commentsbg'),
$enable = $wrap.data('enable'),
$mute = $wrap.data('mute'),
$fgopacity = $wrap.data('fgopacity'),
$mutedopacity = $wrap.data('mutedopacity'),
$loc = $wrap.data('location'),
$end = $('.wtr-end'),
$rtl = $wrap.data('rtl');
//set some defaults
if($fg === null || $fg === '') $fg = '#ef490f';
if($bg === null || $bg === '') $bg = '#CCCCCC';
if($width === null || $width === '') $width = 4;
if($comments_bg === null || $comments_bg === '') $comments_bg = '#999999';
if($fgopacity === null || $fgopacity === '') $fgopacity = '.6';
if($mutedopacity === null || $mutedopacity === '') $mutedopacity = '.5';
if($transparent) {
$bg = 'none';
$comments_bg = 'none';
}
//get touch vs non-touch options
$placement = isTouchDevice() ? $placement_touch : $placement;
$placement_offset = isTouchDevice() ? $placement_offset_touch : $placement_offset;
var $placement_offset_admin = $placement_offset + getTopOffset();
//setup dom elements and add to page
var $progress_bg = $('<div>', {id: 'wtr-progress', class: $placement});
var $progress_fg = $('<div>', {id: 'wtr-slider'});
$progress_bg.addClass('mute');
//add rtl to wrapper element
if($rtl) $progress_bg.addClass('wtr-rtl');
$progress_bg.css('background', $bg);
if($mute) $progress_bg.css('opacity', $mutedopacity);
$progress_fg.css('background', $fg);
$progress_fg.css('opacity', $fgopacity);
//determine end of content
var $contentHeight = $wrap.outerHeight(true) - $content_offset;
var $endOffset = $end.length > 0 ? $end.offset().top : 0;
var $shorter = $endOffset !== 0 ? ($contentHeight + $wrap.offset().top - $endOffset) : 0;
if($shorter) {
wtrDebug('content height is less than window height - progress bar will not be shown on this page');
} else {
wtrDebug('content height is greater than window height - progress bar will be shown on this page');
}
if($comments && !$shorter) {
wtrDebug('comments check passed');
var $progress_comments = $('<div>', {id: 'wtr-progress-comments'}),
$commentsEnd = $('#wtr-comments-end'),
$progress = $('#wtr-progress'),
$wrap = $loc==='home' ? $('body') : $('#wtr-content'),
winHeight = $(window).height(),
totalHeight = $commentsEnd.offset().top - ($wrap.offset().top + $content_offset - $shorter),
commentsHeight = totalHeight - $contentHeight - (winHeight * .25),
orientation = 'left',
percentage = (100 - ((commentsHeight / totalHeight) * 100));
//if position is right or left then our relative orientation is from the top
if($placement=='left' || $placement=='right') orientation = 'top';
//change orientation to right if rtl option is selected
if($rtl && orientation=='left') orientation = 'right';
//console.log('orientation=' + orientation);
$progress_comments.css(orientation, percentage + '%');
$progress_comments.css('background', $comments_bg);
$progress_bg.append($progress_comments);
}
$progress_bg.append($progress_fg);
if($transparent) $progress_bg.addClass('transparent');
if(!$shadow) $progress_bg.addClass('noshadow');
$('body').append($progress_bg);
wtrDebug('progress bar added to DOM');
//adjust style after it's loaded to the DOM
$hidden_by = $width + 6;
$hidden_by_admin = -$hidden_by + getTopOffset();
$width = $width + 'px';
$hidden_by = '-' + $hidden_by + 'px';
$hidden_by_admin = '-' + $hidden_by_admin + 'px';
$('#wtr-progress.left').css({'width': $width, 'left': $hidden_by});
$('#wtr-progress.right').css({'width': $width, 'right': $hidden_by});
$('#wtr-progress.bottom').css({'height': $width, 'bottom': $hidden_by});
$('#wtr-progress.top').css({'height': $width, 'top': $hidden_by});
$('.admin-bar #wtr-progress.top').css({'height': $width, 'top': $hidden_by_admin});
//if there is an offset, update the "shown" class
if($placement_offset) {
wtrDebug('placement_offset check passed, .shown classes updated');
var $showncss = '<style>' +
'#wtr-progress.top.shown {top:' + $placement_offset + 'px!important;}' +
'.admin-bar #wtr-progress.top.shown {top:' + $placement_offset_admin + 'px!important;}' +
'#wtr-progress.bottom.shown {bottom:' + $placement_offset + 'px!important;}' +
'#wtr-progress.left.shown {left:' + $placement_offset + 'px!important;}' +
'#wtr-progress.right.shown {right:' + $placement_offset + 'px!important;}' +
'</style>';
$($showncss).appendTo('body');
}
}
} else {
wtrDebug('#wtr-content not found');
}
wtrDebug('preparing to call wtrProgress()');
wtrProgress();
});
function wtrDebug(msg) {
if(jQuery('body').hasClass('wtr-debug-bar')) {
jQuery('#wtr-debug-bar').append('<span class="wtr-debug-message">' + msg + '</span>');
}
}
//utility for determining touch devices
function isTouchDevice() {
return 'ontouchstart' in window // works on most browsers
|| window.navigator.msMaxTouchPoints > 0; // works on ie10
}
//finds whether the bottom of the element is in the viewport
function bottomVisible(obj,offset){
var a = obj.offset().top + offset,
b = obj.outerHeight(true),
c = jQuery(window).height(),
d = jQuery(window).scrollTop();
return ((c+d) >= (a+b));
}
//finds whether the top of the element is in the viewport
function topVisible(obj,offset){
var viewportHeight = jQuery(window).height(),
documentScrollTop = jQuery(document).scrollTop(),
minTop = documentScrollTop + offset,
maxTop = documentScrollTop + viewportHeight,
objOffset = obj.offset().top;
return (objOffset >= minTop && objOffset <= maxTop);
}
// check how much admin bar is showing
function getTopOffset() {
topOffset = 0;
var $win = jQuery(window).width();
if(jQuery('#wpadminbar').length > 0) {
if($win < 601) {
topOffset += 0;
} else if($win < 783) {
topOffset += 46;
} else {
topOffset += 32;
}
}
return topOffset;
}
function wtrProgress() {
var $win = jQuery(window),
$wrap = jQuery('#wtr-content'),
$progress = jQuery('#wtr-progress'),
$progress_comments = jQuery('#wtr-progress-comments'),
$slider = jQuery('#wtr-slider'),
$end = jQuery('.wtr-end');
if($wrap.length > 0) {
var $touch = $wrap.data('touch');
var $non_touch = $wrap.data('non-touch');
var $mutedfg = $wrap.data('mutedfg');
var $endfg = $wrap.data('endfg');
var $fg = $wrap.data('fg');
var $rtl = $wrap.data('rtl');
var $endreached = false;
if((!isTouchDevice() && $non_touch) || (isTouchDevice() && $touch)) {
var $loc = $wrap.data('location'),
$contentOffset = $wrap.data('content-offset'),
$wrap = $loc==='home' ? jQuery('body') : jQuery('#wtr-content'),
wrapHeight = $wrap.outerHeight(true) - $contentOffset,
winHeight = $win.height(),
$endOffset = $end.length > 0 ? $end.offset().top : 0,
$shorter = $endOffset !== 0 ? (wrapHeight + $wrap.offset().top - $endOffset) : 0;
//reduce total wrap height if wtr-end shortcode is in place
//console.log($shorter);
wrapHeight -= $shorter;
//we only want to do this if the content is greater than the window height
//thus necessitating a visual progress indicator
if(wrapHeight > winHeight) {
var winScroll = $win.scrollTop(),
wrapOffset = $wrap.offset().top + $contentOffset,
beyond = winScroll - wrapOffset + winHeight * .75,
percentage = 0,
topOffset = getTopOffset(),
orientation = 'left',
$rel = $wrap;
//if position is right or left then our relative orientation is from the top
if($progress.hasClass('left') || $progress.hasClass('right')) orientation = 'top';
//change orientation to right if rtl option is selected
if($rtl && orientation=='left') orientation = 'right';
//do we need to account for comments?
if($progress_comments.length > 0) {
var $commentsEnd = jQuery('#wtr-comments-end'),
totalHeight = $commentsEnd.offset().top - wrapOffset,
commentsHeight = totalHeight - $wrap.outerHeight(true);
wrapHeight = totalHeight;
$rel = $commentsEnd;
}
//use wtr-end shortcode as bottom visible rel if it exists
if($shorter > 0) $rel = $end;
//we are into the content
if(bottomVisible($rel, winHeight * .25)) {
$slider.css(orientation, '0');
$progress.addClass('mute');
$slider.css('background', $endfg);
$endreached = true;
wtrDebug('end of content reached');
} else if(beyond > 0 && winScroll > 0) {
$progress.addClass('shown').removeClass('mute');
$slider.css('background', $fg);
//how far past the start are we?
percentage = -(100 - ((beyond / wrapHeight) * 100)); //get a negative percentage
$slider.css(orientation, percentage + '%');
wtrDebug('progress bar percentage: ' + percentage);
} else {
//console.log('winScroll=' + winScroll + '\nwrapOffset=' + wrapOffset);
$slider.css(orientation, '-100%');
$progress.removeClass('shown').removeClass('mute');
$slider.css('background', $fg);
wtrDebug('content has not been scrolled into yet - hide progress bar');
}
//mute progress bar after inactivity
if(!$endreached) {
clearTimeout(jQuery.data(this, 'scrollTimer'));
jQuery.data(this, 'scrollTimer', setTimeout(function() {
$progress.addClass('mute');
$slider.delay(200).queue(function (next) {
wtrDebug('progress bar muted');
jQuery(this).css('background', $mutedfg);
next();
});
}, 200));
}
} else {
wtrDebug('content height is less than window height - no need to show progress bar');
}
}
}
}
jQuery(window).scroll(function() {
wtrProgress();
});