Last active
December 31, 2015 00:39
-
-
Save BFalkner/7909001 to your computer and use it in GitHub Desktop.
Ember and Bootstrap Popup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
popup-link value="Click Me" placement="bottom" | |
| Hey there. | |
a click="hide target='popover'" href="#" Close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.PopupLinkComponent = Ember.Component.extend | |
tagName: 'a' | |
value: 'Popup' | |
animation: true | |
placement: 'right' | |
on: 'click' | |
title: '' | |
showDelay: 0 | |
hideDelay: 0 | |
delay: ((key, value) -> | |
if value? | |
@set 'showDelay', value | |
@set 'hideDelay', value | |
{ | |
show: @get 'showDelay' | |
hide: @get 'hideDelay' | |
} | |
).property('showDelay', 'hideDelay') | |
containerElement: false | |
didInsertElement: -> | |
template = @get 'template' | |
parentView = @_parentView | |
context = parentView.get 'context' | |
controller = parentView.get 'controller' | |
keywords = parentView.cloneKeywords() | |
keywords.popover = @ | |
contentView = @createChildView Ember.View, | |
isVirtual: true | |
template: template | |
context: context | |
controller: controller | |
templateData: | |
keywords: keywords | |
@$().popover | |
html: true | |
content: contentView | |
animation: @get 'animation' | |
placement: @get 'placement' | |
trigger: @get 'on' | |
title: @get 'title' | |
delay: @get 'delay' | |
container: @get 'containerElement' | |
popover = @$().data 'bs.popover' | |
popover.setContent = -> | |
$tip = @tip() | |
title = @getTitle() | |
contentView = @getContent() | |
$tip.find('.popover-title').text(title) | |
$tip.find('.popover-title').hide() unless title | |
contentView.createElement() | |
contentView.$().appendTo $tip.find('.popover-content').empty() | |
contentView.rerender() | |
$tip.removeClass 'fade top bottom left right in' | |
@$().on 'hide.bs.popover', -> | |
popover.tip().one $.support.transition.end, -> | |
popover.tip().detach() | |
willDestroyElement: -> | |
@$().popover 'destroy' | |
actions: | |
show: -> | |
@$().popover 'show' | |
hide: -> | |
@$().popover 'hide' | |
toggle: -> | |
@$().popover 'toggle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment