app/jquery/jquery-bt-0.7.js
author Todd Larsen <tlarsen@google.com>
Tue, 04 Nov 2008 02:50:55 +0000
changeset 440 3a60d5e5c14e
child 815 7b8c65531fbd
permissions -rw-r--r--
Third-party Javascript that should have been part of r891. Same license as JQuery. Patch by: Todd Larsen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
440
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
/*
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
 * jQuery Beauty Tips plugin
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
 * Version 0.7  (10/20/2008)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
 * @requires jQuery v1.2+ (not fully tested on versions prior to 1.2.6)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
 * Dual licensed under the MIT and GPL licenses:
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
 * http://www.opensource.org/licenses/mit-license.php
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
 * http://www.gnu.org/licenses/gpl.html
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
 * No guarantees, warranties, or promises of any kind
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
 */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
/**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
 * @name Beauty Tips
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
 * @type jQuery
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
 * @cat Plugins/bt
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
 * @return jQuery
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
 * @author Jeff Robbins - Lullabot - http://www.lullabot.com
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
 * @credit Inspired by Karl Swedberg's ClueTip
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
 *    (http://plugins.learningjquery.com/cluetip/), which in turn was inspired
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
 *    by Cody Lindley's jTip (http://www.codylindley.com)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
 * @fileoverview
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
 * Beauty Tips is a jQuery tooltips plugin which uses the canvas drawing element
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
 * in the HTML5 spec in order to dynamically draw tooltip "talk bubbles" around
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
 * the descriptive help text associated with an item. This is in many ways
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
 * similar to Google Maps which both provides similar talk-bubbles and uses the
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
 * canvas element to draw them.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
 * The canvas element is supported in modern versions of FireFox, Safari, and
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
 * Opera. However, Internet Explorer needs a separate library called ExplorerCanvas
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
 * included on the page in order to support canvas drawing functions. ExplorerCanvas
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
 * was created by Google for use with their web apps and you can find it here:
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
 * http://excanvas.sourceforge.net/
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
 * Beauty Tips was written to be simple to use and pretty. All of its options
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
 * are documented at the bottom of this file and defaults can be overwritten
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
 * globally for the entire page, or individually on each call.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
 * By default each tooltip will be positioned on the side of the target element
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
 * which has the most free space. This is affected by the scroll position and
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
 * size of the current window, so each Beauty Tip is redrawn each time it is
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    45
 * displayed. It may appear above an element at the bottom of the page, but when
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
 * the page is scrolled down (and the element is at the top of the page) it will
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
 * then appear below it. Additionally, positions can be forced or a preferred
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
 * order can be defined. See examples below.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
 * Usage
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    51
 * The function can be called in a number of ways.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    52
 * $(selector).bt();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
 * $(selector).bt('Content text');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    54
 * $(selector).bt('Content text', {option1: value, option2: value});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    55
 * $(selector).bt({option1: value, option2: value});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
 * Some examples:
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    59
 * @example
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
 * $('[title]').bt();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
 * This is probably the simplest example. It will go through the page finding
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
 * every element which has a title attribute and give it a Beauty Tips popup
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
 * which gets fired on hover.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
 * @example
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    66
 * $('h2').bt('I am an H2 element!', {trigger: 'click', positions: 'top'});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
 * When any H2 element on the page is clicked on, a tip will appear above it.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
 * @example
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
 * $('a[href]').bt({
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
 *  titleSelector: "attr('href')",
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
 *  fill: 'red',
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    73
 *  cssStyles: {color: 'white', fontWeight: 'bold', width: 'auto'},
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    74
 *  width: 400,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
 *  padding: 10,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    76
 *  cornerRadius: 10,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    77
 *  animate: true,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
 *  spikeLength: 15,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    79
 *  spikeGirth: 5,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    80
 *  positions: ['left', 'right', 'bottom'],
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    81
 *  });
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    82
 * This will find all <a> tags and display a red baloon with bold white text
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    83
 * containing the href link. The box will be a variable width up to 400px with
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    84
 * rounded corners and will fade in and animate position toward the target
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    85
 * object when appearing. The script will try to position the box to the left,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    86
 * then to the right, and finally it will place it on the bottom if it does not
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    87
 * fit elsewhere.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    88
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
 * @example
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    90
 * $('#my-table td[title]').bt({
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    91
 *  preShow: function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    92
 *    $(this).data('origBG', $(this).css('background-color'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    93
 *    $(this).css('background-color', 'yellow');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
 *  },
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    95
 *  postHide: function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    96
 *    $(this).css('background-color', $(this).data('origBG'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    97
 *  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
 * });
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    99
 * Find every table cell within #mytable with a title attribute. Hilight the cell
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
 * yellow before displaying the BeautyTip. Restore it to its original background
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   101
 * when hiding/removing the BeautyTip.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   102
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   103
 * @example
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   104
 * $().bt.defaults.fill = 'rgba(102, 102, 255. .8)';
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   105
 * $(selector).bt();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   106
 * All bubbles will be filled with a semi-transparent light-blue background
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   107
 * unless otherwise specified.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   108
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   109
 */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   110
