Skip to content

Commit

Permalink
Fix a bug in story creation
Browse files Browse the repository at this point in the history
  Remove auto scroll from add story method
  Add highlight function for when a story be saved
  • Loading branch information
davidsilveira committed Jan 12, 2018
1 parent 5e18297 commit 0e98dbf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixed
- Adjusted README to use yarn install instead npm install on project setup
- Remove auto scroll to bottom when adding a story and highlights it instead

## [1.16.1] 2018-01-03
### Fixed
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/global_listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ $(function() {
// Show chilly bin if it's hidden
$('.hide_chilly_bin.pressed').click();
var newStoryElement = $('#chilly_bin div.story:last');
$('#chilly_bin').scrollTo(newStoryElement, 100);
});

// keycut listener
Expand Down
16 changes: 12 additions & 4 deletions app/assets/javascripts/views/story_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = FormView.extend({
"fileuploaddone": "attachmentDone",
"fileuploadstart": "attachmentStart",
"fileuploadfail": "attachmentFail",
"click #locate": "highlightSearchedStories"
"click #locate": "highlightSearchedStory"
},

// Triggered whenever a story is dropped to a new position
Expand Down Expand Up @@ -301,6 +301,7 @@ module.exports = FormView.extend({
that.enableForm();
that.model.set({ editing: editMode });
that.toggleControlButtons(false);
that.highlightStory($(that.storyElementId()));
},
error: function(model, response) {
var json = $.parseJSON(response.responseText);
Expand Down Expand Up @@ -373,15 +374,22 @@ module.exports = FormView.extend({
return story;
},

highlightSearchedStories: function () {
let storyID = `#story-${ this.model.get('id') }`;
let storyElement = $(storyID);
highlightSearchedStory: function () {
let storyElement = $(this.storyElementId());
$('.content-wrapper').animate({
scrollTop: storyElement.offset().top - 15
}, 'fast');
this.highlightStory(storyElement);
},

highlightStory: function (storyElement) {
storyElement.effect("highlight", {color: 'lightgreen'}, 1500);
},

storyElementId: function () {
return `#story-${ this.model.get('id') }`;
},

render: function() {
const storyControlsContainer = this.$('[data-story-controls]').get(0);

Expand Down

0 comments on commit 0e98dbf

Please sign in to comment.