Add a general 'ide:loaded' event, to init popover

This commit is contained in:
Shane Kilkelly 2017-11-09 15:12:55 +00:00
parent 470ad36218
commit 766c8d6f0f
2 changed files with 12 additions and 4 deletions

View file

@ -171,6 +171,16 @@ define [
, 200
)
# Count the first 'doc:opened' as a sign that the ide is loaded
# and broadcast a message. This is a good event to listen for
# if you want to wait until the ide is fully loaded and initialized
_loaded = false
$scope.$on 'doc:opened', () ->
if _loaded
return
$scope.$broadcast('ide:loaded')
_loaded = true
DARK_THEMES = [
"ambiance", "chaos", "clouds_midnight", "cobalt", "idle_fingers",
"merbivore", "merbivore_soft", "mono_industrial", "monokai",

View file

@ -2,7 +2,6 @@ define [
"base"
], (App) ->
App.controller "LinkSharingOnboardingController", ($scope, $timeout, event_tracking) ->
$scope._shown = false
popover = angular.element('#onboarding-linksharing')
popover.hide()
@ -11,8 +10,8 @@ define [
$scope.onboarding.linkSharing = 'dismissed'
event_tracking.sendMB "shown-linksharing-onboarding"
$scope.$on 'doc:opened', () ->
return if $scope._shown
$scope.$on 'ide:loaded', () ->
console.log ">> woot"
shareBtn = angular.element('#shareButton')
offset = shareBtn.offset()
popover.show()
@ -21,4 +20,3 @@ define [
top: offset.top + 8 + shareBtn.height(),
left: offset.left
})
$scope.shown = true