From d6aa5c0fe5135b6f4c575c6ce6ca8e1c56475ff4 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Tue, 24 Feb 2015 16:04:00 +0800 Subject: [PATCH] Split post menu into own function --- js/post-filter.js | 318 ++++++++++++++++++---------------------------- js/post-menu.js | 209 ++++++++++++++++++++++++++++++ 2 files changed, 334 insertions(+), 193 deletions(-) create mode 100644 js/post-menu.js diff --git a/js/post-filter.js b/js/post-filter.js index c2c5a764..83684176 100644 --- a/js/post-filter.js +++ b/js/post-filter.js @@ -204,192 +204,150 @@ if (active_page === 'thread' || active_page === 'index') { /* * create filter menu when the button is clicked */ - function addMenu(e, ele, threadId, pageData) { + function initPostMenu(pageData) { - var $ele = $(ele); - var $buffer; + var submenu; + Menu.add_item('filter-menu-hide', 'Hide post'); + Menu.add_item('filter-menu-unhide', 'Unhide post'); - var postId = $ele.find('.post_no').not('[id]').text(); - if (pageData.hasUID) { - var postUid = $ele.find('.poster_id').text(); - } - var postName; - var postTrip = ''; - if (!pageData.forcedAnon) { - postName = (typeof $ele.find('.name').contents()[0] == 'undefined') ? '' : $ele.find('.name').contents()[0].nodeValue.trim(); - postTrip = $ele.find('.trip').text(); - } + submenu = Menu.add_submenu('filter-menu-add', 'Add filter'); + submenu.add_item('filter-add-post-plus', 'Post +', 'Hide post and all replies'); + submenu.add_item('filter-add-id', 'ID'); + submenu.add_item('filter-add-id-plus', 'ID +', 'Hide ID and all replies'); + submenu.add_item('filter-add-name', 'Name'); + submenu.add_item('filter-add-trip', 'Tripcode'); - // get the button's position - var pos = $(e.target).offset(); + submenu = Menu.add_submenu('filter-menu-remove', 'Remove filter'); + submenu.add_item('filter-remove-id', 'ID'); + submenu.add_item('filter-remove-name', 'Name'); + submenu.add_item('filter-remove-trip', 'Tripcode'); - $buffer = $('
').append( - $('