FIX issues with quote button

Fix the following issues
- Quote button quotes only one word on iOS
- Quote reply popup should not come up when selecting the text in the ‘reply’ button
This commit is contained in:
Régis Hanol 2013-11-04 12:51:39 +01:00
parent 934ede7d91
commit 12ac2f2e99
10 changed files with 30 additions and 97 deletions

View File

@ -45,9 +45,7 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
cloned = range.cloneRange(), cloned = range.cloneRange(),
$ancestor = $(range.commonAncestorContainer); $ancestor = $(range.commonAncestorContainer);
// don't display the "quote reply" button if you select text spanning two posts if ($ancestor.closest('.cooked').length === 0) {
// note: the ".contents" is here to prevent selection of the topic summary
if ($ancestor.closest('.topic-body > .contents').length === 0) {
this.set('buffer', ''); this.set('buffer', '');
return; return;
} }

View File

@ -88,18 +88,18 @@ Discourse.Utilities = {
var html = ''; var html = '';
if (typeof window.getSelection !== "undefined") { if (typeof window.getSelection !== "undefined") {
var sel = window.getSelection(); var sel = window.getSelection();
if (sel.rangeCount) { if (sel.rangeCount) {
var container = document.createElement("div"); var container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) { for (var i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents()); container.appendChild(sel.getRangeAt(i).cloneContents());
}
html = container.innerHTML;
} }
html = container.innerHTML;
}
} else if (typeof document.selection !== "undefined") { } else if (typeof document.selection !== "undefined") {
if (document.selection.type === "Text") { if (document.selection.type === "Text") {
html = document.selection.createRange().htmlText; html = document.selection.createRange().htmlText;
} }
} }
// Strip out any .click elements from the HTML before converting it to text // Strip out any .click elements from the HTML before converting it to text

View File

@ -64,8 +64,8 @@ Discourse.QuoteButtonView = Discourse.View.extend({
}) })
.on('selectionchange', function() { .on('selectionchange', function() {
// there is no need to handle this event when the mouse is down // there is no need to handle this event when the mouse is down
// or if there is not a touch in progress // or if there a touch in progress
if (view.get('isMouseDown') || !view.get('isTouchInProgress')) return; if (view.get('isMouseDown') || view.get('isTouchInProgress')) return;
// `selection.anchorNode` is used as a target // `selection.anchorNode` is used as a target
view.selectText(window.getSelection().anchorNode, controller); view.selectText(window.getSelection().anchorNode, controller);
}); });

View File

@ -55,23 +55,13 @@
// Border radius // Border radius
@mixin border-radius-all($radius) { @mixin border-radius-all($radius) {
border-radius: $radius; border-radius: $radius;
}
@mixin border-radius-top($radius) {
border-top-right-radius: $radius;
border-top-left-radius: $radius;
}
@mixin border-radius-bottom($radius) {
border-bottom-right-radius: $radius;
border-bottom-left-radius: $radius;
} }
// Box shadow // Box shadow
@mixin box-shadow($shadow) { @mixin box-shadow($shadow) {
box-shadow: $shadow; box-shadow: $shadow;
} }
// Linear gradient // Linear gradient
@ -81,32 +71,6 @@
background-image: linear-gradient(to bottom, $start-color, $end-color); background-image: linear-gradient(to bottom, $start-color, $end-color);
} }
// Background size
@mixin background-size($size) {
background-size: $size;
}
// Background clip
@mixin background-clip($clip) {
background-clip: $clip;
}
// Rotate
@mixin rotate($degrees) {
-webkit-transform: rotate($degrees);
transform: rotate($degrees);
}
// Scale
@mixin scale($ratio) {
-webkit-transform: scale($ratio);
transform: scale($ratio);
}
// Transition // Transition
@mixin transition($transition) { @mixin transition($transition) {
@ -138,12 +102,6 @@
} }
} }
@mixin fade-soft($time: 1s) {
-webkit-transition: opacity $time ease-in-out;
-ms-transition: opacity $time ease-in-out;
transition: opacity $time ease-in-out;
}
@mixin visible { @mixin visible {
opacity: 1; opacity: 1;
visibility: visible; visibility: visible;
@ -151,16 +109,6 @@
transition-delay: 0s; transition-delay: 0s;
} }
// Decorations
// --------------------------------------------------
// Glow
@mixin glow($color) {
border: 1px solid $color;
box-shadow: 0 0 5px $color;
}
// //
// -------------------------------------------------- // --------------------------------------------------

