Fix back button in no-preview layout

layout setting
This commit is contained in:
RainLoop Team 2014-02-03 19:54:05 +04:00
parent 7bba9c17ea
commit 6928fcc48e
17 changed files with 385 additions and 238 deletions

View file

@ -204,6 +204,11 @@ AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
}
};
AbstractApp.prototype.historyBack = function ()
{
window.history.back();
};
/**
* @param {string} sQuery
* @param {Function} fCallback

View file

@ -236,8 +236,16 @@ Enums.InterfaceAnimation = {
/**
* @enum {number}
*/
Enums.ContactScopeType = {
Enums.Layout = {
'NoPreview': 0,
'SidePreview': 1,
'BottomPreview': 2
};
/**
* @enum {number}
*/
Enums.ContactScopeType = {
'Default': 0,
'ShareAll': 2
};

View file

@ -126,6 +126,14 @@ LinkBuilder.prototype.inbox = function ()
return this.sBase + 'mailbox/Inbox';
};
/**
* @return {string}
*/
LinkBuilder.prototype.messagePreview = function ()
{
return this.sBase + 'mailbox/message-preview';
};
/**
* @param {string=} sScreenName
* @return {string}

View file

@ -751,6 +751,7 @@ Utils.initDataConstructorBySettings = function (oData)
oData.useThreads = ko.observable(true);
oData.replySameFolder = ko.observable(true);
oData.usePreviewPane = ko.observable(true);
oData.layout = ko.observable(Enums.Layout.SidePreview);
oData.useCheckboxesInList = ko.observable(true);
oData.interfaceAnimation.subscribe(function (sValue) {

View file

@ -43,8 +43,18 @@ MailBoxScreen.prototype.onShow = function ()
* @param {string} sFolderHash
* @param {number} iPage
* @param {string} sSearch
* @param {boolean=} bPreview = false
*/
MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch)
MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview)
{
if (Utils.isUnd(bPreview) ? false : !!bPreview)
{
if (!RL.data().usePreviewPane() && !RL.data().message())
{
RL.historyBack();
}
}
else
{
var
oData = RL.data(),
@ -63,10 +73,12 @@ MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch)
if (!oData.usePreviewPane() && oData.message())
{
oData.message(null);
oData.messageFullScreenMode(false);
}
RL.reloadMessageList();
}
}
};
MailBoxScreen.prototype.onStart = function ()
@ -130,6 +142,9 @@ MailBoxScreen.prototype.onStart = function ()
MailBoxScreen.prototype.routes = function ()
{
var
fNormP = function () {
return ['Inbox', 1, '', true];
},
fNormS = function (oRequest, oVals) {
oVals[0] = Utils.pString(oVals[0]);
oVals[1] = Utils.pInt(oVals[1]);
@ -142,7 +157,7 @@ MailBoxScreen.prototype.routes = function ()
oVals[1] = 1;
}
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2])];
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2]), false];
},
fNormD = function (oRequest, oVals) {
oVals[0] = Utils.pString(oVals[0]);
@ -153,7 +168,7 @@ MailBoxScreen.prototype.routes = function ()
oVals[0] = 'Inbox';
}
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1])];
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false];
}
;
@ -161,6 +176,7 @@ MailBoxScreen.prototype.routes = function ()
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}],
[/^([a-zA-Z0-9]+)\/(.+)\/?$/, {'normalize_': fNormD}],
[/^message-preview$/, {'normalize_': fNormP}],
[/^([^\/]*)$/, {'normalize_': fNormS}]
];
};

View file

