Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var applySeparator = function(listClass, maxPosts) {
- if(typeof listClass !== 'string' || typeof maxPosts !== 'number') {
- return;
- }
- var currentList;
- var lastPost;
- var allLists = jQuery(listClass);
- var separator = jQuery('<div/>', {
- 'class' : 'separator',
- css : {
- 'border-bottom' : '4px solid red',
- 'display' : 'block'
- }
- });
- for (var i = allLists.length - 1; i >= 0; i--) {
- console.log(currentList);
- currentList = jQuery(allLists[i]);
- currentList.find('.separator').remove();
- lastPost = currentList.find('.article').not('.list-item-depth-1').slice(0,maxPosts).last();
- if(lastPost.next().hasClass('list-item-depth-1')) {
- lastPost = lastPost.next();
- }
- lastPost.after(separator.clone());
- }
- };
- applySeparator('.article-list', 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement