PluginProbe
WP Ultimate Post Grid / 4.0.1
WP Ultimate Post Grid v4.0.1
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / assets / js / public / grid / empty.js

empty.js in WP Ultimate Post Grid 4.0.1, at assets/js/public/grid/empty.js

50 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { slideDown, slideUp, slideStop } from 'slide-anim';
2
3 export default ( elemId, args ) => {
4 return {
5 isEmpty: false,
6 hideEmpty( temporary = false ) {
7 const emptyElem = document.querySelector( '#' + this.elemId + '-empty' );
8
9 if ( emptyElem ) {
10 if ( temporary ) {
11 if ( ! this.isEmpty ) {
12 emptyElem.style.visibility = 'hidden';
13 }
14 } else {
15 slideStop( emptyElem );
16 slideUp( emptyElem );
17 }
18 }
19 },
20 checkEmpty() {
21 const emptyElem = document.querySelector( '#' + this.elemId + '-empty' );
22
23 if ( emptyElem ) {
24 // Revert optional temporary hide.
25 emptyElem.style.visibility = 'visible';
26
27 // Check if should show or not.
28 const visibleItems = this.isotope.getFilteredItemElements();
29
30 if ( 0 === visibleItems.length && ! this.isEmpty ) {
31 slideStop( emptyElem );
32 slideDown( emptyElem );
33 this.isEmpty = true;
34 } else if ( 0 < visibleItems.length && this.isEmpty ) {
35 this.hideEmpty();
36 this.isEmpty = false;
37 }
38 }
39 },
40 initEmpty() {
41 this.on( 'initReady', () => {
42 this.checkEmpty();
43 });
44
45 this.on( 'visibleItemsChanged', () => {
46 this.checkEmpty();
47 });
48 }
49 }
50 };