1/*! 2 * tipso - A Lightweight Responsive jQuery Tooltip Plugin v1.0.8 3 * Copyright (c) 2014-2015 Bojan Petkovski 4 * http://tipso.object505.com 5 * Licensed under the MIT license 6 * http://object505.mit-license.org/ 7 */ 8 // CommonJS, AMD or browser globals 9 (function (factory) { 10 if (typeof define === 'function' && define.amd) { 11 // AMD. Register as an anonymous module. 12 define(['jquery'], factory); 13 } else if (typeof exports === 'object') { 14 // Node/CommonJS 15 module.exports = factory(require('jquery')); 16 } else { 17 // Browser globals 18 factory(jQuery); 19 } 20}(function($) { 21 var pluginName = "tipso", 22 defaults = { 23 speed : 400, //Animation speed 24 background : '#55b555', 25 titleBackground : '#333333', 26 color : '#ffffff', 27 titleColor : '#ffffff', 28 titleContent : '', //Content of the title bar 29 showArrow : true, 30 position : 'top', 31 width : 200, 32 maxWidth : '', 33 delay : 200, 34 hideDelay : 0, 35 animationIn : '', 36 animationOut : '', 37 offsetX : 0, 38 offsetY : 0, 39 arrowWidth : 8, 40 tooltipHover : false, 41 content : null, 42 ajaxContentUrl : null, 43 ajaxContentBuffer : 0, 44 contentElementId : null, //Normally used for picking template scripts 45 useTitle : false, //Use the title tag as tooptip or not 46 templateEngineFunc: null, //A function that compiles and renders the content 47 onBeforeShow : null, 48 onShow : null, 49 onHide : null 50 }; 51 52 function Plugin(element, options) { 53 this.element = element; 54 this.$element = $(this.element); 55 this.doc = $(document); 56 this.win = $(window); 57 this.settings = $.extend({}, defaults, options); 58 59 /* 60 * Process and add data-attrs to settings as well for ease of use. Also, if 61 * data-tipso is an object then use it as extra settings and if it's not 62 * then use it as a title. 63 */ 64 if (typeof(this.$element.data("tipso")) === "object") 65 { 66 $.extend(this.settings, this.$element.data("tipso")); 67 } 68 69 var data_keys = Object.keys(this.$element.data()); 70 var data_attrs = {}; 71 for (var i = 0; i < data_keys.length; i++) 72 { 73 var key = data_keys[i].replace(pluginName, ""); 74 if (key === "") 75 { 76 continue; 77 } 78 //lowercase first letter 79 key = key.charAt(0).toLowerCase() + key.slice(1); 80 data_attrs[key] = this.$element.data(data_keys[i]); 81 82 //We cannot use extend for data_attrs because they are automatically 83 //lowercased. We need to do this manually and extend this.settings with 84 //data_attrs 85 for (var settings_key in this.settings) 86 { 87 if (settings_key.toLowerCase() == key) 88 { 89 this.settings[settings_key] = data_attrs[key]; 90 } 91 } 92 } 93 94 this._defaults = defaults; 95 this._name = pluginName; 96 this._title = this.$element.attr('title'); 97 this.mode = 'hide'; 98 this.ieFade = !supportsTransitions; 99 100 //By keeping the original prefered position and repositioning by calling 101 //the reposition function we can make for more smart and easier positioning 102 //in complex scenarios! 103 this.settings.preferedPosition = this.settings.position; 104 105 this.init(); 106 } 107 108 $.extend(Plugin.prototype, { 109 init: function() { 110 var obj = this, 111 $e = this.$element, 112 $doc = this.doc; 113 $e.addClass('tipso_style').removeAttr('title'); 114 115 if (obj.settings.tooltipHover) { 116 var waitForHover = null, 117 hoverHelper = null; 118 $e.on('mouseover' + '.' + pluginName, function() { 119 clearTimeout(waitForHover); 120 clearTimeout(hoverHelper); 121 hoverHelper = setTimeout(function(){ 122 obj.show(); 123 }, 150); 124 }); 125 $e.on('mouseout' + '.' + pluginName, function() { 126 clearTimeout(waitForHover); 127 clearTimeout(hoverHelper); 128 waitForHover = setTimeout(function(){ 129 obj.hide(); 130 }, 200); 131 132 obj.tooltip() 133 .on('mouseover' + '.' + pluginName, function() { 134 obj.mode = 'tooltipHover'; 135 }) 136 .on('mouseout' + '.' + pluginName, function() { 137 obj.mode = 'show'; 138 clearTimeout(waitForHover); 139 waitForHover = setTimeout(function(){ 140 obj.hide(); 141 }, 200); 142 }) 143 ; 144 }); 145 } else { 146 $e.on('mouseover' + '.' + pluginName, function() { 147 obj.show(); 148 }); 149 $e.on('mouseout' + '.' + pluginName, function() { 150 obj.hide(); 151 }); 152 } 153 if(obj.settings.ajaxContentUrl) 154 { 155 obj.ajaxContent = null; 156 } 157 }, 158 tooltip: function() { 159 if (!this.tipso_bubble) { 160 this.tipso_bubble = $( 161 '<div class="tipso_bubble"><div class="tipso_title"></div><div class="tipso_content"></div><div class="tipso_arrow"></div></div>' 162 ); 163 } 164 return this.tipso_bubble; 165 }, 166 show: function() { 167 var tipso_bubble = this.tooltip(), 168 obj = this, 169 $win = this.win; 170 171 if (obj.settings.showArrow === false) { 172 tipso_bubble.find(".tipso_arrow").hide(); 173 } 174 else { 175 tipso_bubble.find(".tipso_arrow").show(); 176 } 177 178 if (obj.mode === 'hide') { 179 if ($.isFunction(obj.settings.onBeforeShow)) { 180 obj.settings.onBeforeShow(obj.$element, obj.element, obj); 181 } 182 if (obj.settings.size) { 183 tipso_bubble.addClass(obj.settings.size); 184 } 185 if (obj.settings.width) { 186 tipso_bubble.css({ 187 background: obj.settings.background, 188 color: obj.settings.color, 189 width: obj.settings.width 190 }).hide(); 191 } else if (obj.settings.maxWidth){ 192 tipso_bubble.css({ 193 background: obj.settings.background, 194 color: obj.settings.color, 195 maxWidth: obj.settings.maxWidth 196 }).hide(); 197 } else { 198 tipso_bubble.css({ 199 background: obj.settings.background, 200 color: obj.settings.color, 201 width: 200 202 }).hide(); 203 } 204 tipso_bubble.find('.tipso_title').css({
205 background: obj.settings.titleBackground, 206 color: obj.settings.titleColor 207 }); 208 tipso_bubble.find('.tipso_content').html(obj.content()); 209 tipso_bubble.find('.tipso_title').html(obj.titleContent()); 210 reposition(obj); 211 212 $win.on('resize' + '.' + pluginName, function tipsoResizeHandler () { 213 obj.settings.position = obj.settings.preferedPosition; 214 reposition(obj); 215 }); 216 217 window.clearTimeout(obj.timeout); 218 obj.timeout = null; 219 obj.timeout = window.setTimeout(function() { 220 if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === ''){ 221 tipso_bubble.appendTo('body').stop(true, true).fadeIn(obj.settings 222 .speed, function() { 223 obj.mode = 'show'; 224 if ($.isFunction(obj.settings.onShow)) { 225 obj.settings.onShow(obj.$element, obj.element, obj); 226 } 227 }); 228 } else { 229 tipso_bubble.remove().appendTo('body') 230 .stop(true, true) 231 .removeClass('animated ' + obj.settings.animationOut) 232 .addClass('noAnimation') 233 .removeClass('noAnimation') 234 .addClass('animated ' + obj.settings.animationIn).fadeIn(obj.settings.speed, function() { 235 $(this).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ 236 $(this).removeClass('animated ' + obj.settings.animationIn); 237 }); 238 obj.mode = 'show'; 239 if ($.isFunction(obj.settings.onShow)) { 240 obj.settings.onShow(obj.$element, obj.element, obj); 241 } 242 $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); 243 }); 244 } 245 }, obj.settings.delay); 246 } 247 }, 248 hide: function(force) { 249 var obj = this, 250 $win = this.win, 251 tipso_bubble = this.tooltip(), 252 hideDelay = obj.settings.hideDelay; 253 254 if (force) { 255 hideDelay = 0; 256 obj.mode = 'show'; 257 } 258 259 window.clearTimeout(obj.timeout); 260 obj.timeout = null; 261 obj.timeout = window.setTimeout(function() { 262 if (obj.mode !== 'tooltipHover') { 263 if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === ''){ 264 tipso_bubble.stop(true, true).fadeOut(obj.settings.speed, 265 function() { 266 $(this).remove(); 267 if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') { 268 obj.settings.onHide(obj.$element, obj.element, obj); 269 } 270 obj.mode = 'hide'; 271 $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); 272 }); 273 } else { 274 tipso_bubble.stop(true, true) 275 .removeClass('animated ' + obj.settings.animationIn) 276 .addClass('noAnimation').removeClass('noAnimation') 277 .addClass('animated ' + obj.settings.animationOut) 278 .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ 279 $(this).removeClass('animated ' + obj.settings.animationOut).remove(); 280 if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') { 281 obj.settings.onHide(obj.$element, obj.element, obj); 282 } 283 obj.mode = 'hide'; 284 $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); 285 }); 286 } 287 } 288 }, hideDelay); 289 }, 290 close: function() { 291 this.hide(true); 292 }, 293 destroy: function() { 294 var $e = this.$element, 295 $win = this.win, 296 $doc = this.doc; 297 $e.off('.' + pluginName); 298 $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); 299 $e.removeData(pluginName); 300 $e.removeClass('tipso_style').attr('title', this._title); 301 }, 302 titleContent: function() { 303 var content, 304 $e = this.$element, 305 obj = this; 306 if (obj.settings.titleContent) 307 { 308 content = obj.settings.titleContent; 309 } 310 else 311 { 312 content = $e.data('tipso-title'); 313 } 314 return content; 315 }, 316 content: function() { 317 var content, 318 $e = this.$element, 319 obj = this, 320 title = this._title; 321 if (obj.settings.ajaxContentUrl) 322 { 323 if(obj._ajaxContent) 324 {
325 content = obj._ajaxContent; 326 } 327 else 328 { 329 obj._ajaxContent = content = $.ajax({ 330 type: "GET", 331 url: obj.settings.ajaxContentUrl, 332 async: false 333 }).responseText; 334 if(obj.settings.ajaxContentBuffer > 0) 335 { 336 setTimeout(function(){ 337 obj._ajaxContent = null; 338 }, obj.settings.ajaxContentBuffer); 339 } 340 else 341 { 342 obj._ajaxContent = null; 343 } 344 } 345 } 346 else if (obj.settings.contentElementId) 347 { 348 content = $("#" + obj.settings.contentElementId).text(); 349 } 350 else if (obj.settings.content) 351 { 352 content = obj.settings.content; 353 } 354 else 355 { 356 if (obj.settings.useTitle === true) 357 { 358 content = title; 359 } 360 else 361 { 362 // Only use data-tipso as content if it's not being used for settings 363 if (typeof($e.data("tipso")) === "string") 364 { 365 content = $e.data('tipso'); 366 } 367 } 368 } 369 if (obj.settings.templateEngineFunc !== null) 370 { 371 content = obj.settings.templateEngineFunc(content); 372 } 373 return content; 374 }, 375 update: function(key, value) { 376 var obj = this; 377 if (value) { 378 obj.settings[key] = value; 379 } else { 380 return obj.settings[key]; 381 } 382 } 383 }); 384 385 function realHeight(obj) { 386 var clone = obj.clone(); 387 clone.css("visibility", "hidden"); 388 $('body').append(clone); 389 var height = clone.outerHeight(); 390 var width = clone.outerWidth(); 391 clone.remove(); 392 return { 393 'width' : width, 394 'height' : height 395 }; 396 } 397 398 var supportsTransitions = (function() { 399 var s = document.createElement('p').style, 400 v = ['ms','O','Moz','Webkit']; 401 if( s['transition'] === '' ) return true; 402 while( v.length ) 403 if( v.pop() + 'Transition' in s ) 404 return true; 405 return false; 406 })(); 407 408 function removeCornerClasses(obj) { 409 obj.removeClass("top_right_corner bottom_right_corner top_left_corner bottom_left_corner"); 410 obj.find(".tipso_title").removeClass("top_right_corner bottom_right_corner top_left_corner bottom_left_corner"); 411 } 412 413 function reposition(thisthat) { 414 var tipso_bubble = thisthat.tooltip(), 415 $e = thisthat.$element, 416 obj = thisthat, 417 $win = $(window), 418 arrow = 10, 419 pos_top, pos_left, diff; 420 421 var arrow_color = obj.settings.background; 422 var title_content = obj.titleContent(); 423 if (title_content !== undefined && title_content !== '') { 424 arrow_color = obj.settings.titleBackground; 425 } 426 427 if ($e.parent().outerWidth() > $win.outerWidth()) { 428 $win = $e.parent(); 429 } 430 431 switch (obj.settings.position) 432 { 433 case 'top-right': 434 pos_left = $e.offset().left + ($e.outerWidth()); 435 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 436 tipso_bubble.find('.tipso_arrow').css({ 437 marginLeft: -obj.settings.arrowWidth, 438 marginTop: '', 439 }); 440 if (pos_top < $win.scrollTop()) 441 { 442 pos_top = $e.offset().top + $e.outerHeight() + arrow; 443 444 tipso_bubble.find('.tipso_arrow').css({ 445 'border-bottom-color': arrow_color, 446 'border-top-color': 'transparent', 447 'border-left-color': 'transparent', 448 'border-right-color': 'transparent' 449 }); 450 451 /* 452 * Hide and show the appropriate rounded corners 453 */ 454 removeCornerClasses(tipso_bubble); 455 tipso_bubble.addClass("bottom_right_corner"); 456 tipso_bubble.find(".tipso_title").addClass("bottom_right_corner"); 457 tipso_bubble.find('.tipso_arrow').css({ 458 'border-left-color': arrow_color, 459 }); 460 461 tipso_bubble.removeClass('top-right top bottom left right'); 462 tipso_bubble.addClass('bottom'); 463 } 464 else 465 { 466 tipso_bubble.find('.tipso_arrow').css({ 467 'border-top-color': obj.settings.background, 468 'border-bottom-color': 'transparent ', 469 'border-left-color': 'transparent', 470 'border-right-color': 'transparent' 471 }); 472 473 /* 474 * Hide and show the appropriate rounded corners 475 */ 476 removeCornerClasses(tipso_bubble); 477 tipso_bubble.addClass("top_right_corner"); 478 tipso_bubble.find('.tipso_arrow').css({ 479 'border-left-color': obj.settings.background, 480 }); 481 482 tipso_bubble.removeClass('top bottom left right'); 483 tipso_bubble.addClass('top'); 484 } 485 break; 486 case 'top-left': 487 pos_left = $e.offset().left - (realHeight(tipso_bubble).width); 488 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 489 tipso_bubble.find('.tipso_arrow').css({ 490 marginLeft: -obj.settings.arrowWidth, 491 marginTop: '', 492 }); 493 if (pos_top < $win.scrollTop()) 494 { 495 pos_top = $e.offset().top + $e.outerHeight() + arrow; 496 497 tipso_bubble.find('.tipso_arrow').css({ 498 'border-bottom-color': arrow_color, 499 'border-top-color': 'transparent', 500 'border-left-color': 'transparent', 501 'border-right-color': 'transparent' 502 }); 503 504 /* 505 * Hide and show the appropriate rounded corners 506 */ 507 removeCornerClasses(tipso_bubble); 508 tipso_bubble.addClass("bottom_left_corner"); 509 tipso_bubble.find(".tipso_title").addClass("bottom_left_corner"); 510 tipso_bubble.find('.tipso_arrow').css({ 511 'border-right-color': arrow_color, 512 }); 513 514 tipso_bubble.removeClass('top-right top bottom left right'); 515 tipso_bubble.addClass('bottom'); 516 } 517 else 518 { 519 tipso_bubble.find('.tipso_arrow').css({ 520 'border-top-color': obj.settings.background, 521 'border-bottom-color': 'transparent ', 522 'border-left-color': 'transparent', 523 'border-right-color': 'transparent' 524 }); 525 526 /* 527 * Hide and show the appropriate rounded corners 528 */ 529 removeCornerClasses(tipso_bubble); 530 tipso_bubble.addClass("top_left_corner"); 531 tipso_bubble.find('.tipso_arrow').css({ 532 'border-right-color': obj.settings.background, 533 }); 534 535 tipso_bubble.removeClass('top bottom left right'); 536 tipso_bubble.addClass('top'); 537 } 538 break; 539 540 /* 541 * Bottom right position 542 */ 543 case 'bottom-right': 544 pos_left = $e.offset().left + ($e.outerWidth()); 545 pos_top = $e.offset().top + $e.outerHeight() + arrow; 546 tipso_bubble.find('.tipso_arrow').css({ 547 marginLeft: -obj.settings.arrowWidth, 548 marginTop: '', 549 }); 550 if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight()) 551 { 552 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 553 554 tipso_bubble.find('.tipso_arrow').css({ 555 'border-bottom-color': 'transparent', 556 'border-top-color': obj.settings.background, 557 'border-left-color': 'transparent', 558 'border-right-color': 'transparent' 559 }); 560 561 /* 562 * Hide and show the appropriate rounded corners 563 */ 564 removeCornerClasses(tipso_bubble); 565 tipso_bubble.addClass("top_right_corner"); 566 tipso_bubble.find(".tipso_title").addClass("top_left_corner"); 567 tipso_bubble.find('.tipso_arrow').css({ 568 'border-left-color': obj.settings.background, 569 }); 570 571 tipso_bubble.removeClass('top-right top bottom left right'); 572 tipso_bubble.addClass('top'); 573 } 574 else 575 { 576 tipso_bubble.find('.tipso_arrow').css({ 577 'border-top-color': 'transparent', 578 'border-bottom-color': arrow_color, 579 'border-left-color': 'transparent', 580 'border-right-color': 'transparent' 581 }); 582 583 /* 584 * Hide and show the appropriate rounded corners 585 */ 586 removeCornerClasses(tipso_bubble); 587 tipso_bubble.addClass("bottom_right_corner"); 588 tipso_bubble.find(".tipso_title").addClass("bottom_right_corner"); 589 tipso_bubble.find('.tipso_arrow').css({ 590 'border-left-color': arrow_color, 591 }); 592 593 tipso_bubble.removeClass('top bottom left right'); 594 tipso_bubble.addClass('bottom'); 595 } 596 break; 597 598 /* 599 * Bottom left position 600 */ 601 case 'bottom-left': 602 pos_left = $e.offset().left - (realHeight(tipso_bubble).width); 603 pos_top = $e.offset().top + $e.outerHeight() + arrow; 604 tipso_bubble.find('.tipso_arrow').css({ 605 marginLeft: -obj.settings.arrowWidth, 606 marginTop: '', 607 }); 608 if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight()) 609 { 610 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 611 612 tipso_bubble.find('.tipso_arrow').css({ 613 'border-bottom-color': 'transparent', 614 'border-top-color': obj.settings.background, 615 'border-left-color': 'transparent', 616 'border-right-color': 'transparent' 617 }); 618 619 /* 620 * Hide and show the appropriate rounded corners 621 */ 622 removeCornerClasses(tipso_bubble); 623 tipso_bubble.addClass("top_left_corner"); 624 tipso_bubble.find(".tipso_title").addClass("top_left_corner"); 625 tipso_bubble.find('.tipso_arrow').css({ 626 'border-right-color': obj.settings.background, 627 }); 628 629 tipso_bubble.removeClass('top-right top bottom left right'); 630 tipso_bubble.addClass('top'); 631 } 632 else 633 { 634 tipso_bubble.find('.tipso_arrow').css({ 635 'border-top-color': 'transparent', 636 'border-bottom-color': arrow_color, 637 'border-left-color': 'transparent', 638 'border-right-color': 'transparent' 639 }); 640 641 /* 642 * Hide and show the appropriate rounded corners 643 */ 644 removeCornerClasses(tipso_bubble); 645 tipso_bubble.addClass("bottom_left_corner"); 646 tipso_bubble.find(".tipso_title").addClass("bottom_left_corner"); 647 tipso_bubble.find('.tipso_arrow').css({ 648 'border-right-color': arrow_color, 649 }); 650 651 tipso_bubble.removeClass('top bottom left right'); 652 tipso_bubble.addClass('bottom'); 653 } 654 break; 655 /* 656 * Top position 657 */ 658 case 'top': 659 pos_left = $e.offset().left + ($e.outerWidth() / 2) - (realHeight(tipso_bubble).width / 2); 660 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 661 tipso_bubble.find('.tipso_arrow').css({ 662 marginLeft: -obj.settings.arrowWidth, 663 marginTop: '', 664 }); 665 if (pos_top < $win.scrollTop()) 666 { 667 pos_top = $e.offset().top + $e.outerHeight() + arrow; 668 669 tipso_bubble.find('.tipso_arrow').css({ 670 'border-bottom-color': arrow_color, 671 'border-top-color': 'transparent', 672 'border-left-color': 'transparent', 673 'border-right-color': 'transparent' 674 }); 675 676 tipso_bubble.removeClass('top bottom left right'); 677 tipso_bubble.addClass('bottom'); 678 } 679 else 680 { 681 tipso_bubble.find('.tipso_arrow').css({ 682 'border-top-color': obj.settings.background, 683 'border-bottom-color': 'transparent', 684 'border-left-color': 'transparent', 685 'border-right-color': 'transparent' 686 }); 687 tipso_bubble.removeClass('top bottom left right'); 688 tipso_bubble.addClass('top'); 689 } 690 break; 691 case 'bottom': 692 pos_left = $e.offset().left + ($e.outerWidth() / 2) - (realHeight(tipso_bubble).width / 2); 693 pos_top = $e.offset().top + $e.outerHeight() + arrow; 694 tipso_bubble.find('.tipso_arrow').css({ 695 marginLeft: -obj.settings.arrowWidth, 696 marginTop: '', 697 }); 698 if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight()) 699 { 700 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 701 tipso_bubble.find('.tipso_arrow').css({ 702 'border-top-color': obj.settings.background, 703 'border-bottom-color': 'transparent', 704 'border-left-color': 'transparent', 705 'border-right-color': 'transparent' 706 }); 707 tipso_bubble.removeClass('top bottom left right'); 708 tipso_bubble.addClass('top'); 709 } 710 else 711 { 712 tipso_bubble.find('.tipso_arrow').css({ 713 'border-bottom-color': arrow_color, 714 'border-top-color': 'transparent', 715 'border-left-color': 'transparent', 716 'border-right-color': 'transparent' 717 }); 718 tipso_bubble.removeClass('top bottom left right'); 719 tipso_bubble.addClass(obj.settings.position); 720 } 721 break; 722 case 'left': 723 pos_left = $e.offset().left - realHeight(tipso_bubble).width - arrow; 724 pos_top = $e.offset().top + ($e.outerHeight() / 2) - (realHeight(tipso_bubble).height / 2); 725 tipso_bubble.find('.tipso_arrow').css({ 726 marginTop: -obj.settings.arrowWidth, 727 marginLeft: '' 728 }); 729 if (pos_left < $win.scrollLeft()) 730 { 731 pos_left = $e.offset().left + $e.outerWidth() + arrow; 732 tipso_bubble.find('.tipso_arrow').css({ 733 'border-right-color': obj.settings.background, 734 'border-left-color': 'transparent', 735 'border-top-color': 'transparent', 736 'border-bottom-color': 'transparent' 737 }); 738 tipso_bubble.removeClass('top bottom left right'); 739 tipso_bubble.addClass('right'); 740 } 741 else 742 { 743 tipso_bubble.find('.tipso_arrow').css({ 744 'border-left-color': obj.settings.background, 745 'border-right-color': 'transparent', 746 'border-top-color': 'transparent', 747 'border-bottom-color': 'transparent' 748 }); 749 tipso_bubble.removeClass('top bottom left right'); 750 tipso_bubble.addClass(obj.settings.position); 751 } 752 break; 753 case 'right': 754 pos_left = $e.offset().left + $e.outerWidth() + arrow; 755 pos_top = $e.offset().top + ($e.outerHeight() / 2) - (realHeight(tipso_bubble).height / 2); 756 tipso_bubble.find('.tipso_arrow').css({ 757 marginTop: -obj.settings.arrowWidth, 758 marginLeft: '' 759 }); 760 if (pos_left + arrow + obj.settings.width > $win.scrollLeft() + $win.outerWidth()) 761 { 762 pos_left = $e.offset().left - realHeight(tipso_bubble).width - arrow; 763 tipso_bubble.find('.tipso_arrow').css({ 764 'border-left-color': obj.settings.background, 765 'border-right-color': 'transparent', 766 'border-top-color': 'transparent', 767 'border-bottom-color': 'transparent' 768 }); 769 tipso_bubble.removeClass('top bottom left right'); 770 tipso_bubble.addClass('left'); 771 } 772 else 773 { 774 tipso_bubble.find('.tipso_arrow').css({ 775 'border-right-color': obj.settings.background, 776 'border-left-color': 'transparent', 777 'border-top-color': 'transparent', 778 'border-bottom-color': 'transparent' 779 }); 780 tipso_bubble.removeClass('top bottom left right'); 781 tipso_bubble.addClass(obj.settings.position); 782 } 783 break; 784 } 785 /* 786 * Set the position of the arrow for the corner positions 787 */ 788 if (obj.settings.position === 'top-right') 789 { 790 tipso_bubble.find('.tipso_arrow').css({ 791 'margin-left': -obj.settings.width / 2 792 }); 793 } 794 if (obj.settings.position === 'top-left') 795 { 796 var tipso_arrow = tipso_bubble.find(".tipso_arrow").eq(0); 797 tipso_arrow.css({ 798 'margin-left': obj.settings.width / 2 - 2 * obj.settings.arrowWidth 799 }); 800 } 801 if (obj.settings.position === 'bottom-right') 802 { 803 var tipso_arrow = tipso_bubble.find(".tipso_arrow").eq(0); 804 tipso_arrow.css({ 805 'margin-left': -obj.settings.width / 2, 806
806'margin-top': '' 807 }); 808 } 809 if (obj.settings.position === 'bottom-left') 810 { 811 var tipso_arrow = tipso_bubble.find(".tipso_arrow").eq(0); 812 tipso_arrow.css({ 813 'margin-left': obj.settings.width / 2 - 2 * obj.settings.arrowWidth, 814 'margin-top': '' 815 }); 816 } 817 818 /* 819 * Check out of boundness 820 */ 821 if (pos_left < $win.scrollLeft() && (obj.settings.position === 'bottom' || obj.settings.position === 'top')) 822 { 823 tipso_bubble.find('.tipso_arrow').css({ 824 marginLeft: pos_left - obj.settings.arrowWidth 825 }); 826 pos_left = 0; 827 } 828 if (pos_left + obj.settings.width > $win.outerWidth() && (obj.settings.position === 'bottom' || obj.settings.position === 'top')) 829 { 830 diff = $win.outerWidth() - (pos_left + obj.settings.width); 831 tipso_bubble.find('.tipso_arrow').css({ 832 marginLeft: -diff - obj.settings.arrowWidth, 833 marginTop: '' 834 }); 835 pos_left = pos_left + diff; 836 } 837 if (pos_left < $win.scrollLeft() && 838 (obj.settings.position === 'left' || 839 obj.settings.position === 'right' || 840 obj.settings.position === 'top-right' || 841 obj.settings.position === 'top-left' || 842 obj.settings.position === 'bottom-right' || 843 obj.settings.position === 'bottom-left')) 844 { 845 pos_left = $e.offset().left + ($e.outerWidth() / 2) - (realHeight(tipso_bubble).width / 2); 846 tipso_bubble.find('.tipso_arrow').css({ 847 marginLeft: -obj.settings.arrowWidth, 848 marginTop: '' 849 }); 850 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 851 if (pos_top < $win.scrollTop()) 852 { 853 pos_top = $e.offset().top + $e.outerHeight() + arrow; 854 tipso_bubble.find('.tipso_arrow').css({ 855 'border-bottom-color': arrow_color, 856 'border-top-color': 'transparent', 857 'border-left-color': 'transparent', 858 'border-right-color': 'transparent' 859 }); 860 tipso_bubble.removeClass('top bottom left right'); 861 removeCornerClasses(tipso_bubble); 862 tipso_bubble.addClass('bottom'); 863 } 864 else 865 { 866 tipso_bubble.find('.tipso_arrow').css({ 867 'border-top-color': obj.settings.background, 868 'border-bottom-color': 'transparent', 869 'border-left-color': 'transparent', 870 'border-right-color': 'transparent' 871 }); 872 tipso_bubble.removeClass('top bottom left right'); 873 removeCornerClasses(tipso_bubble); 874 tipso_bubble.addClass('top'); 875 } 876 if (pos_left + obj.settings.width > $win.outerWidth()) 877 { 878 diff = $win.outerWidth() - (pos_left + obj.settings.width); 879 tipso_bubble.find('.tipso_arrow').css({ 880 marginLeft: -diff - obj.settings.arrowWidth, 881 marginTop: '' 882 }); 883 pos_left = pos_left + diff; 884 } 885 if (pos_left < $win.scrollLeft()) 886 { 887 tipso_bubble.find('.tipso_arrow').css({ 888 marginLeft: pos_left - obj.settings.arrowWidth 889 }); 890 pos_left = 0; 891 } 892 } 893 894 /* 895 * If out of bounds from the right hand side 896 */ 897 if (pos_left + obj.settings.width > $win.outerWidth() && 898 (obj.settings.position === 'left' || 899 obj.settings.position === 'right' || 900 obj.settings.position === 'top-right' || 901 obj.settings.position === 'top-left' || 902 obj.settings.position === 'bottom-right' || 903 obj.settings.position === 'bottom-right')) 904 { 905 pos_left = $e.offset().left + ($e.outerWidth() / 2) - (realHeight(tipso_bubble).width / 2); 906 tipso_bubble.find('.tipso_arrow').css({ 907 marginLeft: -obj.settings.arrowWidth, 908 marginTop: '' 909 }); 910 pos_top = $e.offset().top - realHeight(tipso_bubble).height - arrow; 911 if (pos_top < $win.scrollTop()) 912 { 913 pos_top = $e.offset().top + $e.outerHeight() + arrow; 914 tipso_bubble.find('.tipso_arrow').css({ 915 'border-bottom-color': arrow_color, 916 'border-top-color': 'transparent', 917 'border-left-color': 'transparent', 918 'border-right-color': 'transparent' 919 }); 920 921 removeCornerClasses(tipso_bubble); 922 tipso_bubble.removeClass('top bottom left right'); 923 tipso_bubble.addClass('bottom'); 924 } 925 else 926 { 927 tipso_bubble.find('.tipso_arrow').css({ 928 'border-top-color': obj.settings.background, 929 'border-bottom-color': 'transparent', 930 'border-left-color': 'transparent', 931 'border-right-color': 'transparent' 932 }); 933 934 /* 935 * Hide and show the appropriate rounded corners 936 */ 937 removeCornerClasses(tipso_bubble); 938 tipso_bubble.removeClass('top bottom left right'); 939 tipso_bubble.addClass('top'); 940 } 941 if (pos_left + obj.settings.width > $win.outerWidth()) 942 { 943 diff = $win.outerWidth() - (pos_left + obj.settings.width); 944 tipso_bubble.find('.tipso_arrow').css({ 945 marginLeft: -diff - obj.settings.arrowWidth, 946 marginTop: '' 947 }); 948 pos_left = pos_left + diff; 949 } 950 if (pos_left < $win.scrollLeft()) 951 { 952 tipso_bubble.find('.tipso_arrow').css({ 953 marginLeft: pos_left - obj.settings.arrowWidth 954 }); 955 pos_left = 0; 956 } 957 } 958 tipso_bubble.css({ 959 left: pos_left + obj.settings.offsetX, 960 top: pos_top + obj.settings.offsetY 961 }); 962 963 // If positioned right or left and tooltip is out of bounds change position 964 // This position change will be temporary, because preferedPosition is there 965 // to help!! 966 if (pos_top < $win.scrollTop() && (obj.settings.position === 'right' || obj.settings.position === 'left')) 967 { 968 $e.tipso('update', 'position', 'bottom'); 969 reposition(obj); 970 } 971 if (pos_top + realHeight(tipso_bubble).height > $win.scrollTop() + $win.outerHeight() && 972 (obj.settings.position === 'right' || obj.settings.position === 'left')) 973 { 974 $e.tipso('update', 'position', 'top'); 975 reposition(obj); 976 } 977 978 } 979 $[pluginName] = $.fn[pluginName] = function(options) { 980 var args = arguments; 981 if (options === undefined || typeof options === 'object') { 982 if (!(this instanceof $)) { 983 $.extend(defaults, options); 984 } 985 return this.each(function() { 986 if (!$.data(this, 'plugin_' + pluginName)) { 987 $.data(this, 'plugin_' + pluginName, new Plugin(this, options)); 988 } 989 }); 990 } else if (typeof options === 'string' && options[0] !== '_' && options !== 991 'init') { 992 var returns; 993 this.each(function() { 994 var instance = $.data(this, 'plugin_' + pluginName); 995 if (!instance) { 996 instance = $.data(this, 'plugin_' + pluginName, new Plugin( 997 this, options)); 998 } 999 if (instance instanceof Plugin && typeof instance[options] === 1000 'function') { 1001 returns = instance[options].apply(instance, Array.prototype.slice 1002 .call(args, 1)); 1003 } 1004 if (options === 'destroy') { 1005 $.data(this, 'plugin_' + pluginName, null); 1006 } 1007 }); 1008 return returns !== undefined ? returns : this; 1009 } 1010 }; 1011}));
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.