##// END OF EJS Templates
Hide quote button when its click. Cache its selector
neko259 -
r2042:8f0c2e52 default
parent child Browse files
Show More
@@ -27,6 +27,7 b" var REPLY_TO_MSG = '.reply-to-message';"
27 27 var REPLY_TO_MSG_ID = '#reply-to-message-id';
28 28
29 29 var $html = $("html, body");
30 var $quoteButton = $("#quote-button");
30 31
31 32 function moveCaretToEnd(el) {
32 33 var newPos = el.val().length;
@@ -78,8 +79,7 b' function addQuickReply(postId) {'
78 79 function addQuickQuote() {
79 80 var textAreaJq = getPostTextarea();
80 81
81 var quoteButton = $("#quote-button");
82 var postId = quoteButton.attr('data-post-id');
82 var postId = $quoteButton.attr('data-post-id');
83 83 if (postId != null) {
84 84 addQuickReply(postId);
85 85 }
@@ -87,7 +87,7 b' function addQuickQuote() {'
87 87 var textToAdd = '';
88 88 var selection = window.getSelection().toString();
89 89 if (selection.length == 0) {
90 selection = quoteButton.attr('data-text');
90 selection = $quoteButton.attr('data-text');
91 91 }
92 92 if (selection.length > 0) {
93 93 textToAdd += '[quote]' + selection + '[/quote]\n';
@@ -98,6 +98,8 b' function addQuickQuote() {'
98 98 textAreaJq.focus();
99 99
100 100 moveCaretToEnd(textAreaJq);
101
102 $quoteButton.hide();
101 103 }
102 104
103 105 function scrollToBottom() {
@@ -106,14 +108,13 b' function scrollToBottom() {'
106 108
107 109 function showQuoteButton() {
108 110 var selection = window.getSelection().getRangeAt(0).getBoundingClientRect();
109 var quoteButton = $("#quote-button");
110 111 if (selection.width > 0) {
111 112 // quoteButton.offset({ top: selection.top - selection.height, left: selection.left });
112 quoteButton.css({top: selection.top + $(window).scrollTop() - 30, left: selection.left});
113 quoteButton.show();
113 $quoteButton.css({top: selection.top + $(window).scrollTop() - 30, left: selection.left});
114 $quoteButton.show();
114 115
115 116 var text = window.getSelection().toString();
116 quoteButton.attr('data-text', text);
117 $quoteButton.attr('data-text', text);
117 118
118 119 var rect = window.getSelection().getRangeAt(0).getBoundingClientRect();
119 120 var element = $(document.elementFromPoint(rect.x, rect.y));
@@ -126,9 +127,9 b' function showQuoteButton() {'
126 127 postId = postParent.attr('id');
127 128 }
128 129 }
129 quoteButton.attr('data-post-id', postId);
130 $quoteButton.attr('data-post-id', postId);
130 131 } else {
131 quoteButton.hide();
132 $quoteButton.hide();
132 133 }
133 134 }
134 135
General Comments 0
You need to be logged in to leave comments. Login now