* Quote builder even more functional :)

This commit is contained in:
Bryan Ashby 2015-09-15 22:44:31 -06:00
parent 4cba6f4c10
commit 20fb54422a
5 changed files with 34 additions and 14 deletions

View File

@ -603,17 +603,8 @@ function FullScreenEditorModule(options) {
} }
}, },
function loadQuoteLines(callback) { function loadQuoteLines(callback) {
// :TODO: MLTEV's word wrapping -> line[] stuff needs to be made a public API. This can then be used here and elsewhere.
// ...should not be too bad to do at all
// ...probably do want quote markers in place here though, e.g. " Nu> Said some things"
// ...this could be handled via message.getQuoteLines(...) => []
//self.viewControllers.quoteBuilder.getView(3).setItems(['Someone said some shit', 'then they said more shit', 'and what not...', 'hurp durp']);
var quoteView = self.viewControllers.quoteBuilder.getView(3); var quoteView = self.viewControllers.quoteBuilder.getView(3);
var quoteWidth = quoteView.dimens.width; quoteView.setItems(self.replyToMessage.getQuoteLines(quoteView.dimens.width));
console.log(quoteWidth)
var quoteLines = self.replyToMessage.getQuoteLines(quoteWidth);
console.log(quoteLines)
quoteView.setItems(quoteLines);
callback(null); callback(null);
}, },
function setViewFocus(callback) { function setViewFocus(callback) {
@ -700,6 +691,11 @@ function FullScreenEditorModule(options) {
self.viewControllers.footerEditorMenu.setFocus(false); self.viewControllers.footerEditorMenu.setFocus(false);
self.displayQuoteBuilder(); self.displayQuoteBuilder();
}, },
appendQuoteEntry: function(formData, extraArgs) {
// :TODO: Dont' use magic # ID's here
var quoteText = self.viewControllers.quoteBuilder.getView(3).getItem(formData.value.quote);
self.viewControllers.quoteBuilder.getView(1).addText(quoteText);
},
editModeMenuHelp : function(formData, extraArgs) { editModeMenuHelp : function(formData, extraArgs) {
self.viewControllers.footerEditorMenu.setFocus(false); self.viewControllers.footerEditorMenu.setFocus(false);
self.displayHelp(); self.displayHelp();

View File

@ -58,6 +58,10 @@ MenuView.prototype.setItems = function(items) {
} }
}; };
MenuView.prototype.getItem = function(index) {
return this.items[index].text;
};
MenuView.prototype.setFocusItems = function(items) { MenuView.prototype.setFocusItems = function(items) {
var self = this; var self = this;

View File

@ -245,6 +245,8 @@ Message.prototype.persist = function(cb) {
}; };
Message.prototype.getQuoteLines = function(width) { Message.prototype.getQuoteLines = function(width) {
// :TODO: options.maxBlankLines = 1
var quoteLines = []; var quoteLines = [];
var origLines = this.message var origLines = this.message
@ -257,13 +259,10 @@ Message.prototype.getQuoteLines = function(width) {
tabWidth : 4, tabWidth : 4,
}; };
var wrapped;
var quotePrefix = 'Nu> '; // :TODO: build FTN style quote prefix var quotePrefix = 'Nu> '; // :TODO: build FTN style quote prefix
for(var i = 0; i < origLines.length; ++i) { for(var i = 0; i < origLines.length; ++i) {
wrapped = wordWrapText(quotePrefix + origLines[i], wrapOpts).wrapped; Array.prototype.push.apply(quoteLines, wordWrapText(quotePrefix + origLines[i], wrapOpts).wrapped);
Array.prototype.push.apply(quoteLines, wrapped);
} }
return quoteLines; return quoteLines;

View File

@ -993,6 +993,17 @@ MultiLineEditTextView.prototype.setText = function(text) {
//text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'}); //text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'});
this.textLines = [ ]; this.textLines = [ ];
this.addText(text);
/*this.insertRawText(text);
if(this.isEditMode()) {
this.cursorEndOfDocument();
} else if(this.isPreviewMode()) {
this.cursorStartOfDocument();
}*/
};
MultiLineEditTextView.prototype.addText = function(text) {
this.insertRawText(text); this.insertRawText(text);
if(this.isEditMode()) { if(this.isEditMode()) {

View File

@ -673,8 +673,18 @@
//items: [ "just", "testing", "some", "things" ] //items: [ "just", "testing", "some", "things" ]
width: 79 width: 79
height: 4 height: 4
argName: quote
} }
} }
submit: {
*: [
{
value: { quote: null }
action: @method:appendQuoteEntry
}
]
}
} }
} }
} }