Skip to content

Commit 9922aae

Browse files
committed
Merge branch '1.1.x' into 2.0.x
# Conflicts: # composer.json # styles/all/template/event/overall_header_head_append.html
2 parents b473e23 + 3ef5c5f commit 9922aae

8 files changed

+88
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- IF S_VIEWTOPIC -->
2-
<!-- INCLUDECSS @boardtools_quickreply/quickreply_main.css -->
3-
<!-- INCLUDECSS @boardtools_quickreply/quickreply.css -->
2+
<!-- INCLUDECSS @boardtools_quickreply/quickreply_main.css?assets_version={T_ASSETS_VERSION} -->
3+
<!-- INCLUDECSS @boardtools_quickreply/quickreply.css?assets_version={T_ASSETS_VERSION} -->
44
<!-- ELSE IF S_IN_POSTING -->
5-
<!-- INCLUDECSS @boardtools_quickreply/quickreply.css -->
5+
<!-- INCLUDECSS @boardtools_quickreply/quickreply.css?assets_version={T_ASSETS_VERSION} -->
66
<!-- ENDIF -->

styles/all/template/event/posting_editor_subject_after.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
};
1919
// ]]>
2020
</script>
21-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_posting.js -->
21+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_posting.js?assets_version={T_ASSETS_VERSION} -->
2222
<!-- ENDIF -->
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<!-- IF .searchresults and QR_HIDE_POSTS_SUBJECT -->
2-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_searchresults.js -->
2+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_searchresults.js?assets_version={T_ASSETS_VERSION} -->
33
<!-- ENDIF -->

styles/all/template/quickreply_init.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@
166166
//]]>
167167
</script>
168168
<!-- IF S_QUICK_REPLY -->
169-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_style.js -->
170-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_core.js -->
171-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_plugins.js -->
172-
<!-- IF S_QR_SHOW_BUTTON_TRANSLIT --><!-- INCLUDEJS @boardtools_quickreply/translit.js --><!-- ENDIF -->
169+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_style.js?assets_version={T_ASSETS_VERSION} -->
170+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_core.js?assets_version={T_ASSETS_VERSION} -->
171+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_plugins.js?assets_version={T_ASSETS_VERSION} -->
172+
<!-- IF S_QR_SHOW_BUTTON_TRANSLIT --><!-- INCLUDEJS @boardtools_quickreply/translit.js?assets_version={T_ASSETS_VERSION} --><!-- ENDIF -->
173173
<!-- ENDIF -->
174-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_special.js -->
174+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_special.js?assets_version={T_ASSETS_VERSION} -->

styles/all/template/quickreply_plugins.js

+67-12
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
if (evt.type === 'touchstart') {
4646
evt.pageX = evt.originalEvent.touches[0].pageX;
4747
evt.pageY = evt.originalEvent.touches[0].pageY;
48+
} else if (evt.type === 'selectionchange') {
49+
return self._getSelectionCoords();
4850
}
4951

5052
return {
@@ -53,6 +55,41 @@
5355
};
5456
};
5557

