see more
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
7 changed files
with
122 additions
and
6 deletions
| ... | @@ -318,6 +318,16 @@ function course_list() | ... | @@ -318,6 +318,16 @@ function course_list() |
| 318 | margin: 0; | 318 | margin: 0; |
| 319 | padding: 0; | 319 | padding: 0; |
| 320 | } | 320 | } |
| 321 | #load-more{ | ||
| 322 | float:right; | ||
| 323 | margin:5px; | ||
| 324 | } | ||
| 325 | .hidden{visibility:hidden; | ||
| 326 | width:0px!important; | ||
| 327 | height:0px!important; | ||
| 328 | margin:0px!important; | ||
| 329 | padding:0px!important; | ||
| 330 | } | ||
| 321 | </style> | 331 | </style> |
| 322 | <?php return $output; | 332 | <?php return $output; |
| 323 | } | 333 | } | ... | ... |
| ... | @@ -17690,6 +17690,53 @@ | ... | @@ -17690,6 +17690,53 @@ |
| 17690 | $(this).addClass('is-checked'); | 17690 | $(this).addClass('is-checked'); |
| 17691 | }); | 17691 | }); |
| 17692 | }); | 17692 | }); |
| 17693 | |||
| 17694 | //**************************** | ||
| 17695 | // Isotope Load more button | ||
| 17696 | //**************************** | ||
| 17697 | |||
| 17698 | var initShow = 3; //number of images loaded on init & onclick load more button | ||
| 17699 | var counter = initShow; //counter for load more button | ||
| 17700 | var iso = $grid.data('isotope'); // get Isotope instance | ||
| 17701 | console.log('iso'); | ||
| 17702 | console.log(iso); | ||
| 17703 | console.log(iso.elemCount); | ||
| 17704 | loadMore(initShow); //execute function onload | ||
| 17705 | |||
| 17706 | function loadMore(toShow) { | ||
| 17707 | $grid.find(".hidden").removeClass("hidden"); | ||
| 17708 | var hiddenElems = iso.filteredItems.slice(toShow, iso.filteredItems.length).map(function (item) { | ||
| 17709 | console.log('hiddenElem'); | ||
| 17710 | console.log(item.element); | ||
| 17711 | return item.element; | ||
| 17712 | }); | ||
| 17713 | $(hiddenElems).addClass('hidden'); | ||
| 17714 | $grid.isotope('layout'); | ||
| 17715 | |||
| 17716 | //when no more to load, hide show more button | ||
| 17717 | if (hiddenElems.length == 0) { | ||
| 17718 | $("#load-more").hide(); | ||
| 17719 | } else { | ||
| 17720 | $("#load-more").show(); | ||
| 17721 | } | ||
| 17722 | } | ||
| 17723 | |||
| 17724 | //append load more button | ||
| 17725 | $grid.after('<div class="viewPlan"><a href="#" id="load-more">Load More</a></div>'); | ||
| 17726 | |||
| 17727 | //when load more button clicked | ||
| 17728 | $(document).on("click", "#load-more", function (e) { | ||
| 17729 | e.preventDefault(); | ||
| 17730 | if ($('#filters').data('clicked')) { | ||
| 17731 | //when filter button clicked, set initial value for counter | ||
| 17732 | counter = initShow; | ||
| 17733 | j$('#filters').data('clicked', false); | ||
| 17734 | } else { | ||
| 17735 | counter = counter; | ||
| 17736 | } | ||
| 17737 | counter = counter + initShow; | ||
| 17738 | loadMore(counter); | ||
| 17739 | }); | ||
| 17693 | }); | 17740 | }); |
| 17694 | var a = document.querySelector('.blur-image'); | 17741 | var a = document.querySelector('.blur-image'); |
| 17695 | document.addEventListener("DOMContentLoaded", function () { | 17742 | document.addEventListener("DOMContentLoaded", function () { | ... | ... |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
| ... | @@ -4,15 +4,15 @@ | ... | @@ -4,15 +4,15 @@ |
| 4 | "compress": { | 4 | "compress": { |
| 5 | "booleans": true, | 5 | "booleans": true, |
| 6 | "conditionals": true, | 6 | "conditionals": true, |
| 7 | "drop_console": true, | 7 | "drop_console": false, |
| 8 | "drop_debugger": true, | 8 | "drop_debugger": false, |
| 9 | "if_return": true, | 9 | "if_return": true, |
| 10 | "join_vars": true, | 10 | "join_vars": false, |
| 11 | "keep_classnames": false, | 11 | "keep_classnames": false, |
| 12 | "keep_fnames": false, | 12 | "keep_fnames": false, |
| 13 | "reduce_vars": true, | 13 | "reduce_vars": false, |
| 14 | "sequences": true, | 14 | "sequences": true, |
| 15 | "warnings": false, | 15 | "warnings": true, |
| 16 | "ecma": 5 | 16 | "ecma": 5 |
| 17 | }, | 17 | }, |
| 18 | "mangle": { | 18 | "mangle": { | ... | ... |
| ... | @@ -15,7 +15,7 @@ jQuery( document ).ready(function($) { | ... | @@ -15,7 +15,7 @@ jQuery( document ).ready(function($) { |
| 15 | var qsRegex; | 15 | var qsRegex; |
| 16 | 16 | ||
| 17 | // init Isotope | 17 | // init Isotope |
| 18 | var $grid = $('.grid').isotope({ | 18 | var $grid = $('.grid').isotope({ |
| 19 | itemSelector: '.element-item', | 19 | itemSelector: '.element-item', |
| 20 | layoutMode: 'fitRows', | 20 | layoutMode: 'fitRows', |
| 21 | filter: function() { | 21 | filter: function() { |
| ... | @@ -23,6 +23,7 @@ var $grid = $('.grid').isotope({ | ... | @@ -23,6 +23,7 @@ var $grid = $('.grid').isotope({ |
| 23 | } | 23 | } |
| 24 | }); | 24 | }); |
| 25 | 25 | ||
| 26 | |||
| 26 | var filterFns = { | 27 | var filterFns = { |
| 27 | // show if number is greater than 50 | 28 | // show if number is greater than 50 |
| 28 | numberGreaterThan50: function() { | 29 | numberGreaterThan50: function() { |
| ... | @@ -76,6 +77,64 @@ $('.button-group').each( function( i, buttonGroup ) { | ... | @@ -76,6 +77,64 @@ $('.button-group').each( function( i, buttonGroup ) { |
| 76 | }); | 77 | }); |
| 77 | }); | 78 | }); |
| 78 | 79 | ||
| 80 | |||
| 81 | |||
| 82 | //**************************** | ||
| 83 | // Isotope Load more button | ||
| 84 | //**************************** | ||
| 85 | |||
| 86 | var initShow = 3; //number of images loaded on init & onclick load more button | ||
| 87 | var counter = initShow; //counter for load more button | ||
| 88 | var iso = $grid.data('isotope'); // get Isotope instance | ||
| 89 | console.log('iso'); | ||
| 90 | console.log(iso); | ||
| 91 | console.log(iso.elemCount); | ||
| 92 | |||
| 93 | loadMore(initShow); //execute function onload | ||
| 94 | |||
| 95 | function loadMore(toShow) { | ||
| 96 | |||
| 97 | $grid.find(".hidden").removeClass("hidden"); | ||
| 98 | |||
| 99 | var hiddenElems = iso.filteredItems.slice(toShow, iso.filteredItems.length).map(function(item) { | ||
| 100 | console.log('hiddenElem'); | ||
| 101 | console.log(item.element); | ||
| 102 | return item.element; | ||
| 103 | }); | ||
| 104 | $(hiddenElems).addClass('hidden'); | ||
| 105 | $grid.isotope('layout'); | ||
| 106 | |||
| 107 | //when no more to load, hide show more button | ||
| 108 | if (hiddenElems.length == 0) { | ||
| 109 | $("#load-more").hide(); | ||
| 110 | } | ||
| 111 | else { | ||
| 112 | $("#load-more").show(); | ||
| 113 | }; | ||
| 114 | |||
| 115 | } | ||
| 116 | |||
| 117 | |||
| 118 | //append load more button | ||
| 119 | $grid.after('<div class="viewPlan"><a href="#" id="load-more">Load More</a></div>'); | ||
| 120 | |||
| 121 | //when load more button clicked | ||
| 122 | $(document).on("click", "#load-more", function(e) { | ||
| 123 | e.preventDefault(); | ||
| 124 | |||
| 125 | if ($('#filters').data('clicked')) { | ||
| 126 | //when filter button clicked, set initial value for counter | ||
| 127 | counter = initShow; | ||
| 128 | j$('#filters').data('clicked', false); | ||
| 129 | } else { | ||
| 130 | counter = counter; | ||
| 131 | }; | ||
| 132 | |||
| 133 | counter = counter + initShow; | ||
| 134 | |||
| 135 | loadMore(counter); | ||
| 136 | }); | ||
| 137 | |||
| 79 | }); | 138 | }); |
| 80 | 139 | ||
| 81 | var a = document.querySelector('.blur-image'); | 140 | var a = document.querySelector('.blur-image'); | ... | ... |
-
Please register or sign in to post a comment