Fixing remaining broken js files. Collect static command now works as expected.

This commit is contained in:
Samuel Clay 2021-11-26 16:44:11 -05:00
parent fd31c534e8
commit b71f383122
9 changed files with 607 additions and 93 deletions

View file

@ -16,6 +16,7 @@
"ansible/playbooks/*/*": true, "ansible/playbooks/*/*": true,
"archive/*": true, "archive/*": true,
"logs/*": true, "logs/*": true,
"static/*": true,
"media/fonts": true, "media/fonts": true,
"static/*.css": true, "static/*.css": true,
"static/*.js": true, "static/*.js": true,

View file

@ -61,6 +61,7 @@ server {
} }
location /static/ { location /static/ {
gzip_static on;
expires max; expires max;
keepalive_timeout 1; keepalive_timeout 1;
root /srv/newsblur; root /srv/newsblur;

View file

@ -64,6 +64,7 @@ server {
} }
location /static/ { location /static/ {
gzip_static on;
expires max; expires max;
keepalive_timeout 1; keepalive_timeout 1;
root /srv/newsblur; root /srv/newsblur;

View file

@ -7,20 +7,27 @@
scripts = document.getElementsByTagName('script'); scripts = document.getElementsByTagName('script');
for (var i = 0, ii = scripts.length; i < ii; i++) { for (var i = 0, ii = scripts.length; i < ii; i++) {
var path = scripts[i].getAttribute('src'); var path = scripts[i].getAttribute('src');
if(re.test(path)) return path.replace(re, ''); if(re.test(path))
{
var f = path.split ( '/' );
f.pop ();
return f.join ( '/' ) + '/';
}
} }
// when no script found, an empty string causes the least confusion.
return '';
})(); })();
// ##The audiojs interface // ##The audiojs interface
// This is the global object which provides an interface for creating new `audiojs` instances. // This is the global object which provides an interface for creating new `audiojs` instances.
// It also stores all of the construction helper methods and variables. // It also stores all of the construction helper methods and variables.
container[audiojs] = { container[audiojs] = {
instanceCount: 0, instanceCount: 0,
instances: {}, instances: {},
// The markup for the swf. It is injected into the page if there is not support for the `<audio>` element. The `$n`s are placeholders. // The markup for the swf. It is injected into the page if there is not support for the `<audio>` element. The `$n`s are placeholders.
// `$1` The name of the flash movie // `$1` The name of the flash movie
// `$2` The path to the swf // `$2` The path to the swf
// `$3` Cache invalidation // `$3` Cache invalidation
flashSource: '\ flashSource: '\
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="$1" width="1" height="1" name="$1" style="position: absolute; left: -1px;"> \ <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="$1" width="1" height="1" name="$1" style="position: absolute; left: -1px;"> \
<param name="movie" value="$2?playerInstance='+audiojs+'.instances[\'$1\']&datetime=$3"> \ <param name="movie" value="$2?playerInstance='+audiojs+'.instances[\'$1\']&datetime=$3"> \
@ -35,6 +42,7 @@
loop: false, loop: false,
preload: true, preload: true,
imageLocation: path + 'player-graphics.gif', imageLocation: path + 'player-graphics.gif',
retinaImageLocation: path + 'player-graphics@2x.gif',
swfLocation: path + 'audiojs.swf', swfLocation: path + 'audiojs.swf',
useFlash: (function() { useFlash: (function() {
var a = document.createElement('audio'); var a = document.createElement('audio');
@ -113,6 +121,20 @@
.audiojs .error { background: url("$1") -2px -61px no-repeat; } \ .audiojs .error { background: url("$1") -2px -61px no-repeat; } \
.audiojs .pause { background: url("$1") -2px -91px no-repeat; } \ .audiojs .pause { background: url("$1") -2px -91px no-repeat; } \
\ \
@media only screen and (-webkit-min-device-pixel-ratio: 2), \
only screen and (min--moz-device-pixel-ratio: 2), \
only screen and (min-moz-device-pixel-ratio: 2), \
only screen and (-o-min-device-pixel-ratio: 2/1), \
only screen and (min-device-pixel-ratio: 2) { \
.audiojs .play, .audiojs .loading, .audiojs .error, .audiojs .pause { \
background-image: url("$2"); \
-webkit-background-size: 30px 120px; \
-moz-background-size: 30px 120px; \
-o-background-size: 30px 120px; \
background-size: 30px 120px; \
} \
} \
\
.playing .play, .playing .loading, .playing .error { display: none; } \ .playing .play, .playing .loading, .playing .error { display: none; } \
.playing .pause { display: block; } \ .playing .pause { display: block; } \
\ \
@ -155,9 +177,8 @@
}, },
loadProgress: function(percent) { loadProgress: function(percent) {
var player = this.settings.createPlayer, var player = this.settings.createPlayer,
scrubber = getByClass(player.scrubberClass, this.wrapper),
loaded = getByClass(player.loaderClass, this.wrapper); loaded = getByClass(player.loaderClass, this.wrapper);
loaded.style.width = (scrubber.offsetWidth * percent) + 'px'; loaded.style.width = Math.round(100 * percent) + '%';
}, },
playPause: function() { playPause: function() {
if (this.playing) this.settings.play(); if (this.playing) this.settings.play();
@ -165,6 +186,7 @@
}, },
play: function() { play: function() {
var player = this.settings.createPlayer; var player = this.settings.createPlayer;
container[audiojs].helpers.removeClass(this.wrapper, player.errorClass);
container[audiojs].helpers.addClass(this.wrapper, player.playingClass); container[audiojs].helpers.addClass(this.wrapper, player.playingClass);
}, },
pause: function() { pause: function() {
@ -173,9 +195,8 @@
}, },
updatePlayhead: function(percent) { updatePlayhead: function(percent) {
var player = this.settings.createPlayer, var player = this.settings.createPlayer,
scrubber = getByClass(player.scrubberClass, this.wrapper),
progress = getByClass(player.progressClass, this.wrapper); progress = getByClass(player.progressClass, this.wrapper);
progress.style.width = (scrubber.offsetWidth * percent) + 'px'; progress.style.width = Math.round(100 * percent) + '%';
var played = getByClass(player.playedClass, this.wrapper), var played = getByClass(player.playedClass, this.wrapper),
p = this.duration * percent, p = this.duration * percent,
@ -187,10 +208,10 @@
// ### Contructor functions // ### Contructor functions
// `create()` // `create()`
// Used to create a single `audiojs` instance. // Used to create a single `audiojs` instance.
// If an array is passed then it calls back to `createAll()`. // If an array is passed then it calls back to `createAll()`.
// Otherwise, it creates a single instance and returns it. // Otherwise, it creates a single instance and returns it.
create: function(element, options) { create: function(element, options) {
var options = options || {} var options = options || {}
if (element.length) { if (element.length) {
@ -200,14 +221,18 @@
} }
}, },
// `createAll()` // `createAll()`
// Creates multiple `audiojs` instances. // Creates multiple `audiojs` instances.
// If `elements` is `null`, then automatically find any `<audio>` tags on the page and create `audiojs` instances for them. // If `elements` is `null`, then automatically find any `<audio>` tags on the page and create `audiojs` instances for them.
createAll: function(options, elements) { createAll: function(options, elements) {
var audioElements = elements || document.getElementsByTagName('audio'), var audioElements = elements || document.getElementsByTagName('audio'),
instances = [] instances = []
options = options || {}; options = options || {};
for (var i = 0, ii = audioElements.length; i < ii; i++) { for (var i = 0, ii = audioElements.length; i < ii; i++) {
if ((" " + audioElements[i].parentNode.className + " ").replace(/[\n\t]/g, " ").indexOf(" audiojs ") > -1)
continue;
instances.push(this.newInstance(audioElements[i], options)); instances.push(this.newInstance(audioElements[i], options));
} }
return instances; return instances;
@ -244,7 +269,7 @@
this.injectFlash(audio, id); this.injectFlash(audio, id);
this.attachFlashEvents(audio.wrapper, audio); this.attachFlashEvents(audio.wrapper, audio);
} else if (s.useFlash && !s.hasFlash) { } else if (s.useFlash && !s.hasFlash) {
this.settings.flashError.apply(audio); s.flashError.apply(audio);
} }
// Attach event callbacks to the new audiojs instance. // Attach event callbacks to the new audiojs instance.
@ -284,21 +309,14 @@
if (!audio.settings.createPlayer) return; if (!audio.settings.createPlayer) return;
var player = audio.settings.createPlayer, var player = audio.settings.createPlayer,
playPause = getByClass(player.playPauseClass, wrapper), playPause = getByClass(player.playPauseClass, wrapper),
scrubber = getByClass(player.scrubberClass, wrapper), scrubber = getByClass(player.scrubberClass, wrapper);
leftPos = function(elem) {
var curleft = 0;
if (elem.offsetParent) {
do { curleft += elem.offsetLeft; } while (elem = elem.offsetParent);
}
return curleft;
};
container[audiojs].events.addListener(playPause, 'click', function(e) { container[audiojs].events.addListener(playPause, 'click', function(e) {
audio.playPause.apply(audio); audio.playPause.apply(audio);
}); });
container[audiojs].events.addListener(scrubber, 'click', function(e) { container[audiojs].events.addListener(scrubber, 'click', function(e) {
var relativeLeft = e.clientX - leftPos(this); var relativeLeft = e.clientX - this.getBoundingClientRect().left;
audio.skipTo(relativeLeft / scrubber.offsetWidth); audio.skipTo(relativeLeft / scrubber.offsetWidth);
}); });
@ -348,14 +366,14 @@
audio.settings.updatePlayhead.apply(audio, [percent]); audio.settings.updatePlayhead.apply(audio, [percent]);
} }
audio['play'] = function() { audio['play'] = function() {
// If the audio hasn't started preloading, then start it now. // If the audio hasn't started preloading, then start it now.
// Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away. // Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away.
if (!audio.settings.preload) { if (!audio.settings.preload) {
audio.settings.preload = true; audio.settings.preload = true;
audio.element.init(audio.mp3); audio.element.init(audio.mp3);
} }
audio.playing = true; audio.playing = true;
// IE doesn't allow a method named `play()` to be exposed through `ExternalInterface`, so lets go with `pplay()`. // IE doesn't allow a method named `play()` to be exposed through `ExternalInterface`, so lets go with `pplay()`.
// <http://dev.nuclearrooster.com/2008/07/27/externalinterfaceaddcallback-can-cause-ie-js-errors-with-certain-keyworkds/> // <http://dev.nuclearrooster.com/2008/07/27/externalinterfaceaddcallback-can-cause-ie-js-errors-with-certain-keyworkds/>
audio.element.pplay(); audio.element.pplay();
audio.settings.play.apply(audio); audio.settings.play.apply(audio);
@ -394,7 +412,7 @@
// ## Helper functions // ## Helper functions
helpers: { helpers: {
// **Merge two objects, with `obj2` overwriting `obj1`** // **Merge two objects, with `obj2` overwriting `obj1`**
// The merge is shallow, but that's all that is required for our purposes. // The merge is shallow, but that's all that is required for our purposes.
merge: function(obj1, obj2) { merge: function(obj1, obj2) {
for (attr in obj2) { for (attr in obj2) {
@ -407,7 +425,7 @@
clone: function(obj){ clone: function(obj){
if (obj == null || typeof(obj) !== 'object') return obj; if (obj == null || typeof(obj) !== 'object') return obj;
var temp = new obj.constructor(); var temp = new obj.constructor();
for (var key in obj) temp[key] = arguments.callee(obj[key]); for (var key in obj) temp[key] = this.clone(obj[key]);
return temp; return temp;
}, },
// **Adding/removing classnames from elements** // **Adding/removing classnames from elements**
@ -420,13 +438,15 @@
var re = new RegExp('(\\s|^)'+className+'(\\s|$)'); var re = new RegExp('(\\s|^)'+className+'(\\s|$)');
element.className = element.className.replace(re,' '); element.className = element.className.replace(re,' ');
}, },
// **Dynamic CSS injection** // **Dynamic CSS injection**
// Takes a string of css, inserts it into a `<style>`, then injects it in at the very top of the `<head>`. This ensures any user-defined styles will take precedence. // Takes a string of css, inserts it into a `<style>`, then injects it in at the very top of the `<head>`. This ensures any user-defined styles will take precedence.
injectCss: function(audio, string) { injectCss: function(audio, string) {
// If an `audiojs` `<style>` tag already exists, then append to it rather than creating a whole new `<style>`. // If an `audiojs` `<style>` tag already exists, then append to it rather than creating a whole new `<style>`.
var prepend = '', var prepend = '',
styles = document.getElementsByTagName('style'), styles = document.getElementsByTagName('style'),
css = string.replace(/\$1/g, audio.settings.imageLocation); css = string.replace(/\$1/g, audio.settings.imageLocation);
css = css.replace(/\$2/g, audio.settings.retinaImageLocation);
for (var i = 0, ii = styles.length; i < ii; i++) { for (var i = 0, ii = styles.length; i < ii; i++) {
var title = styles[i].getAttribute('title'); var title = styles[i].getAttribute('title');
@ -451,9 +471,9 @@
else style.appendChild(document.createTextNode(prepend + css)); else style.appendChild(document.createTextNode(prepend + css));
if (firstchild) head.insertBefore(style, firstchild); if (firstchild) head.insertBefore(style, firstchild);
else head.appendChild(styleElement); else head.appendChild(style);
}, },
// **Handle all the IE6+7 requirements for cloning `<audio>` nodes** // **Handle all the IE6+7 requirements for cloning `<audio>` nodes**
// Create a html5-safe document fragment by injecting an `<audio>` element into the document fragment. // Create a html5-safe document fragment by injecting an `<audio>` element into the document fragment.
cloneHtml5Node: function(audioTag) { cloneHtml5Node: function(audioTag) {
var fragment = document.createDocumentFragment(), var fragment = document.createDocumentFragment(),
@ -479,7 +499,7 @@
// For modern browsers use the standard DOM-compliant `addEventListener`. // For modern browsers use the standard DOM-compliant `addEventListener`.
if (element.addEventListener) { if (element.addEventListener) {
element.addEventListener(eventName, func, false); element.addEventListener(eventName, func, false);
// For older versions of Internet Explorer, use `attachEvent`. // For older versions of Internet Explorer, use `attachEvent`.
// Also provide a fix for scoping `this` to the calling element and register each listener so the containing elements can be purged on page unload. // Also provide a fix for scoping `this` to the calling element and register each listener so the containing elements can be purged on page unload.
} else if (element.attachEvent) { } else if (element.attachEvent) {
this.listeners.push(element); this.listeners.push(element);
@ -521,15 +541,15 @@
loadTimer = setInterval(function() { loadTimer = setInterval(function() {
audio.loadProgress.apply(audio); audio.loadProgress.apply(audio);
if (audio.loadedPercent >= 1) clearInterval(loadTimer); if (audio.loadedPercent >= 1) clearInterval(loadTimer);
}); }, 200);
} }
}, 10); }, 200);
audio.readyTimer = readyTimer; audio.readyTimer = readyTimer;
audio.loadTimer = loadTimer; audio.loadTimer = loadTimer;
}, },
// **Douglas Crockford's IE6 memory leak fix** // **Douglas Crockford's IE6 memory leak fix**
// <http://javascript.crockford.com/memory/leak.html> // <http://javascript.crockford.com/memory/leak.html>
// This is used to release the memory leak created by the circular references created when fixing `this` scoping for IE. It is called on page unload. // This is used to release the memory leak created by the circular references created when fixing `this` scoping for IE. It is called on page unload.
purge: function(d) { purge: function(d) {
var a = d.attributes, i; var a = d.attributes, i;
@ -544,7 +564,7 @@
} }
}, },
// **DOMready function** // **DOMready function**
// As seen here: <https://github.com/dperini/ContentLoaded/>. // As seen here: <https://github.com/dperini/ContentLoaded/>.
ready: (function() { return function(fn) { ready: (function() { return function(fn) {
var win = window, done = false, top = true, var win = window, done = false, top = true,
@ -650,7 +670,7 @@
var ios = (/(ipod|iphone|ipad)/i).test(navigator.userAgent); var ios = (/(ipod|iphone|ipad)/i).test(navigator.userAgent);
// On iOS this interaction will trigger loading the mp3, so run `init()`. // On iOS this interaction will trigger loading the mp3, so run `init()`.
if (ios && this.element.readyState == 0) this.init.apply(this); if (ios && this.element.readyState == 0) this.init.apply(this);
// If the audio hasn't started preloading, then start it now. // If the audio hasn't started preloading, then start it now.
// Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away. // Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away.
if (!this.settings.preload) { if (!this.settings.preload) {
this.settings.preload = true; this.settings.preload = true;
@ -676,7 +696,7 @@
} }
} }
// **getElementsByClassName** // **getElementsByClassName**
// Having to rely on `getElementsByTagName` is pretty inflexible internally, so a modified version of Dustin Diaz's `getElementsByClassName` has been included. // Having to rely on `getElementsByTagName` is pretty inflexible internally, so a modified version of Dustin Diaz's `getElementsByClassName` has been included.
// This version cleans things up and prefers the native DOM method if it's available. // This version cleans things up and prefers the native DOM method if it's available.
var getByClass = function(searchClass, node) { var getByClass = function(searchClass, node) {
@ -686,7 +706,7 @@
if (node.getElementsByClassName) { if (node.getElementsByClassName) {
matches = node.getElementsByClassName(searchClass); matches = node.getElementsByClassName(searchClass);
} else { } else {
var i, l, var i, l,
els = node.getElementsByTagName("*"), els = node.getElementsByTagName("*"),
pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
@ -699,4 +719,4 @@
return matches.length > 1 ? matches : matches[0]; return matches.length > 1 ? matches : matches[0];
}; };
// The global variable names are passed in here and can be changed if they conflict with anything else. // The global variable names are passed in here and can be changed if they conflict with anything else.
})('audiojs', 'audiojsInstance', this); })('audiojs', 'audiojsInstance', this);

497
media/js/vendor/il.js vendored Normal file
View file

@ -0,0 +1,497 @@
/* ILoader
* imagesLoaded PACKAGED v4.1.4
* JavaScript is all like "You images are done yet or what?"
* MIT License
*/
/**
* EvEmitter v1.1.0
* Lil' event emitter
* MIT License
*/
/* jshint unused: true, undef: true, strict: true */
( function( global, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, window */
if ( typeof define == 'function' && define.amd ) {
// AMD - RequireJS
define( 'ev-emitter/ev-emitter',factory );
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS - Browserify, Webpack
module.exports = factory();
} else {
// Browser globals
global.EvEmitter = factory();
}
}( typeof window != 'undefined' ? window : this, function() {
function EvEmitter() {}
var proto = EvEmitter.prototype;
proto.on = function( eventName, listener ) {
if ( !eventName || !listener ) {
return;
}
// set events hash
var events = this._events = this._events || {};
// set listeners array
var listeners = events[ eventName ] = events[ eventName ] || [];
// only add once
if ( listeners.indexOf( listener ) == -1 ) {
listeners.push( listener );
}
return this;
};
proto.once = function( eventName, listener ) {
if ( !eventName || !listener ) {
return;
}
// add event
this.on( eventName, listener );
// set once flag
// set onceEvents hash
var onceEvents = this._onceEvents = this._onceEvents || {};
// set onceListeners object
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
// set flag
onceListeners[ listener ] = true;
return this;
};
proto.off = function( eventName, listener ) {
var listeners = this._events && this._events[ eventName ];
if ( !listeners || !listeners.length ) {
return;
}
var index = listeners.indexOf( listener );
if ( index != -1 ) {
listeners.splice( index, 1 );
}
return this;
};
proto.emitEvent = function( eventName, args ) {
var listeners = this._events && this._events[ eventName ];
if ( !listeners || !listeners.length ) {
return;
}
// copy over to avoid interference if .off() in listener
listeners = listeners.slice(0);
args = args || [];
// once stuff
var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
for ( var i=0; i < listeners.length; i++ ) {
var listener = listeners[i]
var isOnce = onceListeners && onceListeners[ listener ];
if ( isOnce ) {
// remove listener
// remove before trigger to prevent recursion
this.off( eventName, listener );
// unset once flag
delete onceListeners[ listener ];
}
// trigger listener
listener.apply( this, args );
}
return this;
};
proto.allOff = function() {
delete this._events;
delete this._onceEvents;
};
return EvEmitter;
}));
/*!
* imagesLoaded v4.1.4
* JavaScript is all like "You images are done yet or what?"
* MIT License
*/
( function( window, factory ) { 'use strict';
// universal module definition
/*global define: false, module: false, require: false */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( [
'ev-emitter/ev-emitter'
], function( EvEmitter ) {
return factory( window, EvEmitter );
});
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS
module.exports = factory(
window,
require('ev-emitter')
);
} else {
// browser global
window.imagesLoaded = factory(
window,
window.EvEmitter
);
}
})( typeof window !== 'undefined' ? window : this,
// -------------------------- factory -------------------------- //
function factory( window, EvEmitter ) {
var $ = window.jQuery;
var console = window.console;
// -------------------------- helpers -------------------------- //
// extend objects
function extend( a, b ) {
for ( var prop in b ) {
a[ prop ] = b[ prop ];
}
return a;
}
var arraySlice = Array.prototype.slice;
// turn element or nodeList into an array
function makeArray( obj ) {
if ( Array.isArray( obj ) ) {
// use object if already an array
return obj;
}
var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
return arraySlice.call( obj );
}
// array of single index
return [ obj ];
}
// -------------------------- imagesLoaded -------------------------- //
/**
* @param {Array, Element, NodeList, String} elem
* @param {Object or Function} options - if function, use as callback
* @param {Function} onAlways - callback function
*/
function ImagesLoaded( elem, options, onAlways ) {
// coerce ImagesLoaded() without new, to be new ImagesLoaded()
if ( !( this instanceof ImagesLoaded ) ) {
return new ImagesLoaded( elem, options, onAlways );
}
// use elem as selector string
var queryElem = elem;
if ( typeof elem == 'string' ) {
queryElem = document.querySelectorAll( elem );
}
// bail if bad element
if ( !queryElem ) {
console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
return;
}
this.elements = makeArray( queryElem );
this.options = extend( {}, this.options );
// shift arguments if no options set
if ( typeof options == 'function' ) {
onAlways = options;
} else {
extend( this.options, options );
}
if ( onAlways ) {
this.on( 'always', onAlways );
}
this.getImages();
if ( $ ) {
// add jQuery Deferred object
this.jqDeferred = new $.Deferred();
}
// HACK check async to allow time to bind listeners
setTimeout( this.check.bind( this ) );
}
ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
ImagesLoaded.prototype.options = {};
ImagesLoaded.prototype.getImages = function() {
this.images = [];
// filter & find items if we have an item selector
this.elements.forEach( this.addElementImages, this );
};
/**
* @param {Node} element
*/
ImagesLoaded.prototype.addElementImages = function( elem ) {
// filter siblings
if ( elem.nodeName == 'IMG' ) {
this.addImage( elem );
}
// get background image on element
if ( this.options.background === true ) {
this.addElementBackgroundImages( elem );
}
// find children
// no non-element nodes, #143
var nodeType = elem.nodeType;
if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
return;
}
var childImgs = elem.querySelectorAll('img');
// concat childElems to filterFound array
for ( var i=0; i < childImgs.length; i++ ) {
var img = childImgs[i];
this.addImage( img );
}
// get child background images
if ( typeof this.options.background == 'string' ) {
var children = elem.querySelectorAll( this.options.background );
for ( i=0; i < children.length; i++ ) {
var child = children[i];
this.addElementBackgroundImages( child );
}
}
};
var elementNodeTypes = {
1: true,
9: true,
11: true
};
ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
var style = getComputedStyle( elem );
if ( !style ) {
// Firefox returns null if in a hidden iframe https://bugzil.la/548397
return;
}
// get url inside url("...")
var reURL = /url\((['"])?(.*?)\1\)/gi;
var matches = reURL.exec( style.backgroundImage );
while ( matches !== null ) {
var url = matches && matches[2];
if ( url ) {
this.addBackground( url, elem );
}
matches = reURL.exec( style.backgroundImage );
}
};
/**
* @param {Image} img
*/
ImagesLoaded.prototype.addImage = function( img ) {
var loadingImage = new LoadingImage( img );
this.images.push( loadingImage );
};
ImagesLoaded.prototype.addBackground = function( url, elem ) {
var background = new Background( url, elem );
this.images.push( background );
};
ImagesLoaded.prototype.check = function() {
var _this = this;
this.progressedCount = 0;
this.hasAnyBroken = false;
// complete if no images
if ( !this.images.length ) {
this.complete();
return;
}
function onProgress( image, elem, message ) {
// HACK - Chrome triggers event before object properties have changed. #83
setTimeout( function() {
_this.progress( image, elem, message );
});
}
this.images.forEach( function( loadingImage ) {
loadingImage.once( 'progress', onProgress );
loadingImage.check();
});
};
ImagesLoaded.prototype.progress = function( image, elem, message ) {
this.progressedCount++;
this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
// progress event
this.emitEvent( 'progress', [ this, image, elem ] );
if ( this.jqDeferred && this.jqDeferred.notify ) {
this.jqDeferred.notify( this, image );
}
// check if completed
if ( this.progressedCount == this.images.length ) {
this.complete();
}
if ( this.options.debug && console ) {
console.log( 'progress: ' + message, image, elem );
}
};
ImagesLoaded.prototype.complete = function() {
var eventName = this.hasAnyBroken ? 'fail' : 'done';
this.isComplete = true;
this.emitEvent( eventName, [ this ] );
this.emitEvent( 'always', [ this ] );
if ( this.jqDeferred ) {
var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
this.jqDeferred[ jqMethod ]( this );
}
};
// -------------------------- -------------------------- //
function LoadingImage( img ) {
this.img = img;
}
LoadingImage.prototype = Object.create( EvEmitter.prototype );
LoadingImage.prototype.check = function() {
// If complete is true and browser supports natural sizes,
// try to check for image status manually.
var isComplete = this.getIsImageComplete();
if ( isComplete ) {
// report based on naturalWidth
this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
return;
}
// If none of the checks above matched, simulate loading on detached element.
this.proxyImage = new Image();
this.proxyImage.addEventListener( 'load', this );
this.proxyImage.addEventListener( 'error', this );
// bind to image as well for Firefox. #191
this.img.addEventListener( 'load', this );
this.img.addEventListener( 'error', this );
this.proxyImage.src = this.img.src;
};
LoadingImage.prototype.getIsImageComplete = function() {
// check for non-zero, non-undefined naturalWidth
// fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
return this.img.complete && this.img.naturalWidth;
};
LoadingImage.prototype.confirm = function( isLoaded, message ) {
this.isLoaded = isLoaded;
this.emitEvent( 'progress', [ this, this.img, message ] );
};
// ----- events ----- //
// trigger specified handler for event type
LoadingImage.prototype.handleEvent = function( event ) {
var method = 'on' + event.type;
if ( this[ method ] ) {
this[ method ]( event );
}
};
LoadingImage.prototype.onload = function() {
this.confirm( true, 'onload' );
this.unbindEvents();
};
LoadingImage.prototype.onerror = function() {
this.confirm( false, 'onerror' );
this.unbindEvents();
};
LoadingImage.prototype.unbindEvents = function() {
this.proxyImage.removeEventListener( 'load', this );
this.proxyImage.removeEventListener( 'error', this );
this.img.removeEventListener( 'load', this );
this.img.removeEventListener( 'error', this );
};
// -------------------------- Background -------------------------- //
function Background( url, element ) {
this.url = url;
this.element = element;
this.img = new Image();
}
// inherit LoadingImage prototype
Background.prototype = Object.create( LoadingImage.prototype );
Background.prototype.check = function() {
this.img.addEventListener( 'load', this );
this.img.addEventListener( 'error', this );
this.img.src = this.url;
// check if image is already complete
var isComplete = this.getIsImageComplete();
if ( isComplete ) {
this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
this.unbindEvents();
}
};
Background.prototype.unbindEvents = function() {
this.img.removeEventListener( 'load', this );
this.img.removeEventListener( 'error', this );
};
Background.prototype.confirm = function( isLoaded, message ) {
this.isLoaded = isLoaded;
this.emitEvent( 'progress', [ this, this.element, message ] );
};
// -------------------------- jQuery -------------------------- //
ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
jQuery = jQuery || window.jQuery;
if ( !jQuery ) {
return;
}
// set local variable
$ = jQuery;
// $().imagesLoaded()
$.fn.imagesLoaded = function( options, callback ) {
var instance = new ImagesLoaded( this, options, callback );
return instance.jqDeferred.promise( $(this) );
};
};
// try making plugin
ImagesLoaded.makeJQueryPlugin();
// -------------------------- -------------------------- //
return ImagesLoaded;
});

View file

@ -1,11 +1,11 @@
/*! /*!
* imagesLoaded PACKAGED v4.1.0 * imagesLoaded PACKAGED v4.1.4
* JavaScript is all like "You images are done yet or what?" * JavaScript is all like "You images are done yet or what?"
* MIT License * MIT License
*/ */
/** /**
* EvEmitter v1.0.1 * EvEmitter v1.1.0
* Lil' event emitter * Lil' event emitter
* MIT License * MIT License
*/ */
@ -14,7 +14,7 @@
( function( global, factory ) { ( function( global, factory ) {
// universal module definition // universal module definition
/* jshint strict: false */ /* globals define, module */ /* jshint strict: false */ /* globals define, module, window */
if ( typeof define == 'function' && define.amd ) { if ( typeof define == 'function' && define.amd ) {
// AMD - RequireJS // AMD - RequireJS
define( 'ev-emitter/ev-emitter',factory ); define( 'ev-emitter/ev-emitter',factory );
@ -26,7 +26,7 @@
global.EvEmitter = factory(); global.EvEmitter = factory();
} }
}( this, function() { }( typeof window != 'undefined' ? window : this, function() {
@ -59,8 +59,8 @@ proto.once = function( eventName, listener ) {
// set once flag // set once flag
// set onceEvents hash // set onceEvents hash
var onceEvents = this._onceEvents = this._onceEvents || {}; var onceEvents = this._onceEvents = this._onceEvents || {};
// set onceListeners array // set onceListeners object
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || []; var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
// set flag // set flag
onceListeners[ listener ] = true; onceListeners[ listener ] = true;
@ -85,13 +85,14 @@ proto.emitEvent = function( eventName, args ) {
if ( !listeners || !listeners.length ) { if ( !listeners || !listeners.length ) {
return; return;
} }
var i = 0; // copy over to avoid interference if .off() in listener
var listener = listeners[i]; listeners = listeners.slice(0);
args = args || []; args = args || [];
// once stuff // once stuff
var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
while ( listener ) { for ( var i=0; i < listeners.length; i++ ) {
var listener = listeners[i]
var isOnce = onceListeners && onceListeners[ listener ]; var isOnce = onceListeners && onceListeners[ listener ];
if ( isOnce ) { if ( isOnce ) {
// remove listener // remove listener
@ -102,20 +103,22 @@ proto.emitEvent = function( eventName, args ) {
} }
// trigger listener // trigger listener
listener.apply( this, args ); listener.apply( this, args );
// get next listener
i += isOnce ? 0 : 1;
listener = listeners[i];
} }
return this; return this;
}; };
proto.allOff = function() {
delete this._events;
delete this._onceEvents;
};
return EvEmitter; return EvEmitter;
})); }));
/*! /*!
* imagesLoaded v4.1.0 * imagesLoaded v4.1.4
* JavaScript is all like "You images are done yet or what?" * JavaScript is all like "You images are done yet or what?"
* MIT License * MIT License
*/ */
@ -146,7 +149,7 @@ return EvEmitter;
); );
} }
})( window, })( typeof window !== 'undefined' ? window : this,
// -------------------------- factory -------------------------- // // -------------------------- factory -------------------------- //
@ -167,22 +170,23 @@ function extend( a, b ) {
return a; return a;
} }
var arraySlice = Array.prototype.slice;
// turn element or nodeList into an array // turn element or nodeList into an array
function makeArray( obj ) { function makeArray( obj ) {
var ary = [];
if ( Array.isArray( obj ) ) { if ( Array.isArray( obj ) ) {
// use object if already an array // use object if already an array
ary = obj; return obj;
} else if ( typeof obj.length == 'number' ) {
// convert nodeList to array
for ( var i=0; i < obj.length; i++ ) {
ary.push( obj[i] );
}
} else {
// array of single index
ary.push( obj );
} }
return ary;
var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
return arraySlice.call( obj );
}
// array of single index
return [ obj ];
} }
// -------------------------- imagesLoaded -------------------------- // // -------------------------- imagesLoaded -------------------------- //
@ -198,13 +202,19 @@ function ImagesLoaded( elem, options, onAlways ) {
return new ImagesLoaded( elem, options, onAlways ); return new ImagesLoaded( elem, options, onAlways );
} }
// use elem as selector string // use elem as selector string
var queryElem = elem;
if ( typeof elem == 'string' ) { if ( typeof elem == 'string' ) {
elem = document.querySelectorAll( elem ); queryElem = document.querySelectorAll( elem );
}
// bail if bad element
if ( !queryElem ) {
console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
return;
} }
this.elements = makeArray( elem ); this.elements = makeArray( queryElem );
this.options = extend( {}, this.options ); this.options = extend( {}, this.options );
// shift arguments if no options set
if ( typeof options == 'function' ) { if ( typeof options == 'function' ) {
onAlways = options; onAlways = options;
} else { } else {
@ -223,9 +233,7 @@ function ImagesLoaded( elem, options, onAlways ) {
} }
// HACK check async to allow time to bind listeners // HACK check async to allow time to bind listeners
setTimeout( function() { setTimeout( this.check.bind( this ) );
this.check();
}.bind( this ));
} }
ImagesLoaded.prototype = Object.create( EvEmitter.prototype ); ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
@ -393,7 +401,9 @@ LoadingImage.prototype.check = function() {
}; };
LoadingImage.prototype.getIsImageComplete = function() { LoadingImage.prototype.getIsImageComplete = function() {
return this.img.complete && this.img.naturalWidth !== undefined; // check for non-zero, non-undefined naturalWidth
// fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
return this.img.complete && this.img.naturalWidth;
}; };
LoadingImage.prototype.confirm = function( isLoaded, message ) { LoadingImage.prototype.confirm = function( isLoaded, message ) {

View file

@ -36,22 +36,6 @@ NEWSBLUR.log = function(msg) {
(function($) { (function($) {
$.fn.extend({ $.fn.extend({
textNodes: function() {
var ret = [];
(function(el){
if (!el) return;
if ((el.nodeType == 3)) {
ret.push(el);
} else {
for (var i=0; i < el.childNodes.length; ++i) {
arguments.callee(el.childNodes[i]);
}
}
})(this[0]);
return $(ret);
},
isScrollVisible: function($elem, partial) { isScrollVisible: function($elem, partial) {
var docViewTop = 0; // $(this).scrollTop(); var docViewTop = 0; // $(this).scrollTop();

View file

@ -75,7 +75,7 @@ javascripts:
- js/vendor/bootstrap-transition.js - js/vendor/bootstrap-transition.js
- js/vendor/highlight.js - js/vendor/highlight.js
- js/vendor/fitvid.js - js/vendor/fitvid.js
- js/vendor/imagesLoaded-*.js - js/vendor/il.js
- js/vendor/mark.js - js/vendor/mark.js
- js/newsblur/reader/reader_utils.js - js/newsblur/reader/reader_utils.js
- js/newsblur/reader/reader.js - js/newsblur/reader/reader.js

View file

@ -796,7 +796,7 @@ PIPELINE = {
# 'CSS_COMPRESSOR': 'pipeline.compressors.NoopCompressor', # 'CSS_COMPRESSOR': 'pipeline.compressors.NoopCompressor',
# 'JS_COMPRESSOR': 'pipeline.compressors.NoopCompressor', # 'JS_COMPRESSOR': 'pipeline.compressors.NoopCompressor',
'CLOSURE_BINARY': '/usr/bin/env google-closure-compiler', 'CLOSURE_BINARY': '/usr/bin/env google-closure-compiler',
'CLOSURE_ARGUMENTS': '--language_in ECMASCRIPT_2021 --warning_level QUIET', 'CLOSURE_ARGUMENTS': '--language_in ECMASCRIPT_2021',# --warning_level QUIET',
'JAVASCRIPT': { 'JAVASCRIPT': {
'common': { 'common': {
'source_filenames': assets['javascripts']['common'], 'source_filenames': assets['javascripts']['common'],