From 3848a36069a70cbbe2922a0dd4cc1423520d5798 Mon Sep 17 00:00:00 2001 From: pekepeke Date: Sun, 14 Dec 2008 04:36:25 +0000 Subject: リファクタリング等 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26666 d0d07461-0603-4401-acd4-de1884942a52 --- localkeymode.js | 72 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'localkeymode.js') diff --git a/localkeymode.js b/localkeymode.js index 3ab2ccb..55a7b66 100644 --- a/localkeymode.js +++ b/localkeymode.js @@ -64,16 +64,16 @@ liberator.plugins.LocalKeyMode = (function() { var _isEnable; var _isBindLocalKey = false; - + var _enableTabs = []; var _names; var feedKeys = liberator.modules ? liberator.modules.events.feedkeys : liberator.events.feedkeys; // utility function - function cloneMap(org) { + function cloneMap(org, key) { return new Map( - org.modes, org.names, org.description, org.action, + org.modes, key ? key : org.names, org.description, org.action, {flags:org.flags, rhs:org.rhs, noremap:org.noremap } ); } @@ -102,7 +102,12 @@ liberator.plugins.LocalKeyMode = (function() { // ステータスバーにアイコンを生成 setupStatusBar: function() { var self = this; - var panel = document.createElement('statusbarpanel'); + var panel = document.getElementById('localkeymode-status'); + if (panel) { + let parent = panel.parentNode; + parent.removeChild(panel); + } + panel = document.createElement('statusbarpanel'); panel.setAttribute('id', 'localkeymode-status'); panel.setAttribute('class', 'statusbarpanel-iconic'); panel.setAttribute('src', self.isEnable ? ENABLE_ICON : DISABLE_ICON); @@ -111,17 +116,13 @@ liberator.plugins.LocalKeyMode = (function() { panel, document.getElementById('security-button').nextSibling); return panel; }, - get isEnable() { - return _isEnable; - }, + get isEnable() _isEnable, set isEnable(value) { this.panel.setAttribute('src', value ? ENABLE_ICON : DISABLE_ICON); _isEnable = value; this.loadKeyMap(); }, - get isBinding() { - return _isBindLocalKey; - }, + get isBinding() _isBindLocalKey, set isBinding(value) { this.panel.setAttribute('src', value ? BINDING_ICON : this.isEnable ? ENABLE_ICON : DISABLE_ICON ); @@ -133,14 +134,17 @@ liberator.plugins.LocalKeyMode = (function() { var list = liberator.globalVariables.localKeyMappings; if (!list) return; var self = this; + // キーマップの生成 list.forEach( function( items ) { if ( !(items instanceof Array) || items.length < 2 || !(items[1] instanceof Array) ) return; self.addLocalKeyMap( items[0], items[1] ); } ); + // 補完用アイテムの抽出 this.completeNames = this.keymapnames.map( function(m) { m = (m+'').replace(/[\/\\]+/g, ''); return [m+'', 'maps for [' + m + ']']; } ); + autocommands.add('LocationChange', '.*', 'js liberator.plugins.LocalKeyMode.loadKeyMap();'); }, // ローカルキーマップの生成 addLocalKeyMap: function( uri, items ) { @@ -149,28 +153,24 @@ liberator.plugins.LocalKeyMode = (function() { var delkeys = []; if (!(uri instanceof RegExp) ) uri = new RegExp(uri.replace(/(?=[^-0-9A-Za-z_@])/g, '\\')); - for (let i=0; i [Delete KeyMap]\n'; mappings.remove( modes.NORMAL, key); } ); keymaps.keys.forEach( function( m ) { m.names.forEach( function( key ) { var org = mappings.get(modes.NORMAL, key); - if (org) self.storekeymaps.push( cloneMap(org) ); + if (org) self.storekeymaps.push( cloneMap(org, [key]) ); else self.delkeychars.push( key ); } ); mappings.addUserMap([modes.NORMAL], m.names, m.description, m.action, @@ -224,8 +224,9 @@ liberator.plugins.LocalKeyMode = (function() { }, // ローカルキーマップセット処理 loadKeyMap: function() { + var self = this; // 暫定処置 - if (liberator.plugins.feedKey && liberator.plugins.feedKey.origMap.length >0) return; + //if (liberator.plugins.feedKey && liberator.plugins.feedKey.origMap.length >0) return; this.helpstring = ''; if (this.isBinding) this.restoreKeyMap(); if (!this.isEnable) { @@ -258,6 +259,7 @@ liberator.plugins.LocalKeyMode = (function() { // 割り当てていたローカルキーの削除処理 restoreKeyMap: function() { if (this.isBinding) { + var msg = ""; for (; 0 < this.storekeymaps.length; ) { let m = this.storekeymaps.shift(); mappings.addUserMap([modes.NORMAL], m.names, m.description, m.action, @@ -323,5 +325,3 @@ liberator.plugins.LocalKeyMode = (function() { return new LocalKeyMode(); })(); - -autocommands.add('LocationChange', '.*', 'js liberator.plugins.LocalKeyMode.loadKeyMap();'); -- cgit v1.2.3