@ -18,6 +18,7 @@ function SettingsGeneral()
this.useThreads = oData.useThreads;
this.replySameFolder = oData.replySameFolder;
this.usePreviewPane = oData.usePreviewPane;
this.layout = oData.layout;
this.useCheckboxesInList = oData.useCheckboxesInList;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
@ -135,6 +136,15 @@ SettingsGeneral.prototype.onBuild = function ()
});
});
oData.layout.subscribe(function (nValue) {
oData.messageList([]);
RL.remote().saveSettings(Utils.emptyFunction, {
'Layout': nValue
});
});
oData.useCheckboxesInList.subscribe(function (bValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'UseCheckboxesInList': bValue ? '1' : '0'

View file

@ -49,6 +49,7 @@ AbstractData.prototype.populateDataOnStart = function()
this.useThreads(!!RL.settingsGet('UseThreads'));
this.replySameFolder(!!RL.settingsGet('ReplySameFolder'));
this.usePreviewPane(!!RL.settingsGet('UsePreviewPane'));
this.layout(!!RL.settingsGet('UsePreviewPane') ? Enums.Layout.SidePreview : Enums.Layout.NoPreview); // TODO
this.useCheckboxesInList(!!RL.settingsGet('UseCheckboxesInList'));
this.facebookEnable(!!RL.settingsGet('AllowFacebookSocial'));

View file

@ -48,7 +48,7 @@ function MailBoxMessageListViewModel()
this.dragOverBodyArea = ko.observable(null);
this.messageListItemTemplate = ko.computed(function () {
return oData.usePreviewPane() ?
return Enums.Layout.NoPreview !== oData.layout() ?
'MailMessageListItem' : 'MailMessageListItemNoPreviewPane';
});
@ -163,6 +163,11 @@ function MailBoxMessageListViewModel()
this.selector.on('onItemSelect', _.bind(function (oMessage) {
if (oMessage)
{
if (Enums.Layout.NoPreview === oData.layout())
{
kn.setHash(RL.link().messagePreview(), true);
}
oData.message(oData.staticMessageList.populateByMessageListItem(oMessage));
this.populateMessageBody(oData.message());
}
@ -723,7 +728,7 @@ MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
if (oEvent && self.viewModelVisibility() && oData.useKeyboardShortcuts() && !RL.popupVisibility() && !oData.messageFullScreenMode() && !Utils.inFocus())
{
if (oData.usePreviewPane() || (!oData.message() && (Enums.EventKeyCode.Delete === iKeyCode || Enums.EventKeyCode.A === iKeyCode)))
if (Enums.Layout.NoPreview !== oData.layout() || (!oData.message() && (Enums.EventKeyCode.Delete === iKeyCode || Enums.EventKeyCode.A === iKeyCode)))
{
if (oEvent.ctrlKey && Enums.EventKeyCode.A === iKeyCode)
{

View file

@ -27,7 +27,7 @@ function MailBoxMessageViewViewModel()
this.messagesBodiesDom = oData.messagesBodiesDom;
this.useThreads = oData.useThreads;
this.replySameFolder = oData.replySameFolder;
this.usePreviewPane = oData.usePreviewPane;
this.layout = oData.layout;
this.isMessageSelected = oData.isMessageSelected;
this.messageActiveDom = oData.messageActiveDom;
this.messageError = oData.messageError;
@ -44,7 +44,14 @@ function MailBoxMessageViewViewModel()
// commands
this.closeMessage = Utils.createCommand(this, function () {
if (Enums.Layout.NoPreview === oData.layout())
{
RL.historyBack();
}
else
{
oData.message(null);
}
});
this.replyCommand = createCommandHelper(Enums.ComposeType.Reply);
@ -247,13 +254,13 @@ MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
iKeyCode = oEvent ? oEvent.keyCode : 0
;
if (0 < iKeyCode && (Enums.EventKeyCode.Backspace === iKeyCode || Enums.EventKeyCode.Esc === iKeyCode) &&
if (0 < iKeyCode && (Enums.EventKeyCode.Esc === iKeyCode) &&
self.viewModelVisibility() && oData.useKeyboardShortcuts() && !Utils.inFocus() && oData.message())
{
self.fullScreenMode(false);
if (!oData.usePreviewPane())
if (Enums.Layout.NoPreview === oData.layout())
{
oData.message(null);
RL.historyBack();
}
bResult = false;

View file

@ -1141,9 +1141,11 @@ class Utils
public static function IsRTL($sUtfString)
{
// \x{0591}-\x{05F4} - Hebrew
// \x{FB1D}-\x{FB40} - Hebrew ?
// \x{0621}-\x{064A} - Arabic
return 0 < (int) preg_match('/[\x{0591}-\x{05F4}\x{FB1D}-\x{FB40}\x{0621}-\x{064A}]/u', $sUtfString);
// \x{0600}-\x{068F} - Arabic
// \x{0750}-\x{077F} - Arabic
// \x{08A0}-\x{08FF} - Arabic
// \x{103A0}-\x{103DF} - Old Persian
return 0 < (int) preg_match('/[\x{0591}-\x{05F4}\x{0600}-\x{068F}\x{0750}-\x{077F}\x{08A0}-\x{08FF}\x{103A0}-\x{103DF}]/u', $sUtfString);
}
/**

View file

@ -12,7 +12,7 @@
</label>
</div>
</div>
<div class="control-group">
<!-- <div class="control-group">
<div class="controls">
<label data-bind="click: function () { openPGP(!openPGP()); }">
<i data-bind="css: openPGP() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
@ -20,7 +20,7 @@
Allow OpenPGP (unstable)
</label>
</div>
</div>
</div>-->
<div class="control-group">
<div class="controls">
<a href="#" target="_blank" class="g-ui-link" data-bind="link: phpInfoLink()">Show PHP information</a>

View file

@ -519,8 +519,16 @@ Enums.InterfaceAnimation = {
/**
* @enum {number}
*/
Enums.ContactScopeType = {
Enums.Layout = {
'NoPreview': 0,
'SidePreview': 1,
'BottomPreview': 2
};
/**
* @enum {number}
*/
Enums.ContactScopeType = {
'Default': 0,
'ShareAll': 2
};
@ -1370,6 +1378,7 @@ Utils.initDataConstructorBySettings = function (oData)
oData.useThreads = ko.observable(true);
oData.replySameFolder = ko.observable(true);
oData.usePreviewPane = ko.observable(true);
oData.layout = ko.observable(Enums.Layout.SidePreview);
oData.useCheckboxesInList = ko.observable(true);
oData.interfaceAnimation.subscribe(function (sValue) {
@ -3096,6 +3105,14 @@ LinkBuilder.prototype.inbox = function ()
return this.sBase + 'mailbox/Inbox';
};
/**
* @return {string}
*/
LinkBuilder.prototype.messagePreview = function ()
{
return this.sBase + 'mailbox/message-preview';
};
/**
* @param {string=} sScreenName
* @return {string}
@ -6278,6 +6295,7 @@ AbstractData.prototype.populateDataOnStart = function()
this.useThreads(!!RL.settingsGet('UseThreads'));
this.replySameFolder(!!RL.settingsGet('ReplySameFolder'));
this.usePreviewPane(!!RL.settingsGet('UsePreviewPane'));
this.layout(!!RL.settingsGet('UsePreviewPane') ? Enums.Layout.SidePreview : Enums.Layout.NoPreview); // TODO
this.useCheckboxesInList(!!RL.settingsGet('UseCheckboxesInList'));
this.facebookEnable(!!RL.settingsGet('AllowFacebookSocial'));
@ -7343,6 +7361,11 @@ AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
}
};
AbstractApp.prototype.historyBack = function ()
{
window.history.back();
};
/**
* @param {string} sQuery
* @param {Function} fCallback

File diff suppressed because one or more lines are too long

View file

@ -519,8 +519,16 @@ Enums.InterfaceAnimation = {
/**
* @enum {number}
*/
Enums.ContactScopeType = {
Enums.Layout = {
'NoPreview': 0,
'SidePreview': 1,
'BottomPreview': 2
};
/**
* @enum {number}
*/
Enums.ContactScopeType = {
'Default': 0,
'ShareAll': 2
};
@ -1370,6 +1378,7 @@ Utils.initDataConstructorBySettings = function (oData)
oData.useThreads = ko.observable(true);
oData.replySameFolder = ko.observable(true);
oData.usePreviewPane = ko.observable(true);
oData.layout = ko.observable(Enums.Layout.SidePreview);
oData.useCheckboxesInList = ko.observable(true);
oData.interfaceAnimation.subscribe(function (sValue) {
@ -3096,6 +3105,14 @@ LinkBuilder.prototype.inbox = function ()
return this.sBase + 'mailbox/Inbox';
};
/**
* @return {string}
*/
LinkBuilder.prototype.messagePreview = function ()
{
return this.sBase + 'mailbox/message-preview';
};
/**
* @param {string=} sScreenName
* @return {string}
@ -11350,7 +11367,7 @@ function MailBoxMessageListViewModel()
this.dragOverBodyArea = ko.observable(null);
this.messageListItemTemplate = ko.computed(function () {
return oData.usePreviewPane() ?
return Enums.Layout.NoPreview !== oData.layout() ?
'MailMessageListItem' : 'MailMessageListItemNoPreviewPane';
});
@ -11465,6 +11482,11 @@ function MailBoxMessageListViewModel()
this.selector.on('onItemSelect', _.bind(function (oMessage) {
if (oMessage)
{
if (Enums.Layout.NoPreview === oData.layout())
{
kn.setHash(RL.link().messagePreview(), true);
}
oData.message(oData.staticMessageList.populateByMessageListItem(oMessage));
this.populateMessageBody(oData.message());
}
@ -12025,7 +12047,7 @@ MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
if (oEvent && self.viewModelVisibility() && oData.useKeyboardShortcuts() && !RL.popupVisibility() && !oData.messageFullScreenMode() && !Utils.inFocus())
{
if (oData.usePreviewPane() || (!oData.message() && (Enums.EventKeyCode.Delete === iKeyCode || Enums.EventKeyCode.A === iKeyCode)))
if (Enums.Layout.NoPreview !== oData.layout() || (!oData.message() && (Enums.EventKeyCode.Delete === iKeyCode || Enums.EventKeyCode.A === iKeyCode)))
{
if (oEvent.ctrlKey && Enums.EventKeyCode.A === iKeyCode)
{
@ -12243,7 +12265,7 @@ function MailBoxMessageViewViewModel()
this.messagesBodiesDom = oData.messagesBodiesDom;
this.useThreads = oData.useThreads;
this.replySameFolder = oData.replySameFolder;
this.usePreviewPane = oData.usePreviewPane;
this.layout = oData.layout;
this.isMessageSelected = oData.isMessageSelected;
this.messageActiveDom = oData.messageActiveDom;
this.messageError = oData.messageError;
@ -12260,7 +12282,14 @@ function MailBoxMessageViewViewModel()
// commands
this.closeMessage = Utils.createCommand(this, function () {
if (Enums.Layout.NoPreview === oData.layout())
{
RL.historyBack();
}
else
{
oData.message(null);
}
});
this.replyCommand = createCommandHelper(Enums.ComposeType.Reply);
@ -12463,13 +12492,13 @@ MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
iKeyCode = oEvent ? oEvent.keyCode : 0
;
if (0 < iKeyCode && (Enums.EventKeyCode.Backspace === iKeyCode || Enums.EventKeyCode.Esc === iKeyCode) &&
if (0 < iKeyCode && (Enums.EventKeyCode.Esc === iKeyCode) &&
self.viewModelVisibility() && oData.useKeyboardShortcuts() && !Utils.inFocus() && oData.message())
{
self.fullScreenMode(false);
if (!oData.usePreviewPane())
if (Enums.Layout.NoPreview === oData.layout())
{
oData.message(null);
RL.historyBack();
}
bResult = false;
@ -12665,6 +12694,7 @@ function SettingsGeneral()
this.useThreads = oData.useThreads;
this.replySameFolder = oData.replySameFolder;
this.usePreviewPane = oData.usePreviewPane;
this.layout = oData.layout;
this.useCheckboxesInList = oData.useCheckboxesInList;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
@ -12782,6 +12812,15 @@ SettingsGeneral.prototype.onBuild = function ()
});
});
oData.layout.subscribe(function (nValue) {
oData.messageList([]);
RL.remote().saveSettings(Utils.emptyFunction, {
'Layout': nValue
});
});
oData.useCheckboxesInList.subscribe(function (bValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'UseCheckboxesInList': bValue ? '1' : '0'
@ -13683,6 +13722,7 @@ AbstractData.prototype.populateDataOnStart = function()
this.useThreads(!!RL.settingsGet('UseThreads'));
this.replySameFolder(!!RL.settingsGet('ReplySameFolder'));
this.usePreviewPane(!!RL.settingsGet('UsePreviewPane'));
this.layout(!!RL.settingsGet('UsePreviewPane') ? Enums.Layout.SidePreview : Enums.Layout.NoPreview); // TODO
this.useCheckboxesInList(!!RL.settingsGet('UseCheckboxesInList'));
this.facebookEnable(!!RL.settingsGet('AllowFacebookSocial'));
@ -16318,8 +16358,18 @@ MailBoxScreen.prototype.onShow = function ()
* @param {string} sFolderHash
* @param {number} iPage
* @param {string} sSearch
* @param {boolean=} bPreview = false
*/
MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch)
MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview)
{
if (Utils.isUnd(bPreview) ? false : !!bPreview)
{
if (!RL.data().usePreviewPane() && !RL.data().message())
{
RL.historyBack();
}
}
else
{
var
oData = RL.data(),
@ -16338,10 +16388,12 @@ MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch)
if (!oData.usePreviewPane() && oData.message())
{
oData.message(null);
oData.messageFullScreenMode(false);
}
RL.reloadMessageList();
}
}
};
MailBoxScreen.prototype.onStart = function ()
@ -16405,6 +16457,9 @@ MailBoxScreen.prototype.onStart = function ()
MailBoxScreen.prototype.routes = function ()
{
var
fNormP = function () {
return ['Inbox', 1, '', true];
},
fNormS = function (oRequest, oVals) {
oVals[0] = Utils.pString(oVals[0]);
oVals[1] = Utils.pInt(oVals[1]);
@ -16417,7 +16472,7 @@ MailBoxScreen.prototype.routes = function ()
oVals[1] = 1;
}
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2])];
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2]), false];
},
fNormD = function (oRequest, oVals) {
oVals[0] = Utils.pString(oVals[0]);
@ -16428,7 +16483,7 @@ MailBoxScreen.prototype.routes = function ()
oVals[0] = 'Inbox';
}
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1])];
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false];
}
;
@ -16436,6 +16491,7 @@ MailBoxScreen.prototype.routes = function ()
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}],
[/^([a-zA-Z0-9]+)\/(.+)\/?$/, {'normalize_': fNormD}],
[/^message-preview$/, {'normalize_': fNormP}],
[/^([^\/]*)$/, {'normalize_': fNormS}]
];
};
@ -16672,6 +16728,11 @@ AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
}
};
AbstractApp.prototype.historyBack = function ()
{
window.history.back();
};
/**
* @param {string} sQuery
* @param {Function} fCallback

File diff suppressed because one or more lines are too long