]> git.gir.st - VimFx.git/blob - bootstrap.coffee
Added preferences, some refactoring, hint char hundling bug fixing
[VimFx.git] / bootstrap.coffee
1 "use strict"
2
3 { utils: Cu } = Components
4
5 Cu.import "resource://gre/modules/Services.jsm"
6
7 # Populate the global namespace with console, require, and include
8 do (global = this) ->
9 baseURI = Services.io.newURI __SCRIPT_URI_SPEC__, null, null
10
11 include = (src, scope = {}) ->
12 try
13 uri = Services.io.newURI "packages/#{ src }.js", null, baseURI
14 Services.scriptloader.loadSubScript uri.spec, scope
15 catch error
16 uri = Services.io.newURI src, null, baseURI
17 Services.scriptloader.loadSubScript uri.spec, scope
18
19 return scope
20
21
22 modules = {}
23 require = (src) ->
24 if modules[src]
25 return modules[src]
26 else
27 scope =
28 require: require
29 include: include
30 exports: {}
31
32 include src, scope
33
34 return modules[src] = scope.exports;
35
36 global.include = include
37 global.require = require
38
39 # Include into global scope
40 include("includes/#{ name }.js", this) for name in [
41 'chrome',
42 'console',
43 'unload',
44 'window-utils',
45 ]
46
47 { loadCss } = require 'utils'
48 { watcher } = require 'event-handlers'
49 { getPref
50 , installPrefObserver } = require 'prefs'
51
52 # Firefox will call this method on startup/enabling
53 startup = (data, reason) ->
54 loadCss 'vimff'
55 watchWindows watcher, 'navigator:browser'
56 installPrefObserver()
57
58 # Firefox will call this method on shutdown/disabling
59 shutdown = (data, reason) ->
60 # Don't bother to clean up if the browser is shutting down
61 if reason != APP_SHUTDOWN
62 unload()
Imprint / Impressum