├── .gitignore ├── README.markdown ├── behave.min.js ├── firebug-coffee.coffee └── firebug-coffee.js /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | firebug-pentadactyl.js 2 | ============ 3 | 4 | This scrip allow run some firebug's commands through 5 | pentadactyl's console 6 | 7 | Available commands 8 | ------------------ 9 | 10 | * Global actions 11 | * `open`: 'open firebug window' 12 | * `close`: 'minimize firebug window' 13 | * `toggle`: 'toggle firebug window' 14 | * `disable`: 'exit from firebug' 15 | * `inspect`: 'inspect elements on the page' 16 | * `behave`: 'add Behave.js to firebug console (like auto-pairs)' 17 | 18 | * Console actions 19 | * `console`: 'focuses the firebug console' 20 | * `multiline`: 'open the multiline firebug console editor' 21 | * `toggle-console`: 'toggle between the one-line and multiline firebug console editor' 22 | * `clear`: 'clear console output window' 23 | * `run`: 'run script that was entered in console editor' 24 | 25 | * Navigation 26 | * `tab`: 'focuses the specified firebug tab (console, html, stylesheet, script, dom, net, etc)' 27 | * `tab-side`: 'focuses the specified firebug side tab (css, computed, layout, dom, domSide, watch)' 28 | * `>`: 'focuses the next right firebug tab' 29 | * `<`: 'focuses the next left firebug tab' 30 | * `#`: 'focuses the prev firebug tab' 31 | * `/`: 'search' 32 | 33 | You also may use any combinations of commands: 34 | 35 | ```vim 36 | "examples 37 | :firebug clear run console 38 | :firebug tab html 39 | :firebug tab console run toggle-console 40 | ``` 41 | 42 | 43 | 44 | Installation 45 | ------------ 46 | 47 | Before Installation this file you must have installed firebug plugin for Firefox 48 | Then download this file and put it in pentadactyl's plugin folder 49 | 50 | 51 | Example configuration .pentadactylrc 52 | ------------- 53 | 54 | ```vim 55 | ".pentadactylrc 56 | map -modes=n,v C :firebugdisable 57 | map -modes=n,v ;kk :firebugconsole 58 | map -modes=n,v ;kr :firebugrun 59 | map -modes=n,v ;kc :firebugclear 60 | 61 | "run script on blur firebug console 62 | set fbliverun 63 | ``` 64 | 65 | (version: 0.1.3) maksimr 66 | -------------------------------------------------------------------------------- /behave.min.js: -------------------------------------------------------------------------------- 1 | (function(){var l=l||function(l){"function"!==typeof String.prototype.repeat&&(String.prototype.repeat=function(b){if(1>b)return"";if(b%2)return this.repeat(b-1)+this;b=this.repeat(b/2);return b+b});"function"!==typeof Array.prototype.filter&&(Array.prototype.filter=function(b,c){if(null===this)throw new TypeError;var a=Object(this),e=a.length>>>0;if("function"!=typeof b)throw new TypeError;for(var d=[],h=0;hc&&0===f%2?!0:!1}return!0},isEven:function(b,c){return c%2},levelsDeep:function(){var b= 6 | e.cursor.get(),b=e.editor.get().substring(0,b),c=0,a,g;for(a=0;a': "focuses the next firebug tab(right)" 32 | '<': "focuses the next firebug tab(left)" 33 | '#': "focuses the prev firebug tab" 34 | 35 | '/': "search" 36 | inspect: "toggle the firebug element inspector" 37 | behave: "use Behave.js for console (like auto-pairs)" 38 | 39 | #global action with firebug 40 | open: ()-> fb.toggleBar(true,'console') if not chrome.isOpen() 41 | close: ()-> fb.toggleBar() if chrome.isOpen() 42 | toggle: ()-> fb.toggleBar() 43 | disable: ()-> fb.closeFirebug(true) 44 | inspect: ()-> 45 | fb.toggleBar(true) unless fb.currentContext 46 | fb.Inspector.toggleInspecting(fb.currentContext) 47 | behave: ()-> 48 | if @_editor 49 | @_editor.destroy() 50 | @_editor = null 51 | return 52 | 53 | if !@_editor && cmd && dactyl.plugins && dactyl.plugins.Behave 54 | @_editor = new dactyl.plugins.Behave({ 55 | textarea: cmd.getCommandEditor().editor.textBox 56 | }) 57 | 58 | #console 59 | console: ()-> 60 | @open() if not chrome.isOpen() 61 | chrome.switchToPanel(fb.currentContext, "console") 62 | cmLine = cmd.getSingleRowCommandLine() 63 | cmEditor = cmd.getCommandEditor() 64 | 65 | if fb.commandEditor 66 | if cmEditor.focus then cmEditor.focus() else cmEditor.select() 67 | else 68 | cmLine.select() 69 | 70 | multiline: ()-> cmd.toggleMultiLine(true) if chrome.isOpen() 71 | "toggle-console": () -> cmd.toggleMultiLine() if chrome.isOpen() 72 | 73 | #action with console editor 74 | clear: ()-> fb.Console.clear() if chrome.isOpen() 75 | run: () -> cmd.enter(fb.currentContext) if chrome.isOpen() 76 | 77 | #navigation 78 | 'tab': (panelName = "console") -> chrome.navigate(null,panelName) if chrome.isOpen() 79 | 'tab-side': (panelName) -> chrome.selectSidePanel(panelName) if chrome.isOpen() 80 | '>': () -> chrome.gotoSiblingTab(true) if chrome.isOpen() 81 | '<': () -> chrome.gotoSiblingTab() if chrome.isOpen() 82 | '#': () -> chrome.gotoPreviousTab() if chrome.isOpen() 83 | #search 84 | '/': (text...) -> 85 | if chrome.isOpen() 86 | fb.Search.focus fb.currentContext 87 | fb.Search.search(text.join(' '), fb.currentContext) 88 | #initialize 89 | _initialize: () -> 90 | fb = global.Firebug 91 | chrome = fb.chrome 92 | cmd = fb.CommandLine 93 | 94 | @behave() 95 | } 96 | 97 | #declare in pentadactyl 98 | group.commands.add ['firebug', 'fbpc'], "firebug-pentadactyl (version #{firebug.info.version})", (args) -> 99 | #Firebug may load after pentadactyl 100 | #I think so. 101 | unless chrome then firebug._initialize() 102 | 103 | firebug[command].apply firebug, args[index+1..] for command, index in args when firebug[command] 104 | ,{ 105 | completer: (context)-> context.completions = ([name,firebug.info[name]] for name of firebug when name isnt 'info' or name.indexOf('_')) 106 | } 107 | 108 | group.options.add ["fbliverun"], "run script on blur firebug console","boolean",false, 109 | setter: (value)-> 110 | unless cmd then firebug._initialize() 111 | 112 | cmEditor = cmd.getCommandEditor() 113 | 114 | if value then cmEditor.editor.addEventListener('blur', firebug.run) 115 | else if not value then cmEditor.editor.removeEventListener('blur', firebug.run) 116 | -------------------------------------------------------------------------------- /firebug-coffee.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.3.3 2 | (function() { 3 | "use strict"; 4 | 5 | var chrome, cmd, fb, firebug, global, 6 | __slice = [].slice; 7 | 8 | global = window; 9 | 10 | fb = global.Firebug; 11 | 12 | chrome = fb.chrome; 13 | 14 | cmd = fb.CommandLine; 15 | 16 | firebug = { 17 | info: { 18 | version: '0.1.3', 19 | open: "open firebug window", 20 | close: "minimize firebug window", 21 | toggle: "toggle firebug window", 22 | disable: "exit from firebug", 23 | console: "open console and set focus", 24 | multiline: "multiline console", 25 | "toggle-console": "toggle between one-line and multiline console", 26 | clear: "clear console output window", 27 | run: "run script that was entered in console editor", 28 | 'tab': "focuses the specified firebug tab (console, html, stylesheet, script, dom, net, etc)", 29 | 'tab-side': "focuses the specified firebug side tab (css, computed, layout, dom, domSide, watch)", 30 | '>': "focuses the next firebug tab(right)", 31 | '<': "focuses the next firebug tab(left)", 32 | '#': "focuses the prev firebug tab", 33 | '/': "search", 34 | inspect: "toggle the firebug element inspector", 35 | behave: "use Behave.js for console (like auto-pairs)" 36 | }, 37 | open: function() { 38 | if (!chrome.isOpen()) { 39 | return fb.toggleBar(true, 'console'); 40 | } 41 | }, 42 | close: function() { 43 | if (chrome.isOpen()) { 44 | return fb.toggleBar(); 45 | } 46 | }, 47 | toggle: function() { 48 | return fb.toggleBar(); 49 | }, 50 | disable: function() { 51 | return fb.closeFirebug(true); 52 | }, 53 | inspect: function() { 54 | if (!fb.currentContext) { 55 | fb.toggleBar(true); 56 | } 57 | return fb.Inspector.toggleInspecting(fb.currentContext); 58 | }, 59 | behave: function() { 60 | if (this._editor) { 61 | this._editor.destroy(); 62 | this._editor = null; 63 | return; 64 | } 65 | if (!this._editor && cmd && dactyl.plugins && dactyl.plugins.Behave) { 66 | return this._editor = new dactyl.plugins.Behave({ 67 | textarea: cmd.getCommandEditor().editor.textBox 68 | }); 69 | } 70 | }, 71 | console: function() { 72 | var cmEditor, cmLine; 73 | if (!chrome.isOpen()) { 74 | this.open(); 75 | } 76 | chrome.switchToPanel(fb.currentContext, "console"); 77 | cmLine = cmd.getSingleRowCommandLine(); 78 | cmEditor = cmd.getCommandEditor(); 79 | if (fb.commandEditor) { 80 | if (cmEditor.focus) { 81 | return cmEditor.focus(); 82 | } else { 83 | return cmEditor.select(); 84 | } 85 | } else { 86 | return cmLine.select(); 87 | } 88 | }, 89 | multiline: function() { 90 | if (chrome.isOpen()) { 91 | return cmd.toggleMultiLine(true); 92 | } 93 | }, 94 | "toggle-console": function() { 95 | if (chrome.isOpen()) { 96 | return cmd.toggleMultiLine(); 97 | } 98 | }, 99 | clear: function() { 100 | if (chrome.isOpen()) { 101 | return fb.Console.clear(); 102 | } 103 | }, 104 | run: function() { 105 | if (chrome.isOpen()) { 106 | return cmd.enter(fb.currentContext); 107 | } 108 | }, 109 | 'tab': function(panelName) { 110 | if (panelName == null) { 111 | panelName = "console"; 112 | } 113 | if (chrome.isOpen()) { 114 | return chrome.navigate(null, panelName); 115 | } 116 | }, 117 | 'tab-side': function(panelName) { 118 | if (chrome.isOpen()) { 119 | return chrome.selectSidePanel(panelName); 120 | } 121 | }, 122 | '>': function() { 123 | if (chrome.isOpen()) { 124 | return chrome.gotoSiblingTab(true); 125 | } 126 | }, 127 | '<': function() { 128 | if (chrome.isOpen()) { 129 | return chrome.gotoSiblingTab(); 130 | } 131 | }, 132 | '#': function() { 133 | if (chrome.isOpen()) { 134 | return chrome.gotoPreviousTab(); 135 | } 136 | }, 137 | '/': function() { 138 | var text; 139 | text = 1 <= arguments.length ? __slice.call(arguments, 0) : []; 140 | if (chrome.isOpen()) { 141 | fb.Search.focus(fb.currentContext); 142 | return fb.Search.search(text.join(' '), fb.currentContext); 143 | } 144 | }, 145 | _initialize: function() { 146 | fb = global.Firebug; 147 | chrome = fb.chrome; 148 | cmd = fb.CommandLine; 149 | return this.behave(); 150 | } 151 | }; 152 | 153 | group.commands.add(['firebug', 'fbpc'], "firebug-pentadactyl (version " + firebug.info.version + ")", function(args) { 154 | var command, index, _i, _len, _results; 155 | if (!chrome) { 156 | firebug._initialize(); 157 | } 158 | _results = []; 159 | for (index = _i = 0, _len = args.length; _i < _len; index = ++_i) { 160 | command = args[index]; 161 | if (firebug[command]) { 162 | _results.push(firebug[command].apply(firebug, args.slice(index + 1))); 163 | } 164 | } 165 | return _results; 166 | }, { 167 | completer: function(context) { 168 | var name; 169 | return context.completions = (function() { 170 | var _results; 171 | _results = []; 172 | for (name in firebug) { 173 | if (name !== 'info' || name.indexOf('_')) { 174 | _results.push([name, firebug.info[name]]); 175 | } 176 | } 177 | return _results; 178 | })(); 179 | } 180 | }); 181 | 182 | group.options.add(["fbliverun"], "run script on blur firebug console", "boolean", false, { 183 | setter: function(value) { 184 | var cmEditor; 185 | if (!cmd) { 186 | firebug._initialize(); 187 | } 188 | cmEditor = cmd.getCommandEditor(); 189 | if (value) { 190 | return cmEditor.editor.addEventListener('blur', firebug.run); 191 | } else if (!value) { 192 | return cmEditor.editor.removeEventListener('blur', firebug.run); 193 | } 194 | } 195 | }); 196 | 197 | }).call(this); 198 | --------------------------------------------------------------------------------