FIX: header undocking when opening mobile view
FIX: make it possible to upload an image on iphone FIX: mobile can now upload more than 1 image
This commit is contained in:
parent
faada383fa
commit
e254030760
|
@ -1,5 +1,4 @@
|
|||
function applicable() {
|
||||
|
||||
// This will apply hack on all iDevices
|
||||
return navigator.userAgent.match(/(iPad|iPhone|iPod)/g) &&
|
||||
navigator.userAgent.match(/Safari/g);
|
||||
|
@ -15,7 +14,6 @@ function positioningWorkaround($fixedElement) {
|
|||
|
||||
var done = false;
|
||||
var originalScrollTop = 0;
|
||||
var wasDocked;
|
||||
|
||||
var blurredNow = function(evt) {
|
||||
if (!done && _.include($(document.activeElement).parents(), fixedElement)) {
|
||||
|
@ -27,17 +25,12 @@ function positioningWorkaround($fixedElement) {
|
|||
|
||||
fixedElement.parentElement.style.height = '';
|
||||
$('#main-outlet').show();
|
||||
$('header').show();
|
||||
|
||||
fixedElement.style.position = '';
|
||||
fixedElement.style.top = '';
|
||||
fixedElement.style.height = '';
|
||||
$(window).scrollTop(originalScrollTop);
|
||||
|
||||
if (wasDocked) {
|
||||
$('body').addClass('docked');
|
||||
}
|
||||
|
||||
if (evt) {
|
||||
evt.target.removeEventListener('blur', blurred);
|
||||
}
|
||||
|
@ -63,12 +56,8 @@ function positioningWorkaround($fixedElement) {
|
|||
|
||||
originalScrollTop = $(window).scrollTop();
|
||||
|
||||
wasDocked = $('body').hasClass('docked');
|
||||
|
||||
// take care of body
|
||||
$('#main-outlet').hide();
|
||||
$('header').hide();
|
||||
|
||||
|
||||
fixedElement.style.position = 'absolute';
|
||||
// get out of the way while opening keyboard
|
||||
|
@ -93,7 +82,7 @@ function positioningWorkaround($fixedElement) {
|
|||
}
|
||||
|
||||
const checkForInputs = _.debounce(function(){
|
||||
$fixedElement.find('button,a:not(.autocomplete)').each(function(idx, elem){
|
||||
$fixedElement.find('button,a:not(.mobile-file-upload)').each(function(idx, elem){
|
||||
if ($(elem).parents('.autocomplete').length > 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +94,7 @@ function positioningWorkaround($fixedElement) {
|
|||
$(this).click();
|
||||
});
|
||||
});
|
||||
$fixedElement.find('input,textarea').each(function(){
|
||||
$fixedElement.find('input[type=text],textarea').each(function(){
|
||||
attachTouchStart(this, positioningHack);
|
||||
});
|
||||
}, 100);
|
||||
|
|
|
@ -91,9 +91,7 @@
|
|||
<div class="composer-bottom-right">
|
||||
{{#if site.mobileView}}
|
||||
<input type="file" id="mobile-uploader" />
|
||||
{{#unless view.isUploading}}
|
||||
<a class="mobile-file-upload">{{i18n 'upload'}}</a>
|
||||
{{/unless}}
|
||||
<a class="mobile-file-upload {{if view.isUploading 'hidden'}}">{{i18n 'upload'}}</a>
|
||||
{{else}}
|
||||
<a href {{action "togglePreview"}} class='toggle-preview'>{{{model.toggleText}}}</a>
|
||||
{{/if}}
|
||||
|
|
|
@ -374,7 +374,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
|
|||
// add upload placeholder
|
||||
const markdown = Discourse.Utilities.getUploadPlaceholder(data.files[0].name);
|
||||
this.addMarkdown(markdown);
|
||||
//
|
||||
|
||||
if (data["xhr"]) {
|
||||
const jqHXR = data.xhr();
|
||||
if (jqHXR) {
|
||||
|
@ -496,7 +496,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, {
|
|||
}
|
||||
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
$(".mobile-file-upload").on("click", function () {
|
||||
$(".mobile-file-upload").on("click.uploader", function () {
|
||||
// redirect the click on the hidden file input
|
||||
$("#mobile-uploader").click();
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ export default Ember.View.extend({
|
|||
// Check the dock after the current run loop. While rendering,
|
||||
// it's much slower to calculate `outlet.offset()`
|
||||
Ember.run.next(() => {
|
||||
if (!this.docAt) {
|
||||
if (this.docAt === undefined) {
|
||||
const outlet = $('#main-outlet');
|
||||
if (!(outlet && outlet.length === 1)) return;
|
||||
this.docAt = outlet.offset().top;
|
||||
|
|
|
@ -26,6 +26,7 @@ input {
|
|||
line-height: 3em;
|
||||
}
|
||||
#mobile-uploader { display: none; }
|
||||
.mobile-file-upload.hidden { display: none; }
|
||||
#draft-status, #file-uploading, .mobile-file-upload { display: inline-block; }
|
||||
transition: height .4s ease;
|
||||
width: 100%;
|
||||
|
|
Loading…
Reference in New Issue