mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 00:40:56 -05:00
Fix SpellPaletteView's popover Ace
This commit is contained in:
parent
7f2d3d8b57
commit
b4fe0a3bee
1 changed files with 22 additions and 14 deletions
|
@ -47,22 +47,29 @@ module.exports = class SpellPaletteEntryView extends CocoView
|
|||
Backbone.Mediator.publish 'tome:palette-hovered', thang: @thang, prop: @doc.name, entry: @
|
||||
soundIndex = Math.floor(Math.random() * 4)
|
||||
@playSound "spell-palette-entry-open-#{soundIndex}", 0.75
|
||||
popover = @$el.data('bs.popover')
|
||||
popover?.$tip?.i18n()
|
||||
codeLanguage = @options.language
|
||||
oldEditor.destroy() for oldEditor in @aceEditors
|
||||
@aceEditors = []
|
||||
aceEditors = @aceEditors
|
||||
# Initialize Ace for each popover code snippet
|
||||
popover?.$tip?.find('.docs-ace').each ->
|
||||
aceEditor = utils.initializeACE @, codeLanguage
|
||||
aceEditors.push aceEditor
|
||||
@afterRenderPopover()
|
||||
|
||||
onMouseEnter: (e) ->
|
||||
# Make sure the doc has the updated Thang so it can regenerate its prop value
|
||||
# NOTE: This can't be run twice without resetting the popover content HTML
|
||||
# in between. If you do, Ace will break.
|
||||
afterRenderPopover: ->
|
||||
popover = @$el.data('bs.popover')
|
||||
popover?.$tip?.i18n()
|
||||
codeLanguage = @options.language
|
||||
oldEditor.destroy() for oldEditor in @aceEditors
|
||||
@aceEditors = []
|
||||
aceEditors = @aceEditors
|
||||
# Initialize Ace for each popover code snippet that still needs it
|
||||
popover?.$tip?.find('.docs-ace').each ->
|
||||
aceEditor = utils.initializeACE @, codeLanguage
|
||||
aceEditors.push aceEditor
|
||||
|
||||
resetPopoverContent: ->
|
||||
@$el.data('bs.popover').options.content = @docFormatter.formatPopover()
|
||||
@$el.popover('setContent')
|
||||
@$el.popover 'show' unless @popoverPinned or @otherPopoverPinned
|
||||
|
||||
onMouseEnter: (e) ->
|
||||
@resetPopoverContent()
|
||||
@$el.popover 'show'
|
||||
|
||||
onMouseLeave: (e) ->
|
||||
@$el.popover 'hide' unless @popoverPinned or @otherPopoverPinned
|
||||
|
@ -76,8 +83,9 @@ module.exports = class SpellPaletteEntryView extends CocoView
|
|||
@playSound 'spell-palette-entry-unpin'
|
||||
else
|
||||
@popoverPinned = true
|
||||
@$el.popover 'show'
|
||||
@resetPopoverContent()
|
||||
@$el.add('.spell-palette-popover.popover').addClass 'pinned'
|
||||
@$el.popover 'show'
|
||||
x = $('<button type="button" data-dismiss="modal" aria-hidden="true" class="close">×</button>')
|
||||
$('.spell-palette-popover.popover').append x
|
||||
x.on 'click', @onClick
|
||||
|
|
Loading…
Reference in a new issue