* Fixes to actionKeys with new focus changes
* Various fixes, minor changes
This commit is contained in:
parent
b15d9a0bf8
commit
b2592d0e71
39
core/fse.js
39
core/fse.js
|
@ -195,10 +195,9 @@ function FullScreenEditorModule(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if(self.isReply()) {
|
if(self.isReply()) {
|
||||||
msgOpts.replyToMsgId = self.replyToMessageId;
|
msgOpts.replyToMsgId = self.replyToMessage.messageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
self.message = new Message(msgOpts);
|
self.message = new Message(msgOpts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,12 +217,29 @@ function FullScreenEditorModule(options) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getMessage = function() {
|
this.getMessage = function(cb) {
|
||||||
if(self.isEditMode()) {
|
async.series(
|
||||||
self.buildMessage();
|
[
|
||||||
}
|
function buildIfNecessary(callback) {
|
||||||
|
if(self.isEditMode()) {
|
||||||
|
self.buildMessage(); // creates initial self.message
|
||||||
|
}
|
||||||
|
callback(null);
|
||||||
|
},
|
||||||
|
function populateLocalUserInfo(callback) {
|
||||||
|
if(self.isLocalEmail()) {
|
||||||
|
msg.setLocalFromUserId(self.client.user.userId);
|
||||||
|
msg.setLocalToUserId(self.toUserId);
|
||||||
|
}
|
||||||
|
|
||||||
return self.message;
|
// :TODO: DO THAT!
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
function complete(err) {
|
||||||
|
cb(err, self.message);
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.redrawFooter = function(options, cb) {
|
this.redrawFooter = function(options, cb) {
|
||||||
|
@ -720,7 +736,6 @@ function FullScreenEditorModule(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.menuMethods = {
|
this.menuMethods = {
|
||||||
// :TODO: rename to editModeHeaderSubmit
|
|
||||||
headerSubmit : function(formData, extraArgs) {
|
headerSubmit : function(formData, extraArgs) {
|
||||||
self.switchToBody();
|
self.switchToBody();
|
||||||
},
|
},
|
||||||
|
@ -735,7 +750,8 @@ function FullScreenEditorModule(options) {
|
||||||
switch(self.footerMode) {
|
switch(self.footerMode) {
|
||||||
case 'editor' :
|
case 'editor' :
|
||||||
if(!_.isUndefined(self.viewControllers.footerEditorMenu)) {
|
if(!_.isUndefined(self.viewControllers.footerEditorMenu)) {
|
||||||
self.viewControllers.footerEditorMenu.setFocus(false);
|
//self.viewControllers.footerEditorMenu.setFocus(false);
|
||||||
|
self.viewControllers.footerEditorMenu.detachClientEvents();
|
||||||
}
|
}
|
||||||
self.viewControllers.body.switchFocus(1);
|
self.viewControllers.body.switchFocus(1);
|
||||||
self.observeEditorEvents();
|
self.observeEditorEvents();
|
||||||
|
@ -782,14 +798,11 @@ function FullScreenEditorModule(options) {
|
||||||
var quoteMsgView = self.viewControllers.quoteBuilder.getView(1);
|
var quoteMsgView = self.viewControllers.quoteBuilder.getView(1);
|
||||||
var msgView = self.viewControllers.body.getView(1);
|
var msgView = self.viewControllers.body.getView(1);
|
||||||
|
|
||||||
//msgView.addText(_.trim(quoteMsgView.getData(), '\n'));
|
|
||||||
//msgView.addText(new Array(msgView.dimens.width - 1).join('-') + '\n');
|
|
||||||
msgView.addText(quoteMsgView.getData() + '\n');
|
msgView.addText(quoteMsgView.getData() + '\n');
|
||||||
quoteMsgView.setText('');
|
quoteMsgView.setText('');
|
||||||
|
|
||||||
var footerName = self.getFooterName();
|
var footerName = self.getFooterName();
|
||||||
|
|
||||||
//self.redrawFooter( { clear : true, footerName : footerName }, function footerDisplayed(err) {
|
|
||||||
self.footerMode = 'editor';
|
self.footerMode = 'editor';
|
||||||
|
|
||||||
self.switchFooter(function switched(err) {
|
self.switchFooter(function switched(err) {
|
||||||
|
|
|
@ -10,10 +10,13 @@ var binary = require('binary');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
|
// :TODO: Remove "Ftn" from most of these -- it's implied in the module
|
||||||
exports.stringFromFTN = stringFromFTN;
|
exports.stringFromFTN = stringFromFTN;
|
||||||
exports.getFormattedFTNAddress = getFormattedFTNAddress;
|
exports.getFormattedFTNAddress = getFormattedFTNAddress;
|
||||||
exports.getDateFromFtnDateTime = getDateFromFtnDateTime;
|
exports.getDateFromFtnDateTime = getDateFromFtnDateTime;
|
||||||
|
|
||||||
|
exports.getQuotePrefix = getQuotePrefix;
|
||||||
|
|
||||||
// See list here: https://github.com/Mithgol/node-fidonet-jam
|
// See list here: https://github.com/Mithgol/node-fidonet-jam
|
||||||
|
|
||||||
// :TODO: proably move this elsewhere as a general method
|
// :TODO: proably move this elsewhere as a general method
|
||||||
|
@ -81,6 +84,12 @@ function getFTNMessageID(messageId, areaId) {
|
||||||
return messageId + '.' + areaId + '@' + getFTNAddress() + ' ' + getFTNMessageSerialNumber(messageId)
|
return messageId + '.' + areaId + '@' + getFTNAddress() + ' ' + getFTNMessageSerialNumber(messageId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a FSC-0032 style quote prefixes
|
||||||
|
function getQuotePrefix(name) {
|
||||||
|
// :TODO: Add support for real names (e.g. with spaces) -> initials
|
||||||
|
return ' ' + name[0].toUpperCase() + name[1].toLowerCase() + '> ';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Specs:
|
// Specs:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
var msgDb = require('./database.js').dbs.message;
|
var msgDb = require('./database.js').dbs.message;
|
||||||
var wordWrapText = require('./word_wrap.js').wordWrapText;
|
var wordWrapText = require('./word_wrap.js').wordWrapText;
|
||||||
|
var ftnUtil = require('./ftn_util.js');
|
||||||
|
|
||||||
var uuid = require('node-uuid');
|
var uuid = require('node-uuid');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
@ -244,19 +245,10 @@ Message.prototype.persist = function(cb) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// :TODO: Update this to use a FTN module, e.g. ftn.getQuotePrefix(name)
|
|
||||||
Message.prototype.getFTNQuotePrefix = function(source) {
|
Message.prototype.getFTNQuotePrefix = function(source) {
|
||||||
source = source || 'fromUserName';
|
source = source || 'fromUserName';
|
||||||
|
|
||||||
switch(source) {
|
return ftnUtil.getQuotePrefix(this[source]);
|
||||||
case 'fromUserName' :
|
|
||||||
return this.fromUserName[0].toUpperCase() + this.fromUserName[1].toLowerCase();
|
|
||||||
|
|
||||||
case 'toUserName' :
|
|
||||||
return this.toUserName[0].toUpperCase() + this.toUserName[1].toLowerCase();
|
|
||||||
|
|
||||||
// :TODO: real names
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Message.prototype.getQuoteLines = function(width, options) {
|
Message.prototype.getQuoteLines = function(width, options) {
|
||||||
|
@ -282,7 +274,7 @@ Message.prototype.getQuoteLines = function(width, options) {
|
||||||
|
|
||||||
var quotePrefix = ''; // we need this init even if blank
|
var quotePrefix = ''; // we need this init even if blank
|
||||||
if(options.includePrefix) {
|
if(options.includePrefix) {
|
||||||
quotePrefix = ' ' + this.getFTNQuotePrefix(options.prefixSource || 'fromUserName') + '> ';
|
quotePrefix = this.getFTNQuotePrefix(options.prefixSource || 'fromUserName');
|
||||||
}
|
}
|
||||||
|
|
||||||
var wrapOpts = {
|
var wrapOpts = {
|
||||||
|
|
|
@ -149,53 +149,11 @@ VerticalMenuView.prototype.setFocus = function(focused) {
|
||||||
VerticalMenuView.prototype.onKeyPress = function(ch, key) {
|
VerticalMenuView.prototype.onKeyPress = function(ch, key) {
|
||||||
|
|
||||||
if(key) {
|
if(key) {
|
||||||
var prevFocusedItemIndex = this.focusedItemIndex;
|
|
||||||
|
|
||||||
if(this.isKeyMapped('up', key.name)) {
|
if(this.isKeyMapped('up', key.name)) {
|
||||||
this.focusPrevious();
|
this.focusPrevious();
|
||||||
/*
|
|
||||||
if(0 === this.focusedItemIndex) {
|
|
||||||
this.focusedItemIndex = this.items.length - 1;
|
|
||||||
|
|
||||||
this.viewWindow = {
|
|
||||||
//top : this.items.length - this.maxVisibleItems,
|
|
||||||
top : Math.max(this.items.length - this.maxVisibleItems, 0),
|
|
||||||
bottom : this.items.length - 1
|
|
||||||
};
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.focusedItemIndex--;
|
|
||||||
|
|
||||||
if(this.focusedItemIndex < this.viewWindow.top) {
|
|
||||||
this.viewWindow.top--;
|
|
||||||
this.viewWindow.bottom--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} else if(this.isKeyMapped('down', key.name)) {
|
} else if(this.isKeyMapped('down', key.name)) {
|
||||||
/*if(this.items.length - 1 === this.focusedItemIndex) {
|
|
||||||
this.focusedItemIndex = 0;
|
|
||||||
|
|
||||||
this.viewWindow = {
|
|
||||||
top : 0,
|
|
||||||
bottom : Math.min(this.focusedItemIndex + this.maxVisibleItems, this.items.length) - 1
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
this.focusedItemIndex++;
|
|
||||||
|
|
||||||
if(this.focusedItemIndex > this.viewWindow.bottom) {
|
|
||||||
this.viewWindow.top++;
|
|
||||||
this.viewWindow.bottom++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
this.focusNext();
|
this.focusNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prevFocusedItemIndex !== this.focusedItemIndex) {
|
|
||||||
// :TODO: Optimize this for cases where no scrolling occured & only two items need updated
|
|
||||||
// this.redraw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VerticalMenuView.super_.prototype.onKeyPress.call(this, ch, key);
|
VerticalMenuView.super_.prototype.onKeyPress.call(this, ch, key);
|
||||||
|
@ -211,6 +169,7 @@ VerticalMenuView.prototype.setItems = function(items) {
|
||||||
this.positionCacheExpired = true;
|
this.positionCacheExpired = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// :TODO: Apply draw optimizaitons when only two items need drawn vs entire view!
|
||||||
|
|
||||||
VerticalMenuView.prototype.focusNext = function() {
|
VerticalMenuView.prototype.focusNext = function() {
|
||||||
VerticalMenuView.super_.prototype.focusNext.call(this);
|
VerticalMenuView.super_.prototype.focusNext.call(this);
|
||||||
|
|
|
@ -247,6 +247,9 @@ View.prototype.setFocus = function(focused) {
|
||||||
};
|
};
|
||||||
|
|
||||||
View.prototype.onKeyPress = function(ch, key) {
|
View.prototype.onKeyPress = function(ch, key) {
|
||||||
|
if(false === this.hasFocus) {
|
||||||
|
console.log('doh!');
|
||||||
|
}
|
||||||
assert(this.hasFocus, 'View does not have focus');
|
assert(this.hasFocus, 'View does not have focus');
|
||||||
assert(this.acceptsInput, 'View does not accept input');
|
assert(this.acceptsInput, 'View does not accept input');
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,11 @@ function ViewController(options) {
|
||||||
{ ch : ch, key : key }, // formData
|
{ ch : ch, key : key }, // formData
|
||||||
actionForKey); // action block
|
actionForKey); // action block
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(self.focusedView && self.focusedView.acceptsInput) {
|
||||||
|
self.focusedView.onKeyPress(ch, key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self.focusedView && self.focusedView.acceptsInput) {
|
|
||||||
self.focusedView.onKeyPress(ch, key);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.viewActionListener = function(action, key) {
|
this.viewActionListener = function(action, key) {
|
||||||
|
@ -373,12 +373,12 @@ ViewController.prototype.setFocus = function(focused) {
|
||||||
this.detachClientEvents();
|
this.detachClientEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
// :TODO: without this, setFocus(false) is broken (doens't call focus events); with it, FSE menus break!!
|
this.setViewFocusWithEvents(this.focusedView, focused);
|
||||||
// this.setViewFocusWithEvents(this.focusedView, focused);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ViewController.prototype.switchFocus = function(id) {
|
ViewController.prototype.switchFocus = function(id) {
|
||||||
this.setFocus(true); // ensure events are attached
|
//this.setFocus(true); // ensure events are attached
|
||||||
|
this.attachClientEvents();
|
||||||
|
|
||||||
// remove from old
|
// remove from old
|
||||||
this.setViewFocusWithEvents(this.focusedView, false);
|
this.setViewFocusWithEvents(this.focusedView, false);
|
||||||
|
|
|
@ -774,6 +774,7 @@
|
||||||
width: 27
|
width: 27
|
||||||
argName: to
|
argName: to
|
||||||
focus: true
|
focus: true
|
||||||
|
text: All
|
||||||
}
|
}
|
||||||
"ET3" : {
|
"ET3" : {
|
||||||
"width" : 27,
|
"width" : 27,
|
||||||
|
@ -855,10 +856,14 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"actionKeys" : [ // :TODO: Need better name
|
actionKeys: [ // :TODO: Need better name
|
||||||
{
|
{
|
||||||
"keys" : [ "escape" ],
|
keys: [ "escape" ]
|
||||||
"action" : "@method:editModeEscPressed"
|
action: @method:editModeEscPressed
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keys: [ "?" ]
|
||||||
|
action: @method:editModeMenuHelp
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
// :TODO: something like the following for overriding keymap
|
// :TODO: something like the following for overriding keymap
|
||||||
|
|
|
@ -25,17 +25,15 @@ function AreaPostFSEModule(options) {
|
||||||
this.editorMode = 'edit';
|
this.editorMode = 'edit';
|
||||||
|
|
||||||
this.menuMethods.editModeMenuSave = function(formData, extraArgs) {
|
this.menuMethods.editModeMenuSave = function(formData, extraArgs) {
|
||||||
var msg = self.getMessage();
|
|
||||||
|
|
||||||
|
var msg;
|
||||||
async.series(
|
async.series(
|
||||||
[
|
[
|
||||||
function prepareMessage(callback) {
|
function getMessageObject(callback) {
|
||||||
if(self.isLocalEmail()) {
|
self.getMessage(function gotMsg(err, msgObj) {
|
||||||
msg.setLocalFromUserId(self.client.user.userId);
|
msg = msgObj;
|
||||||
msg.setLocalToUserId(self.toUserId);
|
callback(err);
|
||||||
}
|
});
|
||||||
|
|
||||||
callback(null);
|
|
||||||
},
|
},
|
||||||
function saveMessage(callback) {
|
function saveMessage(callback) {
|
||||||
msg.persist(function persisted(err) {
|
msg.persist(function persisted(err) {
|
||||||
|
|
Loading…
Reference in New Issue