jQuery.fn.bt = function(content, options) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   111
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   112
  if (typeof content != 'string') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   113
    var contentSelect = true;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   114
    options = content;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   115
    content = false;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   116
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   117
  else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   118
    var contentSelect = false;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   119
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   120
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
  return this.each(function(index) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   122
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   123
    var opts = jQuery.extend(false, jQuery.fn.bt.defaults, options);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   124
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   125
    // clean up the options
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   126
    opts.spikeLength = numb(opts.spikeLength);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   127
    opts.spikeGirth = numb(opts.spikeGirth);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   128
    opts.overlap = numb(opts.overlap);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   129
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   130
    var turnOn = function () {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   131
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   132
      if (typeof $(this).data('bt-box') == 'object') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   133
        // if there's already a popup, remove it before creating a new one.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   134
        turnOff.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   135
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   136
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   137
      // trigger preShow function
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   138
      opts.preShow.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   139
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   140
      if (contentSelect) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   141
        // bizarre, I know
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   142
        if (opts.killTitle) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   143
          // if we've killed the title attribute, it's been stored in 'bt-xTitle' so get it..
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   144
          $(this).attr('title', $(this).attr('bt-xTitle'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   145
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   146
        // then evaluate the selector... title is now in place
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   147
        content = eval('$(this).' + opts.titleSelector);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   148
        if (opts.killTitle) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   149
          // now remove the title again, so we don't get double tips
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   150
          $(this).removeAttr('title');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   151
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   152
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   153
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   154
      var offsetParent = $(this).offsetParent();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   155
      var pos = $(this).btPosition();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   156
      var top = numb(pos.top) + numb($(this).css('margin-top')); // IE can return 'auto' for margins
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   157
      var left = numb(pos.left) + numb($(this).css('margin-left'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   158
      var width = $(this).outerWidth();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   159
      var height = $(this).outerHeight();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   160
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   161
      // get the dimensions of the text box
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   162
      var $text = $('<div class="bt-content"></div>').append(content).css({padding: opts.padding + 'px', position: 'absolute', width: opts.width + 'px', zIndex: opts.textzIndex}).css(opts.cssStyles);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   163
      var $box = $('<div class="bt-wrapper"></div>').append($text).addClass(opts.cssClass).css({position: 'absolute', width: opts.width + 'px'}).appendTo(offsetParent);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   164
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   165
      $(this).data('bt-box', $box);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   166
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   167
      // see if the text box will fit in the various positions
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   168
      var scrollTop = numb($(document).scrollTop());
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   169
      var scrollLeft = numb($(document).scrollLeft());
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   170
      var docWidth = numb($(window).width());
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   171
      var docHeight = numb($(window).height());
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   172
      var winRight = scrollLeft + docWidth;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   173
      var winBottom = scrollTop + docHeight;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   174
      var space = new Object();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   175
      space.top = $(this).offset().top - scrollTop;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   176
      space.bottom = docHeight - (($(this).offset().top + height) - scrollTop);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   177
      space.left = $(this).offset().left - scrollLeft;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   178
      space.right = docWidth - (($(this).offset().left + width) - scrollLeft);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   179
      var textOutHeight = numb($text.outerHeight());
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   180
      var textOutWidth = numb($text.outerWidth());
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   181
      if (opts.positions.constructor == String) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   182
        opts.positions = opts.positions.replace(/ /, '').split(',');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   183
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   184
      if (opts.positions[0] == 'most') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   185
        // figure out which is the largest
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   186
        var position = 'top'; // prime the pump
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   187
        for (var pig in space) { // pigs in space!
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   188
          position = space[pig] > space[position] ? pig : position;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   189
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   190
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   191
      else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   192
        for (var x in opts.positions) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   193
          var position = opts.positions[x];
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   194
          if ((position == 'left' || position == 'right') && space[position] > textOutWidth + opts.spikeLength) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   195
            break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   196
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   197
          else if ((position == 'top' || position == 'bottom') && space[position] > textOutHeight + opts.spikeLength) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   198
            break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   199
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   200
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   201
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   202
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   203
      var horiz = left + ((width - textOutWidth)/2);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   204
      var vert = top + ((height - textOutHeight)/2);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   205
      var animDist = opts.animate ? numb(opts.distance) : 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   206
      var points = new Array();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   207
      var textTop, textLeft, textRight, textBottom, textTopSpace, textBottomSpace, textLeftSpace, textRightSpace, crossPoint, textCenter;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   208
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   209
      // Yes, yes, this next bit really could use to be condensed
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   210
      // each switch case is basically doing the same thing in slightly different ways
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   211
      switch(position) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   212
        case 'top':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   213
          // spike on bottom
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   214
          $text.css('margin-bottom', opts.spikeLength + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   215
          $box.css({top: (top - $text.outerHeight(true) - animDist) + opts.overlap, left: horiz});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   216
          // move text left/right if extends out of window
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   217
          textRightSpace = (winRight - opts.windowMargin) - ($text.offset().left + $text.outerWidth(true));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   218
          var xShift = 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   219
          if (textRightSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   220
            // shift it left
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   221
            $box.css('left', (numb($box.css('left')) + textRightSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   222
            xShift -= textRightSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   223
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   224
          // we test left space second to ensure that left of box is visible
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   225
          textLeftSpace = ($text.offset().left + numb($text.css('margin-left'))) - (scrollLeft + opts.windowMargin);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   226
          if (textLeftSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   227
            // shift it right
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   228
            $box.css('left', (numb($box.css('left')) - textLeftSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   229
            xShift += textLeftSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   230
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   231
          textTop = $text.btPosition().top + numb($text.css('margin-top'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   232
          textLeft = $text.btPosition().left + numb($text.css('margin-left'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   233
          textRight = textLeft + $text.outerWidth();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   234
          textBottom = textTop + $text.outerHeight();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   235
          textCenter = {x: textLeft + ($text.outerWidth()/2), y: textTop + ($text.outerHeight()/2)};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   236
          // points[points.length] = {x: x, y: y};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   237
          points[points.length] = spikePoint = {y: textBottom + opts.spikeLength, x: ((textRight-textLeft)/2) + xShift, type: 'spike'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   238
          crossPoint = findIntersectX(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textBottom);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   239
          // make sure that the crossPoint is not outside of text box boundaries
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   240
          crossPoint.x = crossPoint.x < textLeft + opts.spikeGirth/2 + opts.cornerRadius ? textLeft + opts.spikeGirth/2 + opts.cornerRadius : crossPoint.x;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   241
          crossPoint.x =  crossPoint.x > (textRight - opts.spikeGirth/2) - opts.cornerRadius ? (textRight - opts.spikeGirth/2) - opts.CornerRadius : crossPoint.x;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   242
          points[points.length] = {x: crossPoint.x - (opts.spikeGirth/2), y: textBottom, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   243
          points[points.length] = {x: textLeft, y: textBottom, type: 'corner'};  // left bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   244
          points[points.length] = {x: textLeft, y: textTop, type: 'corner'};     // left top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   245
          points[points.length] = {x: textRight, y: textTop, type: 'corner'};    // right top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   246
          points[points.length] = {x: textRight, y: textBottom, type: 'corner'}; // right bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   247
          points[points.length] = {x: crossPoint.x + (opts.spikeGirth/2), y: textBottom, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   248
          points[points.length] = spikePoint;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   249
          break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   250
        case 'left':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   251
          // spike on right
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   252
          $text.css('margin-right', opts.spikeLength + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   253
          $box.css({top: vert + 'px', left: ((left - $text.outerWidth(true) - animDist) + opts.overlap) + 'px'});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   254
          // move text up/down if extends out of window
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   255
          textBottomSpace = (winBottom - opts.windowMargin) - ($text.offset().top + $text.outerHeight(true));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   256
          var yShift = 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   257
          if (textBottomSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   258
            // shift it up
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   259
            $box.css('top', (numb($box.css('top')) + textBottomSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   260
            yShift -= textBottomSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   261
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   262
          // we ensure top space second to ensure that top of box is visible
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   263
          textTopSpace = ($text.offset().top + numb($text.css('margin-top'))) - (scrollTop + opts.windowMargin);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   264
          if (textTopSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   265
            // shift it down
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   266
            $box.css('top', (numb($box.css('top')) - textTopSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   267
            yShift += textTopSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   268
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   269
          textTop = $text.btPosition().top + numb($text.css('margin-top'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   270
          textLeft = $text.btPosition().left + numb($text.css('margin-left'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   271
          textRight = textLeft + $text.outerWidth();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   272
          textBottom = textTop + $text.outerHeight();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   273
          textCenter = {x: textLeft + ($text.outerWidth()/2), y: textTop + ($text.outerHeight()/2)};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   274
          points[points.length] = spikePoint = {x: textRight + opts.spikeLength, y: ((textBottom-textTop)/2) + yShift, type: 'spike'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   275
          crossPoint = findIntersectY(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textRight);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   276
          // make sure that the crossPoint is not outside of text box boundaries
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   277
          crossPoint.y = crossPoint.y < textTop + opts.spikeGirth/2 + opts.cornerRadius ? textTop + opts.spikeGirth/2 + opts.cornerRadius : crossPoint.y;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   278
          crossPoint.y =  crossPoint.y > (textBottom - opts.spikeGirth/2) - opts.cornerRadius ? (textBottom - opts.spikeGirth/2) - opts.cornerRadius : crossPoint.y;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   279
          points[points.length] = {x: textRight, y: crossPoint.y + opts.spikeGirth/2, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   280
          points[points.length] = {x: textRight, y: textBottom, type: 'corner'}; // right bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   281
          points[points.length] = {x: textLeft, y: textBottom, type: 'corner'};  // left bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   282
          points[points.length] = {x: textLeft, y: textTop, type: 'corner'};     // left top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   283
          points[points.length] = {x: textRight, y: textTop, type: 'corner'};    // right top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   284
          points[points.length] = {x: textRight, y: crossPoint.y - opts.spikeGirth/2, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   285
          points[points.length] = spikePoint;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   286
          break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   287
        case 'bottom':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   288
          // spike on top
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   289
          $text.css('margin-top', opts.spikeLength + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   290
          $box.css({top: (top + height + animDist) - opts.overlap, left: horiz});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   291
          // move text up/down if extends out of window
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   292
          textRightSpace = (winRight - opts.windowMargin) - ($text.offset().left + $text.outerWidth(true));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   293
          var xShift = 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   294
          if (textRightSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   295
            // shift it left
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   296
            $box.css('left', (numb($box.css('left')) + textRightSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   297
            xShift -= textRightSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   298
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   299
          // we ensure left space second to ensure that left of box is visible
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   300
          textLeftSpace = ($text.offset().left + numb($text.css('margin-left')))  - (scrollLeft + opts.windowMargin);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   301
          if (textLeftSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   302
            // shift it right
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   303
            $box.css('left', (numb($box.css('left')) - textLeftSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   304
            xShift += textLeftSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   305
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   306
          textTop = $text.btPosition().top + numb($text.css('margin-top'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   307
          textLeft = $text.btPosition().left + numb($text.css('margin-left'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   308
          textRight = textLeft + $text.outerWidth();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   309
          textBottom = textTop + $text.outerHeight();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   310
          textCenter = {x: textLeft + ($text.outerWidth()/2), y: textTop + ($text.outerHeight()/2)};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   311
          points[points.length] = spikePoint = {x: ((textRight-textLeft)/2) + xShift, y: 0, type: 'spike'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   312
          crossPoint = findIntersectX(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textTop);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   313
          // make sure that the crossPoint is not outside of text box boundaries
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   314
          crossPoint.x = crossPoint.x < textLeft + opts.spikeGirth/2 + opts.cornerRadius ? textLeft + opts.spikeGirth/2 + opts.cornerRadius : crossPoint.x;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   315
          crossPoint.x =  crossPoint.x > (textRight - opts.spikeGirth/2) - opts.cornerRadius ? (textRight - opts.spikeGirth/2) - opts.cornerRadius : crossPoint.x;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   316
          points[points.length] = {x: crossPoint.x + opts.spikeGirth/2, y: textTop, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   317
          points[points.length] = {x: textRight, y: textTop, type: 'corner'};    // right top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   318
          points[points.length] = {x: textRight, y: textBottom, type: 'corner'}; // right bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   319
          points[points.length] = {x: textLeft, y: textBottom, type: 'corner'};  // left bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   320
          points[points.length] = {x: textLeft, y: textTop, type: 'corner'};     // left top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   321
          points[points.length] = {x: crossPoint.x - (opts.spikeGirth/2), y: textTop, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   322
          points[points.length] = spikePoint;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   323
          break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   324
        case 'right':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   325
          // spike on left
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   326
          $text.css('margin-left', (opts.spikeLength + 'px'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   327
          $box.css({top: vert + 'px', left: ((left + width + animDist) - opts.overlap) + 'px'});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   328
          // move text up/down if extends out of window
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   329
          textBottomSpace = (winBottom - opts.windowMargin) - ($text.offset().top + $text.outerHeight(true));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   330
          var yShift = 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   331
          if (textBottomSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   332
            // shift it up
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   333
            $box.css('top', (numb($box.css('top')) + textBottomSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   334
            yShift -= textBottomSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   335
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   336
          // we ensure top space second to ensure that top of box is visible
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   337
          textTopSpace = ($text.offset().top + numb($text.css('margin-top'))) - (scrollTop + opts.windowMargin);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   338
          if (textTopSpace < 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   339
            // shift it down
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   340
            $box.css('top', (numb($box.css('top')) - textTopSpace) + 'px');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   341
            yShift += textTopSpace;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   342
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   343
          textTop = $text.btPosition().top + numb($text.css('margin-top'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   344
          textLeft = $text.btPosition().left + numb($text.css('margin-left'));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   345
          textRight = textLeft + $text.outerWidth();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   346
          textBottom = textTop + $text.outerHeight();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   347
          textCenter = {x: textLeft + ($text.outerWidth()/2), y: textTop + ($text.outerHeight()/2)};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   348
          points[points.length] = spikePoint = {x: 0, y: ((textBottom-textTop)/2) + yShift, type: 'spike'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   349
          crossPoint = findIntersectY(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textLeft);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   350
          // make sure that the crossPoint is not outside of text box boundaries
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   351
          crossPoint.y = crossPoint.y < textTop + opts.spikeGirth/2 + opts.cornerRadius ? textTop + opts.spikeGirth/2 + opts.cornerRadius : crossPoint.y;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   352
          crossPoint.y =  crossPoint.y > (textBottom - opts.spikeGirth/2) - opts.cornerRadius ? (textBottom - opts.spikeGirth/2) - opts.cornerRadius : crossPoint.y;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   353
          points[points.length] = {x: textLeft, y: crossPoint.y - opts.spikeGirth/2, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   354
          points[points.length] = {x: textLeft, y: textTop, type: 'corner'};     // left top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   355
          points[points.length] = {x: textRight, y: textTop, type: 'corner'};    // right top corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   356
          points[points.length] = {x: textRight, y: textBottom, type: 'corner'}; // right bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   357
          points[points.length] = {x: textLeft, y: textBottom, type: 'corner'};  // left bottom corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   358
          points[points.length] = {x: textLeft, y: crossPoint.y + opts.spikeGirth/2, type: 'join'};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   359
          points[points.length] = spikePoint;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   360
          break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   361
      } // </ switch >
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   362
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   363
      var canvas = $('<canvas width="'+ (numb($text.outerWidth(true)) + opts.strokeWidth*2) +'" height="'+ (numb($text.outerHeight(true)) + opts.strokeWidth*2) +'"></canvas>').appendTo($box).css({position: 'absolute', top: $text.btPosition().top, left: $text.btPosition().left, zIndex: opts.boxzIndex}).get(0);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   364
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   365
      // if excanvas is set up, we need to initialize the new canvas element
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   366
      if (typeof G_vmlCanvasManager != 'undefined') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   367
        canvas = G_vmlCanvasManager.initElement(canvas);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   368
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   369
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   370
      if (opts.cornerRadius > 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   371
        // round the corners!
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   372
        var newPoints = new Array();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   373
        var newPoint;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   374
        for (var i=0; i<points.length; i++) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   375
          if (points[i].type == 'corner') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   376
            // create two new arc points
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   377
            // find point between this and previous (using modulo in case of ending)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   378
            newPoint = betweenPoint(points[i], points[(i-1)%points.length], opts.cornerRadius);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   379
            newPoint.type = 'arcStart';
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   380
            newPoints[newPoints.length] = newPoint;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   381
            // the original corner point
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   382
            newPoints[newPoints.length] = points[i];
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   383
            // find point between this and next
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   384
            newPoint = betweenPoint(points[i], points[(i+1)%points.length], opts.cornerRadius);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   385
            newPoint.type = 'arcEnd';
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   386
            newPoints[newPoints.length] = newPoint;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   387
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   388
          else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   389
            newPoints[newPoints.length] = points[i];
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   390
          }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   391
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   392
        // overwrite points with new version
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   393
        points = newPoints;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   394
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   395
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   396
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   397
      var ctx = canvas.getContext("2d");
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   398
      drawIt.apply(ctx, [points]);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   399
      ctx.fillStyle = opts.fill;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   400
      if (opts.shadow) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   401
        ctx.shadowOffsetX = 2;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   402
        ctx.shadowOffsetY = 2;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   403
        ctx.shadowBlur = 5;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   404
        ctx.shadowColor =  opts.shadowColor;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   405
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   406
      ctx.closePath();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   407
      ctx.fill();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   408
      if (opts.strokeWidth > 0) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   409
        ctx.lineWidth = opts.strokeWidth;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   410
        ctx.strokeStyle = opts.strokeStyle;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   411
        ctx.beginPath();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   412
        drawIt.apply(ctx, [points]);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   413
        ctx.closePath();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   414
        ctx.stroke();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   415
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   416
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   417
      if (opts.animate) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   418
        $box.css({opacity: 0.1});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   419
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   420
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   421
      $box.css({visibility: 'visible'});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   422
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   423
      if (opts.overlay) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   424
        var overlay = $('<div class="bt-overlay"></div>').css({
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   425
            position: 'absolute',
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   426
            backgroundColor: 'blue',
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   427
            top: top,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   428
            left: left,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   429
            width: width,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   430
            height: height,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   431
            opacity: '.2'
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   432
          }).appendTo(offsetParent);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   433
        $(this).data('overlay', overlay);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   434
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   435
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   436
      var animParams = {opacity: 1};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   437
      if (opts.animate) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   438
        switch (position) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   439
          case 'top':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   440
            animParams.top = $box.btPosition().top + opts.distance;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   441
            break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   442
          case 'left':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   443
            animParams.left = $box.btPosition().left + opts.distance;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   444
            break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   445
          case 'bottom':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   446
            animParams.top = $box.btPosition().top - opts.distance;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   447
            break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   448
          case 'right':
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   449
            animParams.left = $box.btPosition().left - opts.distance;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   450
            break;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   451
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   452
        $box.animate(animParams, {duration: opts.speed, easing: opts.easing});
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   453
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   454
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   455
      // trigger postShow function
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   456
      opts.postShow.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   457
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   458
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   459
    } // </ turnOn() >
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   460
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   461
    var turnOff = function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   462
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   463
      // trigger preHide function
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   464
      opts.preHide.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   465
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   466
      var box = $(this).data('bt-box');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   467
      var overlay = $(this).data('bt-overlay');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   468
      if (typeof box == 'object') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   469
        $(box).remove();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   470
        $(this).removeData('bt-box');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   471
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   472
      if (typeof overlay == 'object') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   473
        $(overlay).remove();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   474
        $(this).removeData('bt-overlay');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   475
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   476
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   477
      // trigger postHide function
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   478
      opts.postHide.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   479
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   480
    } // </ turnOff() >
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   481
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   482
    var refresh = function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   483
      turnOff.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   484
      turnOn.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   485
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   486
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   487
    /**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   488
     * This is sort of the "starting spot" for the this.each()
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   489
     * These are sort of the init functions to handle the call
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   490
     */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   491
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   492
    if (opts.killTitle) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   493
      $(this).find('[title]').andSelf().each(function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   494
        $(this).attr('bt-xTitle', $(this).attr('title')).removeAttr('title');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   495
      });
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   496
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   497
    if (typeof opts.trigger == 'string') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   498
      opts.trigger = [opts.trigger];
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   499
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   500
    if (opts.trigger[0] == 'hover') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   501
      $(this).hover(
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   502
        function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   503
          turnOn.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   504
        },
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   505
        function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   506
          turnOff.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   507
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   508
      );
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   509
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   510
    else if (opts.trigger[0] == 'now') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   511
      var box = $(this).data('bt-box');
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   512
      if (typeof box == 'object') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   513
        turnOff.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   514
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   515
      else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   516
        turnOn.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   517
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   518
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   519
    else if (opts.trigger.length > 1 && opts.trigger[0] != opts.trigger[1]) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   520
      $(this)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   521
        .bind(opts.trigger[0], function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   522
          turnOn.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   523
        })
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   524
        .bind(opts.trigger[1], function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   525
          turnOff.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   526
        });
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   527
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   528
    else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   529
      // toggle using the same event
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   530
      $(this).bind(opts.trigger[0], function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   531
        if (typeof this.triggerToggle == 'undefined') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   532
          this.triggerToggle = false;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   533
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   534
        this.triggerToggle = !this.triggerToggle;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   535
        if (this.triggerToggle) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   536
          turnOn.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   537
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   538
        else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   539
          turnOff.apply(this);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   540
        }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   541
      });
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   542
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   543
  }); // </ this.each() >
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   544
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   545
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   546
  function drawIt(points) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   547
    this.moveTo(points[0].x, points[0].y);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   548
    for (i=1;i<points.length;i++) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   549
      if (points[i-1].type == 'arcStart') {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   550
        // if we're creating a rounded corner
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   551
        //ctx.arc(round5(points[i].x), round5(points[i].y), points[i].startAngle, points[i].endAngle, opts.cornerRadius, false);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   552
        this.quadraticCurveTo(round5(points[i].x), round5(points[i].y), round5(points[(i+1)%points.length].x), round5(points[(i+1)%points.length].y));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   553
        i++;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   554
        //ctx.moveTo(round5(points[i].x), round5(points[i].y));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   555
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   556
      else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   557
        this.lineTo(round5(points[i].x), round5(points[i].y));
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   558
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   559
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   560
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   561
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   562
  /**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   563
   * Round to the nearest .5 pixel to avoid antialiasing
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   564
   * http://developer.mozilla.org/en/Canvas_tutorial/Applying_styles_and_colors
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   565
   */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   566
  function round5(num) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   567
    return Math.round(num - .5) + .5;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   568
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   569
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   570
  /**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   571
   * Ensure that a number is a number... or zero
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   572
   */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   573
  function numb(num) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   574
    return parseInt(num) || 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   575
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   576
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   577
  /**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   578
   * Given two points, find a point which is dist pixels from point1 on a line to point2
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   579
   */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   580
  function betweenPoint(point1, point2, dist) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   581
    // figure out if we're horizontal or vertical
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   582
    var y, x;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   583
    if (point1.x == point2.x) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   584
      // vertical
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   585
      y = point1.y < point2.y ? point1.y + dist : point1.y - dist;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   586
      return {x: point1.x, y: y};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   587
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   588
    else if (point1.y == point2.y) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   589
      // horizontal
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   590
      x = point1.x < point2.x ? point1.x + dist : point1.x - dist;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   591
      return {x:x, y: point1.y};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   592
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   593
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   594
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   595
  function centerPoint(arcStart, corner, arcEnd) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   596
    var x = corner.x == arcStart.x ? arcEnd.x : arcStart.x;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   597
    var y = corner.y == arcStart.y ? arcEnd.y : arcStart.y;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   598
    var startAngle, endAngle;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   599
    if (arcStart.x < arcEnd.x) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   600
      if (arcStart.y > arcEnd.y) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   601
        // arc is on upper left
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   602
        startAngle = (Math.PI/180)*180;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   603
        endAngle = (Math.PI/180)*90;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   604
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   605
      else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   606
        // arc is on upper right
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   607
        startAngle = (Math.PI/180)*90;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   608
        endAngle = 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   609
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   610
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   611
    else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   612
      if (arcStart.y > arcEnd.y) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   613
        // arc is on lower left
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   614
        startAngle = (Math.PI/180)*270;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   615
        endAngle = (Math.PI/180)*180;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   616
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   617
      else {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   618
        // arc is on lower right
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   619
        startAngle = 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   620
        endAngle = (Math.PI/180)*270;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   621
      }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   622
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   623
    return {x: x, y: y, type: 'center', startAngle: startAngle, endAngle: endAngle};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   624
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   625
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   626
  /**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   627
   * Find the intersection point of two lines, each defined by two points
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   628
   * arguments are x1, y1 and x2, y2 for r1 (line 1) and r2 (line 2)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   629
   * It's like an algebra party!!!
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   630
   */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   631
  function findIntersect(r1x1, r1y1, r1x2, r1y2, r2x1, r2y1, r2x2, r2y2) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   632
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   633
    if (r2x1 == r2x2) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   634
      return findIntersectY(r1x1, r1y1, r1x2, r1y2, r2x1);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   635
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   636
    if (r2y1 == r2y2) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   637
      return findIntersectX(r1x1, r1y1, r1x2, r1y2, r2y1);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   638
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   639
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   640
    // m = (y1 - y2) / (x1 - x2)  // <-- how to find the slope
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   641
    // y = mx + b                 // the 'classic' linear equation
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   642
    // b = y - mx                 // how to find b (the y-intersect)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   643
    // x = (y - b)/m              // how to find x
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   644
    var r1m = (r1y1 - r1y2) / (r1x1 - r1x2);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   645
    var r1b = r1y1 - (r1m * r1x1);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   646
    var r2m = (r2y1 - r2y2) / (r2x1 - r2x2);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   647
    var r2b = r2y1 - (r2m * r2x1);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   648
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   649
    var x = (r2b - r1b) / (r1m - r2m);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   650
	  var y = r1m * x + r1b;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   651
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   652
	  return {x: x, y: y};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   653
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   654
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   655
  /**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   656
   * Find the y intersection point of a line and given x vertical
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   657
   */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   658
  function findIntersectY(r1x1, r1y1, r1x2, r1y2, x) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   659
    if (r1y1 == r1y2) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   660
      return {x: x, y: r1y1};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   661
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   662
    var r1m = (r1y1 - r1y2) / (r1x1 - r1x2);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   663
    var r1b = r1y1 - (r1m * r1x1);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   664
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   665
    var y = r1m * x + r1b;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   666
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   667
    return {x: x, y: y};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   668
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   669
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   670
  /**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   671
   * Find the x intersection point of a line and given y horizontal
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   672
   */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   673
  function findIntersectX(r1x1, r1y1, r1x2, r1y2, y) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   674
    if (r1x1 == r1x2) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   675
      return {x: r1x1, y: y};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   676
    }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   677
    var r1m = (r1y1 - r1y2) / (r1x1 - r1x2);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   678
    var r1b = r1y1 - (r1m * r1x1);
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   679
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   680
    // y = mx + b     // your old friend, linear equation
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   681
    // x = (y - b)/m  // linear equation solved for x
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   682
    var x = (y - r1b) / r1m;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   683
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   684
    return {x: x, y: y};
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   685
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   686
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   687
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   688
}; // </ jQuery.fn.bt() >
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   689
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   690
/**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   691
 * jQuery's compat.js (used in Drupal's jQuery upgrade module, overrides the $().position() function
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   692
 *  this is a copy of that function to allow the plugin to work when compat.js is present
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   693
 *  once compat.js is fixed to not override existing functions, this function can be removed
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   694
 *  and .btPosion() can be replaced with .position() above...
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   695
 */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   696
jQuery.fn.btPosition = function() {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   697
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   698
  function num(elem, prop) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   699
    return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   700
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   701
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   702
  var left = 0, top = 0, results;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   703
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   704
  if ( this[0] ) {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   705
    // Get *real* offsetParent
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   706
    var offsetParent = this.offsetParent(),
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   707
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   708
    // Get correct offsets
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   709
    offset       = this.offset(),
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   710
    parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   711
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   712
    // Subtract element margins
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   713
    // note: when an element has margin: auto the offsetLeft and marginLeft
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   714
    // are the same in Safari causing offset.left to incorrectly be 0
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   715
    offset.top  -= num( this, 'marginTop' );
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   716
    offset.left -= num( this, 'marginLeft' );
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   717
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   718
    // Add offsetParent borders
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   719
    parentOffset.top  += num( offsetParent, 'borderTopWidth' );
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   720
    parentOffset.left += num( offsetParent, 'borderLeftWidth' );
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   721
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   722
    // Subtract the two offsets
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   723
    results = {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   724
      top:  offset.top  - parentOffset.top,
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   725
      left: offset.left - parentOffset.left
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   726
    };
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   727
  }
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   728
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   729
  return results;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   730
}; // </ jQuery.fn.btPosition() >
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   731
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   732
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   733
/**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   734
 * Defaults for the beauty tips
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   735
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   736
 * Note this is a variable definition and not a function. So defaults can be
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   737
 * written for an entire page by simply redefining attributes like so:
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   738
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   739
 *   jQuery.fn.bt.defaults.width = 400;
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   740
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   741
 * This would make all Beauty Tips boxes 400px wide.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   742
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   743
 * Each of these options may also be overridden during
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   744
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   745
 * Can be overriden globally or at time of call.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   746
 *
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   747
 */
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   748
jQuery.fn.bt.defaults = {
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   749
  trigger:         'hover',                // trigger to show/hide tip
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   750
                                           // use [on, off] to define separate on/off triggers
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   751
                                           // also use space character to allow multiple events to trigger
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   752
                                           // examples:
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   753
                                           //   ['focus', 'blur'] // focus displays, blur hides
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   754
                                           //   'dblclick'        // dblclick toggles on/off
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   755
                                           //   ['focus mouseover', 'blur mouseout']
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   756
                                           //   'now'             // shows/hides tip without event
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   757
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   758
  width:            200,                   // width (in px) of tooltip box
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   759
                                           //   when combined with cssStyles: {width: 'auto'}, this becomes a max-width for the text
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   760
  padding:          10,                    // padding for content (get more fine grained with cssStyles)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   761
  spikeGirth:       10,                    // width of spike
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   762
  spikeLength:      15,                    // length of spike
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   763
  overlap:          0,                     // spike overlap (px) onto target
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   764
  overlay:          false,                 // display overlay on target (use CSS to style) -- BUGGY!
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   765
  killTitle:        true,                  // kill title tag to avoid double tooltips
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   766
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   767
  textzIndex:       9999,                  // z-index for the text
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   768
  boxzIndex:        9990,                  // z-index for the "talk" box (should always be less than textzIndex)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   769
  positions:        ['most'],              // preference of positions for tip (will use first with available space)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   770
                                           // possible values 'top', 'bottom', 'left', 'right' as an array in order of
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   771
                                           // preference. Last value will be used if others don't have enough space.
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   772
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   773
                                           // or use 'most' to use the area with the most space
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   774
  fill:             "rgb(255, 255, 102)",  // fill color for the tooltip box
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   775
  windowMargin:     10,                        // space (px) to leave between text box and browser edge
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   776
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   777
  strokeWidth:      1,                         // width of stroke around box, **set to 0 for no stroke**
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   778
  strokeStyle:      "#000",                    // color/alpha of stroke
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   779
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   780
  cornerRadius:     5,                         // radius of corners (px), set to 0 for square corners
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   781
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   782
  shadow:           false,                     // use drop shadow? (only displays in Safari and FF 3.1)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   783
  shadowOffsetX:    2,                         // shadow offset x (px)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   784
  shadowOffsetY:    2,                         // shadow offset y (px)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   785
  shadowBlur:       3,                         // shadow blur (px)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   786
  shadowColor:      "#000",                    // shadow color/alpha
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   787
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   788
  animate:          false,                     // animate show/hide of box - EXPERIMENTAL (buggy in IE)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   789
  distance:         15,                        // distance of animation movement (px)
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   790
  easing:           'swing',                   // animation easing
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   791
  speed:            200,                       // speed (ms) of animation
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   792
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   793
  cssClass:         '',                        // CSS class to add to the box wrapper div
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   794
  cssStyles:        {},                        // styles to add the text box
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   795
                                               //   example: {fontFamily: 'Georgia, Times, serif', fontWeight: 'bold'}
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   796
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   797
  titleSelector:    "attr('title')",           // if there is no content argument, use this selector to retrieve the title
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   798
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   799
  preShow:          function(){return;},       // function to run before popup is built and displayed
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   800
  postShow:         function(){return;},       // function to run after popup is built and displayed
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   801
  preHide:          function(){return;},       // function to run before popup is removed
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   802
  postHide:         function(){return;}        // function to run after popup is removed
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   803
3a60d5e5c14e Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   804
}; // </ jQuery.bt.defaults >