58+
/**
59+
* Returns an object containing the coordinates for the end of current text selection.
60+
* Original author: Tim Down (https://stackoverflow.com/a/6847328)
61+
*
62+
* @returns {{x: number, y: number}}
63+
*/
64+
self._getSelectionCoords = function() {
65+
var sel = document.selection, range, rects, rect;
66+
var x = 0, y = 0;
67+
68+
if (sel) {
69+
if (sel.type !== "Control") {
70+
range = sel.createRange();
71+
range.collapse(false);
72+
x = range.boundingLeft;
73+
y = range.boundingBottom;
74+
}
75+
} else if (window.getSelection) {
76+
sel = window.getSelection();
77+
if (sel.rangeCount) {
78+
range = sel.getRangeAt(sel.rangeCount - 1).cloneRange();
79+
if (range.getClientRects) {
80+
range.collapse(false);
81+
rects = range.getClientRects();
82+
if (rects.length > 0) {
83+
rect = rects[rects.length - 1];
84+
x = rect.left;
85+
y = rect.bottom;
86+
}
87+
}
88+
}
89+
}
90+
return { x: x ? x + $(document).scrollLeft() : 0, y: y ? y + $(document).scrollTop() : 0 };
91+
};
92+
5693
/**
5794
* Sets new dropdown and adds body event handler.
5895
*
@@ -173,18 +210,24 @@
173210
}
174211

175212
var coordinates = self._getCoordinates(evt);
213+
if (!coordinates.x && !coordinates.y) {
214+
// Prevent possible positioning bugs (e.g. in IE8)
215+
return;
216+
}
217+
176218
// Which mouse button is pressed?
177219
var key = evt.button || evt.which || null; // IE || FF || Unknown
178220

179221
self._postID = quickreply.style.getPostId($element);
180222

181223
setTimeout(function() { // Timeout prevents popup when clicking on selected text
182224
self._getSelection();
225+
self._removeDropdown();
183226

184227
if (self._selection && key <= 1) { // If text selected && right mouse button not pressed
185-
self._removeDropdown();
186-
self._setDropdown(quickreply.style.quickQuoteDropdown(coordinates.x, coordinates.y)
187-
.mousedown(insertQuickQuote));
228+
var $dropdown = quickreply.style.quickQuoteDropdown(coordinates.x, coordinates.y)
229+
.mousedown(insertQuickQuote);
230+
self._setDropdown($dropdown);
188231
}
189232
}, 0);
190233
}
@@ -195,15 +238,26 @@
195238
* @param {event} evt jQuery Event object
196239
*/
197240
function handleQuickQuote(evt) {
198-
addQuickQuote(evt, $(this));
241+
var $content = $(this);
242+
addQuickQuote(evt, $content);
199243

200244
if (!quickQuoteCancelEvent) {
201-
quickreply.$.qrPosts.on('mousemove', '.content', addQuickQuote);
202-
203-
$(document.body).one('mouseup', function() {
204-
quickreply.$.qrPosts.off('mousemove', '.content', addQuickQuote);
205-
quickQuoteCancelEvent = false;
206-
});
245+
if ('onselectionchange' in document) {
246+
$(document).on('selectionchange.quickreply', function (evt) {
247+
addQuickQuote(evt, $content);
248+
});
249+
$(document.body).one('mouseup', function() {
250+
$(document).off('selectionchange.quickreply');
251+
quickQuoteCancelEvent = false;
252+
});
253+
} else {
254+
// Fall back to mouse events for older browsers - this method has drawbacks on mobile devices
255+
quickreply.$.qrPosts.on('mousemove', '.content', addQuickQuote);
256+
$(document.body).one('mouseup', function() {
257+
quickreply.$.qrPosts.off('mousemove', '.content', addQuickQuote);
258+
quickQuoteCancelEvent = false;
259+
});
260+
}
207261

208262
quickQuoteCancelEvent = true;
209263
}
@@ -214,10 +268,11 @@
214268
*/
215269
self.init = function() {
216270
if ('ontouchstart' in window) {
217-
quickreply.$.qrPosts.on('mousedown touchstart', '.content', handleQuickQuote);
271+
quickreply.$.qrPosts.on('touchstart', '.content', handleQuickQuote);
218272
}
219273

220-
quickreply.$.qrPosts.on('mouseup', '.content', addQuickQuote);
274+
quickreply.$.qrPosts.on('mousedown', '.content', handleQuickQuote)
275+
.on('mouseup', '.content', addQuickQuote);
221276
};
222277
}
223278

styles/all/theme/quickreply_main.css

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
cursor: pointer;
55
}
66

7+
.qr_quickquote {
8+
-webkit-touch-callout: none;
9+
-webkit-user-select: none;
10+
-khtml-user-select: none;
11+
-moz-user-select: none;
12+
-ms-user-select: none;
13+
user-select: none;
14+
}
15+
716
#preview {
817
position: relative;
918
}

styles/pbtech/template/event/viewtopic_body_footer_before.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- IF S_QUICK_REPLY -->
2-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_pbwow.js -->
2+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_pbwow.js?assets_version={T_ASSETS_VERSION} -->
33
<style>
44
/* Remove styling specific for standard quick reply. */
55
#qr_postform .panel {

styles/pbwow3/template/event/viewtopic_body_footer_before.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- IF S_QUICK_REPLY -->
2-
<!-- INCLUDEJS @boardtools_quickreply/quickreply_pbwow.js -->
2+
<!-- INCLUDEJS @boardtools_quickreply/quickreply_pbwow.js?assets_version={T_ASSETS_VERSION} -->
33
<style>
44
/* Remove styling specific for standard quick reply. */
55
#qr_postform > .panel {

0 commit comments

Comments
 (0)