js/bootstrap-popover.js
changeset 0 ba8ab09f730e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/bootstrap-popover.js	Fri Jul 04 16:42:41 2014 +0400
     1.3 @@ -0,0 +1,114 @@
     1.4 +/* ===========================================================
     1.5 + * bootstrap-popover.js v2.3.1
     1.6 + * http://twitter.github.com/bootstrap/javascript.html#popovers
     1.7 + * ===========================================================
     1.8 + * Copyright 2012 Twitter, Inc.
     1.9 + *
    1.10 + * Licensed under the Apache License, Version 2.0 (the "License");
    1.11 + * you may not use this file except in compliance with the License.
    1.12 + * You may obtain a copy of the License at
    1.13 + *
    1.14 + * http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing, software
    1.17 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.18 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.19 + * See the License for the specific language governing permissions and
    1.20 + * limitations under the License.
    1.21 + * =========================================================== */
    1.22 +
    1.23 +
    1.24 +!function ($) {
    1.25 +
    1.26 +  "use strict"; // jshint ;_;
    1.27 +
    1.28 +
    1.29 + /* POPOVER PUBLIC CLASS DEFINITION
    1.30 +  * =============================== */
    1.31 +
    1.32 +  var Popover = function (element, options) {
    1.33 +    this.init('popover', element, options)
    1.34 +  }
    1.35 +
    1.36 +
    1.37 +  /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
    1.38 +     ========================================== */
    1.39 +
    1.40 +  Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
    1.41 +
    1.42 +    constructor: Popover
    1.43 +
    1.44 +  , setContent: function () {
    1.45 +      var $tip = this.tip()
    1.46 +        , title = this.getTitle()
    1.47 +        , content = this.getContent()
    1.48 +
    1.49 +      $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
    1.50 +      $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
    1.51 +
    1.52 +      $tip.removeClass('fade top bottom left right in')
    1.53 +    }
    1.54 +
    1.55 +  , hasContent: function () {
    1.56 +      return this.getTitle() || this.getContent()
    1.57 +    }
    1.58 +
    1.59 +  , getContent: function () {
    1.60 +      var content
    1.61 +        , $e = this.$element
    1.62 +        , o = this.options
    1.63 +
    1.64 +      content = (typeof o.content == 'function' ? o.content.call($e[0]) :  o.content)
    1.65 +        || $e.attr('data-content')
    1.66 +
    1.67 +      return content
    1.68 +    }
    1.69 +
    1.70 +  , tip: function () {
    1.71 +      if (!this.$tip) {
    1.72 +        this.$tip = $(this.options.template)
    1.73 +      }
    1.74 +      return this.$tip
    1.75 +    }
    1.76 +
    1.77 +  , destroy: function () {
    1.78 +      this.hide().$element.off('.' + this.type).removeData(this.type)
    1.79 +    }
    1.80 +
    1.81 +  })
    1.82 +
    1.83 +
    1.84 + /* POPOVER PLUGIN DEFINITION
    1.85 +  * ======================= */
    1.86 +
    1.87 +  var old = $.fn.popover
    1.88 +
    1.89 +  $.fn.popover = function (option) {
    1.90 +    return this.each(function () {
    1.91 +      var $this = $(this)
    1.92 +        , data = $this.data('popover')
    1.93 +        , options = typeof option == 'object' && option
    1.94 +      if (!data) $this.data('popover', (data = new Popover(this, options)))
    1.95 +      if (typeof option == 'string') data[option]()
    1.96 +    })
    1.97 +  }
    1.98 +
    1.99 +  $.fn.popover.Constructor = Popover
   1.100 +
   1.101 +  $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
   1.102 +    placement: 'right'
   1.103 +  , trigger: 'click'
   1.104 +  , content: ''
   1.105 +  , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
   1.106 +  })
   1.107 +
   1.108 +
   1.109 + /* POPOVER NO CONFLICT
   1.110 +  * =================== */
   1.111 +
   1.112 +  $.fn.popover.noConflict = function () {
   1.113 +    $.fn.popover = old
   1.114 +    return this
   1.115 +  }
   1.116 +
   1.117 +}(window.jQuery);