Commits

Jens Diemer committed f4e7d96

* reimplement nick name copy&paste * use $("#id_body").focus(); to scroll down * bugfix for logging (IE)

Comments (0)

Files changed (2)

djangobb_forum/static/djangobb_forum/js/markup/bbcode/board.js

-console.log("board.js loaded");
+// helper function for console logging
+function log() {
+    if (window.console && window.console.log) {
+        try {
+            window.console.log(Array.prototype.join.call(arguments,''));
+        } catch (e) {
+            log("Error:" + e);
+        }
+    }
+}
+log("board.js loaded");
 
 function get_selection() {
     var txt = ''; 
 }
 
 function copy_paste(post_id) {
-    console.log("copy_paste()");
+    log("copy_paste()");
     
     post_div = $("div#"+post_id);
     nick = post_div.find(".username").text();
         txt = $.trim(txt);
     }
     txt = '[quote=' + nick + ']' + txt + '[/quote]\n';
+    paste(txt);
+    return false
+}
+
+function paste(txt) {
     //textarea = $("#id_body");
     textarea = document.forms['post']['body'];
     insertAtCaret(textarea, txt);
+    $("#id_body").focus();
 }
 
 function insertAtCaret (textObj, textFieldValue) {
-    console.log("insertAtCaret(" + textObj + "," + textFieldValue + ")");
+    log("insertAtCaret(" + textObj + "," + textFieldValue + ")");
 	if (document.all) { 
 		if (textObj.createTextRange && textObj.caretPos && !window.opera) { 
 			var caretPos = textObj.caretPos; 
 		} 
 	} 
 }
+
+$(document).ready(function() {
+    $(".username").click(function() {
+        log("paste nickname");
+        var nick = $(this).text();
+        paste("[b]"+nick+"[/b]\n");
+    });
+    $(".username").attr('title', 'Click to paste nick name in reply form.');
+});

djangobb_forum/templates/djangobb_forum/topic.html

 						<li class="postedit">| <a href="{% url djangobb:edit_post post.id %}">{% trans "Edit" %}</a> </li>
 					{% endif %}
 					{% if user.is_authenticated %}
-						<li class="postquote">| <a onclick="copy_paste('p{{ post.id }}');" href="#reply" title="{% trans "Full quote or quote selected text form this post." %}">{% trans "Quote" %}</a></li>
+						<li class="postquote">| <a onclick="return copy_paste('p{{ post.id }}');" href="#reply" title="{% trans "Full quote or quote selected text form this post." %}">{% trans "Quote" %}</a></li>
 					{% endif %}
 				</ul>
 			</div>