Gmail like message list navigation (#70)

This commit is contained in:
RainLoop Team 2014-04-10 04:15:46 +04:00
parent da88e0d2b5
commit fbf17aa6f3
14 changed files with 556 additions and 543 deletions

View file

@ -18,24 +18,33 @@ function Selector(oKoList, oKoSelectedItem,
return _.filter(this.list(), function (oItem) {
return oItem.checked();
});
}, this);
}, this).extend({'rateLimit': 0});
this.isListChecked = ko.computed(function () {
return 0 < this.listChecked().length;
}, this);
this.lastSelectedItem = ko.observable(null);
this.focusedItem = ko.observable(null);
this.selectedItem = oKoSelectedItem;
this.selectedItemUseCallback = true;
this.itemSelectedTrottle = _.throttle(_.bind(this.itemSelected, this), 300);
this.listChecked.subscribe(function (aItems) {
if (0 < aItems.length)
{
this.selectedItem(null);
if (null === this.selectedItem())
{
this.selectedItem.valueHasMutated();
}
else
{
this.selectedItem(null);
}
}
else if (this.bAutoSelect && this.lastSelectedItem())
else if (this.bAutoSelect && this.focusedItem())
{
this.selectedItem(this.lastSelectedItem());
this.selectedItem(this.focusedItem());
}
}, this);
@ -43,17 +52,21 @@ function Selector(oKoList, oKoSelectedItem,
if (oItem)
{
if (this.bAutoSelect)
{
this.lastSelectedItem(oItem);
}
if (this.isListChecked())
{
_.each(this.listChecked(), function (oSubItem) {
oSubItem.checked(false);
});
}
if (this.selectedItemUseCallback)
{
this.itemSelectedTrottle(oItem);
}
}
else if (this.selectedItemUseCallback)
{
this.itemSelected(null);
}
}, this);
@ -96,37 +109,12 @@ function Selector(oKoList, oKoSelectedItem,
this.sLastUid = '';
this.oCallbacks = {};
this.iSelectTimer = 0;
this.bUseKeyboard = true;
this.bAutoSelect = true;
this.emptyFunction = function () {};
this.useItemSelectCallback = true;
this.selectedItem.subscribe(function (oItem) {
if (oItem)
{
this.sLastUid = this.getItemUid(oItem);
this.focusedItem(oItem);
}
if (this.useItemSelectCallback)
{
if (oItem)
{
this.selectItemCallbacks(oItem);
}
else
{
this.selectItemCallbacks(null);
}
}
}, this);
this.focusedItem.subscribe(function (oItem) {
if (oItem)
{
@ -135,47 +123,55 @@ function Selector(oKoList, oKoSelectedItem,
}, this);
var
aCache = [],
aCheckedCache = [],
mFocused = null,
mSelected = null
;
this.list.subscribe(function () {
this.list.subscribe(function (aItems) {
var self = this, aItems = this.list();
var self = this;
if (Utils.isArray(aItems))
{
_.each(aItems, function (oItem) {
if (oItem.checked())
if (oItem)
{
aCheckedCache.push(self.getItemUid(oItem));
}
var sUid = self.getItemUid(oItem);
if (null === mFocused && oItem.focused())
{
mFocused = self.getItemUid(oItem);
aCache.push(sUid);
if (oItem.checked())
{
aCheckedCache.push(sUid);
}
if (null === mFocused && oItem.focused())
{
mFocused = sUid;
}
if (null === mSelected && oItem.selected())
{
mSelected = sUid;
}
}
if (null === mSelected && oItem.selected())
{
mSelected = self.getItemUid(oItem);
}
});
}
}, this, 'beforeChange');
this.list.subscribe(function (aItems) {
this.useItemSelectCallback = false;
var
self = this,
oTemp = null,
bGetNext = false,
aUids = [],
mNextFocused = mFocused,
bChecked = false,
bSelected = false,
iLen = 0
;
this.selectedItemUseCallback = false;
this.focusedItem(null);
this.selectedItem(null);
@ -186,6 +182,13 @@ function Selector(oKoList, oKoSelectedItem,
_.each(aItems, function (oItem) {
var sUid = self.getItemUid(oItem);
aUids.push(sUid);
if (null !== mFocused && mFocused === sUid)
{
self.focusedItem(oItem);
mFocused = null;
}
if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache))
{
@ -194,34 +197,77 @@ function Selector(oKoList, oKoSelectedItem,
iLen--;
}
if (null !== mFocused && mFocused === sUid)
{
self.focusedItem(oItem);
mFocused = null;
}
if (!bChecked && null !== mSelected && mSelected === sUid)
{
bSelected = true;
self.selectedItem(oItem);
mSelected = null;
}
});
this.selectedItemUseCallback = true;
if (!bChecked && !bSelected && this.bAutoSelect)
{
if (self.focusedItem())
{
self.selectedItem(self.focusedItem());
}
else if (0 < aItems.length)
{
if (null !== mNextFocused)
{
bGetNext = false;
mNextFocused = _.find(aCache, function (sUid) {
if (bGetNext && -1 < Utils.inArray(sUid, aUids))
{
return sUid;
}
else if (mNextFocused === sUid)
{
bGetNext = true;
}
return false;
});
if (mNextFocused)
{
oTemp = _.find(aItems, function (oItem) {
return mNextFocused === self.getItemUid(oItem);
});
}
}
self.selectedItem(oTemp || null);
self.focusedItem(self.selectedItem());
}
}
}
this.useItemSelectCallback = true;
aCache = [];
aCheckedCache = [];
mFocused = null;
mSelected = null;
}, this);
this.selectItemCallbacksThrottle = _.debounce(this.selectItemCallbacks, 300);
}
Selector.prototype.selectItemCallbacks = function (oItem)
Selector.prototype.itemSelected = function (oItem)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem);
if (this.isListChecked())
{
if (!oItem)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem || null);
}
}
else
{
if (oItem)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem);
}
}
};
Selector.prototype.goDown = function (bForceSelect)
@ -255,7 +301,7 @@ Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeySco
}
})
.on('click', this.sItemSelector, function (oEvent) {
self.actionClick(ko.dataFor(this), oEvent, true);
self.actionClick(ko.dataFor(this), oEvent);
})
.on('click', this.sItemCheckedSelector, function (oEvent) {
var oItem = ko.dataFor(this);
@ -267,7 +313,7 @@ Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeySco
}
else
{
self.sLastUid = self.getItemUid(oItem);
self.focusedItem(oItem);
oItem.checked(!oItem.checked());
}
}
@ -275,15 +321,12 @@ Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeySco
;
key('enter', sKeyScope, function () {
if (!self.bAutoSelect)
if (self.focusedItem())
{
if (self.focusedItem())
{
self.actionClick(self.focusedItem());
}
return false;
self.actionClick(self.focusedItem());
}
return false;
});
key('ctrl+up, command+up, ctrl+down, command+down', sKeyScope, function () {
@ -372,7 +415,6 @@ Selector.prototype.getItemUid = function (oItem)
Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForceSelect)
{
var
self = this,
iIndex = 0,
iPageStep = 10,
bNext = false,
@ -416,7 +458,6 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
break;
case Enums.EventKeyCode.Down:
case Enums.EventKeyCode.Insert:
// case Enums.EventKeyCode.Space:
if (bNext)
{
oResult = oItem;
@ -473,6 +514,8 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
if (oResult)
{
this.focusedItem(oResult);
if (oFocused)
{
if (bShiftKey)
@ -488,15 +531,10 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
}
}
this.focusedItem(oResult);
if ((this.bAutoSelect || !!bForceSelect) && !this.isListChecked() && Enums.EventKeyCode.Space !== iEventKeyCode)
if ((this.bAutoSelect || !!bForceSelect) &&
!this.isListChecked() && Enums.EventKeyCode.Space !== iEventKeyCode)
{
window.clearTimeout(this.iSelectTimer);
this.iSelectTimer = window.setTimeout(function () {
self.iSelectTimer = 0;
self.actionClick(oResult);
}, 300);
this.selectedItem(oResult);
}
this.scrollToFocused();
@ -511,6 +549,8 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
{
oFocused.checked(!oFocused.checked());
}
this.focusedItem(oFocused);
}
};
@ -622,18 +662,20 @@ Selector.prototype.actionClick = function (oItem, oEvent)
oItem.checked(!oItem.checked());
this.eventClickFunction(oItem, oEvent);
this.focusedItem(oItem);
}
else if (oEvent.ctrlKey)
{
bClick = false;
this.sLastUid = sUid;
this.focusedItem(oItem);
oItem.checked(!oItem.checked());
}
}
if (bClick)
{
this.focusedItem(oItem);
this.selectedItem(oItem);
}
}

