From adbbbb3602e26a69adafa56e7a308b9dca5bff65 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 17 Mar 2015 16:15:12 -0400 Subject: [PATCH] decided to go ahead and deprecate this for 0.7x instead of post-0.7x --- NOTES.md | 22 ----------------- public/src/client/category.js | 2 +- public/src/client/topic/browsing.js | 16 ++++++------ public/src/client/topic/events.js | 4 +-- public/src/client/topic/postTools.js | 34 ++++++++++++++------------ public/src/client/topic/posts.js | 10 ++++---- public/src/client/topic/threadTools.js | 10 ++++---- public/src/components.js | 21 ++++++---------- 8 files changed, 46 insertions(+), 73 deletions(-) delete mode 100644 NOTES.md diff --git a/NOTES.md b/NOTES.md deleted file mode 100644 index 79c8aceb34..0000000000 --- a/NOTES.md +++ /dev/null @@ -1,22 +0,0 @@ -Deprecation TODO's for post - 0.7x -====================================== - -- public/src/components.js: remove pre-0.7x compatibility code -- public/src/client/topic/postTools.js: remove selectors for every post button (ex. ".edit") -- remove all pre-0.7x compatibility selectors for: - Topics - - .post-content - .topic-title - .post_reply - .edit - .delete - .purge - .move - .reply - .quote - .chat - .flag - .thread_active_users - .browsing-users - .thread_active_users - .user-count \ No newline at end of file diff --git a/public/src/client/category.js b/public/src/client/category.js index 4e91b28afe..cdfb7495f5 100644 --- a/public/src/client/category.js +++ b/public/src/client/category.js @@ -55,7 +55,7 @@ define('forum/category', [ navigator.init('#topics-container > .category-item', ajaxify.variables.get('topic_count'), Category.toTop, Category.toBottom, Category.navigatorCallback); } - $('#topics-container').on('click', '[component="post/header"], .topic-title', function() { + $('#topics-container').on('click', '[component="post/header"]', function() { var clickedIndex = $(this).parents('[data-index]').attr('data-index'); $('#topics-container li.category-item').each(function(index, el) { if ($(el).offset().top - $(window).scrollTop() > 0) { diff --git a/public/src/client/topic/browsing.js b/public/src/client/topic/browsing.js index bdb5ee25dd..7c14fab158 100644 --- a/public/src/client/topic/browsing.js +++ b/public/src/client/topic/browsing.js @@ -10,7 +10,7 @@ define('forum/topic/browsing', function() { Browsing.onUpdateUsersInRoom = function(data) { if (data && data.room.indexOf('topic_' + ajaxify.variables.get('topic_id')) !== -1) { - $('.thread_active_users-users, [component="topic/browsing/list"]').parent().toggleClass('hidden', !data.users.length); + $('[component="topic/browsing/list"]').parent().toggleClass('hidden', !data.users.length); for(var i=0; i'); } } @@ -99,11 +99,11 @@ define('forum/topic/browsing', function() { if (!count || count < 0) { count = 0; } - $('.user-count, [component="topic/browsing/count"]').text(count).parent().toggleClass('hidden', count === 0); + $('[component="topic/browsing/count"]').text(count).parent().toggleClass('hidden', count === 0); } function increaseUserCount(incr) { - updateUserCount(parseInt($('.user-count, [component="topic/browsing/count"]').first().text(), 10) + incr); + updateUserCount(parseInt($('[component="topic/browsing/count"]').first().text(), 10) + incr); } return Browsing; diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index 614202c160..c3ecf6d29a 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -159,9 +159,9 @@ define('forum/topic/events', [ if (!app.user.isAdmin && parseInt(data.uid, 10) !== parseInt(app.user.uid, 10)) { if (isDeleted) { - postEl.find('[component="post/content"], .post-content').translateHtml('[[topic:post_is_deleted]]'); + postEl.find('[component="post/content"]').translateHtml('[[topic:post_is_deleted]]'); } else { - postEl.find('[component="post/content"], .post-content').html(data.content); + postEl.find('[component="post/content"]').html(data.content); } } } diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.js index 247623943c..15a8ac3163 100644 --- a/public/src/client/topic/postTools.js +++ b/public/src/client/topic/postTools.js @@ -20,10 +20,12 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com PostTools.toggle = function(pid, isDeleted) { var postEl = components.get('post', 'pid', pid); - postEl.find('.quote, .favourite, .post_reply, .chat, .flag').toggleClass('hidden', isDeleted); - postEl.find('.purge').toggleClass('hidden', !isDeleted); - postEl.find('.delete .i').toggleClass('fa-trash-o', !isDeleted).toggleClass('fa-history', isDeleted); - postEl.find('.delete span').translateHtml(isDeleted ? ' [[topic:restore]]' : ' [[topic:delete]]'); + postEl.find('[component="post/quote"], [component="post/favourite"], [component="post/reply"], [component="post/flag"], [component="user/chat"]') + .toggleClass('hidden', isDeleted); + + postEl.find('[component="post/purge"]').toggleClass('hidden', !isDeleted); + postEl.find('[component="post/delete"] .i').toggleClass('fa-trash-o', !isDeleted).toggleClass('fa-history', isDeleted); + postEl.find('[component="post/delete"] span').translateHtml(isDeleted ? ' [[topic:restore]]' : ' [[topic:delete]]'); }; PostTools.updatePostCount = function() { @@ -78,55 +80,55 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com * Use the components system instead. */ - postContainer.on('click', '.quote, [component="post/quote"]', function() { + postContainer.on('click', '[component="post/quote"]', function() { if (!threadState.locked) { onQuoteClicked($(this), tid, topicName); } }); - postContainer.on('click', '.post_reply, [component="post/reply"]', function() { + postContainer.on('click', '[component="post/reply"]', function() { if (!threadState.locked) { onReplyClicked($(this), tid, topicName); } }); - postContainer.on('click', '.favourite, [component="post/favourite"]', function() { + postContainer.on('click', '[component="post/favourite"]', function() { favouritePost($(this), getData($(this), 'data-pid')); }); - postContainer.on('click', '.upvote, [component="post/upvote"]', function() { + postContainer.on('click', '[component="post/upvote"]', function() { return toggleVote($(this), '.upvoted', 'posts.upvote'); }); - postContainer.on('click', '.downvote, [component="post/downvote"]', function() { + postContainer.on('click', '[component="post/downvote"]', function() { return toggleVote($(this), '.downvoted', 'posts.downvote'); }); - postContainer.on('click', '.votes, [component="post/vote-count"]', function() { + postContainer.on('click', '[component="post/vote-count"]', function() { showVotes(getData($(this), 'data-pid')); }); - postContainer.on('click', '.flag, [component="post/flag"]', function() { + postContainer.on('click', '[component="post/flag"]', function() { flagPost(getData($(this), 'data-pid')); }); - postContainer.on('click', '.edit, [component="post/edit"]', function(e) { + postContainer.on('click', '[component="post/edit"]', function(e) { composer.editPost(getData($(this), 'data-pid')); }); - postContainer.on('click', '.delete, [component="post/delete"]', function(e) { + postContainer.on('click', '[component="post/delete"]', function(e) { deletePost($(this), tid); }); - postContainer.on('click', '.purge, [component="post/purge"]', function(e) { + postContainer.on('click', '[component="post/purge"]', function(e) { purgePost($(this), tid); }); - postContainer.on('click', '.move, [component="post/move"]', function(e) { + postContainer.on('click', '[component="post/move"]', function(e) { openMovePostModal($(this)); }); - postContainer.on('click', '.chat, [component="user/chat"]', function(e) { + postContainer.on('click', '[component="user/chat"]', function(e) { openChat($(this)); }); } diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index af7615f441..e6dffa75c4 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -168,14 +168,14 @@ define('forum/topic/posts', [ isSelfPost = parseInt(postEl.attr('data-uid'), 10) === parseInt(app.user.uid, 10); if (!privileges.editable) { - postEl.find('.edit, .delete, .purge, [component="post/edit"], [component="post/delete"], [component="post/purge"]').remove(); + postEl.find('[component="post/edit"], [component="post/delete"], [component="post/purge"]').remove(); } if (!privileges.move) { - postEl.find('.move, [component="post/move"]').remove(); + postEl.find('[component="post/move"]').remove(); } - postEl.find('.chat, .flag, [component="user/chat"], [component="post/flag"]').toggleClass('hidden', isSelfPost || !app.user.uid); + postEl.find('[component="user/chat"], [component="post/flag"]').toggleClass('hidden', isSelfPost || !app.user.uid); } Posts.loadMorePosts = function(direction) { @@ -226,14 +226,14 @@ define('forum/topic/posts', [ utils.addCommasToNumbers(element.find('.formatted-number')); utils.makeNumbersHumanReadable(element.find('.human-readable-number')); element.find('.timeago').timeago(); - element.find('[component="post/content"] img:not(.emoji), .post-content img:not(.emoji)').addClass('img-responsive').each(function() { + element.find('[component="post/content"] img:not(.emoji)').addClass('img-responsive').each(function() { var $this = $(this); if (!$this.parent().is('a')) { $this.wrap(''); } }); postTools.updatePostCount(); - addBlockquoteEllipses(element.find('[component="post/content"] > blockquote, .post-content > blockquote')); + addBlockquoteEllipses(element.find('[component="post/content"] > blockquote')); hidePostToolsForDeletedPosts(element); showBottomPostBar(); }; diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index 193fe7c607..c1900fc508 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -105,12 +105,12 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func translator.translate(isLocked ? '[[topic:locked]]' : '[[topic:reply]]', function(translated) { var className = isLocked ? 'fa-lock' : 'fa-reply'; - threadEl.find('.post_reply, [component="post/reply"]').html(' ' + translated); - $('.post_reply, [component="post/reply"]').attr('disabled', isLocked).html(isLocked ? ' ' + translated : translated); + threadEl.find('[component="post/reply"]').html(' ' + translated); + $('[component="post/reply"]').attr('disabled', isLocked).html(isLocked ? ' ' + translated : translated); }); - threadEl.find('.quote, .edit, .delete').toggleClass('hidden', isLocked); - $('[component="post/header"] i.fa-lock, .topic-title i.fa-lock').toggleClass('hide', !data.isLocked); + threadEl.find('[component="quote"], [component="edit"], [component="delete"]').toggleClass('hidden', isLocked); + $('[component="post/header"] i.fa-lock').toggleClass('hide', !data.isLocked); ThreadTools.threadState.locked = data.isLocked; } }; @@ -144,7 +144,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func components.get('topic/pin').html(translated); ThreadTools.threadState.pinned = data.isPinned; }); - $('[component="post/header"] i.fa-thumb-tack, .topic-title i.fa-thumb-tack').toggleClass('hide', !data.isPinned); + $('[component="post/header"] i.fa-thumb-tack').toggleClass('hide', !data.isPinned); } }; diff --git a/public/src/components.js b/public/src/components.js index 6014c14184..282e445167 100644 --- a/public/src/components.js +++ b/public/src/components.js @@ -8,33 +8,26 @@ var components = components || {}; return $('[data-' + name + '="' + value + '"]'); }, 'post/content': function(pid) { - var el = components.core.post('pid', pid).find('[component="post/content"]'); - return el.length ? el : $('#content_' + pid); // deprecated after 0.7x + return components.core.post('pid', pid).find('[component="post/content"]'); }, 'post/header': function(pid) { - var el = components.core.post('pid', pid).find('[component="post/header"]'); - return el.length ? el : $('#topic_title_' + pid); // deprecated after 0.7x + return components.core.post('pid', pid).find('[component="post/header"]'); }, 'post/anchor': function(index) { - var el = components.core.post('index', index).find('[component="post/anchor"]'); - return el.length ? el : $('#post_anchor_' + index); // deprecated after 0.7x + return components.core.post('index', index).find('[component="post/anchor"]'); }, 'post/vote-count': function(pid) { - var el = components.core.post('pid', pid).find('[component="post/vote-count"]'); - return el.length ? el : components.core.post('pid', pid).find('.votes'); // deprecated after 0.7x + return components.core.post('pid', pid).find('[component="post/vote-count"]'); }, 'post/favourite-count': function(pid) { - var el = components.core.post('pid', pid).find('[component="post/favourite-count"]'); - return el.length ? el : components.core.post('pid', pid).find('.favouriteCount'); // deprecated after 0.7x + return components.core.post('pid', pid).find('[component="post/favourite-count"]'); }, 'user/postcount': function(uid) { - var el = $('[component="user/postcount"][data-uid="' + uid + '"]'); - return el.length ? el : $('.user_postcount_' + uid); // deprecated after 0.7x + return $('[component="user/postcount"][data-uid="' + uid + '"]'); }, 'user/reputation': function(uid) { - var el = $('[component="user/reputation"][data-uid="' + uid + '"]'); - return el.length ? el : $('.reputation[data-uid="' + uid + '"]'); // deprecated after 0.7x + return $('[component="user/reputation"][data-uid="' + uid + '"]'); } };