lib/assets/javascripts/tao/ui/popover/element.coffee in tao_ui-0.2.3 vs lib/assets/javascripts/tao/ui/popover/element.coffee in tao_ui-0.2.4

- old
+ new

@@ -11,21 +11,26 @@ @attribute 'targetSelector', 'targetTraversal', 'triggerSelector', 'triggerTraversal' @attribute 'triggerAction', default: 'click' - @attribute 'boundarySelector', 'direction', 'arrowAlign', 'arrowVerticalAlign' + @attribute 'boundarySelector', 'direction', 'size' + @attribute 'arrowAlign', default: 'center' + + @attribute 'arrowVerticalAlign', default: 'middle' + @attribute 'offset', type: 'number', default: 0 @attribute 'autoHide', type: 'boolean' @attribute 'autoDestroy', type: 'boolean' _connected: -> @_initTarget() @_initTrigger() + @_initSize() @_activeChanged() if @active _initTarget: -> @target = if @targetTraversal && @targetSelector @jq[@targetTraversal]?(@targetSelector) @@ -47,10 +52,13 @@ @triggerEl.on 'mouseenter.tao-popover', (e) => @active = true .on 'mouseleave.tao-popover', (e) => @active = false + _initSize: -> + @jq.width(@size) if @size + _activeChanged: -> if @active @refresh() @_enableAutoHide() if @autoHide @trigger 'tao:show' @@ -63,10 +71,11 @@ $(document).on "mousedown.tao-popover-#{@taoId}", (e) => return unless @active target = $ e.target return if target.is(@target) or @jq.has(target).length or target.is(@) @active = false + null _disableAutoHide: -> $(document).off "mousedown.tao-popover-#{@taoId}" refresh: -> @@ -86,13 +95,15 @@ offset: @offset @jq.css top: @position.top left: @position.left + @ toggleActive: -> @active = !@active + @ beforeCache: -> if @autoDestroy @remove() else @@ -100,9 +111,10 @@ remove: -> @trigger 'tao:beforeRemove' @jq.remove() @trigger 'tao:remove' + @ _disconnected: -> @triggerEl.off '.tao-popover' $(document).off ".tao-popover-#{@taoId}"