This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fb2aab
commit b3b696b
Showing
11 changed files
with
222 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
export default Ember.Component.extend({ | ||
tagName: "div", | ||
classNames: 'docked-post' | ||
classNames: 'docked-post', | ||
|
||
test: function() { | ||
var imgs = this.$('img') | ||
if (imgs.length) { | ||
imgs.each(function(i){ | ||
$(this).one("load", function() { | ||
$('.docked-composer-top').scrollTop($('.docked-post-stream').height()) | ||
}).each(function() { | ||
if(this.complete) $(this).load(); | ||
}); | ||
}) | ||
} | ||
}.on('didInsertElement'), | ||
|
||
}) |
73 changes: 73 additions & 0 deletions
73
assets/javascripts/discourse/components/docked-upload.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { default as computed, on, observes } from 'ember-addons/ember-computed-decorators'; | ||
import { uploadTranslate } from 'discourse/controllers/upload-selector'; | ||
|
||
export default Ember.Component.extend({ | ||
tagName: "div", | ||
classNameBindings: [':docked-upload', ':docked-modal', 'visible::hidden'], | ||
local: true, | ||
imageUrl: null, | ||
showMore: false, | ||
remote: Ember.computed.not("local"), | ||
|
||
@on('didInsertElement') | ||
@observes('local') | ||
selectedChanged() { | ||
Ember.run.next(() => { | ||
// *HACK* to select the proper radio button | ||
const value = this.get('local') ? 'local' : 'remote'; | ||
$('input:radio[name="upload"]').val([value]); | ||
$('.inputs input:first').focus(); | ||
}); | ||
}, | ||
|
||
@computed() | ||
title() { | ||
return uploadTranslate("title"); | ||
}, | ||
|
||
touchStart(evt) { | ||
// HACK: workaround Safari iOS being really weird and not shipping click events | ||
if (this.capabilities.isSafari && evt.target.id === "filename-input") { | ||
this.$('#filename-input').click(); | ||
} | ||
}, | ||
|
||
@computed | ||
uploadIcon() { | ||
return Discourse.Utilities.allowsAttachments() ? "upload" : "picture-o"; | ||
}, | ||
|
||
close: function() { | ||
this.set('visible', false) | ||
}, | ||
|
||
actions: { | ||
upload() { | ||
if (this.get('local')) { | ||
this.$().parents('.docked-editor').fileupload('add', { fileInput: $('#filename-input') }); | ||
} else { | ||
const imageUrl = this.get('imageUrl') || ''; | ||
const imageLink = imageUrl.substr(imageUrl.lastIndexOf('/') + 1) | ||
this.sendAction('addText', `![${imageLink}](${imageUrl})`) | ||
} | ||
this.close() | ||
}, | ||
|
||
closeModal() { | ||
this.close() | ||
}, | ||
|
||
useLocal() { | ||
this.setProperties({ local: true, showMore: false}); | ||
}, | ||
|
||
useRemote() { | ||
this.set("local", false); | ||
}, | ||
|
||
toggleShowMore() { | ||
this.toggleProperty("showMore"); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
assets/javascripts/discourse/connectors/header-before-dropdowns/messages-menu-wrapper.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{{#if currentUser}} | ||
{{#unless site.mobileView}} | ||
{{messages-menu visible=messagesVisible | ||
showUploadSelector="showUploadSelector"}} | ||
{{messages-menu visible=messagesVisible}} | ||
{{/unless}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
assets/javascripts/discourse/templates/components/docked-upload.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="modal-body"> | ||
<div class="radios"> | ||
<input type="radio" id="local" value="local" name="upload" {{action "useLocal"}}> | ||
<label class="radio" for="local">{{i18n 'upload_selector.from_my_computer'}}</label> | ||
{{#if local}} | ||
<div class="inputs"> | ||
<input type="file" id="filename-input" multiple><br> | ||
</div> | ||
{{/if}} | ||
</div> | ||
<div class="radios"> | ||
<input type="radio" id="remote" value="remote" name="upload" {{action "useRemote"}}> | ||
<label class="radio" for="remote">{{i18n 'upload_selector.from_the_web'}}</label> | ||
{{#if remote}} | ||
<div class="inputs"> | ||
{{input value=imageUrl placeholder="http://example.com/image.png"}} | ||
</div> | ||
{{/if}} | ||
</div> | ||
<div class="hint"> | ||
{{#if capabilities.canPasteImages}} | ||
{{i18n 'upload_selector.hint'}} | ||
{{else}} | ||
{{i18n 'upload_selector.hint_for_supported_browsers'}} | ||
{{/if}} | ||
</div> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
{{d-button action="upload" class='btn-primary' icon=uploadIcon label='upload'}} | ||
<a href {{action "closeModal"}}>{{i18n 'cancel'}}</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.