From e1edc480c7eea7073b99d8566f900fd883bad969 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 May 2013 06:56:59 -0400 Subject: [PATCH] KeyBinding -> Key --- ChangeLog | 2 ++ lib/client.js | 14 ++++++------- lib/client/editor/_ace.js | 8 +++---- lib/client/editor/_codemirror.js | 14 ++++++------- lib/client/{keyBinding.js => key.js} | 4 ++-- lib/client/menu.js | 31 ++++++++++++++-------------- lib/client/terminal.js | 26 +++++++++++------------ lib/client/viewer.js | 28 ++++++++++++------------- 8 files changed, 65 insertions(+), 62 deletions(-) rename lib/client/{keyBinding.js => key.js} (99%) diff --git a/ChangeLog b/ChangeLog index 9b4b9041..1cbab1f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ dispatch * Set F3 to veiw. +* Renamed KeyBinding -> Key. + 2012.04.22, v0.2.0 diff --git a/lib/client.js b/lib/client.js index ef3b2841..483eaac8 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2,12 +2,12 @@ * @CloudFunc - обьект содержащий общий функционал * клиентский и серверный */ -var Util, DOM, CloudFunc, KeyBinding, CloudCmd; +var Util, DOM, CloudFunc, CloudCmd; (function(Util, DOM){ 'use strict'; - var Config, Modules, FileTemplate, PathTemplate, Events = DOM.Events; + var Key, Config, Modules, FileTemplate, PathTemplate, Events = DOM.Events; /* Клиентский обьект, содержащий функциональную часть*/ CloudCmd = { @@ -159,10 +159,10 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; function initModules(pCallBack){ loadModule({ /* привязываем клавиши к функциям */ - path : 'keyBinding.js', + path : 'key.js', func : function(){ - KeyBinding = CloudCmd.KeyBinding; - KeyBinding.init(); + Key = CloudCmd.Key; + Key.init(); } }); @@ -311,7 +311,7 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; }); Util.exec(pCallBack); - CloudCmd.KeyBinding(); + CloudCmd.Key(); } @@ -368,7 +368,7 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; lOnContextMenu_f = function(pEvent){ var lReturn_b = true; - KeyBinding && KeyBinding.unSet(); + Key && Key.unSet(); /* getting html element * currentTarget - DOM event diff --git a/lib/client/editor/_ace.js b/lib/client/editor/_ace.js index d93dc1c4..974d1080 100644 --- a/lib/client/editor/_ace.js +++ b/lib/client/editor/_ace.js @@ -6,7 +6,7 @@ var CloudCmd, CloudFunc, ace; "use strict"; var cloudcmd = CloudCmd, Util = CloudCmd.Util, - KeyBinding = CloudCmd.KeyBinding, + Key = CloudCmd.Key, AceEditor = {}, AceLoaded = false, ReadOnly = false, @@ -137,7 +137,7 @@ var CloudCmd, CloudFunc, ace; initAce_f(data); /* removing keyBinding if set */ - KeyBinding.unSet(); + Key.unSet(); Util.hidePanel(); Util.Images.hideLoad(); @@ -150,7 +150,7 @@ var CloudCmd, CloudFunc, ace; /* function hides Ace editor */ AceEditor.hide = (function() { var lElem = AceElement; - KeyBinding.set(); + Key.set(); if(lElem && FM) FM.removeChild(lElem); @@ -168,7 +168,7 @@ var CloudCmd, CloudFunc, ace; var key_event = function(pEvent){ /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ + if( Key.get() ){ /* if f4 or f3 pressed */ var lF3 = cloudcmd.KEY.F3; var lF4 = cloudcmd.KEY.F4; diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 149b7bd2..155c0546 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -3,7 +3,7 @@ var CloudCmd, Util, DOM, CodeMirror; (function(CloudCmd, Util, DOM){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, CodeMirrorEditor = {}, FM, CodeMirrorElement, @@ -139,7 +139,7 @@ var CloudCmd, Util, DOM, CodeMirror; success : function(data){ if( DOM.hidePanel() ){ Util.exec(pCallBack, data); - KeyBinding.unSet(); + Key.unSet(); } DOM.Images.hideLoad(); @@ -155,7 +155,7 @@ var CloudCmd, Util, DOM, CodeMirror; * function hides CodeMirror editor */ function hide() { - KeyBinding.set(); + Key.set(); if(CodeMirrorElement && FM) FM.removeChild(CodeMirrorElement); @@ -184,12 +184,12 @@ var CloudCmd, Util, DOM, CodeMirror; CallBacks.pop(); /* добавляем обработчик клавишь */ - DOM.Events.addKey( lKeyListener ); + DOM.Events.addKey( lListener ); DOM.setButtonKey('f4', CodeMirrorEditor.show); - function lKeyListener(pEvent){ + function lListener(pEvent){ /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ + if( Key.get() ){ var lF4 = CloudCmd.KEY.F4, lKey = pEvent.keyCode; @@ -201,4 +201,4 @@ var CloudCmd, Util, DOM, CodeMirror; CloudCmd.Editor.CodeMirror = CodeMirrorEditor; -})(CloudCmd, Util, DOM); \ No newline at end of file +})(CloudCmd, Util, DOM); diff --git a/lib/client/keyBinding.js b/lib/client/key.js similarity index 99% rename from lib/client/keyBinding.js rename to lib/client/key.js index 70471c09..236b0d57 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/key.js @@ -43,9 +43,9 @@ var CloudCmd, Util, DOM; TRA : 192 /* Typewritten Reverse Apostrophe (`) */ }; - CloudCmd.KeyBinding = new KeyBindingProto(); + CloudCmd.Key = new KeyProto(); - function KeyBindingProto(){ + function KeyProto(){ var Binded, KEY = CloudCmd.KEY, lTabPanel = { diff --git a/lib/client/menu.js b/lib/client/menu.js index 9fe8c9d6..02d00d1c 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -5,7 +5,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, MenuSeted = false, Menu = {}, Position, @@ -186,7 +186,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; var m = "clicked: " + key; Util.log(m, options); - KeyBinding.set(); + Key.set(); }, // define the elements of the menu @@ -248,7 +248,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.setCurrentFile(lElement); } - KeyBinding.set(); + Key.set(); } } @@ -291,24 +291,25 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.jqueryLoad ]); - var lKeyListener = function(pEvent){ + DOM.Events.addKey( lListener ); + + function lListener(pEvent){ var lKEY = CloudCmd.KEY, - lKeyCode = pEvent.keyCode; + lF10 = lKEY.F10, + lESC = lKEY.ESC, + lKey = pEvent.keyCode, + lShift = pEvent.shiftKey; /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ - /* if shift + F10 pressed */ - if(lKeyCode === lKEY.F10 && pEvent.shiftKey){ + if( Key.get() ){ + if(lKey === lF10 && lShift){ $( DOM.getCurrentFile() ).contextMenu(); DOM.preventDefault(pEvent); } } - else if (lKeyCode === lKEY.ESC) - KeyBinding.set(); - }; - - /* добавляем обработчик клавишь */ - DOM.Events.addKey( lKeyListener ); + else if (lKey === lESC) + Key.set(); + } }; CloudCmd.Menu = Menu; -})(CloudCmd, Util, DOM, CloudFunc); \ No newline at end of file +})(CloudCmd, Util, DOM, CloudFunc); diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 783fbe96..d6390a8b 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -4,7 +4,7 @@ var CloudCmd, Util, DOM, $; (function(CloudCmd, Util, DOM){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, TerminalId, Term, Hidden = false, @@ -79,7 +79,7 @@ var CloudCmd, Util, DOM, $; if( DOM.hidePanel() ){ Hidden = false; DOM.show(TerminalId); - KeyBinding.unSet(); + Key.unSet(); Term.resume(); } }; @@ -92,7 +92,7 @@ var CloudCmd, Util, DOM, $; DOM.hide(TerminalId); DOM.showPanel(); - KeyBinding.set(); + Key.set(); Term.pause(); }; @@ -101,7 +101,6 @@ var CloudCmd, Util, DOM, $; * function bind keys */ CloudCmd.Terminal.init = function(){ - /* loading js and css*/ Util.loadOnLoad([ JqueryTerminal.show, load, @@ -109,26 +108,27 @@ var CloudCmd, Util, DOM, $; DOM.jqueryLoad, ]); - /* добавляем обработчик клавишь */ - var lKeyListener = function(pEvent){ + DOM.Events.addKey( lListener ); + + function lListener(pEvent){ var lRet = true, lKEY = CloudCmd.KEY, - lKeyCode = pEvent.keyCode, - lKeyBinded = KeyBinding.get(); + lESC = lKEY.ESC, + lTRA = lKEY.TRA, + lKey = pEvent.keyCode, + lBinded = Key.get(); /* если клавиши можно обрабатывать */ - if(Hidden && lKeyBinded && lKeyCode === lKEY.TRA){ + if(Hidden && lBinded && lKey === lTRA){ JqueryTerminal.show(); DOM.preventDefault(pEvent); lRet = false; } - else if(!Hidden && lKeyCode === lKEY.ESC) + else if(!Hidden && lKey === lESC) JqueryTerminal.hide(); return lRet; - }; - - DOM.Events.addKey( lKeyListener ); + } }; CloudCmd.Terminal.JqueryTerminal = JqueryTerminal; diff --git a/lib/client/viewer.js b/lib/client/viewer.js index b7c8d7a3..9baa81a4 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -5,13 +5,13 @@ var CloudCmd, Util, DOM, CloudFunc, $; (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, FancyBox = {}, Config = { beforeShow : function(){ DOM.Images.hideLoad(); - KeyBinding.unSet(); + Key.unSet(); }, afterShow : function(){ @@ -20,7 +20,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; lEditor.focus(); }, - beforeClose : Util.retFunc( KeyBinding.set ), + beforeClose : Util.retFunc( Key.set ), openEffect : 'none', closeEffect : 'none', @@ -123,7 +123,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.jqueryLoad ]); - DOM.Events.addKey(lKeyListener); + DOM.Events.addKey(lListener); DOM.setButtonKey('f3', lView); function lView(){ @@ -131,22 +131,22 @@ var CloudCmd, Util, DOM, CloudFunc, $; FancyBox.show( DOM.getCurrentFile() ); } - function lKeyListener(pEvent){ + function lListener(pEvent){ var lKEY = CloudCmd.KEY, lF3 = lKEY.F3, - F1 = lKEY.F1, - lKeyBinded = KeyBinding.get(), - lKeyCode = pEvent.keyCode; + lF1 = lKEY.F1, + lBinded = Key.get(), + lKey = pEvent.keyCode; /* если клавиши можно обрабатывать */ - if( lKeyBinded){ - switch(lKeyCode){ + if( lBinded){ + switch(lKey){ case lF3: lView(); DOM.preventDefault(pEvent); - break; - - case lKEY.F1: + break; + + case lF1: FancyBox.showHelp(); break; } @@ -156,4 +156,4 @@ var CloudCmd, Util, DOM, CloudFunc, $; CloudCmd.Viewer.FancyBox = FancyBox; -})(CloudCmd, Util, DOM, CloudFunc); \ No newline at end of file +})(CloudCmd, Util, DOM, CloudFunc);