1/* =========================================================== 2 * bootstrap-tooltip.js v2.1.1 3 * http://twitter.github.com/bootstrap/javascript.html#tooltips 4 * Inspired by the original jQuery.tipsy by Jason Frame 5 * =========================================================== 6 * Copyright 2012 Twitter, Inc. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 * ========================================================== */ 20 21 22!function ($) { 23 24 "use strict"; // jshint ;_; 25 26 27 /* TOOLTIP PUBLIC CLASS DEFINITION 28 * =============================== */ 29 30 var Tooltip = function (element, options) { 31 this.init('tooltip', element, options) 32 } 33 34 Tooltip.prototype = { 35 36 constructor: Tooltip 37 38 , init: function (type, element, options) { 39 var eventIn 40 , eventOut 41 42 this.type = type 43 this.$element = $(element) 44 this.options = this.getOptions(options) 45 this.enabled = true 46 47 if (this.options.trigger == 'click') { 48 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) 49 } else if (this.options.trigger != 'manual') { 50 eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' 51 eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur' 52 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) 53 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) 54 } 55 56 this.options.selector ? 57 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : 58 this.fixTitle() 59 } 60 61 , getOptions: function (options) { 62 options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data()) 63 64 if (options.delay && typeof options.delay == 'number') { 65 options.delay = { 66 show: options.delay 67 , hide: options.delay 68 } 69 } 70 71 return options 72 } 73 74 , enter: function (e) { 75 var self = $(e.currentTarget)[this.type](this._options).data(this.type) 76 77 clearTimeout(this.removeTimeout) 78 if (!self.options.delay || !self.options.delay.show) return self.show() 79 80 clearTimeout(this.timeout) 81 self.hoverState = 'in' 82 this.timeout = setTimeout(function() { 83 if (self.hoverState == 'in') self.show() 84 }, self.options.delay.show) 85 } 86 87 , leave: function (e) { 88 var self = $(e.currentTarget)[this.type](this._options).data(this.type) 89 90 if (this.timeout) clearTimeout(this.timeout) 91 if (!self.options.delay || !self.options.delay.hide) return self.hide() 92 93 self.hoverState = 'out' 94 this.timeout = setTimeout(function() { 95 if (self.hoverState == 'out') self.hide() 96 }, self.options.delay.hide) 97 } 98 99 , show: function () { 100 var $tip 101 , inside 102 , pos 103 , actualWidth 104 , actualHeight 105 , placement 106 , tp 107 108 if (this.hasContent() && this.enabled) { 109 $tip = this.tip() 110 this.setContent() 111 112 if (this.options.animation) { 113 $tip.addClass('fade') 114 } 115 116 placement = typeof this.options.placement == 'function' ? 117 this.options.placement.call(this, $tip[0], this.$element[0]) : 118 this.options.placement 119 120 inside = /in/.test(placement) 121 122 $tip 123 .remove() 124 .css({ top: 0, left: 0, display: 'block' }) 125 .appendTo(inside ? this.$element : document.body) 126 127 pos = this.getPosition(inside) 128 129 actualWidth = $tip[0].offsetWidth 130 actualHeight = $tip[0].offsetHeight 131 132 switch (inside ? placement.split(' ')[1] : placement) { 133 case 'bottom': 134 tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2} 135 break 136 case 'top': 137 tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2} 138 break 139 case 'left': 140 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth} 141 break 142 case 'right': 143 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width} 144 break 145 } 146 147 $tip 148 .css(tp) 149 .addClass(placement) 150 .addClass('in') 151 } 152 } 153 154 , setContent: function () { 155 var $tip = this.tip() 156 , title = this.getTitle() 157 158 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) 159 $tip.removeClass('fade in top bottom left right') 160 } 161 162 , hide: function () { 163 var that = this 164 , $tip = this.tip() 165 166 $tip.removeClass('in') 167 168 function removeWithAnimation() { 169 that.removeTimeout = setTimeout(function () {
170 $tip.off($.support.transition.end).remove() 171 }, 500) 172 173 $tip.one($.support.transition.end, function () { 174 clearTimeout(that.removeTimeout) 175 $tip.remove() 176 }) 177 } 178 179 $.support.transition && this.$tip.hasClass('fade') ? 180 removeWithAnimation() : 181 $tip.remove() 182 183 return this 184 } 185 186 , fixTitle: function () { 187 var $e = this.$element 188 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { 189 $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title') 190 } 191 } 192 193 , hasContent: function () { 194 return this.getTitle() 195 } 196 197 , getPosition: function (inside) { 198 return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), { 199 width: this.$element[0].offsetWidth 200 , height: this.$element[0].offsetHeight 201 }) 202 } 203 204 , getTitle: function () { 205 var title 206 , $e = this.$element 207 , o = this.options 208 209 title = $e.attr('data-original-title') 210 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) 211 212 return title 213 } 214 215 , tip: function () { 216 return this.$tip = this.$tip || $(this.options.template) 217 } 218 219 , validate: function () { 220 if (!this.$element[0].parentNode) { 221 this.hide() 222 this.$element = null 223 this.options = null 224 } 225 } 226 227 , enable: function () { 228 this.enabled = true 229 } 230 231 , disable: function () { 232 this.enabled = false 233 } 234 235 , toggleEnabled: function () { 236 this.enabled = !this.enabled 237 } 238 239 , toggle: function () { 240 this[this.tip().hasClass('in') ? 'hide' : 'show']() 241 } 242 243 , destroy: function () { 244 this.hide().$element.off('.' + this.type).removeData(this.type) 245 } 246 247 } 248 249 250 /* TOOLTIP PLUGIN DEFINITION 251 * ========================= */ 252 253 $.fn.tooltip = function ( option ) { 254 return this.each(function () { 255 var $this = $(this) 256 , data = $this.data('tooltip') 257 , options = typeof option == 'object' && option 258 if (!data) $this.data('tooltip', (data = new Tooltip(this, options))) 259 if (typeof option == 'string') data[option]() 260 }) 261 } 262 263 $.fn.tooltip.Constructor = Tooltip 264 265 $.fn.tooltip.defaults = { 266 animation: true 267 , placement: 'top' 268 , selector: false 269 , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' 270 , trigger: 'hover' 271 , title: '' 272 , delay: 0 273 , html: true 274 } 275 276}(window.jQuery); 277 278 279jQuery(document).ready(function($) { 280 281 $('.meta-category a, .meta-author a').tooltip({placement: 'top'}); 282 $('.tooltips').tooltip({ selector: "a[rel=tooltip]" }); 283 $('#topbar .social-icons a').tooltip({placement: 'bottom', animation: true}); 284 $('.sharebox .social-icons a').tooltip({placement: 'top'}); 285 $('.member-social a').tooltip({placement: 'top'}); 286 $('#copyright .social-icons a').tooltip({placement: 'top'}); 287 $('.social-icon a').tooltip({placement: 'top'}); 288 $('.portfolio-widget-item a').tooltip({placement: 'bottom'}); 289 $('#header-cart').tooltip({placement: 'top'}); 290 291});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.