Created
February 5, 2018 19:53
-
-
Save rivaadara111/6de684aa3f9483af3748db8df983404e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
//dynamically load in popular block as object | |
function MostPopular(popularBlock) { | |
var self = this; | |
if (popularBlock == undefined) { | |
var popularBlock = $('.gi-table-wrap'); | |
} | |
this.lazyPopular = new Waypoint({ | |
element: document.getElementById('gi-table-wrap'), | |
handler: function(direction) { | |
this.destroy(); | |
self.getdata(); | |
}, | |
offset: '100%' | |
}); | |
this.getdata = function() { | |
var li = '', | |
i = ''; | |
$.getJSON("/files/mostpopular.json", function(data) { | |
for (var i = 0; i < data.length; i++) { | |
li += '<li class="gi-popular-li event "><a href="/node/' + data[i].nid + '"><figure>' + '<img src=' + data[i].img + '/></figure>' + '<h3 class="title">' + data[i].title + '</h3>' + '</a></li>'; | |
} | |
this.ol = document.createElement('ol'); | |
this.ol.className += 'gi-popular-ol list links numbered events'; | |
this.ol.innerHTML = li; | |
popularBlock.append(this.ol).find('.center-gif').remove(); | |
popularBlock.find('.gi-popular-ol').addClass('fade'); | |
}); | |
}; | |
} | |
window.MostPopular = MostPopular; | |
var mostPopular = new MostPopular(); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment