• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourcepublicjavascriptscommonyobi.ShortcutKey.js
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Yona 1.16.0 Upload
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
File name
Commit message
Commit date
bootstrap
Source Code Upload
02-04
help
Source Code Upload
02-04
images
Source Code Upload
02-04
javascripts
Source Code Upload
02-04
stylesheets
Source Code Upload
02-04
compiler.jar
Source Code Upload
02-04
File name
Commit message
Commit date
common
Source Code Upload
02-04
lib
Source Code Upload
02-04
service
Source Code Upload
02-04
template
Source Code Upload
02-04
yona-common.js
Source Code Upload
02-04
yona-layout.js
Source Code Upload
02-04
yona-lib.js
Source Code Upload
02-04
File name
Commit message
Commit date
yobi.Attachments.js
Source Code Upload
02-04
yobi.CodeCommentBlock.js
Source Code Upload
02-04
yobi.CodeCommentBox.js
Source Code Upload
02-04
yobi.Comment.js
Source Code Upload
02-04
yobi.CommentForm.js
Source Code Upload
02-04
yobi.Common.js
Source Code Upload
02-04
yobi.Files.js
Source Code Upload
02-04
yobi.Interval.js
Source Code Upload
02-04
yobi.LoginDialog.js
Source Code Upload
02-04
yobi.Markdown.js
Source Code Upload
02-04
yobi.Mention.js
Source Code Upload
02-04
yobi.OriginalMessage.js
Source Code Upload
02-04
yobi.Pagination.js
Source Code Upload
02-04
yobi.ShortcutKey.js
Source Code Upload
02-04
yobi.WatcherList.js
Source Code Upload
02-04
yobi.ui.Calendar.js
Source Code Upload
02-04
yobi.ui.Dialog.js
Source Code Upload
02-04
yobi.ui.Dropdown.js
Source Code Upload
02-04
yobi.ui.Mergely.js
Source Code Upload
02-04
yobi.ui.Select2.js
Source Code Upload
02-04
yobi.ui.Tabs.js
Source Code Upload
02-04
yobi.ui.Toast.js
Source Code Upload
02-04
yobi.ui.Typeahead.js
Source Code Upload
02-04
yona.CommentAttachmentsUpdate.js
Source Code Upload
02-04
yona.KeyControl.js
Source Code Upload
02-04
yona.ReceiverList.js
Source Code Upload
02-04
yona.Sha1.js
Source Code Upload
02-04
yona.SubComment.js
Source Code Upload
02-04
yona.Subtask.js
Source Code Upload
02-04
yona.Tasklist.js
Source Code Upload
02-04
yona.TitleHeadAutoCompletion.js
Source Code Upload
02-04
yona.Usermenu.js
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
/** * Yobi, Project Hosting SW * * Copyright 2012 NAVER Corp. * http://yobi.io * * @author Yi EungJun * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ yobi.ShortcutKey = (function(htOptions){ var htVar = {}; var htHandlers = {}; /** * initialize */ function _init(htOptions){ _initVar(); _attachEvent(); } /** * initialize variables */ function _initVar(){ htVar.rxTrim = /\s+/g; htVar.aFormTags = ["INPUT", "TEXTAREA"]; htVar.aCombinationKeys = ["CTRL", "ALT", "SHIFT"]; htVar.htKeycodeMap = { '13':'ENTER', '38':'UP', '40':'DOWN', '37':'LEFT', '39':'RIGHT', '13':'ENTER', '27':'ESC', '32':'SPACE', '8':'BACKSPACE', '9':'TAB', '46':'DELETE', '33':'PAGEUP', '34':'PAGEDOWN', '36':'HOME', '35':'END', '65':'A', '66':'B', '67':'C', '68':'D', '69':'E', '70':'F', '71':'G', '72':'H', '73':'I', '74':'J', '75':'K', '76':'L', '77':'M', '78':'N', '79':'O', '80':'P', '81':'Q', '82':'R', '83':'S', '84':'T', '85':'U', '86':'V', '87':'W', '88':'X', '89':'Y', '90':'Z', '48':'0', '49':'1', '50':'2', '51':'3', '52':'4', '53':'5', '54':'6', '55':'7', '56':'8', '57':'9', '219':'[', '221':']', '186':';', '222':'\'', '188':',', '190':'.', '191':'/', '189':'-', '187':'=', '220':'\\', '192':'`', '112':'F1', '113':'F2', '114':'F3', '115':'F4', '116':'F5', '117':'F6', '118':'F7', '119':'F8', '120':'F9', '121':'F10', '122':'F11', '123':'F12' }; } /** * add event listener */ function _attachEvent(){ $(window).on({ "keydown" : _onKeyDown, "beforeunload": destroy // free memory }); } function _detachEvent(){ $(window).off({ "keydown" : _onKeyDown, "beforeunload": destroy // free memory }); } /** * global keyDown event handler */ function _onKeyDown(weEvt){ var sKeyInput = _getKeyString(weEvt); var fHandler = htHandlers[sKeyInput]; if(typeof fHandler === "function"){ _runEventHandler(fHandler, weEvt, sKeyInput); } } function _runEventHandler(fHandler, weEvt, sKeyInput){ var sTagName = weEvt.target.tagName.toUpperCase(); var htInfo = { "weEvt" : weEvt, "welTarget" : $(weEvt.target), "sTagName" : sTagName, "sKeyInput" : sKeyInput, "bFormInput": (htVar.aFormTags.indexOf(sTagName) > -1) }; try { fHandler(htInfo); }catch(e){} finally { htInfo = null; } } /** * attach Shortcut Key Handler * @param {String} vKey keyCombiation String e.g. CTRL+ENTER * @param {String} fHandler handler function * or * @param {Hash Table} vKey {"keyCombination:function(){}, "key":function(){}} */ function attachHandler(vKey, fHandler){ if(typeof vKey === "string"){ return _setHandler(vKey, fHandler); } var fHandler, sKey; for(sKey in vKey){ fHandler = vKey[sKey]; _setHandler(sKey, fHandler); } } function _setHandler(sKey, fHandler){ sKey = _normalizeKeyString(sKey); htHandlers[sKey] = fHandler; } /** * detach Shortcut Key Handler * @param {String} sKey * @param {String} fHandler */ function detachHandler(sKeyInput){ var sKey = _normalizeKeyString(sKeyInput); delete htHandlers[sKey]; } /** * generate key string from keyDown event * @param {Wrapped Event} weEvt */ function _getKeyString(weEvt){ var sMainKey = htVar.htKeycodeMap[weEvt.keyCode]; if(typeof sMainKey === "undefined"){ // ignore event if not on keyMap return; } // generate key combination var aKeys = []; var sKeyString = ""; if(weEvt.altKey){ aKeys.push("ALT"); } if(weEvt.ctrlKey || weEvt.metaKey){ aKeys.push("CTRL"); } if(weEvt.shiftKey){ aKeys.push("SHIFT"); } aKeys.push(sMainKey); sKeyString = aKeys.join("+").toUpperCase(); return sKeyString; } /** * normalize Key String * @param {String} sKey */ function _normalizeKeyString(sKey){ sKey = sKey.toUpperCase() || ""; sKey = sKey.replace(htVar.rxTrim, ''); sKey = sKey.split("+").sort(function(v){ return -1 * (htVar.aCombinationKeys.indexOf(v)); }).join("+"); return sKey; } /** * Get Key Handlers. for debug. * @return {Hash Table} */ function getHandlers(){ return htHandlers; } /** * set keyMap link * @param {Hash Table} htKeyMap * @example * setKeymapLink({ * "N": "http://www.naver.com" * }); */ function setKeymapLink(htKeyMap){ var sKey; var fHandler = function(htInfo){ if(!htInfo.bFormInput){ document.location.href = htKeyMap[htInfo.sKeyInput]; } }; for(sKey in htKeyMap){ if(htKeyMap[sKey]){ attachHandler(sKey, fHandler); } else { detachHandler(sKey); } } } /** * destroy this */ function destroy(){ _detachEvent(); htHandlers = htVar = null; } _init(htOptions); // public interface return { "attach": attachHandler, "detach": detachHandler, "getHandlers": getHandlers, "setKeymapLink": setKeymapLink }; })();

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up