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()
46 function cmtBbOpen(id) {
47 $("#comment-edit-bb-" + id).show();
49 function cmtBbClose(id) {
50 $("#comment-edit-bb-" + id).hide();
53 function commentExpand(id) {
54 $("#comment-edit-text-" + id).value = '';
55 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
56 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
57 $("#comment-edit-text-" + id).focus();
58 $("#mod-cmnt-wrap-" + id).show();
59 openMenu("comment-edit-submit-wrapper-" + id);
63 function commentClose(obj,id) {
65 obj.value = aStr.comment;
66 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
67 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
68 $("#mod-cmnt-wrap-" + id).hide();
69 closeMenu("comment-edit-submit-wrapper-" + id);
75 function showHideCommentBox(id) {
76 if( $('#comment-edit-form-' + id).is(':visible')) {
77 $('#comment-edit-form-' + id).hide();
80 $('#comment-edit-form-' + id).show();
84 function commentOpenUI(obj, id) {
85 $(document).unbind( "click.commentOpen", handler );
87 var handler = function() {
88 if(obj.value == aStr.comment) {
90 $("#comment-edit-text-" + id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty");
91 // Choose an arbitrary tab index that's greater than what we're using in jot (3 of them)
92 // The submit button gets tabindex + 1
93 $("#comment-edit-text-" + id).attr('tabindex','9');
94 $("#comment-edit-submit-" + id).attr('tabindex','10');
95 $("#comment-edit-submit-wrapper-" + id).show();
99 $(document).bind( "click.commentOpen", handler );
102 function commentCloseUI(obj, id) {
103 $(document).unbind( "click.commentClose", handler );
105 var handler = function() {
106 if(obj.value === '') {
107 obj.value = aStr.comment;
108 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full").addClass("comment-edit-text-empty");
109 $("#comment-edit-text-" + id).removeAttr('tabindex');
110 $("#comment-edit-submit-" + id).removeAttr('tabindex');
111 $("#comment-edit-submit-wrapper-" + id).hide();
115 $(document).bind( "click.commentClose", handler );
118 // test if there is default content in the jot text box and remove it
119 function jotTextOpenUI(obj) {
120 if(obj.value == aStr.share) {
122 $(".modal-body #profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
126 // insert default content into the jot text box
128 function jotTextCloseUI(obj) {
129 if(obj.value === '') {
130 obj.value = aStr.share;
131 $(".modal-body #profile-jot-text").removeClass("profile-jot-text-full").addClass("profile-jot-text-empty");
135 function commentOpen(obj,id) {
136 if(obj.value == aStr.comment) {
138 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
139 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
140 $("#mod-cmnt-wrap-" + id).show();
141 openMenu("comment-edit-submit-wrapper-" + id);
147 function commentInsert(obj,id) {
148 var tmpStr = $("#comment-edit-text-" + id).val();
149 if(tmpStr == aStr.comment) {
151 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
152 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
153 openMenu("comment-edit-submit-wrapper-" + id);
155 var ins = $(obj).html();
156 ins = ins.replace('<','<');
157 ins = ins.replace('>','>');
158 ins = ins.replace('&','&');
159 ins = ins.replace('"','"');
160 $("#comment-edit-text-" + id).val(tmpStr + ins);
163 function qCommentInsert(obj,id) {
164 var tmpStr = $("#comment-edit-text-" + id).val();
165 if(tmpStr == aStr.comment) {
167 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
168 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
169 openMenu("comment-edit-submit-wrapper-" + id);
171 var ins = $(obj).val();
172 ins = ins.replace('<','<');
173 ins = ins.replace('>','>');
174 ins = ins.replace('&','&');
175 ins = ins.replace('"','"');
176 $("#comment-edit-text-" + id).val(tmpStr + ins);
180 function confirmDelete() { return confirm(aStr.delitem); }
182 function dropItem(url, object) {
183 var confirm = confirmDelete();
185 $('body').css('cursor', 'wait');
186 $(object).fadeTo('fast', 0.33, function () {
187 $.get(url).done(function() {
189 $('body').css('cursor', 'auto');