diff --git a/core/config.js b/core/config.js index 99572287..a199d54d 100644 --- a/core/config.js +++ b/core/config.js @@ -50,7 +50,7 @@ function init(configPath, cb) { // if(!_.has(mergedConfig, 'messages.areas.') || !_.isArray(mergedConfig.messages.areas) || - 0 == mergedConfig.messages.areas.length || + 0 === mergedConfig.messages.areas.length || !_.isString(mergedConfig.messages.areas[0].name)) { var msgAreasErr = new Error('Please create at least one message area'); diff --git a/core/fse.js b/core/fse.js index 24d0c336..a8cc6843 100644 --- a/core/fse.js +++ b/core/fse.js @@ -816,6 +816,29 @@ function FullScreenEditorModule(options) { self.observeEditorEvents(); }; + + this.quoteBuilderFinalize = function() { + // :TODO: fix magic #'s + var quoteMsgView = self.viewControllers.quoteBuilder.getView(1); + var msgView = self.viewControllers.body.getView(1); + + var quoteLines = quoteMsgView.getData(); + + if(quoteLines.trim().length > 0) { + msgView.addText(quoteMsgView.getData() + '\n'); + + } + + quoteMsgView.setText(''); + + var footerName = self.getFooterName(); + + self.footerMode = 'editor'; + + self.switchFooter(function switched(err) { + self.switchFromQuoteBuilderToBody(); + }); + }; this.menuMethods = { // @@ -893,23 +916,19 @@ function FullScreenEditorModule(options) { var quoteText = self.viewControllers.quoteBuilder.getView(3).getItem(formData.value.quote); quoteMsgView.addText(quoteText); - self.viewControllers.quoteBuilder.getView(3).focusNext(); + // + // If this is *not* the last item, advance. Otherwise, do nothing as we + // don't want to jump back to the top and repeat already quoted lines + // + var quoteListView = self.viewControllers.quoteBuilder.getView(3); + if(quoteListView.getData() !== quoteListView.getCount() - 1) { + quoteListView.focusNext(); + } else { + self.quoteBuilderFinalize(); + } }, quoteBuilderEscPressed : function(formData, extraArgs) { - // :TODO: fix magic #'s - var quoteMsgView = self.viewControllers.quoteBuilder.getView(1); - var msgView = self.viewControllers.body.getView(1); - - msgView.addText(quoteMsgView.getData() + '\n'); - quoteMsgView.setText(''); - - var footerName = self.getFooterName(); - - self.footerMode = 'editor'; - - self.switchFooter(function switched(err) { - self.switchFromQuoteBuilderToBody(); - }); + self.quoteBuilderFinalize(); }, /* replyDiscard : function(formData, extraArgs) { diff --git a/core/menu_view.js b/core/menu_view.js index 4ad4c977..cf2aabd1 100644 --- a/core/menu_view.js +++ b/core/menu_view.js @@ -68,6 +68,16 @@ MenuView.prototype.setItems = function(items) { } }; +MenuView.prototype.getCount = function() { + return this.items.length; +}; + +MenuView.prototype.getItems = function() { + return _.map(this.items, function itemIter(i) { + return i.text; + }); +}; + MenuView.prototype.getItem = function(index) { return this.items[index].text; };