FIX: Jump to post on iOS was broken - replace with prompt

This commit is contained in:
Robin Ward 2016-07-26 15:08:04 -04:00
parent 2a4006fe0c
commit 424bb143db
4 changed files with 39 additions and 21 deletions

View File

@ -168,17 +168,29 @@ export default Ember.Component.extend({
}
},
_jumpTo(postIndex) {
postIndex = parseInt(postIndex, 10);
// Validate the post index first
if (isNaN(postIndex) || postIndex < 1) {
postIndex = 1;
}
if (postIndex > this.get('postStream.filteredPostsCount')) {
postIndex = this.get('postStream.filteredPostsCount');
}
this.set('toPostIndex', postIndex);
this._beforeJump();
this.sendAction('jumpToIndex', postIndex);
},
actions: {
toggleExpansion(opts) {
this.toggleProperty('expanded');
if (this.get('expanded')) {
this.set('userWantsToJump', false);
this.set('toPostIndex', this.get('progressPosition'));
if(opts && opts.highlight){
// TODO: somehow move to view?
Em.run.next(function(){
$('.jump-form input').select().focus();
});
if (opts && opts.highlight) {
Ember.run.next(() => $('.jump-form input').select().focus());
}
if (!this.site.mobileView && !this.capabilities.isIOS) {
Ember.run.schedule('afterRender', () => this.$('input').focus());
@ -186,19 +198,14 @@ export default Ember.Component.extend({
}
},
jumpPost() {
let postIndex = parseInt(this.get('toPostIndex'), 10);
jumpPrompt() {
const postIndex = prompt(I18n.t('topic.progress.jump_prompt_long'));
if (postIndex === null) { return; }
this._jumpTo(postIndex);
},
// Validate the post index first
if (isNaN(postIndex) || postIndex < 1) {
postIndex = 1;
}
if (postIndex > this.get('postStream.filteredPostsCount')) {
postIndex = this.get('postStream.filteredPostsCount');
}
this.set('toPostIndex', postIndex);
this._beforeJump();
this.sendAction('jumpToIndex', postIndex);
jumpPost() {
this._jumpTo(this.get('toPostIndex'));
},
jumpTop() {

View File

@ -6,10 +6,15 @@
class="full no-text"
icon="caret-up"
label="topic.progress.go_top"}}
<div class='jump-form'>
{{input value=toPostIndex}}
{{d-button action="jumpPost" label="topic.progress.go"}}
</div>
{{#unless capabilities.isIOS}}
<div class='jump-form'>
{{input value=toPostIndex}}
{{d-button action="jumpPost" label="topic.progress.go"}}
</div>
{{else}}
{{d-button action="jumpPrompt" class="full jump-prompt" label="topic.progress.jump_prompt"}}
{{/unless}}
{{d-button action="jumpBottom"
disabled=jumpBottomDisabled
class="full no-text jump-bottom"

View File

@ -133,6 +133,10 @@
width: 55px;
}
}
button.btn.jump-prompt {
margin: 0;
}
button.btn.jump-bottom {
margin: 5px 0 0 0;
}

View File

@ -1349,6 +1349,8 @@ en:
go_bottom: "bottom"
go: "go"
jump_bottom: "jump to last post"
jump_prompt: "jump to post"
jump_prompt_long: "What post would you like to jump to?"
jump_bottom_with_number: "jump to post %{post_number}"
total: total posts
current: current post