From bfdc58b90c09a3737acb405e4eded338572566d0 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 11 Aug 2015 22:28:43 -0600 Subject: [PATCH] * Few updates to FSE class, some notes --- core/fse--class.js | 70 +++++++++++++++++++++++++++--- mods/art/msg_area_post_header.ans | Bin 0 -> 582 bytes mods/menu.json | 2 +- 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 mods/art/msg_area_post_header.ans diff --git a/core/fse--class.js b/core/fse--class.js index e11a06a8..86e2bbd6 100644 --- a/core/fse--class.js +++ b/core/fse--class.js @@ -40,6 +40,14 @@ function FullScreenEditor(options) { this.editorMode = 'edit'; // view | edit | editMenu | + // :TODO: viewControllers management should be a mixin that can be thrown in here, menu_module.js, etc. + this.viewControllers = {}; + this.addViewController = function(name, vc) { + assert(!self.viewControllers[name]); + self.viewControllers[name] = vc; + return vc; + } + this.getFooterName = function(editorMode) { editorMode = editorMode || this.editorMode; return 'footer' + _.capitalize(editorMode); // e.g.. 'footerEditMenu' @@ -149,6 +157,7 @@ function FullScreenEditor(options) { ); }; + /* this.createViewsForEmail = function() { var menuLoadOpts = { callingMenu : self }; @@ -202,11 +211,63 @@ function FullScreenEditor(options) { } ); }; + */ - this.createViewsForArea = function() { - console.log('views would be created and stuff') + this.createInitialViews = function(cb) { + + var menuLoadOpts = { callingMenu : self }; + + async.series( + [ + function header(callback) { + menuLoadOpts.formId = self.getFormId('header'); + menuLoadOpts.mciMap = self.mciData.header.mciMap; + + self.addViewController( + 'header', + new ViewController( { client : self.client, formId : menuLoadOpts.formId } ) + ).loadFromMenuConfig(menuLoadOpts, function headerReady(err) { + callback(err); + }); + }, + function body(callback) { + menuLoadOpts.formId = self.getFormId('body'); + menuLoadOpts.mciMap = self.mciData.body.mciMap; + + self.addViewController( + 'body', + new ViewController( { client : self.client, formId : menuLoadOpts.formId } ) + ).loadFromMenuConfig(menuLoadOpts, function bodyReady(err) { + callback(err); + }); + }, + function footer(callback) { + var footerName = self.getFooterName(); + + menuLoadOpts.formId = self.getFormId(footerName); + menuLoadOpts.mciMap = self.mciData[footerName].mciMap; + + self.addViewController( + footerName, + new ViewController( { client : self.client, formId : menuLoadOpts.formId } ) + ).loadFromMenuConfig(menuLoadOpts, function footerReady(err) { + callback(err); + }); + }, + function prepare(callback) { + var header = self.viewControllers.header; + var from = header.getView(1); + from.acceptsFocus = false; + from.setText(self.client.user.username); + + callback(null); + } + ], + function complete(err) { + cb(err); + } + ); }; - } require('util').inherits(FullScreenEditor, events.EventEmitter); @@ -223,8 +284,7 @@ FullScreenEditor.prototype.enter = function() { }); }, function createViews(callback) { - var createViewsFor = 'createViewsFor' + _.capitalize(self.editorType); // e.g. 'createViewsForEmail' - self[createViewsFor](function viewsCreated(err) { + self.createInitialViews(function viewsCreated(err) { callback(err); }); } diff --git a/mods/art/msg_area_post_header.ans b/mods/art/msg_area_post_header.ans new file mode 100644 index 0000000000000000000000000000000000000000..0900ecd047367558e6cbb612042b6a86f874915d GIT binary patch literal 582 zcmb_YJr9CF428kP#K}z-7AHc|<3x;1NYFT#n1C)!YFtc+3DJ$e=l}AxoXBkK(2v)? z*WNiL#VVdrtfR{FeW%o6#Xb^`oH29-RSdQTl3s-()`a0ty92=g)x6PA4ryGdR_pp+ z8CBO61WvXtk>K8GRwy2H%6X8QR>Klc$$e2pZ3_viE6?Bj$_4UMUfoH9- zn)ig;v-0QpcD+2zzOSG*Ohgt87d