Reset the list scroll postition when changing pages (Closes #144)

This commit is contained in:
RainLoop Team 2014-04-27 02:23:00 +04:00
parent 90d59e108f
commit 0fcd7cf122
5 changed files with 80 additions and 14 deletions

View file

@ -582,6 +582,29 @@ Selector.prototype.scrollToFocused = function ()
return false;
};
/**
* @param {boolean=} bFast = false
* @return {boolean}
*/
Selector.prototype.scrollToTop = function (bFast)
{
if (!this.oContentVisible || !this.oContentScrollable)
{
return false;
}
if (bFast)
{
this.oContentScrollable.scrollTop(0);
}
else
{
this.oContentScrollable.stop().animate({'scrollTop': 0}, 200);
}
return true;
};
Selector.prototype.eventClickFunction = function (oItem, oEvent)
{
var

View file

@ -218,8 +218,13 @@ function WebMailDataStorage()
this.messageListThreadUids([]);
}, this);
this.messageListEndSearch = ko.observable('');
this.messageListEndFolder = ko.observable('');
this.messageListEndSearch = ko.observable('');
this.messageListEndPage = ko.observable(1);
this.messageListEndHash = ko.computed(function () {
return this.messageListEndFolder() + '|' + this.messageListEndSearch() + '|' + this.messageListEndPage();
}, this);
this.messageListPageCount = ko.computed(function () {
var iPage = Math.ceil(this.messageListCount() / this.messagesPerPage());
@ -1133,9 +1138,10 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
oRainLoopData.messageListCount(iCount);
oRainLoopData.messageListSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
oRainLoopData.messageListEndSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
oRainLoopData.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
oRainLoopData.messageListPage(Math.ceil((iOffset / oRainLoopData.messagesPerPage()) + 1));
oRainLoopData.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
oRainLoopData.messageListEndSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
oRainLoopData.messageListEndPage(oRainLoopData.messageListPage());
oRainLoopData.messageList(aList);
oRainLoopData.messageListIsNotCompleted(false);

View file

@ -208,6 +208,10 @@ function MailBoxMessageListViewModel()
return oMessage ? oMessage.generateUid() : '';
});
oData.messageListEndHash.subscribe(function (mValue) {
this.selector.scrollToTop();
}, this);
oData.layout.subscribe(function (mValue) {
this.selector.autoSelect(Enums.Layout.NoPreview !== mValue);
}, this);

View file

@ -4578,6 +4578,29 @@ Selector.prototype.scrollToFocused = function ()
return false;
};
/**
* @param {boolean=} bFast = false
* @return {boolean}
*/
Selector.prototype.scrollToTop = function (bFast)
{
if (!this.oContentVisible || !this.oContentScrollable)
{
return false;
}
if (bFast)
{
this.oContentScrollable.scrollTop(0);
}
else
{
this.oContentScrollable.stop().animate({'scrollTop': 0}, 200);
}
return true;
};
Selector.prototype.eventClickFunction = function (oItem, oEvent)
{
var
@ -12201,6 +12224,10 @@ function MailBoxMessageListViewModel()
return oMessage ? oMessage.generateUid() : '';
});
oData.messageListEndHash.subscribe(function (mValue) {
this.selector.scrollToTop();
}, this);
oData.layout.subscribe(function (mValue) {
this.selector.autoSelect(Enums.Layout.NoPreview !== mValue);
}, this);
@ -15294,8 +15321,13 @@ function WebMailDataStorage()
this.messageListThreadUids([]);
}, this);
this.messageListEndSearch = ko.observable('');
this.messageListEndFolder = ko.observable('');
this.messageListEndSearch = ko.observable('');
this.messageListEndPage = ko.observable(1);
this.messageListEndHash = ko.computed(function () {
return this.messageListEndFolder() + '|' + this.messageListEndSearch() + '|' + this.messageListEndPage();
}, this);
this.messageListPageCount = ko.computed(function () {
var iPage = Math.ceil(this.messageListCount() / this.messagesPerPage());
@ -16209,9 +16241,10 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
oRainLoopData.messageListCount(iCount);
oRainLoopData.messageListSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
oRainLoopData.messageListEndSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
oRainLoopData.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
oRainLoopData.messageListPage(Math.ceil((iOffset / oRainLoopData.messagesPerPage()) + 1));
oRainLoopData.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
oRainLoopData.messageListEndSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : '');
oRainLoopData.messageListEndPage(oRainLoopData.messageListPage());
oRainLoopData.messageList(aList);
oRainLoopData.messageListIsNotCompleted(false);

File diff suppressed because one or more lines are too long