* Message view prev/next
* Message view up/down movement * Some new experimental MCI codes * Put cursor @ top of document in MLTEV preview mode * Fix fse finishedLoading() * Menus can have names, clients have current status
This commit is contained in:
parent
1f3948d84c
commit
6517f50e0c
|
@ -78,9 +78,9 @@ function FullScreenEditorModule(options) {
|
|||
// editorType : email | area
|
||||
// editorMode : view | edit | quote
|
||||
//
|
||||
// extraArgs:
|
||||
// extraArgs - view mode
|
||||
// messageAreaName
|
||||
// messageNumber / messageTotal
|
||||
// messageIndex / messageTotal
|
||||
//
|
||||
//
|
||||
this.editorType = config.editorType;
|
||||
|
@ -88,7 +88,7 @@ function FullScreenEditorModule(options) {
|
|||
|
||||
if(_.isObject(options.extraArgs)) {
|
||||
this.messageAreaName = options.extraArgs.messageAreaName || Message.WellKnownAreaNames.Private;
|
||||
this.messageNumber = options.extraArgs.messageNumber || 0;
|
||||
this.messageIndex = options.extraArgs.messageIndex || 0;
|
||||
this.messageTotal = options.extraArgs.messageTotal || 0;
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,7 @@ function FullScreenEditorModule(options) {
|
|||
var bodyMessageView = self.viewControllers.body.getView(1);
|
||||
if(bodyMessageView && _.has(self, 'message.message')) {
|
||||
bodyMessageView.setText(self.message.message);
|
||||
//bodyMessageView.redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -493,7 +494,7 @@ function FullScreenEditorModule(options) {
|
|||
setHeaderText(MCICodeIds.ViewModeHeader.To, self.message.toUserName);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.Subject, self.message.subject);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.DateTime, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat()));
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.MsgNum, self.messageNumber.toString());
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.MsgNum, (self.messageIndex + 1).toString());
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.MsgTotal, self.messageTotal.toString());
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.ViewCount, self.message.viewCount);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.HashTags, 'TODO hash tags');
|
||||
|
|
|
@ -29,6 +29,8 @@ function MCIViewFactory(client) {
|
|||
this.client = client;
|
||||
}
|
||||
|
||||
// :TODO: This portion should be made more generic so pipe code formatting can use it!
|
||||
// e..g MCIPrint() -> enigmaToAnsi() ->
|
||||
MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
||||
|
||||
var self = this;
|
||||
|
@ -38,6 +40,10 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
|||
return area ? area.desc : '';
|
||||
}
|
||||
|
||||
function getCurrentMenuDescription() {
|
||||
return _.has(self, 'client.currentMenuModule.menuConfig.desc') ? self.client.currentMenuModule.menuConfig.desc : '';
|
||||
}
|
||||
|
||||
try {
|
||||
return {
|
||||
BN : Config.general.boardName,
|
||||
|
@ -57,10 +63,13 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
|||
UF : this.client.user.properties.affiliation,
|
||||
UT : this.client.user.properties.theme_id,
|
||||
MS : moment(this.client.user.properties.account_created).format(this.client.currentTheme.helpers.getDateFormat()),
|
||||
CS : this.client.currentStatus,
|
||||
MD : getCurrentMenuDescription(),
|
||||
|
||||
MA : getMessageAreaDescription(),
|
||||
|
||||
|
||||
|
||||
SH : this.client.term.termHeight.toString(),
|
||||
SW : this.client.term.termWidth.toString(),
|
||||
|
||||
|
|
|
@ -138,16 +138,6 @@ function MenuModule(options) {
|
|||
menuUtil.handleAction(self.client, null, self.menuConfig);
|
||||
}
|
||||
};
|
||||
|
||||
this.setMenuStatus = function(status) {
|
||||
self.menuStatus = status;
|
||||
};
|
||||
|
||||
if(_.isString(this.menuConfig.status)) {
|
||||
self.setMenuStatus(self.menuConfig.status);
|
||||
} else {
|
||||
self.setMenuStatus('Browsing menus');
|
||||
}
|
||||
}
|
||||
|
||||
require('util').inherits(MenuModule, PluginModule);
|
||||
|
@ -158,6 +148,12 @@ MenuModule.prototype.enter = function(client) {
|
|||
this.client = client;
|
||||
assert(_.isObject(client));
|
||||
|
||||
if(_.isString(this.menuConfig.status)) {
|
||||
this.client.currentStatus = this.menuConfig.status;
|
||||
} else {
|
||||
this.client.currentStatus = 'Browsing menus';
|
||||
}
|
||||
|
||||
this.initSequence();
|
||||
};
|
||||
|
||||
|
|
|
@ -1049,8 +1049,14 @@ MultiLineEditTextView.prototype.setFocus = function(focused) {
|
|||
MultiLineEditTextView.prototype.setText = function(text) {
|
||||
//text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'});
|
||||
|
||||
this.textLines = [ ];
|
||||
this.insertRawText(text);
|
||||
|
||||
if(this.isEditMode()) {
|
||||
this.cursorEndOfDocument();
|
||||
} else if(this.isPreviewMode()) {
|
||||
this.cursorStartOfDocument();
|
||||
}
|
||||
};
|
||||
|
||||
MultiLineEditTextView.prototype.getData = function() {
|
||||
|
|
Binary file not shown.
|
@ -255,6 +255,7 @@
|
|||
"messageArea" : {
|
||||
"module" : "msg_area",
|
||||
"art" : "MSGAREA",
|
||||
"desc" : "Message Area",
|
||||
"options" : { "cls" : true },
|
||||
"prompt" : "menuCommand",
|
||||
"submit" : [
|
||||
|
@ -439,13 +440,15 @@
|
|||
"HM1" : {
|
||||
// (P)rev/(N)ext/Post/(R)eply/(Q)uit/(?)Help
|
||||
// (#)Jump/(L)Index (msg list)/Last
|
||||
|
||||
// :TODO: Continue, Save, Discard, Clear, Quote, Help
|
||||
"items" : [ "Prev", "Next", "Reply", "Quit", "Help" ]
|
||||
}
|
||||
},
|
||||
"submit" : {
|
||||
"*" : [
|
||||
{
|
||||
"value" : { "1" : 0 },
|
||||
"action" : "@method:prevMessage"
|
||||
},
|
||||
{
|
||||
"value" : { "1" : 1 },
|
||||
"action" : "@method:nextMessage"
|
||||
|
@ -457,9 +460,15 @@
|
|||
]
|
||||
},
|
||||
"actionKeys" : [
|
||||
/*
|
||||
{
|
||||
"keys" : [ "escape" ],
|
||||
"action" : "@method:editModeEscPressed" // :TODO: fixme
|
||||
},
|
||||
*/
|
||||
{
|
||||
"keys" : [ "down arrow", "up arrow", "page up", "page down" ],
|
||||
"action" : "@method:movementKeyPressed"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -34,31 +34,33 @@ function AreaViewFSEModule(options) {
|
|||
|
||||
this.messageList = this.messageList || [];
|
||||
this.messageIndex = this.messageIndex || 0;
|
||||
|
||||
this.messageNumber = this.messageIndex + 1;
|
||||
this.messageTotal = this.messageList.length;
|
||||
|
||||
//assert(_.isString(options.extraArgs.messageAreaName), 'messageAreaName must be supplied!');
|
||||
//assert(options.extraArgs.messageId, 'messageId must be supplied!');
|
||||
//assert(_.isString(options.extraArgs.messageUuid), 'messageUuid must be supplied!');
|
||||
//this.messageUuid = options.extraArgs.messageUuid;
|
||||
/*
|
||||
this.loadMessage = function(uuid) {
|
||||
var msg = new Message();
|
||||
msg.load( { uuid : uuid, user : self.client.user }, function loaded(err) {
|
||||
// :TODO: Hrm... if error...
|
||||
self.setMessage(msg);
|
||||
});
|
||||
};
|
||||
*/
|
||||
|
||||
this.menuMethods.nextMessage = function(formData, extraArgs) {
|
||||
// :TODO: Next shouldn't even be a option if this is not the case:
|
||||
if(self.messageIndex + 1 < self.messageList.length) {
|
||||
self.messageNumber++; // :TODO: should consolidate index + number?
|
||||
self.loadMessageByUuid(self.messageList[self.messageIndex++].messageUuid);
|
||||
}
|
||||
self.messageIndex++;
|
||||
|
||||
self.loadMessageByUuid(self.messageList[self.messageIndex].messageUuid);
|
||||
}
|
||||
};
|
||||
|
||||
this.menuMethods.prevMessage = function(formData, extraArgs) {
|
||||
if(self.messageIndex > 0) {
|
||||
self.messageIndex--;
|
||||
|
||||
self.loadMessageByUuid(self.messageList[self.messageIndex].messageUuid);
|
||||
}
|
||||
};
|
||||
|
||||
this.menuMethods.movementKeyPressed = function(formData, extraArgs) {
|
||||
var bodyView = self.viewControllers.body.getView(1);
|
||||
|
||||
switch(formData.key.name) {
|
||||
case 'down arrow' : bodyView.scrollDocumentUp(); break;
|
||||
case 'up arrow' : bodyView.scrollDocumentDown(); break;
|
||||
case 'page up' : bodyView.keyPressPageUp(); break;
|
||||
case 'page down' : bodyView.keyPressPageDown(); break;
|
||||
}
|
||||
};
|
||||
|
||||
this.loadMessageByUuid = function(uuid) {
|
||||
|
@ -71,18 +73,8 @@ function AreaViewFSEModule(options) {
|
|||
|
||||
require('util').inherits(AreaViewFSEModule, FullScreenEditorModule);
|
||||
|
||||
/*
|
||||
AreaViewFSEModule.prototype.enter = function(client) {
|
||||
AreaViewFSEModule.super_.prototype.enter.call(this, client);
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
AreaViewFSEModule.prototype.finishedLoading = function() {
|
||||
//AreaViewFSEModule.super_.prototype.finishedLoading.call(this);
|
||||
|
||||
if(this.messageList.length) {
|
||||
console.log('loading from index ' + this.messageIndex)
|
||||
this.loadMessageByUuid(this.messageList[this.messageIndex].messageUuid);
|
||||
}
|
||||
};
|
|
@ -45,9 +45,7 @@ function MessageListModule(options) {
|
|||
MenuModule.call(this, options);
|
||||
|
||||
var self = this;
|
||||
|
||||
var config = this.menuConfig.config;
|
||||
// config.listType : public | private
|
||||
|
||||
this.listType = config.listType || 'public';
|
||||
|
||||
|
@ -56,52 +54,16 @@ function MessageListModule(options) {
|
|||
this.menuMethods = {
|
||||
selectMessage : function(formData, extraArgs) {
|
||||
if(1 === formData.submitId) {
|
||||
/*
|
||||
extraArgs.messageAreaName
|
||||
extraArgs.messageList
|
||||
extraArgs.messageListIndex
|
||||
*/
|
||||
|
||||
var selected = self.messageList[formData.value.message];
|
||||
//console.log(selected);
|
||||
|
||||
var modOpts = {
|
||||
name : 'messageAreaViewPost', // :TODO: should come from config?
|
||||
extraArgs : {
|
||||
messageAreaName : self.messageAreaName,
|
||||
messageList : self.messageList,
|
||||
messageListIndex : formData.value.message,
|
||||
messageIndex : formData.value.message,
|
||||
}
|
||||
};
|
||||
|
||||
self.client.gotoMenuModule(modOpts);
|
||||
|
||||
/*
|
||||
//
|
||||
// Load full Message object
|
||||
//
|
||||
var msg = new Message();
|
||||
msg.load( { uuid : selected.messageUuid, user : self.client.user }, function loaded(err) {
|
||||
|
||||
if(err) {
|
||||
// :TODO: Now what?!
|
||||
console.log(err)
|
||||
} else {
|
||||
var modOpts = {
|
||||
// :TODO: get this name from config
|
||||
name : 'messageAreaViewPost',
|
||||
extraArgs : {
|
||||
message : msg,
|
||||
messageAreaName : self.messageAreaName,
|
||||
messageNumber : formData.value.message + 1,
|
||||
messageTotal : self.messageList.length,
|
||||
},
|
||||
};
|
||||
|
||||
self.client.gotoMenuModule(modOpts);
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -122,7 +84,6 @@ MessageListModule.prototype.enter = function(client) {
|
|||
|
||||
MessageListModule.prototype.mciReady = function(mciData, cb) {
|
||||
var self = this;
|
||||
|
||||
var vc = self.viewControllers.msgList = new ViewController( { client : self.client } );
|
||||
|
||||
async.series(
|
||||
|
|
Loading…
Reference in New Issue