mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 08:18:18 +08:00
Get the "quote reply" button working on iOS
This commit is contained in:
parent
d0f810dee5
commit
b7a7d8b006
|
@ -49,10 +49,11 @@ Discourse.PostView = Discourse.View.extend({
|
||||||
this.toggleProperty('post.selected');
|
this.toggleProperty('post.selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Discourse.get('currentUser.enable_quoting')) return;
|
||||||
if ($(e.target).closest('.cooked').length === 0) return;
|
if ($(e.target).closest('.cooked').length === 0) return;
|
||||||
|
|
||||||
var qbc = this.get('controller.controllers.quoteButton');
|
var qbc = this.get('controller.controllers.quoteButton');
|
||||||
if (qbc && Discourse.get('currentUser.enable_quoting')) {
|
if (qbc) {
|
||||||
e.context = this.get('post');
|
e.context = this.get('post');
|
||||||
qbc.selectText(e);
|
qbc.selectText(e);
|
||||||
}
|
}
|
||||||
|
@ -259,6 +260,29 @@ Discourse.PostView = Discourse.View.extend({
|
||||||
if (controller && controller.postRendered) {
|
if (controller && controller.postRendered) {
|
||||||
controller.postRendered(post);
|
controller.postRendered(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make the selection work under iOS
|
||||||
|
// "selectionchange" event is only supported in IE, Safari & Chrome
|
||||||
|
var postView = this;
|
||||||
|
$(document).on('selectionchange', function(e) {
|
||||||
|
// quoting as been disabled by the user
|
||||||
|
if (!Discourse.get('currentUser.enable_quoting')) return;
|
||||||
|
// find out whether we currently are selecting inside a post
|
||||||
|
var closestPosts = $(window.getSelection().anchorNode).closest('.topic-post');
|
||||||
|
if (closestPosts.length === 0) return;
|
||||||
|
// this event is bound for every posts in the topic, but is triggered on "document"
|
||||||
|
// we should therefore filter the event to only the right post
|
||||||
|
if (closestPosts[0].id !== postView.elementId) return;
|
||||||
|
var qbc = postView.get('controller.controllers.quoteButton');
|
||||||
|
if (qbc) {
|
||||||
|
e.context = postView.get('post');
|
||||||
|
qbc.selectText(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
willDestroyElement: function() {
|
||||||
|
$(document).off('selectionchange');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,11 @@
|
||||||
pre code {
|
pre code {
|
||||||
max-height: 690px;
|
max-height: 690px;
|
||||||
}
|
}
|
||||||
|
.post-menu-area {
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
}
|
||||||
@include hover {
|
@include hover {
|
||||||
.gutter {
|
.gutter {
|
||||||
.reply-new,
|
.reply-new,
|
||||||
|
@ -387,6 +392,9 @@
|
||||||
@include hover {
|
@include hover {
|
||||||
background-color: mix($gray, $light_gray, 5%);
|
background-color: mix($gray, $light_gray, 5%);
|
||||||
}
|
}
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
}
|
}
|
||||||
.embedded-posts.bottom {
|
.embedded-posts.bottom {
|
||||||
@include border-radius-bottom(4px);
|
@include border-radius-bottom(4px);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user