| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-31 14:10:20 -04:00
										 |  |  | /* globals config, app, ajaxify, define, socket, utils */ | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | define('forum/topic/posts', [ | 
					
						
							|  |  |  | 	'forum/pagination', | 
					
						
							|  |  |  | 	'forum/infinitescroll', | 
					
						
							|  |  |  | 	'forum/topic/postTools', | 
					
						
							| 
									
										
										
										
											2015-03-31 14:10:20 -04:00
										 |  |  | 	'navigator', | 
					
						
							|  |  |  | 	'components' | 
					
						
							|  |  |  | ], function(pagination, infinitescroll, postTools, navigator, components) { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	var Posts = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Posts.onNewPost = function(data) { | 
					
						
							| 
									
										
										
										
											2015-09-29 17:09:41 -04:00
										 |  |  | 		if (!data || !data.posts || !data.posts.length) { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 17:09:41 -04:00
										 |  |  | 		if (parseInt(data.posts[0].tid, 10) !== parseInt(ajaxify.data.tid, 10)) { | 
					
						
							| 
									
										
										
										
											2015-09-13 15:14:29 -04:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 13:24:27 -05:00
										 |  |  | 		data.loggedIn = app.user.uid ? true : false; | 
					
						
							| 
									
										
										
										
											2015-09-29 16:36:37 -04:00
										 |  |  | 		data.posts.forEach(function(post) { | 
					
						
							|  |  |  | 			post.selfPost = !!app.user.uid && parseInt(post.uid, 10) === parseInt(app.user.uid, 10); | 
					
						
							|  |  |  | 			post.display_moderator_tools = post.selfPost || ajaxify.data.isAdminOrMod; | 
					
						
							|  |  |  | 			post.display_move_tools = ajaxify.data.isAdminOrMod; | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 		updatePostCounts(data.posts); | 
					
						
							| 
									
										
										
										
											2015-10-20 18:08:59 -04:00
										 |  |  | 		ajaxify.data.postcount ++; | 
					
						
							|  |  |  | 		postTools.updatePostCount(ajaxify.data.postcount); | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-01 20:10:51 -05:00
										 |  |  | 		if (config.usePagination) { | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 			onNewPostPagination(data); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			onNewPostInfiniteScroll(data); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 	function updatePostCounts(posts) { | 
					
						
							|  |  |  | 		for (var i=0; i<posts.length; ++i) { | 
					
						
							|  |  |  | 			var cmp = components.get('user/postcount', posts[i].uid); | 
					
						
							| 
									
										
										
										
											2015-03-27 14:21:04 -04:00
										 |  |  | 			cmp.html(parseInt(cmp.attr('data-postcount'), 10) + 1); | 
					
						
							| 
									
										
										
										
											2015-03-27 16:27:28 -04:00
										 |  |  | 			utils.addCommasToNumbers(cmp); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-09-13 15:14:29 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 	function onNewPostPagination(data) { | 
					
						
							| 
									
										
										
										
											2015-02-17 18:52:54 -05:00
										 |  |  | 		function scrollToPost() { | 
					
						
							| 
									
										
										
										
											2015-09-13 15:14:29 -04:00
										 |  |  | 			scrollToPostIfSelf(data.posts[0]); | 
					
						
							| 
									
										
										
										
											2015-02-17 18:52:54 -05:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		var posts = data.posts; | 
					
						
							| 
									
										
										
										
											2015-02-17 18:52:54 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-07 16:13:37 -04:00
										 |  |  | 		ajaxify.data.pagination.pageCount = Math.max(1, Math.ceil((posts[0].topic.postcount - 1) / config.postsPerPage)); | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 		var direction = config.topicPostSort === 'oldest_to_newest' || config.topicPostSort === 'most_votes' ? 1 : -1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-07 16:13:37 -04:00
										 |  |  | 		var isPostVisible = (ajaxify.data.pagination.currentPage === ajaxify.data.pagination.pageCount && direction === 1) || (ajaxify.data.pagination.currentPage === 1 && direction === -1); | 
					
						
							| 
									
										
										
										
											2015-02-17 18:52:54 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 		if (isPostVisible) { | 
					
						
							|  |  |  | 			createNewPosts(data, components.get('post').not('[data-index=0]'), direction, scrollToPost); | 
					
						
							| 
									
										
										
										
											2015-02-17 18:52:54 -05:00
										 |  |  | 		} else if (parseInt(posts[0].uid, 10) === parseInt(app.user.uid, 10)) { | 
					
						
							| 
									
										
										
										
											2015-10-07 16:13:37 -04:00
										 |  |  | 			pagination.loadPage(ajaxify.data.pagination.pageCount, scrollToPost); | 
					
						
							| 
									
										
										
										
											2015-02-01 20:10:51 -05:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 	function onNewPostInfiniteScroll(data) { | 
					
						
							|  |  |  | 		var direction = config.topicPostSort === 'oldest_to_newest' || config.topicPostSort === 'most_votes' ? 1 : -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		createNewPosts(data, components.get('post').not('[data-index=0]'), direction, function(html) { | 
					
						
							|  |  |  | 			if (html) { | 
					
						
							|  |  |  | 				html.addClass('new'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			scrollToPostIfSelf(data.posts[0]); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function scrollToPostIfSelf(post) { | 
					
						
							|  |  |  | 		var isSelfPost = parseInt(post.uid, 10) === parseInt(app.user.uid, 10); | 
					
						
							|  |  |  | 		if (isSelfPost) { | 
					
						
							|  |  |  | 			navigator.scrollBottom(post.index); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function createNewPosts(data, repliesSelector, direction, callback) { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		callback = callback || function() {}; | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 		if (!data || (data.posts && !data.posts.length)) { | 
					
						
							| 
									
										
										
										
											2015-02-26 15:14:27 -05:00
										 |  |  | 			return callback(); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		function removeAlreadyAddedPosts() { | 
					
						
							| 
									
										
										
										
											2015-10-04 01:13:47 -04:00
										 |  |  | 			var newPosts = $('[component="post"].new'); | 
					
						
							| 
									
										
										
										
											2015-03-25 15:51:11 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			if (newPosts.length === data.posts.length) { | 
					
						
							|  |  |  | 				var allSamePids = true; | 
					
						
							|  |  |  | 				newPosts.each(function(index, el) { | 
					
						
							|  |  |  | 					if (parseInt($(el).attr('data-pid'), 10) !== parseInt(data.posts[index].pid, 10)) { | 
					
						
							|  |  |  | 						allSamePids = false; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (allSamePids) { | 
					
						
							|  |  |  | 					newPosts.each(function() { | 
					
						
							|  |  |  | 						$(this).removeClass('new'); | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 					data.posts.length = 0; | 
					
						
							|  |  |  | 					return; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-25 16:20:27 -04:00
										 |  |  | 			if (newPosts.length && data.posts.length > 1) { | 
					
						
							| 
									
										
										
										
											2015-03-25 15:51:11 -04:00
										 |  |  | 				data.posts.forEach(function(post) { | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 					var p = components.get('post', 'pid', post.pid); | 
					
						
							|  |  |  | 					if (p.hasClass('new')) { | 
					
						
							| 
									
										
										
										
											2015-09-26 18:29:27 -04:00
										 |  |  | 						p.remove(); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-09-26 18:29:27 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 			data.posts = data.posts.filter(function(post) { | 
					
						
							| 
									
										
										
										
											2015-10-04 01:13:47 -04:00
										 |  |  | 				return $('[component="post"][data-pid="' + post.pid + '"]').length === 0; | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		removeAlreadyAddedPosts(); | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-26 15:14:27 -05:00
										 |  |  | 		if (!data.posts.length) { | 
					
						
							|  |  |  | 			return callback(); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 		var after, before; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-26 22:27:10 -04:00
										 |  |  | 		if (direction > 0 && repliesSelector.length) { | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 			after = repliesSelector.last(); | 
					
						
							| 
									
										
										
										
											2015-09-26 22:27:10 -04:00
										 |  |  | 		} else if (direction < 0 && repliesSelector.length) { | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 			before = repliesSelector.first(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-22 08:14:51 +00:00
										 |  |  | 		data.slug = ajaxify.data.slug; | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2015-07-20 17:12:41 -04:00
										 |  |  | 		$(window).trigger('action:posts.loading', {posts: data.posts, after: after, before: before}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-29 23:58:48 -04:00
										 |  |  | 		app.parseAndTranslate('topic', 'posts', data, function(html) { | 
					
						
							| 
									
										
										
										
											2015-02-26 15:14:27 -05:00
										 |  |  | 			if (after) { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 				html.insertAfter(after); | 
					
						
							| 
									
										
										
										
											2015-02-26 15:14:27 -05:00
										 |  |  | 			} else if (before) { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 				// Save document height and position for future reference (about 5 lines down)
 | 
					
						
							|  |  |  | 				var height = $(document).height(), | 
					
						
							| 
									
										
										
										
											2015-09-26 18:29:27 -04:00
										 |  |  | 					scrollTop = $(window).scrollTop(); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				html.insertBefore(before); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 				// Now restore the relative position the user was on prior to new post insertion
 | 
					
						
							| 
									
										
										
										
											2015-09-26 18:29:27 -04:00
										 |  |  | 				$(window).scrollTop(scrollTop + ($(document).height() - height)); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2015-03-17 13:38:18 -04:00
										 |  |  | 				components.get('topic').append(html); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-04 01:13:47 -04:00
										 |  |  | 			infinitescroll.removeExtra($('[component="post"]'), direction, 40); | 
					
						
							| 
									
										
										
										
											2015-09-26 18:29:27 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-16 10:43:56 +03:00
										 |  |  | 			$(window).trigger('action:posts.loaded', {posts: data.posts}); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 16:36:37 -04:00
										 |  |  | 			Posts.processPage(html); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 16:36:37 -04:00
										 |  |  | 			callback(html); | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Posts.loadMorePosts = function(direction) { | 
					
						
							| 
									
										
										
										
											2015-03-17 13:38:18 -04:00
										 |  |  | 		if (!components.get('topic').length || navigator.scrollActive) { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 		var replies = components.get('post').not('[data-index=0]').not('.new'); | 
					
						
							|  |  |  | 		var afterEl = direction > 0 ? replies.last() : replies.first(); | 
					
						
							|  |  |  | 		var after = parseInt(afterEl.attr('data-index'), 10) || 0; | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-06 14:33:43 -04:00
										 |  |  | 		var tid = ajaxify.data.tid; | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 		if (!utils.isNumber(tid) || !utils.isNumber(after) || (direction < 0 && components.get('post', 'index', 0).length)) { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var indicatorEl = $('.loading-indicator'); | 
					
						
							|  |  |  | 		if (!indicatorEl.is(':animated')) { | 
					
						
							|  |  |  | 			indicatorEl.fadeIn(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		infinitescroll.loadMore('topics.loadMore', { | 
					
						
							|  |  |  | 			tid: tid, | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 			after: after, | 
					
						
							|  |  |  | 			direction: direction | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		}, function (data, done) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			indicatorEl.fadeOut(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (data && data.posts && data.posts.length) { | 
					
						
							| 
									
										
										
										
											2015-10-03 20:17:28 -04:00
										 |  |  | 				createNewPosts(data, replies, direction, done); | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2015-02-11 12:54:54 -05:00
										 |  |  | 				if (app.user.uid) { | 
					
						
							| 
									
										
										
										
											2014-11-29 02:07:19 -05:00
										 |  |  | 					socket.emit('topics.markAsRead', [tid]); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 				navigator.update(); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2015-09-24 21:14:34 -04:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-29 16:19:04 -04:00
										 |  |  | 	Posts.processPage = function(posts) { | 
					
						
							| 
									
										
										
										
											2015-10-24 22:29:22 -04:00
										 |  |  | 		Posts.showBottomPostBar(); | 
					
						
							| 
									
										
										
										
											2015-11-10 13:18:06 -05:00
										 |  |  | 		posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive'); | 
					
						
							| 
									
										
										
										
											2015-10-04 01:13:47 -04:00
										 |  |  | 		app.createUserTooltips(posts); | 
					
						
							| 
									
										
										
										
											2015-05-29 16:19:04 -04:00
										 |  |  | 		app.replaceSelfLinks(posts.find('a')); | 
					
						
							|  |  |  | 		utils.addCommasToNumbers(posts.find('.formatted-number')); | 
					
						
							|  |  |  | 		utils.makeNumbersHumanReadable(posts.find('.human-readable-number')); | 
					
						
							| 
									
										
										
										
											2015-08-17 16:26:35 -04:00
										 |  |  | 		posts.find('.timeago').timeago(); | 
					
						
							| 
									
										
										
										
											2015-10-28 15:16:14 -04:00
										 |  |  | 		Posts.wrapImagesInLinks(posts); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		addBlockquoteEllipses(posts.find('[component="post/content"] > blockquote > blockquote')); | 
					
						
							|  |  |  | 		hidePostToolsForDeletedPosts(posts); | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Posts.wrapImagesInLinks = function(posts) { | 
					
						
							| 
									
										
										
										
											2015-05-29 16:19:04 -04:00
										 |  |  | 		posts.find('[component="post/content"] img:not(.emoji)').each(function() { | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 			var $this = $(this); | 
					
						
							|  |  |  | 			if (!$this.parent().is('a')) { | 
					
						
							|  |  |  | 				$this.wrap('<a href="' + $this.attr('src') + '" target="_blank">'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-15 12:18:21 -04:00
										 |  |  | 	Posts.showBottomPostBar = function() { | 
					
						
							| 
									
										
										
										
											2015-10-24 22:29:22 -04:00
										 |  |  | 		var mainPost = components.get('post', 'index', 0); | 
					
						
							| 
									
										
										
										
											2015-10-24 23:03:12 -04:00
										 |  |  | 		var posts = $('[component="post"]'); | 
					
						
							|  |  |  | 		if (!!mainPost.length && posts.length > 1 && $('.post-bar').length < 2) { | 
					
						
							| 
									
										
										
										
											2015-10-24 22:29:22 -04:00
										 |  |  | 			$('.post-bar').clone().appendTo(mainPost); | 
					
						
							| 
									
										
										
										
											2015-10-24 23:03:12 -04:00
										 |  |  | 		} else if (mainPost.length && posts.length < 2) { | 
					
						
							|  |  |  | 			mainPost.find('.post-bar').remove(); | 
					
						
							| 
									
										
										
										
											2015-10-24 22:29:22 -04:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-10-15 12:18:21 -04:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-29 16:19:04 -04:00
										 |  |  | 	function hidePostToolsForDeletedPosts(posts) { | 
					
						
							|  |  |  | 		posts.each(function() { | 
					
						
							|  |  |  | 			if ($(this).hasClass('deleted')) { | 
					
						
							| 
									
										
										
										
											2015-07-06 12:39:05 -04:00
										 |  |  | 				postTools.toggle($(this).attr('data-pid'), true); | 
					
						
							| 
									
										
										
										
											2015-05-29 16:19:04 -04:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-11-18 14:33:14 -05:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function addBlockquoteEllipses(blockquotes) { | 
					
						
							|  |  |  | 		blockquotes.each(function() { | 
					
						
							|  |  |  | 			var $this = $(this); | 
					
						
							|  |  |  | 			if ($this.find(':hidden:not(br)').length && !$this.find('.toggle').length) { | 
					
						
							|  |  |  | 				$this.append('<i class="fa fa-angle-down pointer toggle"></i>'); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return Posts; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-25 19:09:39 -05:00
										 |  |  | }); |