2 * @brief The file contains functions for text editing and commenting
6 function insertFormatting(comment,BBcode,id) {
8 var tmpStr = $("#comment-edit-text-" + id).val();
9 if(tmpStr == comment) {
11 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
12 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
13 openMenu("comment-edit-submit-wrapper-" + id);
14 $("#comment-edit-text-" + id).val(tmpStr);
17 textarea = document.getElementById("comment-edit-text-" +id);
18 if (document.selection) {
20 selected = document.selection.createRange();
22 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
24 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
25 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
26 var start = textarea.selectionStart;
27 var end = textarea.selectionEnd;
29 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
31 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
37 function showThread(id) {
38 $("#collapsed-comments-" + id).show()
39 $("#collapsed-comments-" + id + " .collapsed-comments").show()
41 function hideThread(id) {
42 $("#collapsed-comments-" + id).hide()
43 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
47 function cmtBbOpen(id) {
48 $("#comment-edit-bb-" + id).show();
50 function cmtBbClose(id) {
51 $("#comment-edit-bb-" + id).hide();
54 function commentExpand(id) {
55 $("#comment-edit-text-" + id).value = '';
56 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
57 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
58 $("#comment-edit-text-" + id).focus();
59 $("#mod-cmnt-wrap-" + id).show();
60 openMenu("comment-edit-submit-wrapper-" + id);
64 function commentClose(obj,id) {
66 obj.value = aStr.comment;
67 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
68 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
69 $("#mod-cmnt-wrap-" + id).hide();
70 closeMenu("comment-edit-submit-wrapper-" + id);
76 function showHideCommentBox(id) {
77 if( $('#comment-edit-form-' + id).is(':visible')) {
78 $('#comment-edit-form-' + id).hide();
81 $('#comment-edit-form-' + id).show();
85 function commentOpenUI(obj, id) {
86 $(document).unbind( "click.commentOpen", handler );
88 var handler = function() {
89 if(obj.value == aStr.comment) {
91 $("#comment-edit-text-" + id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty");
92 // Choose an arbitrary tab index that's greater than what we're using in jot (3 of them)
93 // The submit button gets tabindex + 1
94 $("#comment-edit-text-" + id).attr('tabindex','9');
95 $("#comment-edit-submit-" + id).attr('tabindex','10');
96 $("#comment-edit-submit-wrapper-" + id).show();
100 $(document).bind( "click.commentOpen", handler );
103 function commentCloseUI(obj, id) {
104 $(document).unbind( "click.commentClose", handler );
106 var handler = function() {
107 if(obj.value === '') {
108 obj.value = aStr.comment;
109 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full").addClass("comment-edit-text-empty");
110 $("#comment-edit-text-" + id).removeAttr('tabindex');
111 $("#comment-edit-submit-" + id).removeAttr('tabindex');
112 $("#comment-edit-submit-wrapper-" + id).hide();
116 $(document).bind( "click.commentClose", handler );
118 function commentOpen(obj,id) {
119 if(obj.value == aStr.comment) {
121 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
122 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
123 $("#mod-cmnt-wrap-" + id).show();
124 openMenu("comment-edit-submit-wrapper-" + id);
130 function commentInsert(obj,id) {
131 var tmpStr = $("#comment-edit-text-" + id).val();
132 if(tmpStr == aStr.comment) {
134 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
135 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
136 openMenu("comment-edit-submit-wrapper-" + id);
138 var ins = $(obj).html();
139 ins = ins.replace('<','<');
140 ins = ins.replace('>','>');
141 ins = ins.replace('&','&');
142 ins = ins.replace('"','"');
143 $("#comment-edit-text-" + id).val(tmpStr + ins);
146 function qCommentInsert(obj,id) {
147 var tmpStr = $("#comment-edit-text-" + id).val();
148 if(tmpStr == aStr.comment) {
150 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
151 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
152 openMenu("comment-edit-submit-wrapper-" + id);
154 var ins = $(obj).val();
155 ins = ins.replace('<','<');
156 ins = ins.replace('>','>');
157 ins = ins.replace('&','&');
158 ins = ins.replace('"','"');
159 $("#comment-edit-text-" + id).val(tmpStr + ins);
163 function confirmDelete() { return confirm(aStr.delitem); }