1/** 2 * @package HikaShop for Joomla! 3 * @version 4.2.2 4 * @author hikashop.com 5 * @copyright (C) 2010-2019 HIKARI SOFTWARE. All rights reserved. 6 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html 7 */ 8if(window.jQuery && typeof(jQuery.noConflict) == "function" && !window.hkjQuery) 9 window.hkjQuery = jQuery.noConflict(); 10 11!function ($) { 12 "use strict"; 13 14/* TOOLTIP PUBLIC CLASS DEFINITION 15 * =============================== */ 16var HKTooltip = function (element, options) { this.init('hktooltip', element, options); }; 17HKTooltip.prototype = { 18 constructor: HKTooltip, 19 20 init: function (type, element, options) { 21 var t = this, eventIn, eventOut, triggers, trigger, i; 22 t.type = type; 23 t.$element = $(element); 24 t.options = t.getOptions(options); 25 t.enabled = true; 26 triggers = t.options.trigger.split(' '); 27 28 for(i = triggers.length; i--;) { 29 trigger = triggers[i]; 30 if (trigger == 'click') { 31 t.$element.on('click.' + t.type, t.options.selector, $.proxy(t.toggle, t)); 32 } else if (trigger != 'manual') { 33 eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'; 34 eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'; 35 t.$element.on(eventIn + '.' + t.type, t.options.selector, $.proxy(t.enter, t)); 36 t.$element.on(eventOut + '.' + t.type, t.options.selector, $.proxy(t.leave, t)); 37 } 38 } 39 40 t.options.selector ? (t._options = $.extend({}, t.options, { trigger: 'manual', selector: '' })) : t.fixTitle(); 41 }, 42 43 getOptions: function (options) { 44 options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options); 45 if (options.delay && typeof options.delay == 'number') { 46 options.delay = { show: options.delay, hide: options.delay }; 47 } 48 return options; 49 }, 50 51 enter: function (e) { 52 var defaults = $.fn[this.type].defaults, options = {}, self; 53 54 this._options && $.each(this._options, function (key, value) { 55 if (defaults[key] != value) options[key] = value; 56 }, this); 57 58 self = $(e.currentTarget)[this.type](options).data(this.type); 59 60 if (!self.options.delay || !self.options.delay.show) return self.show(); 61 62 clearTimeout(this.timeout); 63 self.hoverState = 'in'; 64 this.timeout = setTimeout(function() { 65 if (self.hoverState == 'in') self.show(); 66 }, self.options.delay.show); 67 }, 68 69 leave: function (e) { 70 var self = $(e.currentTarget)[this.type](this._options).data(this.type); 71 72 if (this.timeout) clearTimeout(this.timeout); 73 if (!self.options.delay || !self.options.delay.hide) return self.hide(); 74 75 self.hoverState = 'out'; 76 this.timeout = setTimeout(function() { 77 if (self.hoverState == 'out') self.hide(); 78 }, self.options.delay.hide); 79 }, 80 81 show: function () { 82 var $tip, pos, actualWidth, actualHeight, placement, tp, e = $.Event('show'); 83 84 if (!this.hasContent() || !this.enabled) 85 return; 86 87 this.$element.trigger(e); 88 if (e.isDefaultPrevented()) return; 89 $tip = this.tip(); 90 this.setContent(); 91 92 if (this.options.animation) { 93 $tip.addClass('hkfade'); 94 } 95 96 placement = typeof this.options.placement == 'function' ? 97 this.options.placement.call(this, $tip[0], this.$element[0]) : 98 this.options.placement; 99 100 $tip 101 .detach() 102 .css({ top: 0, left: 0, display: 'block' }); 103 104 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element); 105 106 pos = this.getPosition(); 107 108 actualWidth = $tip[0].offsetWidth; 109 actualHeight = $tip[0].offsetHeight; 110 111 switch (placement) { 112 case 'bottom': 113 tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}; 114 break; 115 case 'top': 116 tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}; 117 break; 118 case 'left': 119 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}; 120 break; 121 case 'right': 122 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}; 123 break; 124 } 125 126 this.applyPlacement(tp, placement); 127 this.$element.trigger('shown'); 128 }, 129 130 applyPlacement: function(offset, placement){ 131 var $tip = this.tip(), width = $tip[0].offsetWidth, height = $tip[0].offsetHeight, actualWidth, actualHeight, delta, replace; 132 133 $tip 134 .offset(offset) 135 .addClass(placement) 136 .addClass('in'); 137 138 actualWidth = $tip[0].offsetWidth; 139 actualHeight = $tip[0].offsetHeight; 140 141 if (placement == 'top' && actualHeight != height) { 142 offset.top = offset.top + height - actualHeight; 143 replace = true; 144 } 145 146 if (placement == 'bottom' || placement == 'top') { 147 delta = 0; 148 149 if (offset.left < 0){ 150 delta = offset.left * -2; 151 offset.left = 0; 152 $tip.offset(offset); 153 actualWidth = $tip[0].offsetWidth; 154 actualHeight = $tip[0].offsetHeight; 155 } 156 157 this.replaceArrow(delta - width + actualWidth, actualWidth, 'left'); 158 } else { 159 this.replaceArrow(actualHeight - height, actualHeight, 'top'); 160 } 161 162 if (replace) $tip.offset(offset); 163 }, 164 165 replaceArrow: function(delta, dimension, position){ 166 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : ''); 167 }, 168 169 setContent: function () { 170 var $tip = this.tip(), title = this.getTitle(); 171 $tip.find('.hk-tooltip-inner')[this.options.html ? 'html' : 'text'](title); 172 $tip.removeClass('hkfade in top bottom left right'); 173 }, 174 175 hide: function () { 176 // var that = this, $tip = this.tip(), e = $.Event('hide'); 177 var that = this, $tip = this.tip(), e = $.Event('hideme'); 178 179 this.$element.trigger(e); 180 if (e.isDefaultPrevented()) return 181 182 $tip.removeClass('in'); 183 184 function removeWithAnimation() { 185 var timeout = setTimeout(function () {
186 $tip.off($.support.transition.end).detach(); 187 }, 500); 188 189 $tip.one($.support.transition.end, function () { 190 clearTimeout(timeout); 191 $tip.detach(); 192 }); 193 } 194 195 $.support.transition && this.$tip.hasClass('hkfade') ? 196 removeWithAnimation() : 197 $tip.detach(); 198 199 this.$element.trigger('hidden'); 200 201 return this; 202 }, 203 204 fixTitle: function () { 205 var $e = this.$element; 206 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { 207 $e.attr('data-original-title', $e.attr('title') || '').attr('title', ''); 208 } 209 }, 210 211 hasContent: function () { return this.getTitle(); }, 212 213 getPosition: function () { 214 var el = this.$element[0]; 215 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { 216 width: el.offsetWidth 217 , height: el.offsetHeight 218 }, this.$element.offset()); 219 }, 220 221 getTitle: function () { 222 var title, $e = this.$element, o = this.options; 223 title = $e.attr('data-original-title') || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title); 224 return title; 225 }, 226 227 tip: function () { return this.$tip = this.$tip || $(this.options.template); }, 228 229 arrow: function() { return this.$arrow = this.$arrow || this.tip().find(".hk-tooltip-arrow"); }, 230 231 validate: function () { 232 if (!this.$element[0].parentNode) { 233 this.hide(); 234 this.$element = null; 235 this.options = null; 236 } 237 }, 238 239 enable: function () { this.enabled = true; }, 240 disable: function () { this.enabled = false; }, 241 toggleEnabled: function () { this.enabled = !this.enabled; }, 242 243 toggle: function (e) { 244 var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this; 245 self.tip().hasClass('in') ? self.hide() : self.show(); 246 }, 247 248 destroy: function () { 249 this.hide().$element.off('.' + this.type).removeData(this.type); 250 } 251}; 252 253 254/* TOOLTIP PLUGIN DEFINITION 255 * ========================= */ 256 257var old = $.fn.hktooltip; 258 259$.fn.hktooltip = function ( option ) { 260 return this.each(function () { 261 var $this = $(this), data = $this.data('hktooltip'), options = typeof option == 'object' && option; 262 if (!data) $this.data('hktooltip', (data = new HKTooltip(this, options))); 263 if (typeof option == 'string') data[option](); 264 }); 265}; 266 267$.fn.hktooltip.Constructor = HKTooltip; 268 269$.fn.hktooltip.defaults = { 270 animation: true, 271 placement: 'top', 272 selector: false, 273 template: '<div class="hk-tooltip"><div class="hk-tooltip-arrow"></div><div class="hk-tooltip-inner"></div></div>', 274 trigger: 'hover focus', 275 title: '', 276 delay: 0, 277 html: true, 278 container: false 279}; 280 281 282/* TOOLTIP NO CONFLICT 283 * =================== */ 284$.fn.hktooltip.noConflict = function () { 285 $.fn.hktooltip = old; 286 return this; 287}; 288 289}(window.hkjQuery); 290 291hkjQuery(function(){ hkjQuery('[data-toggle="hk-tooltip"]').hktooltip({"html": true,"container": "body"}); });
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.