Show More
@@ -338,8 +338,11 b' class Post(models.Model, Viewable):' | |||||
338 |
|
338 | |||
339 | replacements = dict() |
|
339 | replacements = dict() | |
340 | for post_id in REGEX_REPLY.findall(self.get_raw_text()): |
|
340 | for post_id in REGEX_REPLY.findall(self.get_raw_text()): | |
341 | absolute_post_id = str(Post.objects.get(id=post_id).global_id) |
|
341 | try: | |
342 | replacements[post_id] = absolute_post_id |
|
342 | absolute_post_id = str(Post.objects.get(id=post_id).global_id) | |
|
343 | replacements[post_id] = absolute_post_id | |||
|
344 | except Post.DoesNotExist: | |||
|
345 | pass | |||
343 |
|
346 | |||
344 | text = self.get_raw_text() or '' |
|
347 | text = self.get_raw_text() or '' | |
345 | for key in replacements: |
|
348 | for key in replacements: |
@@ -96,17 +96,24 b' function addQuickReply(postId) {' | |||||
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | function addQuickQuote() { |
|
98 | function addQuickQuote() { | |
|
99 | var textAreaJq = $('textarea'); | |||
|
100 | ||||
|
101 | var quoteButton = $("#quote-button"); | |||
|
102 | var postId = quoteButton.attr('data-post-id'); | |||
|
103 | if (postId != null && getForm().prev().attr('id') != postId) { | |||
|
104 | addQuickReply(postId); | |||
|
105 | } | |||
|
106 | ||||
99 | var textToAdd = ''; |
|
107 | var textToAdd = ''; | |
100 | var textAreaJq = $('textarea'); |
|
|||
101 | var selection = window.getSelection().toString(); |
|
108 | var selection = window.getSelection().toString(); | |
102 | if (selection.length == 0) { |
|
109 | if (selection.length == 0) { | |
103 |
selection = |
|
110 | selection = quoteButton.attr('data-text'); | |
104 | } |
|
111 | } | |
105 | if (selection.length > 0) { |
|
112 | if (selection.length > 0) { | |
106 | textToAdd += '[quote]' + selection + '[/quote]\n'; |
|
113 | textToAdd += '[quote]' + selection + '[/quote]\n'; | |
107 | } |
|
114 | } | |
108 |
|
115 | |||
109 | textAreaJq.val(textAreaJq.val()+ textToAdd); |
|
116 | textAreaJq.val(textAreaJq.val() + textToAdd); | |
110 |
|
117 | |||
111 | textAreaJq.focus(); |
|
118 | textAreaJq.focus(); | |
112 |
|
119 | |||
@@ -128,6 +135,15 b' function showQuoteButton() {' | |||||
128 |
|
135 | |||
129 | var text = window.getSelection().toString(); |
|
136 | var text = window.getSelection().toString(); | |
130 | quoteButton.attr('data-text', text); |
|
137 | quoteButton.attr('data-text', text); | |
|
138 | ||||
|
139 | var rect = window.getSelection().getRangeAt(0).getBoundingClientRect(); | |||
|
140 | var element = $(document.elementFromPoint(rect.x, rect.y)); | |||
|
141 | var postParent = element.parents('.post'); | |||
|
142 | if (postParent.length > 0) { | |||
|
143 | quoteButton.attr('data-post-id', postParent.attr('id')); | |||
|
144 | } else { | |||
|
145 | quoteButton.attr('data-post-id', null); | |||
|
146 | } | |||
131 | } else { |
|
147 | } else { | |
132 | quoteButton.hide(); |
|
148 | quoteButton.hide(); | |
133 | } |
|
149 | } |
General Comments 0
You need to be logged in to leave comments.
Login now