Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid errors with undefined populator, selector #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/plugins/oer/popover/lib/popover-plugin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,14 @@ define [ 'aloha', 'jquery' ], (Aloha, jQuery) ->
insideScope = false

Aloha.bind 'aloha-selection-changed', (event, rangeObject) ->
# How this is even possible I do not understand, but apparently it is
# possible for our helper to not be completely initialised at this point.
if not (helper.populator and helper.selector)
return

# Hide all popovers except for the current one maybe?
$el = jQuery(rangeObject.getCommonAncestorContainer())
$el = $el.parents(helper.selector) if not $el.is(helper.selector)
$el = $el.parents(helper.selector).eq(0) if not $el.is(helper.selector)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for .eq(0) instead of .first()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing specific, I just don't have first() near the top of my mental cheatsheet :-) Isn't it the same thing anyway? first() probably reads easier though.


if Aloha.activeEditable
# Hide other tooltips of the same type
Expand All @@ -342,7 +347,7 @@ define [ 'aloha', 'jquery' ], (Aloha, jQuery) ->
if insideScope isnt enteredLinkScope
insideScope = enteredLinkScope
if not $el.is(helper.selector)
$el = $el.parents(helper.selector)
$el = $el.parents(helper.selector).eq(0)
if enteredLinkScope
$el.trigger 'show'
$el.data('aloha-bubble-selected', true)
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/oer/popover/lib/popover-plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.