Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Is it possible to hide/show popover instead of adding and removing it?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jamie Johnson  
View profile  
 More options Nov 13 2012, 12:38 pm
From: Jamie Johnson <jej2...@gmail.com>
Date: Tue, 13 Nov 2012 09:38:51 -0800 (PST)
Local: Tues, Nov 13 2012 12:38 pm
Subject: Is it possible to hide/show popover instead of adding and removing it?

I am wondering if it's possible to not remove a tooltip on hide and instead
just set it's visibility to none.  I'm currently manually hiding/showing
the popover element which works, but I am wondering if there is something
built in that can be used to do this.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jamie Johnson  
View profile  
 More options Nov 13 2012, 1:07 pm
From: Jamie Johnson <jej2...@gmail.com>
Date: Tue, 13 Nov 2012 10:07:11 -0800 (PST)
Local: Tues, Nov 13 2012 1:07 pm
Subject: Re: Is it possible to hide/show popover instead of adding and removing it?

I slightly modified PopOver to do what I want, not sure if it's the best
way or not, but my very simple tests worked fine.  The real difference is
adding the popover content to the document in the constructor (maybe should
be init?) and then just showing/hiding the tip instead of adding and
removing it.  Code shown below.  Any thoughts?  

!function ($) {

  "use strict"; // jshint ;_;

 /* POPOVEREX PUBLIC CLASS DEFINITION

  * =============================== */

  var PopoverEx = function (element, options) {

    this.init('popoverex', element, options)

    var $tip,

        placement,

        inside

    $tip = this.tip()

    this.setContent()

    placement = typeof this.options.placement == 'function' ?

          this.options.placement.call(this, $tip[0], this.$element[0]) :

          this.options.placement

        inside = /in/.test(placement)

    $tip

        .remove()

        .css({ top: 0, left: 0, display: 'block' })

        .appendTo(inside ? this.$element : document.body).hide()

  }

  /* NOTE: POPOVEREX EXTENDS BOOTSTRAP-POPOVER.js

     ========================================== */

  PopoverEx.prototype = $.extend({}, $.fn.popover.Constructor.prototype, {

    constructor: PopoverEx

  , show: function () {

      var $tip

        , inside

        , pos

        , actualWidth

        , actualHeight

        , placement

        , tp

      if (this.hasContent() && this.enabled) {

        $tip = this.tip()

        if (this.options.animation) {

          $tip.addClass('fade')

        }

        placement = typeof this.options.placement == 'function' ?

          this.options.placement.call(this, $tip[0], this.$element[0]) :

          this.options.placement

        inside = /in/.test(placement)

        $tip.show()

        pos = this.getPosition(inside)

        actualWidth = $tip[0].offsetWidth

        actualHeight = $tip[0].offsetHeight

        switch (inside ? placement.split(' ')[1] : placement) {

          case 'bottom':

            tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 -
actualWidth / 2}

            break

          case 'top':

            tp = {top: pos.top - actualHeight, left: pos.left + pos.width /
2 - actualWidth / 2}

            break

          case 'left':

            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left:
pos.left - actualWidth}

            break

          case 'right':

            tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left:
pos.left + pos.width}

            break

        }

        $tip

          .css(tp)

          .addClass(placement)

          .addClass('in')

      }

    }

    , hide: function () {

      var that = this

        , $tip = this.tip()

      $tip.removeClass('in')

      function removeWithAnimation() {

        var timeout = setTimeout(function () {

          $tip.off($.support.transition.end).hide()

        }, 500)

        $tip.one($.support.transition.end, function () {

          clearTimeout(timeout)

          $tip.hide()

        })

      }

      $.support.transition && this.$tip.hasClass('fade') ?

        removeWithAnimation() :

        $tip.hide()

      return this

    }

  })

 /* POPOVEREX PLUGIN DEFINITION

  * ======================= */

  $.fn.popoverex = function (option) {

    return this.each(function () {

      var $this = $(this)

        , data = $this.data('popover')

        , options = typeof option == 'object' && option

      if (!data) $this.data('popover', (data = new PopoverEx(this,
options)))

      if (typeof option == 'string') data[option]()

    })

  }

  $.fn.popoverex.Constructor = PopoverEx

  $.fn.popoverex.defaults = $.extend({} , $.fn.popover.defaults, {

    placement: 'right'

  , trigger: 'click'

  , content: ''

  , template: '<div class="popover"><div class="arrow"></div><div
class="popover-inner"><h3 class="popover-title"></h3><div
class="popover-content"><p></p></div></div></div>'

  })


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »