• Hi guys.

    I use in MCEcomments plug-in with iNove theme.
    In this specific theme in comments section there is option to “Reply” and “Quote” comments.
    In the normal textarea the “Replay” and “Quote” work excellent, but how can i make this “Reply” and “Quote” and MCEcomments(based on TinyMCE Editor)?

    that some code from iNove theme(that related to the “Reply” and “Quote”):

    • function.php – lines: 501/526
    • <div class="info">
      			<div class="date">
      				<?php printf( __('%1$s at %2$s', 'inove'), get_comment_time(__('F jS, Y', 'inove')), get_comment_time(__('H:i', 'inove')) ); ?>
      					 | <a href="#comment-<?php comment_ID() ?>"><?php printf('#%1$s', ++$commentcount); ?></a>
      			</div>
      			<div class="act">
      				<a href="javascript:void(0);" onclick="MGJS_CMT.reply('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment');"><?php _e('Reply', 'inove'); ?></a> |
      				<a href="javascript:void(0);" onclick="MGJS_CMT.quote('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'commentbody-<?php comment_ID() ?>', 'comment');"><?php _e('Quote', 'inove'); ?></a>
      				<?php
      					if (function_exists("qc_comment_edit_link")) {
      						qc_comment_edit_link('', ' | ', '', __('Edit', 'inove'));
      					}
      					edit_comment_link(__('Advanced edit', 'inove'), ' | ', '');
      				?>
      			</div>
      			<div class="fixed"></div>
      			<div class="content">
      				<?php if ($comment->comment_approved == '0') : ?>
      					<p><small><?php _e('Your comment is awaiting moderation.', 'inove'); ?></small></p>
      				<?php endif; ?>
      
      				<div id="commentbody-<?php comment_ID() ?>">
      					<?php comment_text(); ?>
      				</div>
      			</div>
      		</div>
    • js/comment.js – all file
    • /*
      Author: mg12
      Update: 2008/05/05
      Author URI: http://www.neoease.com/
      */
      (function() {
      
      function reply(authorId, commentId, commentBox) {
      	var author = MGJS.$(authorId).innerHTML;
      	var insertStr = '<a href="#' + commentId + '">@' + author.replace(/\t|\n|\r\n/g, "") + ' </a> \n';
      
      	appendReply(insertStr, commentBox);
      }
      
      function quote(authorId, commentId, commentBodyId, commentBox) {
      	var author = MGJS.$(authorId).innerHTML;
      	var comment = MGJS.$(commentBodyId).innerHTML;
      
      	var insertStr = '<blockquote cite="#' + commentBodyId + '">';
      	insertStr += '\n<strong><a href="#' + commentId + '">' + author.replace(/\t|\n|\r\n/g, "") + '</a> :</strong>';
      	insertStr += comment.replace(/\t/g, "");
      	insertStr += '</blockquote>\n';
      
      	insertQuote(insertStr, commentBox);
      }
      
      function appendReply(insertStr, commentBox) {
      	if(MGJS.$(commentBox) && MGJS.$(commentBox).type == 'textarea') {
      		field = MGJS.$(commentBox);
      
      	} else {
      		alert("The comment box does not exist!");
      		return false;
      	}
      
      	if (field.value.indexOf(insertStr) > -1) {
      		alert("You've already appended this reply!");
      		return false;
      	}
      
      	if (field.value.replace(/\s|\t|\n/g, "") == '') {
      		field.value = insertStr;
      	} else {
      		field.value = field.value.replace(/[\n]*$/g, "") + '\n\n' + insertStr;
      	}
      	field.focus();
      }
      
      function insertQuote(insertStr, commentBox) {
      	if(MGJS.$(commentBox) && MGJS.$(commentBox).type == 'textarea') {
      		field = MGJS.$(commentBox);
      
      	} else {
      		alert("The comment box does not exist!");
      		return false;
      	}
      
      	if(document.selection) {
      		field.focus();
      		sel = document.selection.createRange();
      		sel.text = insertStr;
      		field.focus();
      
      	} else if (field.selectionStart || field.selectionStart == '0') {
      		var startPos = field.selectionStart;
      		var endPos = field.selectionEnd;
      		var cursorPos = startPos;
      		field.value = field.value.substring(0, startPos)
      					+ insertStr
      					+ field.value.substring(endPos, field.value.length);
      		cursorPos += insertStr.length;
      		field.focus();
      		field.selectionStart = cursorPos;
      		field.selectionEnd = cursorPos;
      
      	} else {
      		field.value += insertStr;
      		field.focus();
      	}
      }
      
      window['MGJS_CMT'] = {};
      window['MGJS_CMT']['reply'] = reply;
      window['MGJS_CMT']['quote'] = quote;
      
      })();

      that some code from MCEcomments plug-in(that related to the “Reply” and “Quote”):

    • setting – all file
    • function brstonewline(element_id, html, body) {
      html = html.replace(/<br\s*\/>/gi, "\n");
      return html;
      }
      
      function insertHTML(html) {
      tinyMCE.execCommand("mceInsertContent",false, html);
      }
      tinyMCE.init(
      {mode : "exact",
      elements : "comment",
      theme : "advanced",
      theme_advanced_buttons1 : "bold,italic,underline,|,strikethrough,|,bullist,numlist,|,undo,redo,|,link,unlink,|,removeformat",
      theme_advanced_buttons2 : "",
      theme_advanced_buttons3 : "",
      theme_advanced_toolbar_location : "top",
      theme_advanced_toolbar_align : "left",
      theme_advanced_statusbar_location : "none",
      theme_advanced_resizing : false,
      theme_advanced_resize_horizontal : false,
      theme_advanced_disable : "code",
      force_p_newlines : false,
      force_br_newlines : true,
      forced_root_block : "",
      gecko_spellcheck : true,
      content_css : "http://www.codim.co.il/wp-includes/js/tinymce/wordpress.css",
      directionality : "rtl",
      save_callback : "brstonewline",
      entity_encoding : "raw",plugins : "",
      extended_valid_elements : "a[name|href|title],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],blockquote[cite]",
      language : "he"}
      );
      
      var subBtn = document.getElementById("submit");
      if (subBtn != null) {
      subBtn.onclick=function() {
      var inst = tinyMCE.getInstanceById("comment");
      document.getElementById("comment").value = inst.getContent();
      document.getElementById("commentform").submit();
      return false;
        }
      }
  • The topic ‘Use quote and reply with MCEcomments’ is closed to new replies.