Skip to content

Commit

Permalink
more d2 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pudge committed Mar 27, 2008
1 parent b60e688 commit d1816e7
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 65 deletions.
5 changes: 3 additions & 2 deletions Slash/Utility/Comments/Comments.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ EOT
my $link = join(" ", @link);

if (@link) {
$commentsub = "$link";
$commentsub = $link;
}

}
Expand Down Expand Up @@ -2071,6 +2071,7 @@ EOT

my $class = $comment->{class};
my $classattr = $discussion2 ? qq[ class="$class"] : '';
my $contain = $class eq 'full' ? ' contain' : '';

my $head = $discussion2 ? <<EOT1 : <<EOT2;
<h4><a id="comment_link_$comment->{cid}" name="comment_link_$comment->{cid}" href="$gSkin->{rootdir}/comments.pl?sid=$comment->{sid}&amp;cid=$comment->{cid}" onclick="return setFocusComment($comment->{cid})">$comment->{subject}</a>
Expand All @@ -2080,7 +2081,7 @@ EOT2

my $return = '';
$return = <<EOT if !$options->{noshow_show};
<li id="tree_$comment->{cid}" class="comment">
<li id="tree_$comment->{cid}" class="comment$contain">
<div id="comment_status_$comment->{cid}" class="commentstatus"></div>
<div id="comment_$comment->{cid}"$classattr>
EOT
Expand Down
5 changes: 4 additions & 1 deletion plugins/Ajax/htdocs/ajax.pl
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ sub main {
$rkey->use;
}
if (!$rkey->success) {
# feel free to send msgdiv => 'thisdivhere' to the ajax call,
# and any reskey error messages will be sent to it
if ($form->{msgdiv}) {
header_ajax({ content_type => 'application/json' });
(my $msgdiv = $form->{msgdiv}) =~ s/[^\w-]+//g;
print Data::JavaScript::Anon->anon_dump({
html => { $msgdiv => $rkey->errstr },
html => { $msgdiv => $rkey->errstr },
eval_last => "\$('#$msgdiv').show()"
});
}
$rkey->ERROR($op);
Expand Down
6 changes: 3 additions & 3 deletions plugins/Ajax/templates/edit_comment;ajax;default
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ __template__
<p class="warning">
[% IF constants.allow_anonymous %]
You are not logged in. You can <a href=\"${gSkin.rootdir}/login.pl\">log
in now</a>, or <a href="[% gSkin.rootdir %]/users.pl">Create an Account</a>/
in now</a>, or <a href="[% gSkin.rootdir %]/users.pl">Create an Account</a>.
[% ELSE %]
You are not logged in. You can <a href=\"${gSkin.rootdir}/login.pl\">log
in now</a>, <a href="[% gSkin.rootdir %]/users.pl">Create an Account</a>,
Expand All @@ -35,7 +35,7 @@ __template__

[% IF !user.is_anon || constants.allow_anonymous %]
<form action="[% gSkin.rootdir %]/comments.pl" method="post">
<div id="replyto_preview_[% pid %]" class="replyto_reply" onclick="editReply([% pid %])"></div>
<div id="replyto_preview_[% pid %]" class="replyto_reply" ondblclick="editReply([% pid %])"></div>
<div id="replyto_reply_[% pid %]" class="replyto_reply">
<input type="hidden" name="sid" value="[% sid %]">
[% IF pid %]<input type="hidden" name="pid" value="[% pid %]">[% END %]
Expand All @@ -58,7 +58,7 @@ __template__
<textarea wrap="virtual" name="postercomment_[% pid %]" id="postercomment_[% pid %]" rows="[% user.textarea_rows || constants.textarea_rows %]" cols="[% user.textarea_cols || constants.textarea_cols %]"></textarea>
</div>
</div>
<div id="replyto_msg_[% pid %]" class="replyto_msg"></div>
<div id="replyto_msg_[% pid %]" class="replyto_msg" style="display: none"></div>
<div class="replyto_buttons">
<span id="replyto_buttons_1_[% pid %]">
<input type="button" name="preview_[% pid %]" id="preview_[% pid %]" value="Preview" class="button" onclick="previewReply([% pid %]); return false;">
Expand Down
38 changes: 22 additions & 16 deletions themes/slashcode/htdocs/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,16 @@ html > body .commentwrap table {
.comment > .oneline {
border: 1px solid #e5e5e5;
margin: 1em 0 0 0;
padding: .3em 0 0 0;
padding: 0.35em 0 0 0.25em;
position: relative;
width: 99%;
height: 1.3em;
overflow: hidden;
}

.comment > .currcomment {
border: 1px dotted #666;
margin: 0.85em 0px -0.15em -0.15em;
border: .15em solid rgb(142,142,142);
}

/* lots of space between lines */
Expand Down Expand Up @@ -385,28 +386,33 @@ div.ccw-panel, #ccw-control,

.nbutton{
background: #666 url("/images/corner_w_tl.png") top left no-repeat;
color:#fff;
margin:0.25em;
padding: .4em 0;
color:#fff;
margin:0.25em;
padding: .4em 0;
}
.nbutton p{
display:inline;
background: transparent url("/images/corner_w_tr.png") top right no-repeat;
padding: .4em 0;
display:inline;
background: transparent url("/images/corner_w_tr.png") top right no-repeat;
padding: .4em 0;
}
.nbutton p b{
display:inline;
background: transparent url("/images/corner_w_bl.png") bottom left no-repeat;
padding: .4em 0;
display:inline;
background: transparent url("/images/corner_w_bl.png") bottom left no-repeat;
padding: .4em 0;
}
.nbutton p b a {
background: transparent url("/images/corner_w_br.png") bottom right no-repeat !important;
padding: .4em 1em;
color:#fff !important;
font-weight:normal;
text-decoration:none;
background: transparent url("/images/corner_w_br.png") bottom right no-repeat !important;
padding: .4em 1em;
color:#fff !important;
font-weight:normal;
text-decoration:none;
}
.nbutton:hover {background-color: #444}

span.current {position: absolute; left: .5em; margin-top: -.2em; z-index: 0; font-weight: bold; font-size: 197%;}

.contain {
border: .15em solid #d5d5d5;
border-top: none;
}

122 changes: 83 additions & 39 deletions themes/slashcode/htdocs/images/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function updateComment(cid, mode) {
if (!cd.innerHTML) {
var cs = fetchEl('comment_sub_' + cid);
if (cs)
cs.innerHTML = '<span class="commentload">Loading ...</span>';
cs.innerHTML = '<span class="commentload">Loading...</span>';
fetch_comments.push(cid);
fetch_comments_pieces[cid] = 1;
doshort = 1;
Expand All @@ -93,7 +93,14 @@ function updateComment(cid, mode) {
}
// if (doshort)
setShortSubject(cid, mode, cl);
existingdiv.className = existingdiv.className.replace(/full|hidden|oneline/, mode);
var new_class = existingdiv.className.replace(/full|hidden|oneline/, mode);
if (new_class != existingdiv.className) {
existingdiv.className = new_class;
var parentdiv = fetchEl('tree_' + cid);
parentdiv.className = parentdiv.className.replace(' contain', '');
if (mode == 'full')
parentdiv.className = parentdiv.className + ' contain';
}
if (adTimerUrl) {
var addiv = fetchEl('comment_ad_' + cid);
if (addiv) {
Expand Down Expand Up @@ -941,7 +948,7 @@ function readRest(cid) {
}
};

shrunkdiv.innerHTML = 'Loading...';
shrunkdiv.innerHTML = '<span class="loading">Loading...</span>';
ajax_update(params, 'comment_body_' + cid, handlers);

return false;
Expand Down Expand Up @@ -992,22 +999,36 @@ function editReply(pid) {
if (!replydiv || !reply || !preview)
return false;

setReplyMsg(pid, '');
preview.style.display = 'none';
reply.style.display = 'block';

$dom('replyto_buttons_2_' + pid).style.display = 'none';
$dom('replyto_buttons_1_' + pid).style.display = 'inline';
}

function setReplyMsg(pid, msg) {
if (!pid)
return;
var msgdiv = $('#replyto_msg_' + pid);
if (!msgdiv)
return;

msgdiv.html(msg);
if (msg)
msgdiv.show();
else
msgdiv.hide();
}

function replyPreviewOrSubmit (pid, op, handlers) {
var replydiv = $dom('replyto_' + pid);
var reply = $dom('replyto_reply_' + pid);
var preview = $dom('replyto_preview_' + pid);
var this_reskey = $dom('reskey_reply_' + pid);
var msgdiv = 'replyto_msg_' + pid;
var msg = $dom(msgdiv);

if (!replydiv || !reply || !preview || !this_reskey || !msg)
if (!replydiv || !reply || !preview || !this_reskey)
return false;

var params = {};
Expand All @@ -1028,20 +1049,18 @@ function replyPreviewOrSubmit (pid, op, handlers) {
if (postanon && postanon.checked)
params['postanon'] = postanon.value;

msg.innerHTML = 'Loading...';
setReplyMsg(pid, '<span class="loading">Loading...</span>');
ajax_update(params, '', handlers);
}

function submitReply(pid) {
return replyPreviewOrSubmit(pid, 'comments_submit_reply', {
onComplete: function(transport) {
var msg = $dom('replyto_msg_' + pid);
msg.innerHTML = '';
setReplyMsg(pid, '');
var response = json_handler(transport);

var cid = response.cid;
if (response.error)
msg.innerHTML = response.error;
setReplyMsg(pid, response.error);
else if (cid) {
cancelReply(pid);
addComment(cid, { pid: pid, kids: [] }, '', 1);
Expand All @@ -1055,17 +1074,15 @@ function submitReply(pid) {
function previewReply(pid) {
return replyPreviewOrSubmit(pid, 'comments_preview_reply', {
onComplete: function(transport) {
var msg = $dom('replyto_msg_' + pid);
msg.innerHTML = '';
setReplyMsg(pid, '');
var response = json_handler(transport);

if (response.error)
msg.innerHTML = response.error;
setReplyMsg(pid, response.error);
if (response.html) {
$dom('replyto_reply_' + pid).style.display = 'none';
$dom('replyto_preview_' + pid).style.display = 'block';
$dom('replyto_buttons_1_' + pid).style.display = 'none';
$dom('replyto_buttons_2_' + pid).style.display = 'inline';
$('#replyto_reply_' + pid).hide();
$('#replyto_preview_' + pid).show();
$('#replyto_buttons_1_' + pid).hide();
$('#replyto_buttons_2_' + pid).show();
}
}
});
Expand All @@ -1087,15 +1104,15 @@ function replyTo(pid) {
params['pid'] = pid;
params['sid'] = discussion_id;

replydiv.innerHTML = 'Loading...';
replydiv.innerHTML = '<span class="loading">Loading...</span>';

var handlers = {
onComplete: function(transport) {
json_handler(transport);
if (pid) { // XXX
var reply_link = $dom('reply_link_' + pid);
reply_link_html[pid] = reply_link.innerHTML;
reply_link.innerHTML = '<a href="#" onclick="cancelReply(' + pid + '); return false;">Cancel Reply</a>';
reply_link.innerHTML = '<p><b><a href="#" onclick="cancelReply(' + pid + '); return false;">Cancel Reply</a></b></p>';
}
$dom('postercomment_' + pid).focus();
}
Expand Down Expand Up @@ -1849,19 +1866,19 @@ function setCurrentComment (cid) {
if (cid == current_cid)
return;

this_id = fetchEl('comment_top_' + current_cid);
if (this_id)
this_id.className = this_id.className.replace(' newcomment', ' oldcomment');
this_id = $('#comment_top_' + current_cid);
this_id.removeClass('newcomment');
this_id.addClass('oldcomment');

this_id = fetchEl('comment_' + current_cid);
if (this_id)
this_id.className = this_id.className.replace(' currcomment', '');
this_id = $('#comment_' + current_cid);
this_id.removeClass('currcomment');
$('.current').remove();
}


this_id = fetchEl('comment_' + cid);
if (this_id)
this_id.className = this_id.className + ' currcomment';
this_id = $('#comment_' + cid);
this_id.addClass('currcomment');
this_id.before('<span class="current">&rsaquo;</span>');

current_cid = cid;
}
Expand All @@ -1878,14 +1895,15 @@ next unread comm: F
reply to current comment: R
parent of current comment: P
history (modlog) of current comment: M
skip to end (last): V XXX
skip to top (first): T XXX
get more comments: G XXX
skip to end (last): V
skip to top (first): T
get more comments: G
lower top threshold: [
raise top threshold: [
raise top threshold: ]
lower bottom threshold: ,
raise bottom threshold: .
toggle d2 widget: /
toggle d2 widget: / XXX
hide_modal_box(): esc XXX
*/

var validkeys = {
Expand All @@ -1911,7 +1929,6 @@ var validkeys = {
',' : { thresh : 1, bottom : 1, down: 1 },
'.' : { thresh : 1, bottom : 1, up : 1 },

// esc = hide_modal_box() ?
};

validkeys['H'] = validkeys['A'];
Expand Down Expand Up @@ -1976,10 +1993,13 @@ function keyHandler(e, k) {
ajaxFetchComments(0, 1);

else if (keyo['skip']) { // XXX how to find top/bottom?
if (keyo['top'])
1;
if (keyo['bottom'])
1;
if (keyo['top']) {
next_cid = commTreeFirstComm();
update = 1;
} else if (keyo['bottom']) {
next_cid = commTreeLastComm();
update = 1;
}
}

// threshold keys keys
Expand Down Expand Up @@ -2107,6 +2127,30 @@ function commTreeNextComm (cid, old_cid, getNextUnread) {
return commTreeNextComm(comments[cid].pid, cid, getNextUnread);
}

function commTreeLastComm () {
var this_cid = current_cid;
if (!current_cid)
this_cid = last_updated_comments[0];
for (;;) {
var new_cid = commTreeNextComm(this_cid);
if (!new_cid)
return this_cid;
this_cid = new_cid;
}
}

function commTreeFirstComm () {
var this_cid = current_cid;
if (!current_cid)
this_cid = last_updated_comments[0];
for (;;) {
var new_cid = commTreePrevComm(this_cid, 2);
if (!new_cid)
return this_cid;
this_cid = new_cid;
}
}

function commTreePrevComm (cid, to_parent) {
var root_kids = rootSort();
var comm = comments[cid];
Expand Down
2 changes: 1 addition & 1 deletion themes/slashcode/templates/dispComment;misc;default
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ __name__
dispComment
__template__
[% IF !options.noshow_show %]
<li id="tree_[% cid %]" class="comment">
<li id="tree_[% cid %]" class="comment[% IF class == 'full' %] contain[% END %]">
<div id="comment_status_[% cid %]" class="commentstatus"></div>
<div id="comment_[% cid %]"[% IF discussion2 %] class="[% class %]"[% END %]>
[% END; IF !options.noshow %]
Expand Down
2 changes: 1 addition & 1 deletion themes/slashcode/templates/printCommComments;misc;default
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ __template__
[% END %]
[% thread = Slash.displayThread(sid, pid, lvl, comments) %]
[% IF thread || discussion2 %]
[% UNLESS cid %]<ul id="commentlisting">[% END %]
[% UNLESS cid %]<ul id="commentlisting"[% IF discussion2 %] class="d2"[% END %]>[% END %]
[% thread || '' %]
<li id="roothiddens" class="hide"></li>
[% UNLESS cid %]</ul>[% END %]
Expand Down
Loading

0 comments on commit d1816e7

Please sign in to comment.