Commits

Jens Diemer committed d9a21f8

merge reply / quote stuff
---
.../djangobb_forum/js/markup/bbcode/board.js | 53 ++++++++++++--------
djangobb_forum/templates/djangobb_forum/topic.html | 25 +++++----
2 files changed, 43 insertions(+), 35 deletions(-)

  • Participants
  • Parent commits d761cf8

Comments (0)

Files changed (2)

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

-var txt = ''
+console.log("board.js loaded");
 
-function copyQ(nick) { 
-	txt = '' 
-	if (document.getSelection) {
-		txt = document.getSelection()
-	} else 
-	if (document.selection) {
-		txt = document.selection.createRange().text;
-	} 
-	txt = '[quote=' + nick + ']' + txt + '[/quote]\n'
+function get_selection() {
+    var txt = ''; 
+    if (document.getSelection) {
+        txt = document.getSelection();
+    } else 
+    if (document.selection) {
+        txt = document.selection.createRange().text;
+    }
+    return txt
 }
 
-function insertAtCaret (textObj, textFieldValue) { 
+function copy_paste(post_id) {
+    console.log("copy_paste()");
+    
+    post_div = $("div#"+post_id);
+    nick = post_div.find(".username").text();
+    
+    txt = get_selection(); // quote selection
+    if (txt == '') {
+        // quote the complete post content
+        // FIXME: We should get the markup here (Ajax view?)
+        txt = post_div.find("div.postmsg").text();
+    }
+    txt = $.trim(txt);
+    txt = '[quote=' + nick + ']' + txt + '[/quote]\n';
+    //textarea = $("#id_body");
+    textarea = document.forms['post']['body'];
+    insertAtCaret(textarea, txt);
+}
+
+function insertAtCaret (textObj, textFieldValue) {
+    console.log("insertAtCaret(" + textObj + "," + textFieldValue + ")");
 	if (document.all) { 
 		if (textObj.createTextRange && textObj.caretPos && !window.opera) { 
 			var caretPos = textObj.caretPos; 
 		} 
 	} 
 }
-
-function pasteQ() {
-	if (txt!='' && document.forms['post']['body']) 
-	insertAtCaret(document.forms['post']['body'], txt); 
-} 
-
-function pasteN(text) { 
-	if (text != '' && document.forms['post']['body'])
-	insertAtCaret(document.forms['post']['body'], "[b]" + text + "[/b]\n");
-}
-

djangobb_forum/templates/djangobb_forum/topic.html

 <div class="linkst">
 	<div class="inbox">
 		<div class="pagelink conl">{% paginate %}</div>
-		{% if not topic.closed and user.is_authenticated %}
-			<p class="postlink conr"><a href="{% url djangobb:add_post topic.id %}">{% trans "Reply" %}</a></p>
-		{% endif %}
 		<ul>
 			<li>
 			<a href="{% url djangobb:index %}">{% trans "Root" %} </a></li><li>&raquo; {% link topic.forum %} </li><li>&raquo; {{ topic.name }}
 			<div class="inbox">
 				<div class="postleft">
 					<dl>
-						<dt><strong><a href="javascript:pasteN('{{ post.user.username }}');">{{ post.user.username }}</a></strong></dt>
+						<dt><strong class="username">{{ post.user.username }}</strong></dt>
 						<dd class="usertitle">
 							{% if post.user.forum_profile.status %}
 								<strong>{{ post.user.forum_profile.status }}</strong>
 					{% if moderator or post|forum_posted_by:user %}
 						<li class="postedit">| <a href="{% url djangobb:edit_post post.id %}">{% trans "Edit" %}</a> </li>
 					{% endif %}
-					<li class="postquote">| <a href="{% url djangobb:add_post topic.id %}?post_id={{ post.id }}">{% trans "Reply" %}</a> </li>
 					{% if user.is_authenticated %}
-						<li class="postquote">| <a onmouseover="copyQ('{{ post.user.username }}');" href="javascript:pasteQ();">{% trans "Quote" %}</a></li>
+						<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>
 					{% endif %}
 				</ul>
 			</div>
 <div class="postlinksb">
 	<div class="inbox">
 		<div class="pagelink conl">{% paginate %}</div>
-		<p class="postlink conr"><a href="{% url djangobb:add_post topic.id %}">{% trans "Reply" %}</a></p>
-				<ul><li><a href="{% url djangobb:index %}">{% trans "Root" %} </a></li><li>&raquo; {% link topic.forum %} </li><li>&raquo; {{ topic }}
-				<a href="{% url djangobb:forum_topic_feed topic.id %}"><img src="{{ STATIC_URL }}djangobb_forum/img/feed-icon-small.png"  alt="[RSS Feed]" title="[RSS Feed]" class="breadcrumb_rss" /></a>
-				</li></ul>
+			<ul>
+			    <li><a href="{% url djangobb:index %}">{% trans "Root" %} </a></li>
+			    <li>&raquo; {% link topic.forum %} </li>
+			    <li>
+			        &raquo; {{ topic }}<a href="{% url djangobb:forum_topic_feed topic.id %}"><img src="{{ STATIC_URL }}djangobb_forum/img/feed-icon-small.png" alt="[RSS Feed]" title="[RSS Feed]" class="breadcrumb_rss" /></a>
+			    </li>
+            </ul>
 		{% if user.is_authenticated %}
 			{% if subscribed %}
 				<a class="subscribelink clearb" href="{% url djangobb:forum_delete_subscription topic.id %}?from_topic">{% trans "Unsubscribe" %}</a>
 	</div>
 </div>
 {% if not topic.closed and user.is_authenticated %}
-<div class="blockform">
-	<h2><span>{% trans "Quick post" %}</span></h2>
+<div class="blockform" id="reply">
+	<h2><span>{% trans "Reply" %}</span></h2>
 	<div class="box">
-		<form id="post" action="{% url djangobb:add_post topic.id %}" method="post" enctype="multipart/form-data">
+		<form id="post" action="{% url djangobb:add_post topic.id %}" method="post" enctype="multipart/form-data">		    
 			{% csrf_token %}
 			<div class="inform">
 				<fieldset>