View File

@ -432,8 +432,7 @@ div.ac-wrap {
} }
#wmd-input, #wmd-preview { #wmd-input, #wmd-preview {
box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
width: 100%; width: 100%;
height: 100%; height: 100%;
min-height: 100%; min-height: 100%;
@ -453,7 +452,7 @@ div.ac-wrap {
top: 0; top: 0;
height: 100%; height: 100%;
min-height: 100%; min-height: 100%;
box-sizing: border-box; @include box-sizing(border-box);
border: 0; border: 0;
border-top: 36px solid transparent; border-top: 36px solid transparent;
@include border-radius-all(0); @include border-radius-all(0);
@ -461,8 +460,7 @@ div.ac-wrap {
} }
.textarea-wrapper, .preview-wrapper { .textarea-wrapper, .preview-wrapper {
position: relative; position: relative;
box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
height: 100%; height: 100%;
min-height: 100%; min-height: 100%;
margin: 0; margin: 0;

View File

@ -11,13 +11,14 @@
} }
.post-actions { .post-actions {
@include unselectable;
clear: both; clear: both;
text-align: right; text-align: right;
.post-action { .post-action {
display: inline-block; display: inline-block;
margin-left: 10px; margin-left: 10px;
margin-top: 10px; margin-top: 10px;
} }
} }
.post-menu-area { .post-menu-area {
margin-bottom: 10px; margin-bottom: 10px;

View File

@ -78,9 +78,7 @@
.btn { .btn {
width: 100%; width: 100%;
margin-bottom: 5px; margin-bottom: 5px;
-webkit-box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
box-sizing: border-box;
} }
} }
h2 { h2 {

View File

@ -389,8 +389,7 @@ div.ac-wrap {
} }
#wmd-input, #wmd-preview { #wmd-input, #wmd-preview {
box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
width: 100%; width: 100%;
height: 100%; height: 100%;
min-height: 100%; min-height: 100%;
@ -410,7 +409,7 @@ div.ac-wrap {
top: 0; top: 0;
height: 100%; height: 100%;
min-height: 100%; min-height: 100%;
box-sizing: border-box; @include box-sizing(border-box);
border: 0; border: 0;
border-top: 36px solid transparent; border-top: 36px solid transparent;
@include border-radius-all(0); @include border-radius-all(0);
@ -418,8 +417,7 @@ div.ac-wrap {
} }
.textarea-wrapper, .preview-wrapper { .textarea-wrapper, .preview-wrapper {
position: relative; position: relative;
box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
height: 100%; height: 100%;
min-height: 100%; min-height: 100%;
margin: 0; margin: 0;

View File

@ -147,9 +147,7 @@ $caption-subtitle-color: #BDBDBD !default;
left: 0; left: 0;
top: 0; top: 0;
padding: 0 $popup-padding-left; padding: 0 $popup-padding-left;
-webkit-box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
box-sizing: border-box;
} }
// Vertical centerer helper // Vertical centerer helper
@ -453,9 +451,7 @@ button::-moz-focus-inner {
height: auto; height: auto;
display: block; display: block;
line-height: 0; line-height: 0;
-webkit-box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: $image-padding-top 0 $image-padding-bottom; padding: $image-padding-top 0 $image-padding-bottom;
margin: 0 auto; margin: 0 auto;
} }
@ -534,9 +530,7 @@ button::-moz-focus-inner {
top: auto; top: auto;
padding: 3px 5px; padding: 3px 5px;
position: fixed; position: fixed;
-webkit-box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
box-sizing: border-box;
} }
.mfp-img-mobile .mfp-bottom-bar:empty { .mfp-img-mobile .mfp-bottom-bar:empty {
padding: 0; padding: 0;

View File

@ -73,9 +73,7 @@
.btn { .btn {
width: 100%; width: 100%;
margin-bottom: 5px; margin-bottom: 5px;
-webkit-box-sizing: border-box; @include box-sizing(border-box);
-moz-box-sizing: border-box;
box-sizing: border-box;
} }
} }
h2 { h2 {