Skip to content

Commit

Permalink
Merge pull request #1290 from edward-shen/develop
Browse files Browse the repository at this point in the history
newsfeed now remembers user configuration settings for descriptions after fullscreen view. Fixes #1282.
  • Loading branch information
MichMich authored May 16, 2018
2 parents 349af24 + 55a161f commit 3049ba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Fixed browser-side code to work on the Midori browser.
- Fixed issue where heat index was reporting incorrect values in Celsius and Fahrenheit. [#1263](https://github.com/MichMich/MagicMirror/issues/1263)
- Fixed weatherforecast to use dt_txt field instead of dt to handle timezones better
- newsfeed now remembers to show the description when `"ARTICLE_LESS_DETAILS"` is called if the user wants to always show the description. [#1282](https://github.com/MichMich/MagicMirror/issues/1282)

### Updated
- Updated Italian translation
Expand Down
15 changes: 8 additions & 7 deletions modules/default/newsfeed/newsfeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Module.register("newsfeed",{

this.registerFeeds();

this.isShowingDescription = this.config.showDescription;
},

// Override socket notification handler.
Expand Down Expand Up @@ -133,7 +134,7 @@ Module.register("newsfeed",{

if (this.config.removeStartTags == "description" || this.config.removeStartTags == "both") {

if (this.config.showDescription) {
if (this.isShowingDescription) {
for (f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].description.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].description.length);
Expand All @@ -152,7 +153,7 @@ Module.register("newsfeed",{
}
}

if (this.config.showDescription) {
if (this.isShowingDescription) {
for (f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.endTags[f].length);
Expand All @@ -169,7 +170,7 @@ Module.register("newsfeed",{
wrapper.appendChild(title);
}

if (this.config.showDescription) {
if (this.isShowingDescription) {
var description = document.createElement("div");
description.className = "small light" + (!this.config.wrapDescription ? " no-wrap" : "");
var txtDesc = this.newsItems[this.activeItem].description;
Expand Down Expand Up @@ -323,7 +324,7 @@ Module.register("newsfeed",{
},

resetDescrOrFullArticleAndTimer: function() {
this.config.showDescription = false;
this.isShowingDescription = this.config.showDescription;
this.config.showFullArticle = false;
this.scrollPosition = 0;
// reset bottom bar alignment
Expand Down Expand Up @@ -366,16 +367,16 @@ Module.register("newsfeed",{
}
// display full article
else {
this.config.showDescription = !this.config.showDescription;
this.config.showFullArticle = !this.config.showDescription;
this.isShowingDescription = !this.isShowingDescription;
this.config.showFullArticle = !this.isShowingDescription;
// make bottom bar align to top to allow scrolling
if(this.config.showFullArticle == true){
document.getElementsByClassName("region bottom bar")[0].style.bottom = "inherit";
document.getElementsByClassName("region bottom bar")[0].style.top = "-90px";
}
clearInterval(timer);
timer = null;
Log.info(this.name + " - showing " + this.config.showDescription ? "article description" : "full article");
Log.info(this.name + " - showing " + this.isShowingDescription ? "article description" : "full article");
this.updateDom(100);
}
} else if(notification == "ARTICLE_SCROLL_UP"){
Expand Down

0 comments on commit 3049ba0

Please sign in to comment.