Changeset 2371626
- Timestamp:
- 08/29/2020 05:27:37 PM (6 years ago)
- Location:
- image-wall/trunk
- Files:
-
- 1 added
- 1 deleted
- 4 edited
-
image-wall.js (modified) (4 diffs)
-
image-wall.php (modified) (2 diffs)
-
imagesloaded.pkgd.min.js (modified) (1 diff)
-
infinite-scroll.pkgd.min.js (added)
-
jquery.infinitescroll.js (deleted)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
image-wall/trunk/image-wall.js
r901018 r2371626 15 15 16 16 (function($) { 17 17 18 18 //// Helper functions to access data generated in the PHP and stored in the HTML //// 19 function tmn_iw_get_column_width(){ 19 function tmn_iw_get_column_width(){ 20 20 return parseInt($('#tmn-image-wall').attr('column_width')); 21 21 } 22 23 function tmn_iw_get_buffer_pixels(){ 22 23 function tmn_iw_get_buffer_pixels(){ 24 24 return parseInt($('#tmn-image-wall').attr('buffer_pixels')); 25 25 } 26 27 function tmn_iw_move_image_wall_to_end(){ 26 27 function tmn_iw_move_image_wall_to_end(){ 28 28 return $('#tmn-image-wall').attr('move_to_end') === 'true'; 29 } 30 31 function tmn_iw_get_scroll_img_url(){ 29 } 30 31 function tmn_iw_get_scroll_img_url(){ 32 32 return $('#tmn-image-wall').attr('scroll_img_url'); 33 33 } … … 38 38 } 39 39 40 var $container = $('#tmn-image-wall'); 40 var $container = $('#tmn-image-wall'); 41 41 if(tmn_iw_move_image_wall_to_end()){ 42 42 if(iw_debug) console.log('Image Wall: Moving the Image Wall to the end.'); 43 $container.appendTo('body'); 43 $container.appendTo('body'); 44 44 $('#tmn-image-wall-next').appendTo('body'); 45 45 } … … 48 48 var $prep_area = $('#tmn-image-wall-prep'); 49 49 $container.html($prep_area.html()).prepend('<div id="tmn-image-wall-scroll-messages"></div>'); 50 50 51 51 if(iw_debug) console.log('Image Wall: Setting up Images Loaded on the Image Wall.'); 52 52 $container.imagesLoaded(function(){ … … 62 62 63 63 if(iw_debug) console.log('Image Wall: Starting Infinite Scroll.'); 64 $container.infinitescroll({ 65 navSelector : '#tmn-image-wall-next',66 bufferPx : tmn_iw_get_buffer_pixels(),67 nextSelector : '#tmn-image-wall-next',68 itemSelector : '#tmn-image-wall-prep',69 pathParse : isotopeParseLoadMoreImagesPath,70 loading: {71 msgTextloading : "Congratulations, you've reached the end of the internet.", // tmniwjsi18n.msgTextloading , 72 msgText : "Loading more images...", //tmniwjsi18n.msgText ,73 finishedMsg : "You have reached the end of the internet!", //tmniwjsi18n.finishedMsg ,74 selector : '#tmn-image-wall-scroll-messages',75 img : tmn_iw_get_scroll_img_url()76 },77 debug : true78 79 },80 function( newElements ) {81 if(iw_debug) console.log('Image Wall: New images found through Infinite Scroll.');82 var tempHolder = $( newElements );83 var theimages = tempHolder.find('img')84 var theitems = tempHolder.find('.tmn-image-wall-item-link')85 86 if(theimages.length == 0) {87 if(iw_debug) console.log('Image Wall: No new images found. Asking for another batch.'); 88 $container.infinitescroll('scroll');64 65 $container.infiniteScroll({ 66 path: '#tmn-image-wall-next', 67 history: false, 68 append: false, // disable automatic appending 69 scrollThreshold: tmn_iw_get_buffer_pixels(), 70 }); 71 72 $container.on( 'load.infiniteScroll', function( event, response ) { 73 if(iw_debug) console.log('Image Wall: New images found through Infinite Scroll.'); 74 var tempHolder = $( response ); 75 var theimages = tempHolder.find('img') 76 var theitems = tempHolder.find('.tmn-image-wall-item-link') 77 if(theimages.length == 0) { 78 if(iw_debug) console.log('Image Wall: No new images found. Asking for another batch.'); 79 $container.infiniteScroll('loadNextPage') 80 tempHolder.remove(); 81 } else { 82 theimages.imagesLoaded(function (imgLoad) { 83 if(iw_debug) console.log('Image Wall: ' + imgLoad.images.length +' images loaded from temporary holder. Adding them to the Image Wall.'); 84 theimages.css( 'opacity', 0); 85 $container.append( theitems ).masonry( 'appended', theitems, true ); 86 theimages.css( 'opacity', 1); 87 88 if(iw_debug) console.log('Image Wall: No more images in the temporary holder. Removing it.'); 89 89 tempHolder.remove(); 90 } else { 91 theimages.imagesLoaded(function (imgLoad) { 92 if(iw_debug) console.log('Image Wall: ' + imgLoad.images.length +' images loaded from temporary holder. Adding them to the Image Wall.'); 93 theimages.css( 'opacity', 0); 94 $container.append( theitems ).masonry( 'appended', theitems, true ); 95 theimages.css( 'opacity', 1); 96 97 if(iw_debug) console.log('Image Wall: No more images in the temporary holder. Removing it.'); 98 tempHolder.remove(); 99 }); 100 if(iw_debug) console.log('Image Wall: New image added to the Image Wall. Appending it to the body while we wait for images to load.'); 101 tempHolder.appendTo($('body')); 102 } 90 }); 91 if(iw_debug) console.log('Image Wall: New image added to the Image Wall. Appending it to the body while we wait for images to load.'); 103 92 } 104 );105 93 }); 94 106 95 if(iw_debug) console.log('Image Wall: Removing the initial prep area. (Infinite scroll should be done with it by now.)'); 107 96 $prep_area.remove(); 108 97 109 98 })( jQuery ); -
image-wall/trunk/image-wall.php
r2183904 r2371626 4 4 Plugin URI: http://www.themodernnomad.com/image-wall-plugin/#utm_campaign=Image_Wall&utm_source=wordpress&utm_medium=website&utm_content=plugin_link 5 5 Description: Browse posts/pages by their images, displayed randomly on an infinitely scrollable page. The images link back to the posts where they are attached. 6 Version: 2.186 Version: 3.0 7 7 Author: Gustav Andersson, Marco Catellani 8 8 Author URI: http://www.themodernnomad.com/about/#utm_campaign=Image_Wall&utm_source=wordpress&utm_medium=website&utm_content=author_link … … 329 329 global $post; 330 330 if ( preg_match('/(?<!\[)\[image_wall.*?\]/', $post->post_content) ) { 331 wp_register_script ( 'imagesLoaded', plugins_url( 'imagesloaded.pkgd.min.js' , __FILE__ ), array(), ' 3.1.4', true );332 wp_register_script ( 'infinitescroll', plugins_url( ' jquery.infinitescroll.js' , __FILE__ ), array('imagesLoaded'), '2.0b2.120519', true );333 wp_enqueue_script ('tmniwjs', plugins_url( 'image-wall.js' , __FILE__ ), array('jquery', 'jquery-masonry', 'infinitescroll', 'imagesLoaded'), ' 2', true);331 wp_register_script ( 'imagesLoaded', plugins_url( 'imagesloaded.pkgd.min.js' , __FILE__ ), array(), '4.1.4', true ); 332 wp_register_script ( 'infinitescroll', plugins_url( 'infinite-scroll.pkgd.min.js' , __FILE__ ), array('imagesLoaded'), '3.0.6', true ); 333 wp_enqueue_script ('tmniwjs', plugins_url( 'image-wall.js' , __FILE__ ), array('jquery', 'jquery-masonry', 'infinitescroll', 'imagesLoaded'), '3', true); 334 334 /* 335 335 $translation_array = array( -
image-wall/trunk/imagesloaded.pkgd.min.js
r896393 r2371626 1 1 /*! 2 * imagesLoaded PACKAGED v 3.1.42 * imagesLoaded PACKAGED v4.1.4 3 3 * JavaScript is all like "You images are done yet or what?" 4 4 * MIT License 5 5 */ 6 6 7 (function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("eventEmitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(this,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function c(e){this.img=e}function f(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);for(var i=n.querySelectorAll("img"),r=0,o=i.length;o>r;r++){var s=i[r];this.addImage(s)}}},s.prototype.addImage=function(e){var t=new c(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),c.prototype=new t,c.prototype.check=function(){var e=v[this.img.src]||new f(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},c.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return f.prototype=new t,f.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},f.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},f.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},f.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},f.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},f.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});7 !function(e,t){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",t):"object"==typeof module&&module.exports?module.exports=t():e.EvEmitter=t()}("undefined"!=typeof window?window:this,function(){function e(){}var t=e.prototype;return t.on=function(e,t){if(e&&t){var i=this._events=this._events||{},n=i[e]=i[e]||[];return n.indexOf(t)==-1&&n.push(t),this}},t.once=function(e,t){if(e&&t){this.on(e,t);var i=this._onceEvents=this._onceEvents||{},n=i[e]=i[e]||{};return n[t]=!0,this}},t.off=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){var n=i.indexOf(t);return n!=-1&&i.splice(n,1),this}},t.emitEvent=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){i=i.slice(0),t=t||[];for(var n=this._onceEvents&&this._onceEvents[e],o=0;o<i.length;o++){var r=i[o],s=n&&n[r];s&&(this.off(e,r),delete n[r]),r.apply(this,t)}return this}},t.allOff=function(){delete this._events,delete this._onceEvents},e}),function(e,t){"use strict";"function"==typeof define&&define.amd?define(["ev-emitter/ev-emitter"],function(i){return t(e,i)}):"object"==typeof module&&module.exports?module.exports=t(e,require("ev-emitter")):e.imagesLoaded=t(e,e.EvEmitter)}("undefined"!=typeof window?window:this,function(e,t){function i(e,t){for(var i in t)e[i]=t[i];return e}function n(e){if(Array.isArray(e))return e;var t="object"==typeof e&&"number"==typeof e.length;return t?d.call(e):[e]}function o(e,t,r){if(!(this instanceof o))return new o(e,t,r);var s=e;return"string"==typeof e&&(s=document.querySelectorAll(e)),s?(this.elements=n(s),this.options=i({},this.options),"function"==typeof t?r=t:i(this.options,t),r&&this.on("always",r),this.getImages(),h&&(this.jqDeferred=new h.Deferred),void setTimeout(this.check.bind(this))):void a.error("Bad element for imagesLoaded "+(s||e))}function r(e){this.img=e}function s(e,t){this.url=e,this.element=t,this.img=new Image}var h=e.jQuery,a=e.console,d=Array.prototype.slice;o.prototype=Object.create(t.prototype),o.prototype.options={},o.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},o.prototype.addElementImages=function(e){"IMG"==e.nodeName&&this.addImage(e),this.options.background===!0&&this.addElementBackgroundImages(e);var t=e.nodeType;if(t&&u[t]){for(var i=e.querySelectorAll("img"),n=0;n<i.length;n++){var o=i[n];this.addImage(o)}if("string"==typeof this.options.background){var r=e.querySelectorAll(this.options.background);for(n=0;n<r.length;n++){var s=r[n];this.addElementBackgroundImages(s)}}}};var u={1:!0,9:!0,11:!0};return o.prototype.addElementBackgroundImages=function(e){var t=getComputedStyle(e);if(t)for(var i=/url\((['"])?(.*?)\1\)/gi,n=i.exec(t.backgroundImage);null!==n;){var o=n&&n[2];o&&this.addBackground(o,e),n=i.exec(t.backgroundImage)}},o.prototype.addImage=function(e){var t=new r(e);this.images.push(t)},o.prototype.addBackground=function(e,t){var i=new s(e,t);this.images.push(i)},o.prototype.check=function(){function e(e,i,n){setTimeout(function(){t.progress(e,i,n)})}var t=this;return this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?void this.images.forEach(function(t){t.once("progress",e),t.check()}):void this.complete()},o.prototype.progress=function(e,t,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded,this.emitEvent("progress",[this,e,t]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,e),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&a&&a.log("progress: "+i,e,t)},o.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(e,[this]),this.emitEvent("always",[this]),this.jqDeferred){var t=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[t](this)}},r.prototype=Object.create(t.prototype),r.prototype.check=function(){var e=this.getIsImageComplete();return e?void this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),void(this.proxyImage.src=this.img.src))},r.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},r.prototype.confirm=function(e,t){this.isLoaded=e,this.emitEvent("progress",[this,this.img,t])},r.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},r.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},r.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},r.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype=Object.create(r.prototype),s.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url;var e=this.getIsImageComplete();e&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},s.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype.confirm=function(e,t){this.isLoaded=e,this.emitEvent("progress",[this,this.element,t])},o.makeJQueryPlugin=function(t){t=t||e.jQuery,t&&(h=t,h.fn.imagesLoaded=function(e,t){var i=new o(this,e,t);return i.jqDeferred.promise(h(this))})},o.makeJQueryPlugin(),o}); -
image-wall/trunk/readme.txt
r2261006 r2371626 3 3 Tags: gallery, galleries, images, ajax, image, media, photo, photos, shortcode, 4 4 Requires at least: 3.5 5 Tested up to: 5. 3.25 Tested up to: 5.5 6 6 Stable tag: trunk 7 7 Donate link: http://www.themodernnomad.com/#utm_campaign=Image_Wall&utm_source=wordpress&utm_medium=website&utm_content=donation … … 122 122 = 2.18 = 123 123 * Fixed a bug where you could not save pages that included the image wall shortcode! Thanks to K. Morano for alerting me to this problem. 124 125 = 3.0 = 126 * Wordpress 5.5 compatible. I had to upgrade some dependencies and change the code to handle the jQuery change in WordPress v5.5. It works on my personal wall now, but those are famous last words for a programmer! So, after upgrading to this version, check that it all works, and if it doesn't, let me know. 127 * The loading messages have disappeared. I decided to let them go in an effort to change as little as possible to reduce the risk of introducing serious bugs. This is now a decade old code that I haven't looked at for a looong time, so the less I change, the better.
Note: See TracChangeset
for help on using the changeset viewer.