From 3f75512de28f1866e998edc4dee39d1bfbd1992d Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Fri, 22 Nov 2013 15:02:57 -0800 Subject: [PATCH] Tooltips can now override the default options --- src/space-pen-extensions.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/space-pen-extensions.coffee b/src/space-pen-extensions.coffee index 7808f077b..8374d55a3 100644 --- a/src/space-pen-extensions.coffee +++ b/src/space-pen-extensions.coffee @@ -22,6 +22,7 @@ tooltipDefaults = container: 'body' html: true placement: 'auto top' + viewportPadding: 2 modifiers = cmd: '⌘' @@ -60,16 +61,20 @@ getKeystroke = (bindings) -> "#{replaceModifiers(bindings[0].keystroke)}" else '' - -jQuery.fn.setTooltip = (title, {command, commandElement}={}) -> +# options from http://getbootstrap.com/javascript/#tooltips +jQuery.fn.setTooltip = (tooltipOptions, {command, commandElement}={}) -> atom.requireWithGlobals('bootstrap/js/tooltip', {jQuery}) + tooltipOptions = {title: tooltipOptions} if _.isString(tooltipOptions) + bindings = if commandElement atom.keymap.keyBindingsForCommandMatchingElement(command, commandElement) else atom.keymap.keyBindingsForCommand(command) - this.tooltip(jQuery.extend(tooltipDefaults, {title: "#{title} #{getKeystroke(bindings)}"})) + tooltipOptions.title = "#{tooltipOptions.title} #{getKeystroke(bindings)}" + + this.tooltip(jQuery.extend(tooltipDefaults, tooltipOptions)) jQuery.fn.setTooltip.getKeystroke = getKeystroke jQuery.fn.setTooltip.replaceModifiers = replaceModifiers