Skip to content

Commit

Permalink
Add thread hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
ahushh committed Aug 31, 2013
1 parent 3ae74a2 commit ce5097f
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 6 deletions.
3 changes: 3 additions & 0 deletions messages/en.msg
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ ExpandPost: Show full.
ShrinkPost: Shrink message.

Sage: sage
HideThread: Hide thread
ThreadIsHidden: Thread is hidden.
ShowThread: Show thread
######################################################################################
#### Settings
######################################################################################
Expand Down
3 changes: 3 additions & 0 deletions messages/ru.msg
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ ExpandPost: Полный текст.
ShrinkPost: Обрезать текст.

Sage: сажа
HideThread: Скрыть тред
ThreadIsHidden: Тред скрыт.
ShowThread: Показать тред
######################################################################################
#### Settings
######################################################################################
Expand Down
1 change: 1 addition & 0 deletions static/css/ash.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ footer {
}

.reply-post {
display: table;
background: none repeat scroll 0% 0% #CFCFCF;
border-radius: 3px;
border: 1px solid #EEEEEE;
Expand Down
1 change: 1 addition & 0 deletions static/css/futaba.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ footer {
}

.reply-post {
display: table;
background: none repeat scroll 0% 0% #F0E0D6;
border: 1px solid #DDCCC5;
margin: 4px;
Expand Down
4 changes: 2 additions & 2 deletions static/css/postmodern.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ footer {
}

.op-post {
display: inline-block !important;
display: inline-block;
width: 98%;
margin: 3px;
padding: 5px;
Expand All @@ -126,7 +126,7 @@ footer {
}

.reply-post {
display: inline-block !important;
display: inline-block;
width: 98%;
background: none repeat scroll 0% 0% #CACACA;
border: 1px dotted rgba(0,0,0,0.5);
Expand Down
54 changes: 51 additions & 3 deletions templates/default-layout.julius
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function baseInit() {
// Init
//-----------------------------------------------------------------
checkHighlighted();
initHiddenThreads();
baseInit();
initSymbolCounter();
$('textarea').autosize()
Expand Down Expand Up @@ -154,6 +155,51 @@ function addEmbeddedPlayer(post) {
});
}
//-----------------------------------------------------------------
// thread hiding
//-----------------------------------------------------------------
function initHiddenThreads() {
var ths = JSON.parse(localStorage.getItem('hidden-threads'));
if (!ths) return false;
$('.op-post').each(function() {
var fullId = $(this).attr('id');
var threadId = extractPost(fullId);
var board = extractBoard(fullId);
if (ths[threadId+'-'+board]) {
hideThread(threadId, board);
}
});
}

function hideThread(threadId, board) {
var ths = JSON.parse(localStorage.getItem('hidden-threads'));
if (!ths) {
ths = {};
}
if (!ths[threadId+'-'+board]) {
ths[threadId+'-'+board] = 1;
}
localStorage.setItem('hidden-threads', JSON.stringify(ths));

$('#thread-'+threadId).find('.op-post').hide();
$('#thread-'+threadId).find('.reply-post').hide();
if ($('#thread-'+threadId).has('.hidden-thread').length) {
$('#thread-'+threadId).find('.hidden-thread').show()
} else {
$('#thread-'+threadId).append('<span class=hidden-thread> No. '+threadId+' '+#{toJSON $ msgrender MsgThreadIsHidden}+' <img class=icon-show-thread src="@{StaticR img_blank_gif}" onclick="showThread('+threadId+', \''+board+'\')" alt="'+#{toJSON $ msgrender MsgShowThread}+'" title="'+#{toJSON $ msgrender MsgShowThread}+'"></span>');
}
}

function showThread(threadId,board) {
var ths = JSON.parse(localStorage.getItem('hidden-threads'));
if (ths) {
delete ths[threadId+'-'+board];
localStorage.setItem('hidden-threads', JSON.stringify(ths));
}
$('#thread-'+threadId).find('.op-post').show();
$('#thread-'+threadId).find('.reply-post').show();
$('#thread-'+threadId).find('.hidden-thread').hide();
}
//-----------------------------------------------------------------
// popup messages
//-----------------------------------------------------------------
function popupMessage(text, delay, icon) {
Expand Down Expand Up @@ -234,9 +280,11 @@ function doImageExpanding(post) {
function checkHighlighted() {
var postId = window.location.hash.substr(1);
if (postId) {
var thread = /\/thread\/[\w_]+\/(\d+)/.exec(document.URL)[1];
var board = /\/thread\/([\w_]+)\/\d+/.exec(document.URL)[1];
highlightPost("post-"+postId+"-"+thread+"-"+board);
var thread = /\/thread\/[\w_]+\/(\d+)/.exec(document.URL);
var board = /\/thread\/([\w_]+)\/\d+/.exec(document.URL);
if (thread && board) {
highlightPost("post-"+postId+"-"+thread[1]+"-"+board[1]);
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion templates/default-layout.lucius
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ hr {
}

.reply-post {
display: table;
min-width: 40em;
overflow: hidden;
word-wrap: break-word;
Expand Down Expand Up @@ -149,6 +148,16 @@ hr {
cursor: auto;
}

.icon-hide-thread {
background-position: -1061px -77px;
float: right;
}

.icon-show-thread {
float: right;
background-position: -1037px -77px;
}

.admin-table {
border-collapse: collapse;
font-size: 0.8em;
Expand Down
1 change: 1 addition & 0 deletions templates/op-post.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $with thread <- show $ postLocalId $ entityVal eOpPostW
<span .reply-title>#{postTitle $ entityVal $ eOpPostW}
<span .poster-name>#{postName $ entityVal eOpPostW}
<span .time>#{myFormatTime tOffsetW $ postDate $ entityVal $ eOpPostW}
<img onclick="hideThread(#{thread}, '#{board}')" src=@{StaticR img_blank_gif} title=_{MsgHideThread} alt=_{MsgHideThread} .icon-hide-thread>
<div .thread-status>
$if postSticked $ entityVal $ eOpPostW
<img src=@{StaticR img_blank_gif} title=sticked alt=sticked .icon-thread-sticked>
Expand Down

0 comments on commit ce5097f

Please sign in to comment.