Skip to content

Commit

Permalink
inline replies
Browse files Browse the repository at this point in the history
  • Loading branch information
voitto committed Aug 26, 2009
1 parent 6e7c92d commit 83d9f0f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 11 deletions.
4 changes: 4 additions & 0 deletions app/omb/plugins/omb.php
Expand Up @@ -367,6 +367,10 @@ function wp_set_post_fields_after( &$model, &$rec ) {
$rec->set_value( 'uri', $request->url_for( array(
'resource'=>'__'.$rec->id,
)));
if (isset($_POST['parent_id']) && is_numeric($_POST['parent_id']) && is_ajax()) {
$rec->set_value( 'parent_id',$_POST['parent_id']);
$rec->set_value( 'local',1);
}
$rec->save_changes();
}
}
Expand Down
13 changes: 5 additions & 8 deletions app/omb/plugins/wp.php
Expand Up @@ -22,11 +22,8 @@ function post_reply_link($arr,$post_id) {
global $the_post,$request;
if (!isset($the_post->id))
return;

echo $arr['before'].'<a href="'.$request->url_for(array(
'resource' => 'posts',
'id' => $post_id,
)).'" class="post-reply-link" rel="'. $post_id.'">' . $txt['wp_reply'] . '</a>';
$ccrurl = 'JavaScript:inline_comment('.$post_id.','.$post_id.');';
echo $arr['before'].'<a href="'.$ccrurl.'" class="post-reply-link" rel="'. $post_id.'">' . $txt['wp_reply'] . '</a>';


}
Expand Down Expand Up @@ -71,12 +68,12 @@ function render_comment(&$post,&$profile,&$parent) {
// $cctime = date( "g:i A" , strtotime($post->created) );
// $ccdate = date( get_settings('date_format'), strtotime($post->created) );
$ccurl = $request->url_for(array('resource'=>'posts','id'=>$post->id));
$ccrurl = $request->url_for(array('resource'=>'posts','id'=>$parent->id));
$ccrurl = 'JavaScript:inline_comment('.$post->id.','.$parent->id.');';
$comments .= '<h4>';
$comments .= ' <span class="meta">';
// $comments .= $cctime.' <em>on</em> '.$ccdate;
$comments .= '<span class="actions">';
$comments .= '<a href="'.$ccurl.'">Permalink</a> | <a rel=\'nofollow\' class=\'comment-reply-link\' href=\''.$ccrurl.'\'>' . $txt['wp_reply'] . '</a>';
$comments .= '<a href="'.$ccurl.'">Permalink</a> | <a rel=\'nofollow\' class=\'comment-reply-link\' href="'.$ccrurl.'">' . $txt['wp_reply'] . '</a>';
if ( get_profile_id() == $post->profile_id ) {
$comments .= ' | <a href="'.get_edit_post_link( $post ).'" class="post-edit-link" rel="'. $post->id.'">'.$txt['wp_Edit'].'</a>';
$comments .= ' | <a href="'.get_edit_post_link( $post, 'remove' ).'" class="post-remove-link" rel="'. $post->id.'">'.$txt['wp_remove'].'</a>';
Expand Down Expand Up @@ -1384,7 +1381,7 @@ function profile_get_avatar(&$profile,$size='normal') {
$TwitterUser =& $db->model('TwitterUser');
$tu = $TwitterUser->find_by('profile_id',$profile->id);
if ($tu && !empty($tu->screen_name))
return 'http://twivatar.org/'.$tu->screen_name.'/'.$size;
return 'http://dbscript.net/twivatar/index.php?size='.$size.'&user='.$tu->screen_name;
return $profile->avatar;
}

Expand Down
1 change: 1 addition & 0 deletions db/boot.php
Expand Up @@ -610,6 +610,7 @@

// echo value after single-field Ajax PUT call
after_filter( 'ajax_put_field', 'update_from_post' );
after_filter( 'ajax_put_field', 'insert_from_post' );


// authenticate yourself without OpenID
Expand Down
2 changes: 1 addition & 1 deletion wp-content/themes/p2/comments.php
Expand Up @@ -11,7 +11,7 @@

if ( have_comments ) {

echo "<div class=\"commentlist\">\n";
echo "<div id=\"commentcontent-".$the_post->id."\" class=\"commentlist\">\n";
wp_list_comments(array('callback' => 'prologue_comment'));
echo "</div>\n";
if ( get_option('page_comments') && (get_query_var('cpage') > 1 || get_query_var('cpage') < get_comment_pages_count() ) ) {
Expand Down
34 changes: 34 additions & 0 deletions wp-content/themes/p2/header.php
Expand Up @@ -50,6 +50,40 @@ function facebook_onlogin() {
</script>
<?php endif; ?>

<script src="<?php base_path(); ?>resource/jeditable/jquery.jeditable.js" type="text/javascript"></script>
<script type="text/javascript">
function inline_comment(postid,parentid) {
var cdiv = '#commentcontent-'+postid;
var submit_to = '<?php echo $request->url_for(array(
'resource' => 'posts'
)); ?>';
$(cdiv).append('<p class="editable_comment" id="'+cdiv+'editable"></p>');
$(".editable_comment").editable(submit_to, {
indicator : "<img src=\''. base_path(true).'resource/jeditable/indicator.gif\'>",
submitdata : function() {
return {"method":"post","parent_id":parentid};
},
name : "post[title]",
type : "textarea",
noappend : "true",
submit : "OK",
tooltip : "Click to edit...",
cancel : "Cancel",
callback : function(value, settings) {
return(value);
}
});
$(".editable_comment").trigger('click');
}
</script>
<style type="text/css">
.editable_comment {
width:380px;
height:40px;
padding-bottom:35px;
}
</style>

</head>
<body onload="JavaScript:setMaxLength();"<?php if(is_single()) echo ' class="single"'; ?>>

Expand Down
4 changes: 2 additions & 2 deletions wp-content/themes/p2/index.php
Expand Up @@ -70,8 +70,8 @@
function test(data) {
data = data.substring(0,(data.length - 10));
eval( "data = " + data );
if (data['in_reply_to'] > 0) {
var selectr = "#prologue-"+data['in_reply_to']+" ul#comments";
if (data['in_reply_to']) {
var selectr = data['in_reply_to'];
$(selectr).append(data['html']);
} else {
$("#postlist").prepend(data['html']);
Expand Down

0 comments on commit 83d9f0f

Please sign in to comment.