aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/clipboard.coffee3
-rw-r--r--lib/dom_utils.coffee3
-rw-r--r--lib/find_mode_history.coffee3
-rw-r--r--lib/handler_stack.coffee3
-rw-r--r--lib/keyboard_utils.coffee3
-rw-r--r--lib/rect.coffee3
-rw-r--r--lib/settings.coffee7
-rw-r--r--lib/utils.coffee13
8 files changed, 21 insertions, 17 deletions
diff --git a/lib/clipboard.coffee b/lib/clipboard.coffee
index af143dd9..1d378e76 100644
--- a/lib/clipboard.coffee
+++ b/lib/clipboard.coffee
@@ -25,5 +25,6 @@ Clipboard =
value
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Clipboard = Clipboard
+extend window, root unless exports?
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index ff5991dc..e771d436 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -416,5 +416,6 @@ DomUtils =
style.textContent = Settings.get "userDefinedLinkHintCss"
document.head.appendChild style
-root = exports ? window
+root = exports ? (window.root ?= {})
root.DomUtils = DomUtils
+extend window, root unless exports?
diff --git a/lib/find_mode_history.coffee b/lib/find_mode_history.coffee
index ff660bd2..93698266 100644
--- a/lib/find_mode_history.coffee
+++ b/lib/find_mode_history.coffee
@@ -46,5 +46,6 @@ FindModeHistory =
refreshRawQueryList: (query, rawQueryList) ->
([ query ].concat rawQueryList.filter (q) => q != query)[0..@max]
-root = exports ? window
+root = exports ? (window.root ?= {})
root.FindModeHistory = FindModeHistory
+extend window, root unless exports?
diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee
index 806b707f..2439f55c 100644
--- a/lib/handler_stack.coffee
+++ b/lib/handler_stack.coffee
@@ -1,4 +1,4 @@
-root = exports ? window
+root = exports ? (window.root ?= {})
class HandlerStack
constructor: ->
@@ -120,3 +120,4 @@ class HandlerStack
root.HandlerStack = HandlerStack
root.handlerStack = new HandlerStack()
+extend window, root unless exports?
diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee
index 1a1ea797..681ee139 100644
--- a/lib/keyboard_utils.coffee
+++ b/lib/keyboard_utils.coffee
@@ -101,5 +101,6 @@ KeyboardUtils =
KeyboardUtils.init()
-root = exports ? window
+root = exports ? (window.root ?= {})
root.KeyboardUtils = KeyboardUtils
+extend window, root unless exports?
diff --git a/lib/rect.coffee b/lib/rect.coffee
index d4807cc2..59764d18 100644
--- a/lib/rect.coffee
+++ b/lib/rect.coffee
@@ -91,5 +91,6 @@ Rect =
(rect1, rect2) ->
halfOverlapChecker(rect1, rect2) or halfOverlapChecker rect2, rect1
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Rect = Rect
+extend window, root unless exports?
diff --git a/lib/settings.coffee b/lib/settings.coffee
index 38718990..fd1ef268 100644
--- a/lib/settings.coffee
+++ b/lib/settings.coffee
@@ -202,7 +202,7 @@ Settings.init()
# Perform migration from old settings versions, if this is the background page.
if Utils.isBackgroundPage()
- Settings.onLoaded ->
+ Settings.applyMigrations = ->
unless Settings.get "settingsVersion"
# This is a new install. For some settings, we retain a legacy default behaviour for existing users but
# use a non-default behaviour for new users.
@@ -218,5 +218,8 @@ if Utils.isBackgroundPage()
# be removed after 1.58 has been out for sufficiently long.
Settings.nuke "copyNonDefaultsToChromeStorage-20150717"
-root = exports ? window
+ Settings.onLoaded Settings.applyMigrations.bind Settings
+
+root = exports ? (window.root ?= {})
root.Settings = Settings
+extend window, root unless exports?
diff --git a/lib/utils.coffee b/lib/utils.coffee
index d0a82cf7..6f38be8f 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -32,14 +32,6 @@ Utils =
# Returns true whenever the current page is the extension's background page.
isBackgroundPage: -> @isExtensionPage() and chrome.extension.getBackgroundPage?() == window
- # Takes a dot-notation object string and calls the function that it points to with the correct value for
- # 'this'.
- invokeCommandString: (str, args...) ->
- [names..., name] = str.split '.'
- obj = window
- obj = obj[component] for component in names
- obj[name].apply obj, args
-
# Escape all special characters, so RegExp will parse the string 'as is'.
# Taken from http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
escapeRegexSpecialCharacters: do ->
@@ -335,8 +327,11 @@ class JobRunner
onReady: (callback) ->
@fetcher.use callback
-root = exports ? window
+root = exports ? (window.root ?= {})
root.Utils = Utils
root.SimpleCache = SimpleCache
root.AsyncDataFetcher = AsyncDataFetcher
root.JobRunner = JobRunner
+unless exports?
+ root.extend = extend
+ extend window, root