From 34ca5d4014c0fc3bdbc7469a13ee7cbeab4bcba4 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 17 May 2014 23:00:04 -0700 Subject: [PATCH] Tooltips shouldn't stay visible after clicking --- src/UI/Shared/Tooltip.js | 28 ++++++++++++++++++++++++++++ src/UI/app.js | 15 +++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/UI/Shared/Tooltip.js diff --git a/src/UI/Shared/Tooltip.js b/src/UI/Shared/Tooltip.js new file mode 100644 index 000000000..11906faf9 --- /dev/null +++ b/src/UI/Shared/Tooltip.js @@ -0,0 +1,28 @@ +'use strict'; +define( + [ + 'jquery' + ], function ($) { + return { + + appInitializer: function () { + console.log('starting signalR'); + + $('body').tooltip({ + selector: '[title]', + container: 'body' + }); + + $(document).click(function(e) { + + if ($(e.target).attr('title') !== undefined) { + return; + } + + $('.tooltip').remove(); + }); + + return this; + } + }; + }); diff --git a/src/UI/app.js b/src/UI/app.js index a54198702..016761351 100644 --- a/src/UI/app.js +++ b/src/UI/app.js @@ -68,13 +68,7 @@ require.config({ deps: [ 'jquery' - ], - init: function ($) { - $('body').tooltip({ - selector: '[title]', - container: 'body' - }); - } + ] }, backstrech : { deps: @@ -249,9 +243,10 @@ define( 'Shared/Modal/ModalController', 'Shared/ControlPanel/ControlPanelController', 'System/StatusModel', + 'Shared/Tooltip', 'Instrumentation/StringFormat', 'LifeCycle' - ], function ($, Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController, ControlPanelController, serverStatusModel) { + ], function ($, Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController, ControlPanelController, serverStatusModel, Tooltip) { new SeriesController(); new ModalController(); @@ -268,6 +263,10 @@ define( app: app }); + app.addInitializer(Tooltip.appInitializer, { + app: app + }); + app.addInitializer(function () { Backbone.history.start({ pushState: true, root: serverStatusModel.get('urlBase') }); RouteBinder.bind();