* Minor work on post view FSE / related

This commit is contained in:
Bryan Ashby 2015-09-02 23:11:17 -06:00
parent 8b3b36fd83
commit 42ddabd875
7 changed files with 91 additions and 39 deletions

View File

@ -346,10 +346,10 @@ function FullScreenEditorModule(options) {
},
function setInitialData(callback) {
switch(self.editorMode) {
switch(self.editorMode) {
case 'view' :
if(self.message) {
self.initHeaderFromMessage();
self.initHeaderViewMode();
var bodyMessageView = self.viewControllers.body.getView(1);
if(bodyMessageView && _.has(self, 'message.message')) {
@ -426,21 +426,38 @@ function FullScreenEditorModule(options) {
}
};
this.initHeaderFromMessage = function() {
this.initHeaderViewMode = function() {
assert(_.isObject(self.message));
var fromView = self.viewControllers.header.getView(1); // TL
var toView = self.viewControllers.header.getView(2); // TL
var subjView = self.viewControllers.header.getView(3); // TL
var tsView = self.viewControllers.header.getView(5); // TL
fromView.setText(self.message.fromUserName);
toView.setText(self.message.toUserName);
subjView.setText(self.message.subject);
tsView.setText(moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat()));
function setHeaderText(id, text) {
var v = self.viewControllers.header.getView(id);
if(v) {
v.setText(text);
}
}
/* TL1 - From
TL2 - To
TL3 - Subject
TL5 - Date/Time (TODO: format)
TL6 - Message number
TL7 - Mesage total (in area)
TL8 - View Count
TL9 - Hash tags
TL10 - Message ID
TL11 - Reply to message ID*/
setHeaderText(1, self.message.fromUserName);
setHeaderText(2, self.message.toUserName);
setHeaderText(3, self.message.subject);
setHeaderText(5, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat()));
setHeaderText(6, '1'); // :TODO: Message number
setHeaderText(7, '100'); // :TODO: Message total
setHeaderText(8, self.message.viewCount);
setHeaderText(9, 'TODO hash tags');
setHeaderText(10, self.message.messageId);
setHeaderText(11, self.message.replyToMessageId);
};
this.displayHelp = function() {

View File

@ -145,12 +145,20 @@ function getFormConfigByIDAndMap(menuConfig, formId, mciMap, cb) {
Log.trace( { mciKey : mciReqKey }, 'Looking for MCI configuration key');
//
// Exact, explicit match?
//
if(_.isObject(formForId[mciReqKey])) {
Log.trace( { mciKey : mciReqKey }, 'Using exact configuration key match');
cb(null, formForId[mciReqKey]);
return;
}
//
// Generic match
//
if(_.has(formForId, 'mci') || _.has(formForId, 'submit')) {
Log.trace('Using generic configuration');
cb(null, formForId);
return;
}

View File

@ -124,6 +124,14 @@ function MultiLineEditTextView(options) {
}[sgrFor] || self.getSGR();
};
this.isEditMode = function() {
return 'edit' === self.mode;
};
this.isPreviewMode = function() {
return 'preview' === self.mode;
};
// :TODO: Most of the calls to this could be avoided via incrementRow(), decrementRow() that keeps track or such
this.getTextLinesIndex = function(row) {
if(!_.isNumber(row)) {
@ -1050,6 +1058,10 @@ MultiLineEditTextView.prototype.getData = function() {
};
MultiLineEditTextView.prototype.setPropertyValue = function(propName, value) {
switch(propName) {
case 'mode' : this.mode = value; break;
}
MultiLineEditTextView.super_.prototype.setPropertyValue.call(this, propName, value);
};
@ -1064,6 +1076,16 @@ var HANDLED_SPECIAL_KEYS = [
'delete line',
];
/*
var EDIT_MODE_KEYS = [
'line feed', 'insert', 'tab', 'backspace', 'del', 'delete line'
];
*/
var PREVIEW_MODE_KEYS = [
'up', 'down', 'page up', 'page down'
];
MultiLineEditTextView.prototype.onKeyPress = function(ch, key) {
var self = this;
var handled;
@ -1071,13 +1093,18 @@ MultiLineEditTextView.prototype.onKeyPress = function(ch, key) {
if(key) {
HANDLED_SPECIAL_KEYS.forEach(function aKey(specialKey) {
if(self.isKeyMapped(specialKey, key.name)) {
if(self.isPreviewMode() && -1 === PREVIEW_MODE_KEYS.indexOf(specialKey)) {
return;
}
self[_.camelCase('keyPress ' + specialKey)]();
handled = true;
}
});
}
if(ch && strUtil.isPrintable(ch)) {
if(self.isEditMode() && ch && strUtil.isPrintable(ch)) {
this.keyPressCharacter(ch);
}

View File

@ -127,9 +127,14 @@ TextView.prototype.setText = function(text) {
this.text = strUtil.stylizeString(this.text, this.hasFocus ? this.focusTextStyle : this.textStyle);
/*
if(this.resizable) {
this.dimens.width = this.text.length + widthDelta;
}
*/
if(this.autoScale.width) {
this.dimens.width = this.text.length + widthDelta;
}
this.redraw();
};

View File

@ -232,7 +232,7 @@ function ViewController(options) {
return;
}
var mciConf = config.mci[mci];
var mciConf = config.mci[mci];
self.setViewPropertiesFromMCIConf(view, mciConf);

Binary file not shown.

View File

@ -372,29 +372,23 @@
},
"form" : {
"0" : {
"TLTLTLTL" : {
"mci" : {
"TL1" : {
"width" : 36
},
"TL2" : {
"width" : 36
},
"TL3" : {
"width" : 65
},
"TL5" : {
"width" : 19
},
"MA5" : {
"width" : 19,
"textOverflow" : "..."
}
/*,
"TL4" : {
"width" : 19,
"textOverflow" : "..."
}*/
"mci" : {
"TL1" : {
"width" : 36
},
"TL2" : {
"width" : 36
},
"TL3" : {
"width" : 39,
"textOverflow" : "..."
},
"TL5" : {
"width" : 19
},
"MA5" : {
"width" : 19,
"textOverflow" : "..."
}
}
},
@ -403,7 +397,8 @@
"mci" : {
"MT1" : {
"width" : 79,
"height" : 17
"height" : 17,
"mode" : "preview"
}
},
"submit" : {