Changeset 10586
- Timestamp:
- 04/27/08 19:09:21 (7 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/browser_object.js
r8958 r10586 1 1 // Vimperator plugin: 'Map behave like text-object' 2 // Version: 0. 23 // Last Change: 05-Apr-2008. Jan 20082 // Version: 0.3 3 // Last Change: 27-Apr-2008. Jan 2008 4 4 // License: Creative Commons 5 5 // Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid … … 17 17 // Motions: 18 18 // 'd' : Delete 19 // 'r' : Reload 19 20 // 'y' : Yank 20 21 // Scopes: … … 22 23 // 'r' : Right 23 24 // 'a' : All 25 // 'c' : Current 24 26 // 'o' : Other 27 // 's' : Same host 25 28 // Target: 26 29 // 't' : Tabs 27 30 (function(){ 28 function Tab(){ 29 return { 30 close: function(ary){ 31 for each(var i in ary) 32 i.close(); 33 }, 34 yank: function(ary){ 35 var copyStrings = []; 36 for each(var i in ary) 37 copyStrings.push(i.document.title); 38 liberator.copyToClipboard(copyStrings.join(", ")); 39 }, 31 function Tab(){} 32 Tab.prototype = { 33 close: function(ary){ 34 for each(var i in ary) 35 i.close(); 36 }, 37 yank: function(ary){ 38 var copyStrings = []; 39 for each(var i in ary) 40 copyStrings.push(i.document.location.href); 41 liberator.copyToClipboard(copyStrings.join(", ")); 42 }, 43 reload: function(ary){ 44 for each(var i in ary) 45 i.document.location.reload(); 46 }, 40 47 41 //default function 42 active: function(){ 43 return Application.activeWindow.activeTab.index; 44 }, 45 collection: function(){ 46 return Application.activeWindow.tabs; 47 }, 48 } 49 } 48 //default function 49 active: function() Application.activeWindow.activeTab.index , 50 identify: function(i){try{return i.document.location.host}catch(e){}}, 51 collection: function() Application.activeWindow.tabs , 52 }; 50 53 51 54 function Container(){ … … 80 83 browserObject.motions.add('d','close'); 81 84 browserObject.motions.add('y','yank'); 85 browserObject.motions.add('r','reload'); 82 86 83 87 browserObject.scopes.add('l',function(ary){ … … 93 97 return [ary[i] for (i in ary) if (i != active)]; 94 98 }); 95 browserObject.scopes.add(' i',function(ary){96 return [ary[this.active()]];97 });98 browserObject.scopes.add('a',function(ary){99 return ary;99 browserObject.scopes.add('c',function(ary) [ary[this.active()]]); 100 browserObject.scopes.add('a',function(ary) ary); 101 browserObject.scopes.add('s',function(ary){ 102 var activeIdentify = this.identify(ary[this.active()]); 103 return [ary[i] for (i in ary) if (this.identify(ary[i]) == activeIdentify)]; 100 104 }); 101 105 … … 104 108 var prefix = liberator.globalVariables.browser_object_prefix || ""; 105 109 for (let m in browserObject.motions){ 110 let motion = m; 106 111 for (let s in browserObject.scopes){ 107 let motion = m;108 112 let scope = s; 109 liberator.log(motion.id + scope.id);110 113 111 114 liberator.mappings.addUserMap([liberator.modes.NORMAL], [prefix + motion.id + scope.id], 112 115 "Browser Object Mapping", 113 116 function (arg) { 114 var target = browserObject.targets.get(arg); 115 var targetCollection = target.handler.collection(); 117 var target, targetCollection; 116 118 117 targetCollection = scope.handler.call(target.handler,targetCollection); 118 target.handler[motion.handler].call(target.handler,targetCollection); 119 target = browserObject.targets.get(arg); 120 if(!target){ 121 liberator.echoerr("BrowserObject: target not found"); 122 return; 123 } 124 125 targetCollection = scope.handler.call(target.handler,target.handler.collection()); 126 if(target.handler[motion.handler]) 127 target.handler[motion.handler].call(target.handler,targetCollection); 128 else 129 liberator.echoerr("BrowserObject: motion handler not found"); 119 130 }, 120 131 { flags: liberator.Mappings.flags.ARGUMENT}); 121 132 } 133 let map = liberator.mappings.get(null,motion.id); 134 if(!prefix && map){ 135 liberator.mappings.addUserMap([liberator.modes.NORMAL], 136 [motion.id + motion.id], map.description, map.action, 137 {}); 138 } 122 139 } 123 124 if(prefix == "")125 liberator.mappings.addUserMap([liberator.modes.NORMAL], ["dd"],126 "Delete current buffer",127 function (count) { liberator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); },128 { flags: liberator.Mappings.flags.COUNT });129 140 })();
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)