##// END OF EJS Templates
add mark panel
rt@lightning -
r228:8e4f78c8 default
parent child Browse files
Show More
@@ -0,0 +1,34 b''
1 function addMarkToMsg(start, end) {
2 var textarea = document.getElementById('id_text');
3 if(!textarea) return;
4 if( document.selection ) {
5 textarea.focus();
6 sel = document.selection.createRange();
7 sel.text = start + sel.text + end;
8 } else if(textarea.selectionStart || textarea.selectionStart == '0') {
9 textarea.focus();
10 var startPos = textarea.selectionStart;
11 var endPos = textarea.selectionEnd;
12 textarea.value = textarea.value.substring(0, startPos) + start + textarea.value.substring(startPos, endPos) + end + textarea.value.substring( endPos, textarea.value.length );
13 } else {
14 textarea.value += start + end;
15 }
16 return false;
17 }
18
19 function addMarkPanel() {
20 $('.mark_btn').on('click', function() {
21 switch($(this).attr('id')) {
22 case "italic":
23 return addMarkToMsg('_', '_');
24 case "bold":
25 return addMarkToMsg('__', '__');
26 case "spoiler":
27 return addMarkToMsg('%%', '%%');
28 case "comment":
29 return addMarkToMsg('//', '');
30 case "quote":
31 return addMarkToMsg('>', '');
32 }
33 });
34 }
@@ -14,4 +14,5 b''
14 14
15 15 addRefLinkMap();
16 16 addPopups();
17 })
17 addMarkPanel();
18 });
General Comments 0
You need to be logged in to leave comments. Login now