* Fix separation of editorMode vs footerMode

This commit is contained in:
Bryan Ashby 2015-09-04 14:28:05 -06:00
parent ddc806bd39
commit f587b228bc
2 changed files with 33 additions and 35 deletions

View File

@ -62,7 +62,7 @@ function FullScreenEditorModule(options) {
// //
// menuConfig.config: // menuConfig.config:
// editorType : email | area // editorType : email | area
// editorMode : view | edit | quote (private: editMenu | ... ) // editorMode : view | edit | quote
// //
// extraArgs: // extraArgs:
// messageAreaName // messageAreaName
@ -72,15 +72,11 @@ function FullScreenEditorModule(options) {
this.editorType = config.editorType; this.editorType = config.editorType;
this.editorMode = config.editorMode; this.editorMode = config.editorMode;
console.log('editorMode=' + this.editorMode)
if(_.isObject(options.extraArgs)) { if(_.isObject(options.extraArgs)) {
this.messageAreaName = options.extraArgs.messageAreaName || Message.WellKnownAreaNames.Private; this.messageAreaName = options.extraArgs.messageAreaName || Message.WellKnownAreaNames.Private;
} }
this.isEditMode = function() { this.isEditMode = function() {
console.log(self.editorMode)
return 'edit' === self.editorMode; return 'edit' === self.editorMode;
}; };
@ -92,23 +88,29 @@ function FullScreenEditorModule(options) {
return 'email' === self.editorType && Message.WellKnownAreaNames.Private === self.messageAreaName; return 'email' === self.editorType && Message.WellKnownAreaNames.Private === self.messageAreaName;
}; };
this.getFooterName = function(editorMode) { this.getFooterName = function() {
editorMode = editorMode || self.editorMode; return 'footer' + _.capitalize(self.footerMode); // e.g. 'footerEditor', 'footerEditorMenu', ...
return 'footer' + _.capitalize(editorMode); // e.g.. 'footerEditMenu'
}; };
this.getFormId = function(name) { this.getFormId = function(name) {
return { return {
header : 0, header : 0,
body : 1, body : 1,
footerEdit : 2, footerEditor : 2,
footerEditMenu : 3, footerEditorMenu : 3,
footerView : 4, footerView : 4,
help : 50, help : 50,
}[name]; }[name];
}; };
this.setInitialFooterMode = function() {
switch(self.editorMode) {
case 'edit' : self.footerMode = 'editor'; break;
case 'view' : self.footerMode = 'view'; break;
}
};
this.buildMessage = function() { this.buildMessage = function() {
var headerValues = self.viewControllers.header.getFormData().value; var headerValues = self.viewControllers.header.getFormData().value;
@ -120,7 +122,6 @@ function FullScreenEditorModule(options) {
message : self.viewControllers.body.getFormData().value.message, message : self.viewControllers.body.getFormData().value.message,
}; };
console.log(msgOpts)
self.message = new Message(msgOpts); self.message = new Message(msgOpts);
}; };
@ -131,9 +132,7 @@ function FullScreenEditorModule(options) {
}; };
this.getMessage = function() { this.getMessage = function() {
console.log('getMessage')
if(self.isEditMode()) { if(self.isEditMode()) {
console.log('want build msg')
self.buildMessage(); self.buildMessage();
} }
@ -227,8 +226,6 @@ function FullScreenEditorModule(options) {
this.switchFooter = function(cb) { this.switchFooter = function(cb) {
var footerName = self.getFooterName(); var footerName = self.getFooterName();
console.log('footerName=' + footerName)
self.redrawFooter( { footerName : footerName, clear : true }, function artDisplayed(err, artData) { self.redrawFooter( { footerName : footerName, clear : true }, function artDisplayed(err, artData) {
if(err) { if(err) {
cb(err); cb(err);
@ -287,6 +284,8 @@ function FullScreenEditorModule(options) {
}); });
}, },
function displayFooter(callback) { function displayFooter(callback) {
self.setInitialFooterMode();
var footerName = self.getFooterName(); var footerName = self.getFooterName();
self.redrawFooter( { footerName : footerName }, function artDisplayed(err, artData) { self.redrawFooter( { footerName : footerName }, function artDisplayed(err, artData) {
mciData[footerName] = artData; mciData[footerName] = artData;
@ -387,7 +386,6 @@ function FullScreenEditorModule(options) {
switch(self.editorMode) { switch(self.editorMode) {
case 'edit' : case 'edit' :
self.editModeFocus = 'editor';
self.switchToHeader(); self.switchToHeader();
break; break;
@ -425,7 +423,7 @@ function FullScreenEditorModule(options) {
this.updateEditModePosition = function(pos) { this.updateEditModePosition = function(pos) {
if('edit' === this.editorMode) { if('edit' === this.editorMode) {
var posView = self.viewControllers.footerEdit.getView(1); var posView = self.viewControllers.footerEditor.getView(1);
if(posView) { if(posView) {
self.client.term.rawWrite(ansi.savePos()); self.client.term.rawWrite(ansi.savePos());
posView.setText(_.padLeft(String(pos.row + 1), 2, '0') + ',' + _.padLeft(String(pos.col + 1), 2, '0')); posView.setText(_.padLeft(String(pos.row + 1), 2, '0') + ',' + _.padLeft(String(pos.col + 1), 2, '0'));
@ -436,7 +434,7 @@ function FullScreenEditorModule(options) {
this.updateTextEditMode = function(mode) { this.updateTextEditMode = function(mode) {
if('edit' === this.editorMode) { if('edit' === this.editorMode) {
var modeView = self.viewControllers.footerEdit.getView(2); var modeView = self.viewControllers.footerEditor.getView(2);
if(modeView) { if(modeView) {
self.client.term.rawWrite(ansi.savePos()); self.client.term.rawWrite(ansi.savePos());
modeView.setText('insert' === mode ? 'INS' : 'OVR'); modeView.setText('insert' === mode ? 'INS' : 'OVR');
@ -487,7 +485,7 @@ function FullScreenEditorModule(options) {
function helpDisplayed(err, artData) { function helpDisplayed(err, artData) {
self.client.waitForKeyPress(function keyPress(ch, key) { self.client.waitForKeyPress(function keyPress(ch, key) {
self.redrawScreen(); self.redrawScreen();
self.viewControllers.footerEditMenu.setFocus(true); self.viewControllers.footerEditorMenu.setFocus(true);
}); });
} }
); );
@ -523,7 +521,7 @@ function FullScreenEditorModule(options) {
self.switchToBody(); self.switchToBody();
}, },
editModeEscPressed : function(formData, extraArgs) { editModeEscPressed : function(formData, extraArgs) {
self.editModeFocus = 'editor' === self.editModeFocus ? 'editMenu' : 'editor'; self.footerMode = 'editor' === self.footerMode ? 'editorMenu' : 'editor';
//self.editorMode = 'edit' === self.editorMode ? 'editMenu' : 'edit'; //self.editorMode = 'edit' === self.editorMode ? 'editMenu' : 'edit';
self.switchFooter(function next(err) { self.switchFooter(function next(err) {
@ -531,18 +529,18 @@ function FullScreenEditorModule(options) {
// :TODO:... what now? // :TODO:... what now?
console.log(err) console.log(err)
} else { } else {
switch(self.editModeFocus) { switch(self.footerMode) {
case 'editor' : case 'editor' :
if(!_.isUndefined(self.viewControllers.footerEditMenu)) { if(!_.isUndefined(self.viewControllers.footerEditorMenu)) {
self.viewControllers.footerEditMenu.setFocus(false); self.viewControllers.footerEditorMenu.setFocus(false);
} }
self.viewControllers.body.switchFocus(1); self.viewControllers.body.switchFocus(1);
self.observeEditorEvents(); self.observeEditorEvents();
break; break;
case 'editMenu' : case 'editorMenu' :
self.viewControllers.body.setFocus(false); self.viewControllers.body.setFocus(false);
self.viewControllers.footerEditMenu.switchFocus(1); self.viewControllers.footerEditorMenu.switchFocus(1);
break; break;
default : throw new Error('Unexpected mode'); default : throw new Error('Unexpected mode');
@ -560,7 +558,7 @@ function FullScreenEditorModule(options) {
}, },
editModeMenuHelp : function(formData, extraArgs) { editModeMenuHelp : function(formData, extraArgs) {
self.viewControllers.footerEditMenu.setFocus(false); self.viewControllers.footerEditorMenu.setFocus(false);
self.displayHelp(); self.displayHelp();
} }
}; };

View File

@ -464,8 +464,8 @@
"art" : { "art" : {
"header" : "msg_area_post_header", "header" : "msg_area_post_header",
"body" : "demo_fse_netmail_body.ans", "body" : "demo_fse_netmail_body.ans",
"footerEdit" : "demo_fse_netmail_footer_edit.ans", "footerEditor" : "demo_fse_netmail_footer_edit.ans",
"footerEditMenu" : "demo_fse_netmail_footer_edit_menu.ans", "footerEditorMenu" : "demo_fse_netmail_footer_edit_menu.ans",
"footerView" : "demo_fse_netmail_footer_view.ans", "footerView" : "demo_fse_netmail_footer_view.ans",
"help" : "demo_fse_netmail_help.ans" "help" : "demo_fse_netmail_help.ans"
}, },
@ -1069,8 +1069,8 @@
"art" : { "art" : {
"header" : "demo_fse_netmail_header.ans", "header" : "demo_fse_netmail_header.ans",
"body" : "demo_fse_netmail_body.ans", "body" : "demo_fse_netmail_body.ans",
"footerEdit" : "demo_fse_netmail_footer_edit.ans", "footerEditor" : "demo_fse_netmail_footer_edit.ans",
"footerEditMenu" : "demo_fse_netmail_footer_edit_menu.ans", "footerEditorMenu" : "demo_fse_netmail_footer_edit_menu.ans",
"footerView" : "demo_fse_netmail_footer_view.ans", "footerView" : "demo_fse_netmail_footer_view.ans",
"help" : "demo_fse_netmail_help.ans" "help" : "demo_fse_netmail_help.ans"
} }