View file

@ -55,10 +55,12 @@ MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPrevie
{
if (Utils.isUnd(bPreview) ? false : !!bPreview)
{
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())
{
RL.historyBack();
}
_.delay(function () {
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())
{
RL.historyBack();
}
}, 5);
}
else
{

View file

@ -192,7 +192,7 @@ function WebMailDataStorage()
// message list
this.staticMessageList = [];
this.messageList = ko.observableArray([]);
this.messageList = ko.observableArray([]).extend({'rateLimit': 0});
this.messageListCount = ko.observable(0);
this.messageListSearch = ko.observable('');
@ -263,6 +263,11 @@ function WebMailDataStorage()
{
this.message.focused(false);
this.hideMessageBodies();
if (Enums.Layout.NoPreview === RL.data().layout())
{
RL.historyBack();
}
}
else if (Enums.Layout.NoPreview === this.layout())
{
@ -303,7 +308,11 @@ function WebMailDataStorage()
return _.filter(this.messageList(), function (oItem) {
return oItem.checked();
});
}, this);
}, this).extend({'rateLimit': 0});
this.hasCheckedMessages = ko.computed(function () {
return 0 < this.messageListChecked().length;
}, this).extend({'rateLimit': 0});
this.messageListCheckedOrSelected = ko.computed(function () {
@ -752,9 +761,6 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
iUnseenCount = 0,
oData = RL.data(),
oCache = RL.cache(),
bMoveSelected = false,
bGetNext = false,
oNextMessage = null,
aMessageList = oData.messageList(),
oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw),
oToFolder = '' === sToFolderFullNameRaw ? null : oCache.getFolderFromCacheList(sToFolderFullNameRaw || ''),
@ -770,11 +776,6 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
{
iUnseenCount++;
}
if (oMessage.selected())
{
bMoveSelected = true;
}
});
if (oFromFolder && !bCopy)
@ -810,29 +811,6 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
}
else
{
// select next message // TODO
// if (bMoveSelected)
// {
// _.each(aMessageList, function (oMessage) {
// if (!oNextMessage && oMessage)
// {
// if (bGetNext && !oMessage.checked() && !oMessage.deleted() && !oMessage.selected())
// {
// oNextMessage = oMessage;
// }
// else if (!bGetNext && oMessage.selected())
// {
// bGetNext = true;
// }
// }
// });
//
// if (oNextMessage)
// {
// this.currentMessage(oNextMessage);
// }
// }
oData.messageListIsNotCompleted(true);
_.each(aMessages, function (oMessage) {
@ -1046,7 +1024,6 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
iLen = 0,
iCount = 0,
iOffset = 0,
aPrevList = [],
aList = [],
iUtc = moment().unix(),
aStaticList = oRainLoopData.staticMessageList,
@ -1140,26 +1117,9 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
oRainLoopData.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
oRainLoopData.messageListPage(Math.ceil((iOffset / oRainLoopData.messagesPerPage()) + 1));
aPrevList = oRainLoopData.messageList();
if (aPrevList.length !== aList.length)
{
oRainLoopData.messageList(aList);
}
else if (this.calculateMessageListHash(aPrevList) !== this.calculateMessageListHash(aList))
{
oRainLoopData.messageList(aList);
}
aPrevList = [];
oRainLoopData.messageList(aList);
oRainLoopData.messageListIsNotCompleted(false);
oMessage = oRainLoopData.message();
// TODO
// if (oMessage && oRainLoopData.messageList.setSelectedByUid)
// {
// oRainLoopData.messageList.setSelectedByUid(oMessage.generateUid());
// }
if (aStaticList.length < aList.length)
{
oRainLoopData.staticMessageList = aList;

View file

@ -230,7 +230,7 @@ html.rl-no-preview-pane {
}
&.focused .sidebarParent {
background-color: #bbb !important;
background-color: #ccc !important;
}
&.e-single-line {
@ -471,10 +471,6 @@ html.rl-no-preview-pane {
background-color: #398CF2 !important;
}
&.focused .sidebarParent {
background-color: darken(#398CF2, 5%) !important;
}
.delimiter {
background-color: #398CF2;
.opacity(20);

View file

@ -38,6 +38,21 @@ html.rl-no-preview-pane {
background-color: #fff;
.b-message-view-checked-helper {
text-align: center;
font-size: 70px;
line-height: 70px;
padding-top: 140px;
color: #999;
.icon-mail {
font-size: 100px;
font-size: 50px;
line-height: 90px;
padding-left: 10px;
}
}
.b-message-view-desc {
text-align: center;
font-size: 24px;

View file

@ -24,6 +24,8 @@ function MailBoxMessageViewViewModel()
this.keyScope = oData.keyScope;
this.message = oData.message;
this.currentMessage = oData.currentMessage;
this.messageListChecked = oData.messageListChecked;
this.hasCheckedMessages = oData.hasCheckedMessages;
this.messageLoading = oData.messageLoading;
this.messageLoadingThrottle = oData.messageLoadingThrottle;
this.messagesBodiesDom = oData.messagesBodiesDom;
@ -38,14 +40,14 @@ function MailBoxMessageViewViewModel()
this.fullScreenMode = oData.messageFullScreenMode;
this.showFullInfo = ko.observable(false);
this.messageDomFocused = ko.observable(false);
this.messageDomFocused = ko.observable(false).extend({'rateLimit': 0});
this.messageVisibility = ko.computed(function () {
return !this.messageLoadingThrottle() && !!this.message();
}, this);
this.message.subscribe(function (oMessage) {
if (!oMessage && this.currentMessage())
if (!oMessage)
{
this.currentMessage(null);
}
@ -55,14 +57,7 @@ function MailBoxMessageViewViewModel()
// commands
this.closeMessage = Utils.createCommand(this, function () {
if (Enums.Layout.NoPreview === oData.layout())
{
RL.historyBack();
}
else
{
oData.message(null);
}
oData.message(null);
});
this.replyCommand = createCommandHelper(Enums.ComposeType.Reply);
@ -138,7 +133,6 @@ function MailBoxMessageViewViewModel()
return this.message() ? this.message().pgpSignedVerifyUser() : '';
}, this);
this.message.subscribe(function (oMessage) {
this.messageActiveDom(null);
@ -392,11 +386,7 @@ MailBoxMessageViewViewModel.prototype.escShortcuts = function ()
}
else
{
this.message.focused(false);
if (Enums.Layout.NoPreview === RL.data().layout())
{
RL.historyBack();
}
this.message(null);
}
return false;

View file

@ -123,7 +123,11 @@
</div>
<div class="b-content thm-message-view-background-color">
<div>
<div class="b-message-view-desc" data-bind="visible: !message() && '' === messageError()">
<div class="b-message-view-checked-helper" data-bind="visible: !message() && '' === messageError() && hasCheckedMessages()">
<span data-bind="text: messageListChecked().length"></span>
<i class="icon-mail"></i>
</div>
<div class="b-message-view-desc" data-bind="visible: !message() && '' === messageError() && !hasCheckedMessages()">
<span class="i18n" data-i18n-text="MESSAGE/MESSAGE_VIEW_DESC"></span>
</div>
<div class="b-message-view-desc error" data-bind="visible: !message() && '' !== messageError()">

View file

@ -6844,7 +6844,7 @@ html.rl-no-preview-pane .messageList.message-selected {
height: 100%;
}
.messageList .b-content .messageListItem.focused .sidebarParent {
background-color: #bbb !important;
background-color: #ccc !important;
}
.messageList .b-content .messageListItem.e-single-line {
height: 35px;
@ -7045,9 +7045,6 @@ html.rl-no-preview-pane .messageList.message-selected {
.messageList .b-content .messageListItem.selected .sidebarParent {
background-color: #398CF2 !important;
}
.messageList .b-content .messageListItem.selected.focused .sidebarParent {
background-color: #217ef0 !important;
}
.messageList .b-content .messageListItem.selected .delimiter {
background-color: #398CF2;
opacity: 0.2;
@ -7137,6 +7134,19 @@ html.rl-no-preview-pane .messageView.message-selected {
border-bottom-right-radius: 3px;
background-color: #fff;
}
.messageView .b-content .b-message-view-checked-helper {
text-align: center;
font-size: 70px;
line-height: 70px;
padding-top: 140px;
color: #999;
}
.messageView .b-content .b-message-view-checked-helper .icon-mail {
font-size: 100px;
font-size: 50px;
line-height: 90px;
padding-left: 10px;
}
.messageView .b-content .b-message-view-desc {
text-align: center;
font-size: 24px;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -3920,24 +3920,33 @@ function Selector(oKoList, oKoSelectedItem,
return _.filter(this.list(), function (oItem) {
return oItem.checked();
});
}, this);
}, this).extend({'rateLimit': 0});
this.isListChecked = ko.computed(function () {
return 0 < this.listChecked().length;
}, this);
this.lastSelectedItem = ko.observable(null);
this.focusedItem = ko.observable(null);
this.selectedItem = oKoSelectedItem;
this.selectedItemUseCallback = true;
this.itemSelectedTrottle = _.throttle(_.bind(this.itemSelected, this), 300);
this.listChecked.subscribe(function (aItems) {
if (0 < aItems.length)
{
this.selectedItem(null);
if (null === this.selectedItem())
{
this.selectedItem.valueHasMutated();
}
else
{
this.selectedItem(null);
}
}
else if (this.bAutoSelect && this.lastSelectedItem())
else if (this.bAutoSelect && this.focusedItem())
{
this.selectedItem(this.lastSelectedItem());
this.selectedItem(this.focusedItem());
}
}, this);
@ -3945,17 +3954,21 @@ function Selector(oKoList, oKoSelectedItem,
if (oItem)
{
if (this.bAutoSelect)
{
this.lastSelectedItem(oItem);
}
if (this.isListChecked())
{
_.each(this.listChecked(), function (oSubItem) {
oSubItem.checked(false);
});
}
if (this.selectedItemUseCallback)
{
this.itemSelectedTrottle(oItem);
}
}
else if (this.selectedItemUseCallback)
{
this.itemSelected(null);
}
}, this);
@ -3998,37 +4011,12 @@ function Selector(oKoList, oKoSelectedItem,
this.sLastUid = '';
this.oCallbacks = {};
this.iSelectTimer = 0;
this.bUseKeyboard = true;
this.bAutoSelect = true;
this.emptyFunction = function () {};
this.useItemSelectCallback = true;
this.selectedItem.subscribe(function (oItem) {
if (oItem)
{
this.sLastUid = this.getItemUid(oItem);
this.focusedItem(oItem);
}
if (this.useItemSelectCallback)
{
if (oItem)
{
this.selectItemCallbacks(oItem);
}
else
{
this.selectItemCallbacks(null);
}
}
}, this);
this.focusedItem.subscribe(function (oItem) {
if (oItem)
{
@ -4037,47 +4025,55 @@ function Selector(oKoList, oKoSelectedItem,
}, this);
var
aCache = [],
aCheckedCache = [],
mFocused = null,
mSelected = null
;
this.list.subscribe(function () {
this.list.subscribe(function (aItems) {
var self = this, aItems = this.list();
var self = this;
if (Utils.isArray(aItems))
{
_.each(aItems, function (oItem) {
if (oItem.checked())
if (oItem)
{
aCheckedCache.push(self.getItemUid(oItem));
}
var sUid = self.getItemUid(oItem);
if (null === mFocused && oItem.focused())
{
mFocused = self.getItemUid(oItem);
aCache.push(sUid);
if (oItem.checked())
{
aCheckedCache.push(sUid);
}
if (null === mFocused && oItem.focused())
{
mFocused = sUid;
}
if (null === mSelected && oItem.selected())
{
mSelected = sUid;
}
}
if (null === mSelected && oItem.selected())
{
mSelected = self.getItemUid(oItem);
}
});
}
}, this, 'beforeChange');
this.list.subscribe(function (aItems) {
this.useItemSelectCallback = false;
var
self = this,
oTemp = null,
bGetNext = false,
aUids = [],
mNextFocused = mFocused,
bChecked = false,
bSelected = false,
iLen = 0
;
this.selectedItemUseCallback = false;
this.focusedItem(null);
this.selectedItem(null);
@ -4088,6 +4084,13 @@ function Selector(oKoList, oKoSelectedItem,
_.each(aItems, function (oItem) {
var sUid = self.getItemUid(oItem);
aUids.push(sUid);
if (null !== mFocused && mFocused === sUid)
{
self.focusedItem(oItem);
mFocused = null;
}
if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache))
{
@ -4096,34 +4099,77 @@ function Selector(oKoList, oKoSelectedItem,
iLen--;
}
if (null !== mFocused && mFocused === sUid)
{
self.focusedItem(oItem);
mFocused = null;
}
if (!bChecked && null !== mSelected && mSelected === sUid)
{
bSelected = true;
self.selectedItem(oItem);
mSelected = null;
}
});
this.selectedItemUseCallback = true;
if (!bChecked && !bSelected && this.bAutoSelect)
{
if (self.focusedItem())
{
self.selectedItem(self.focusedItem());
}
else if (0 < aItems.length)
{
if (null !== mNextFocused)
{
bGetNext = false;
mNextFocused = _.find(aCache, function (sUid) {
if (bGetNext && -1 < Utils.inArray(sUid, aUids))
{
return sUid;
}
else if (mNextFocused === sUid)
{
bGetNext = true;
}
return false;
});
if (mNextFocused)
{
oTemp = _.find(aItems, function (oItem) {
return mNextFocused === self.getItemUid(oItem);
});
}
}
self.selectedItem(oTemp || null);
self.focusedItem(self.selectedItem());
}
}
}
this.useItemSelectCallback = true;
aCache = [];
aCheckedCache = [];
mFocused = null;
mSelected = null;
}, this);
this.selectItemCallbacksThrottle = _.debounce(this.selectItemCallbacks, 300);
}
Selector.prototype.selectItemCallbacks = function (oItem)
Selector.prototype.itemSelected = function (oItem)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem);
if (this.isListChecked())
{
if (!oItem)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem || null);
}
}
else
{
if (oItem)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem);
}
}
};
Selector.prototype.goDown = function (bForceSelect)
@ -4157,7 +4203,7 @@ Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeySco
}
})
.on('click', this.sItemSelector, function (oEvent) {
self.actionClick(ko.dataFor(this), oEvent, true);
self.actionClick(ko.dataFor(this), oEvent);
})
.on('click', this.sItemCheckedSelector, function (oEvent) {
var oItem = ko.dataFor(this);
@ -4169,7 +4215,7 @@ Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeySco
}
else
{
self.sLastUid = self.getItemUid(oItem);
self.focusedItem(oItem);
oItem.checked(!oItem.checked());
}
}
@ -4177,15 +4223,12 @@ Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeySco
;
key('enter', sKeyScope, function () {
if (!self.bAutoSelect)
if (self.focusedItem())
{
if (self.focusedItem())
{
self.actionClick(self.focusedItem());
}
return false;
self.actionClick(self.focusedItem());
}
return false;
});
key('ctrl+up, command+up, ctrl+down, command+down', sKeyScope, function () {
@ -4274,7 +4317,6 @@ Selector.prototype.getItemUid = function (oItem)
Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForceSelect)
{
var
self = this,
iIndex = 0,
iPageStep = 10,
bNext = false,
@ -4318,7 +4360,6 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
break;
case Enums.EventKeyCode.Down:
case Enums.EventKeyCode.Insert:
// case Enums.EventKeyCode.Space:
if (bNext)
{
oResult = oItem;
@ -4375,6 +4416,8 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
if (oResult)
{
this.focusedItem(oResult);
if (oFocused)
{
if (bShiftKey)
@ -4390,15 +4433,10 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
}
}
this.focusedItem(oResult);
if ((this.bAutoSelect || !!bForceSelect) && !this.isListChecked() && Enums.EventKeyCode.Space !== iEventKeyCode)
if ((this.bAutoSelect || !!bForceSelect) &&
!this.isListChecked() && Enums.EventKeyCode.Space !== iEventKeyCode)
{
window.clearTimeout(this.iSelectTimer);
this.iSelectTimer = window.setTimeout(function () {
self.iSelectTimer = 0;
self.actionClick(oResult);
}, 300);
this.selectedItem(oResult);
}
this.scrollToFocused();
@ -4413,6 +4451,8 @@ Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForc
{
oFocused.checked(!oFocused.checked());
}
this.focusedItem(oFocused);
}
};
@ -4524,18 +4564,20 @@ Selector.prototype.actionClick = function (oItem, oEvent)
oItem.checked(!oItem.checked());
this.eventClickFunction(oItem, oEvent);
this.focusedItem(oItem);
}
else if (oEvent.ctrlKey)
{
bClick = false;
this.sLastUid = sUid;
this.focusedItem(oItem);
oItem.checked(!oItem.checked());
}
}
if (bClick)
{
this.focusedItem(oItem);
this.selectedItem(oItem);
}
}
@ -12685,6 +12727,8 @@ function MailBoxMessageViewViewModel()
this.keyScope = oData.keyScope;
this.message = oData.message;
this.currentMessage = oData.currentMessage;
this.messageListChecked = oData.messageListChecked;
this.hasCheckedMessages = oData.hasCheckedMessages;
this.messageLoading = oData.messageLoading;
this.messageLoadingThrottle = oData.messageLoadingThrottle;
this.messagesBodiesDom = oData.messagesBodiesDom;
@ -12699,14 +12743,14 @@ function MailBoxMessageViewViewModel()
this.fullScreenMode = oData.messageFullScreenMode;
this.showFullInfo = ko.observable(false);
this.messageDomFocused = ko.observable(false);
this.messageDomFocused = ko.observable(false).extend({'rateLimit': 0});
this.messageVisibility = ko.computed(function () {
return !this.messageLoadingThrottle() && !!this.message();
}, this);
this.message.subscribe(function (oMessage) {
if (!oMessage && this.currentMessage())
if (!oMessage)
{
this.currentMessage(null);
}
@ -12716,14 +12760,7 @@ function MailBoxMessageViewViewModel()
// commands
this.closeMessage = Utils.createCommand(this, function () {
if (Enums.Layout.NoPreview === oData.layout())
{
RL.historyBack();
}
else
{
oData.message(null);
}
oData.message(null);
});
this.replyCommand = createCommandHelper(Enums.ComposeType.Reply);
@ -12799,7 +12836,6 @@ function MailBoxMessageViewViewModel()
return this.message() ? this.message().pgpSignedVerifyUser() : '';
}, this);
this.message.subscribe(function (oMessage) {
this.messageActiveDom(null);
@ -13053,11 +13089,7 @@ MailBoxMessageViewViewModel.prototype.escShortcuts = function ()
}
else
{
this.message.focused(false);
if (Enums.Layout.NoPreview === RL.data().layout())
{
RL.historyBack();
}
this.message(null);
}
return false;
@ -14929,7 +14961,7 @@ function WebMailDataStorage()
// message list
this.staticMessageList = [];
this.messageList = ko.observableArray([]);
this.messageList = ko.observableArray([]).extend({'rateLimit': 0});
this.messageListCount = ko.observable(0);
this.messageListSearch = ko.observable('');
@ -15000,6 +15032,11 @@ function WebMailDataStorage()
{
this.message.focused(false);
this.hideMessageBodies();
if (Enums.Layout.NoPreview === RL.data().layout())
{
RL.historyBack();
}
}
else if (Enums.Layout.NoPreview === this.layout())
{
@ -15040,7 +15077,11 @@ function WebMailDataStorage()
return _.filter(this.messageList(), function (oItem) {
return oItem.checked();
});
}, this);
}, this).extend({'rateLimit': 0});
this.hasCheckedMessages = ko.computed(function () {
return 0 < this.messageListChecked().length;
}, this).extend({'rateLimit': 0});
this.messageListCheckedOrSelected = ko.computed(function () {
@ -15489,9 +15530,6 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
iUnseenCount = 0,
oData = RL.data(),
oCache = RL.cache(),
bMoveSelected = false,
bGetNext = false,
oNextMessage = null,
aMessageList = oData.messageList(),
oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw),
oToFolder = '' === sToFolderFullNameRaw ? null : oCache.getFolderFromCacheList(sToFolderFullNameRaw || ''),
@ -15507,11 +15545,6 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
{
iUnseenCount++;
}
if (oMessage.selected())
{
bMoveSelected = true;
}
});
if (oFromFolder && !bCopy)
@ -15547,29 +15580,6 @@ WebMailDataStorage.prototype.removeMessagesFromList = function (
}
else
{
// select next message // TODO
// if (bMoveSelected)
// {
// _.each(aMessageList, function (oMessage) {
// if (!oNextMessage && oMessage)
// {
// if (bGetNext && !oMessage.checked() && !oMessage.deleted() && !oMessage.selected())
// {
// oNextMessage = oMessage;
// }
// else if (!bGetNext && oMessage.selected())
// {
// bGetNext = true;
// }
// }
// });
//
// if (oNextMessage)
// {
// this.currentMessage(oNextMessage);
// }
// }
oData.messageListIsNotCompleted(true);
_.each(aMessages, function (oMessage) {
@ -15783,7 +15793,6 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
iLen = 0,
iCount = 0,
iOffset = 0,
aPrevList = [],
aList = [],
iUtc = moment().unix(),
aStaticList = oRainLoopData.staticMessageList,
@ -15877,26 +15886,9 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
oRainLoopData.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
oRainLoopData.messageListPage(Math.ceil((iOffset / oRainLoopData.messagesPerPage()) + 1));
aPrevList = oRainLoopData.messageList();
if (aPrevList.length !== aList.length)
{
oRainLoopData.messageList(aList);
}
else if (this.calculateMessageListHash(aPrevList) !== this.calculateMessageListHash(aList))
{
oRainLoopData.messageList(aList);
}
aPrevList = [];
oRainLoopData.messageList(aList);
oRainLoopData.messageListIsNotCompleted(false);
oMessage = oRainLoopData.message();
// TODO
// if (oMessage && oRainLoopData.messageList.setSelectedByUid)
// {
// oRainLoopData.messageList.setSelectedByUid(oMessage.generateUid());
// }
if (aStaticList.length < aList.length)
{
oRainLoopData.staticMessageList = aList;
@ -17659,10 +17651,12 @@ MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPrevie
{
if (Utils.isUnd(bPreview) ? false : !!bPreview)
{
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())
{
RL.historyBack();
}
_.delay(function () {
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())
{
RL.historyBack();
}
}, 5);
}
else
{

File diff suppressed because one or more lines are too long