penguin/AstroJS

Javascript framework for my blog

commit 6674931273ba185bc632200f743111ed8d8c8739

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-04-03T17:12:11Z
subjectVim Init
commit 6674931273ba185bc632200f743111ed8d8c8739
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-04-03T17:12:11Z

    Vim Init
---
 botanjs/src/Astro/Blog/AstroEdit/_this.js | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/botanjs/src/Astro/Blog/AstroEdit/_this.js b/botanjs/src/Astro/Blog/AstroEdit/_this.js
index d59c4b1..34a3da9 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/_this.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/_this.js
@@ -23,6 +23,8 @@
 	var Uploader                                   = __import( "Astro.Blog.AstroEdit.Uploader" );
 	/** @type {Astro.Blog.AstroEdit.SiteLibrary} */
 	var SiteLibrary                                = __import( "Astro.Blog.AstroEdit.SiteLibrary" );
+	/** @type {Components.Vim.VimArea} */
+	var VimArea                                    = __import( "Components.Vim.VimArea" );
 
 	// calls the smart bar
 	var SmartInput                                 = __import( "Astro.Blog.AstroEdit.SmartInput" );
@@ -100,6 +102,35 @@
 		Dand.id( "ae_drop_btn" ).onclick = function () { article.drop(); };;
 
 		adjustLayout();
+
+		VimTrigger();
+	};
+
+	var VimTrigger = function()
+	{
+		var f10Binding = function ( e )
+		{
+			e = e || window.event;
+			if ( e.keyCode ) code = e.keyCode;
+			else if ( e.which ) code = e.which;
+
+			if ( code == 121 )
+			{
+				e.preventDefault();
+				var node = document.activeElement;
+				if( node.nodeName == "TEXTAREA" )
+				{
+					new VimArea( node );
+					node.blur();
+					node.focus();
+				}
+			}
+		};
+
+		//Attach the var with the event = function
+		if(document.addEventListener) document.addEventListener('keydown', f10Binding, false);
+		else if(document.attachEvent) document.attachEvent('onkeydown', f10Binding);
+		else document.onkeydown = f10Binding;
 	};
 
 	var adjustLayout  = function ()