penguin/AstroJS

Javascript framework for my blog

commit 33c515cd081f0a382fce49e304a86eefab5441a7

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-02-22T01:45:59Z
subjectEarly dynamic module loading for SmartInput
commit 33c515cd081f0a382fce49e304a86eefab5441a7
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-02-22T01:45:59Z

    Early dynamic module loading for SmartInput
---
 .../SmartInput/CandidateAction/Heading.js          | 29 ++++++++++++++++++++++
 .../src/Astro/Blog/AstroEdit/SmartInput/_this.js   | 27 +++++++++++++++-----
 ...o.Blog.AstroEdit.SmartInput.ICandidateAction.js |  6 +++++
 3 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/CandidateAction/Heading.js b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/CandidateAction/Heading.js
new file mode 100644
index 0000000..aa5f836
--- /dev/null
+++ b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/CandidateAction/Heading.js
@@ -0,0 +1,29 @@
+(function ()
+{
+	var ns = __namespace( "Astro.Blog.AstroEdit.SmartInput.CandidateAction" );
+
+	/** @type {System.utils.IKey} */
+	var IKey                              = __import( "System.utils.IKey" );
+	/** @type {System.utils.DataKey} */
+	var DataKey                           = __import( "System.utils.DataKey" );
+	/** @type {Dandelion.IDOMElement} */
+	var IDOMElement                       = __import( "Dandelion.IDOMElement" );
+	/** @type {Dandelion} */
+	var Dand                              = __import( "Dandelion" );
+
+	/** @type {Astro.Blog.AstroEdit.SmartInput.ICandidateAction} */
+	var Heading = function ( visualizer )
+	{
+		this.visualizer = visualizer;
+	};
+
+	Heading.prototype.GetCandidates = function( handler )
+	{
+	};
+
+	Heading.prototype.Process = function( key )
+	{
+	};
+
+	ns[ NS_EXPORT ]( EX_CLASS, "Heading", Heading );
+})();
diff --git a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js
index 538e933..19e26a3 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/SmartInput/_this.js
@@ -11,14 +11,12 @@
 	var Cycle                                   = __import( "System.Cycle" );
 	/** @type {System.Debug} */
 	var debug                                   = __import( "System.Debug" );
+	/** @type {System.Net.ClassLoader} */
+	var Loader                                  = __import( "System.Net.ClassLoader" );
 	/** @type {System.utils} */
 	var utils                                   = __import( "System.utils" );
-	/** @type {System.utils.Perf} */
-	var Perf                                    = __import( "System.utils.Perf" );
 	/** @type {System.utils.DataKey} */
 	var DataKey                                 = __import( "System.utils.DataKey" );
-	/** @type {System.utils.EventKey} */
-	var EventKey                                = __import( "System.utils.EventKey" );
 	/** @type {System.utils.IKey} */
 	var IKey                                    = __import( "System.utils.IKey" );
 	/** @type {Components.MessageBox} */
@@ -26,6 +24,9 @@
 	/** @type {Astro.Blog.Config} */
 	var Config                                  = __import( "Astro.Blog.Config" );
 
+	var moduleNs = "Astro.Blog.AstroEdit.SmartInput.CandidateAction.";
+	var service_uri = Config.get( "ServiceUri" );
+
 	var KeyHandler = function( sender, handler )
 	{
 		return function( e )
@@ -38,6 +39,12 @@
 		};
 	};
 
+	var LoadModule = function( mod, handler )
+	{
+		var ldr = new Loader( service_uri );
+		ldr.load( moduleNs + mod, handler );
+	};
+
 	/** @param {Astro.Blog.AstroEdit.Visualizer} */
 	var SmartInput = function ( visualizer, CandidatesOvd )
 	{
@@ -117,6 +124,14 @@
 			return null;
 		};
 
+		var ModuleLoaded = function( e )
+		{
+			/** @type {Astro.Blog.AstroEdit.SmartInput.ICandidateAction} */
+			var module = new ( __import( e ) )( visualizer );
+
+			// XXX
+		};
+
 		var HandleInput = function( sender, e )
 		{
 			// Don't handle if holding shift or ctrl key
@@ -154,9 +169,9 @@
 					if( selected )
 					{
 						insert = undefined;
-
-
 						sender.BindingBox.close();
+
+						LoadModule( Cands[ selected.getDAttribute( "key" ) ].module, ModuleLoaded );
 					}
 					else
 					{
diff --git a/botanjs/src/externs/Astro.Blog.AstroEdit.SmartInput.ICandidateAction.js b/botanjs/src/externs/Astro.Blog.AstroEdit.SmartInput.ICandidateAction.js
new file mode 100644
index 0000000..1ab9e35
--- /dev/null
+++ b/botanjs/src/externs/Astro.Blog.AstroEdit.SmartInput.ICandidateAction.js
@@ -0,0 +1,6 @@
+/** @constructor */
+Astro.Blog.AstroEdit.SmartInput.ICandidateAction = function(){};
+/** @type {function} */
+Astro.Blog.AstroEdit.SmartInput.ICandidateAction.GetCandidates;
+/** @type {function} */
+Astro.Blog.AstroEdit.SmartInput.ICandidateAction.Process;