author | Lennard de Rijk <ljvderijk@gmail.com> |
Fri, 23 Jan 2009 11:32:53 +0000 | |
changeset 914 | 6ec8dd2a73b3 |
parent 815 | 7b8c65531fbd |
permissions | -rw-r--r-- |
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 |
|
815
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
121 |
var tooltips_pool = []; |
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
122 |
|
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
123 |
|
440
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
124 |
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
|
125 |
|
815
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
126 |
tooltips_pool.push(this); |
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
127 |
|
440
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
128 |
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
|
129 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
130 |
// 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
|
131 |
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
|
132 |
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
|
133 |
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
|
134 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
135 |
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
|
136 |
|
815
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
137 |
for (var x in tooltips_pool) { |
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
138 |
turnOff.apply(tooltips_pool[x]); |
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
139 |
} |
7b8c65531fbd
Tooltips now properly disappear when another text box with a tooltip has been highlighted.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
440
diff
changeset
|
140 |
|
440
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
141 |
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
|
142 |
// 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
|
143 |
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
|
144 |
} |
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 |
// 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
|
147 |
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
|
148 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
149 |
if (contentSelect) { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
150 |
// 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
|
151 |
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
|
152 |
// 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
|
153 |
$(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
|
154 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
155 |
// 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
|
156 |
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
|
157 |
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
|
158 |
// 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
|
159 |
$(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
|
160 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
161 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
162 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
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
|
168 |
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
|
169 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
170 |
// 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
|
171 |
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
|
172 |
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
|
173 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
174 |
$(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
|
175 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
176 |
// 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
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
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
|
191 |
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
|
192 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
193 |
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
|
194 |
// 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
|
195 |
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
|
196 |
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
|
197 |
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
|
198 |
} |
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 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
201 |
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
|
202 |
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
|
203 |
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
|
204 |
break; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
205 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
206 |
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
|
207 |
break; |
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 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
210 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
211 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
212 |
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
|
213 |
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
|
214 |
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
|
215 |
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
|
216 |
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
|
217 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
218 |
// 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
|
219 |
// 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
|
220 |
switch(position) { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
221 |
case 'top': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
222 |
// 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
|
223 |
$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
|
224 |
$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
|
225 |
// 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
|
226 |
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
|
227 |
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
|
228 |
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
|
229 |
// 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
|
230 |
$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
|
231 |
xShift -= textRightSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
232 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
233 |
// 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
|
234 |
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
|
235 |
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
|
236 |
// 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
|
237 |
$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
|
238 |
xShift += textLeftSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
239 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
240 |
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
|
241 |
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
|
242 |
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
|
243 |
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
|
244 |
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
|
245 |
// 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
|
246 |
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
|
247 |
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
|
248 |
// 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
|
249 |
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
|
250 |
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
|
251 |
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
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
break; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
259 |
case 'left': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
260 |
// 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
|
261 |
$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
|
262 |
$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
|
263 |
// 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
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
// 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
|
268 |
$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
|
269 |
yShift -= textBottomSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
270 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
271 |
// 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
|
272 |
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
|
273 |
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
|
274 |
// 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
|
275 |
$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
|
276 |
yShift += textTopSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
277 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
278 |
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
|
279 |
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
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
// 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
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
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
|
290 |
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
|
291 |
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
|
292 |
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
|
293 |
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
|
294 |
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
|
295 |
break; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
296 |
case 'bottom': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
297 |
// 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
|
298 |
$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
|
299 |
$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
|
300 |
// 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
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
// 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
|
305 |
$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
|
306 |
xShift -= textRightSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
307 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
308 |
// 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
|
309 |
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
|
310 |
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
|
311 |
// 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
|
312 |
$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
|
313 |
xShift += textLeftSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
314 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
315 |
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
|
316 |
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
|
317 |
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
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
// 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
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
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
|
328 |
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
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
break; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
333 |
case 'right': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
334 |
// 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
|
335 |
$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
|
336 |
$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
|
337 |
// 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
|
338 |
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
|
339 |
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
|
340 |
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
|
341 |
// 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
|
342 |
$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
|
343 |
yShift -= textBottomSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
344 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
345 |
// 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
|
346 |
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
|
347 |
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
|
348 |
// 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
|
349 |
$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
|
350 |
yShift += textTopSpace; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
351 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
// 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
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
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
|
364 |
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
|
365 |
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
|
366 |
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
|
367 |
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
|
368 |
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
|
369 |
break; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
370 |
} // </ switch > |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
371 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
372 |
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
|
373 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
374 |
// 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
|
375 |
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
|
376 |
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
|
377 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
378 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
379 |
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
|
380 |
// 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
|
381 |
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
|
382 |
var newPoint; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
383 |
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
|
384 |
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
|
385 |
// 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
|
386 |
// 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
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
// 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
|
391 |
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
|
392 |
// 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
|
393 |
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
|
394 |
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
|
395 |
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
|
396 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
397 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
398 |
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
|
399 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
400 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
401 |
// 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
|
402 |
points = newPoints; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
403 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
404 |
} |
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 |
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
|
407 |
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
|
408 |
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
|
409 |
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
|
410 |
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
|
411 |
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
|
412 |
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
|
413 |
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
|
414 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
415 |
ctx.closePath(); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
416 |
ctx.fill(); |
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.strokeWidth > 0) { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
418 |
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
|
419 |
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
|
420 |
ctx.beginPath(); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
421 |
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
|
422 |
ctx.closePath(); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
423 |
ctx.stroke(); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
424 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
425 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
426 |
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
|
427 |
$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
|
428 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
429 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
430 |
$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
|
431 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
432 |
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
|
433 |
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
|
434 |
position: 'absolute', |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
435 |
backgroundColor: 'blue', |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
436 |
top: top, |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
437 |
left: left, |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
438 |
width: width, |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
439 |
height: height, |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
440 |
opacity: '.2' |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
441 |
}).appendTo(offsetParent); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
442 |
$(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
|
443 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
444 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
445 |
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
|
446 |
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
|
447 |
switch (position) { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
448 |
case 'top': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
449 |
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
|
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 |
case 'left': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
452 |
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
|
453 |
break; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
454 |
case 'bottom': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
455 |
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
|
456 |
break; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
457 |
case 'right': |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
458 |
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
|
459 |
break; |
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 |
$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
|
462 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
463 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
464 |
// 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
|
465 |
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
|
466 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
467 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
468 |
} // </ turnOn() > |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
469 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
470 |
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
|
471 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
472 |
// 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
|
473 |
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
|
474 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
$(box).remove(); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
479 |
$(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
|
480 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
481 |
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
|
482 |
$(overlay).remove(); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
483 |
$(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
|
484 |
} |
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 |
// 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
|
487 |
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
|
488 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
489 |
} // </ turnOff() > |
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 |
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
|
492 |
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
|
493 |
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
|
494 |
} |
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 |
* 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
|
498 |
* 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
|
499 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
500 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
501 |
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
|
502 |
$(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
|
503 |
$(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
|
504 |
}); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
505 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
506 |
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
|
507 |
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
|
508 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
509 |
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
|
510 |
$(this).hover( |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
511 |
function() { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
512 |
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
|
513 |
}, |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
514 |
function() { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
515 |
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
|
516 |
} |
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[0] == 'now') { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
520 |
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
|
521 |
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
|
522 |
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
|
523 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
524 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
525 |
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
|
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 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
|
529 |
$(this) |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
530 |
.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 |
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
|
532 |
}) |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
533 |
.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
|
534 |
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
|
535 |
}); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
536 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
537 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
538 |
// 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
|
539 |
$(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
|
540 |
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
|
541 |
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
|
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.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
|
544 |
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
|
545 |
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
|
546 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
547 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
548 |
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
|
549 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
550 |
}); |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
551 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
552 |
}); // </ this.each() > |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
553 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
554 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
555 |
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
|
556 |
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
|
557 |
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
|
558 |
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
|
559 |
// 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
|
560 |
//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
|
561 |
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
|
562 |
i++; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
563 |
//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
|
564 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
565 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
566 |
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
|
567 |
} |
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 |
/** |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
572 |
* 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
|
573 |
* 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
|
574 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
575 |
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
|
576 |
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
|
577 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
578 |
|
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 |
* 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
|
581 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
582 |
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
|
583 |
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
|
584 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
585 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
586 |
/** |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
587 |
* 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
|
588 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
589 |
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
|
590 |
// 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
|
591 |
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
|
592 |
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
|
593 |
// vertical |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
594 |
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
|
595 |
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
|
596 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
597 |
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
|
598 |
// horizontal |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
599 |
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
|
600 |
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
|
601 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
602 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
603 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
604 |
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
|
605 |
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
|
606 |
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
|
607 |
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
|
608 |
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
|
609 |
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
|
610 |
// 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
|
611 |
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
|
612 |
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
|
613 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
614 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
615 |
// 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
|
616 |
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
|
617 |
endAngle = 0; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
618 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
619 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
620 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
621 |
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
|
622 |
// 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
|
623 |
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
|
624 |
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
|
625 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
626 |
else { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
627 |
// 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
|
628 |
startAngle = 0; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
629 |
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
|
630 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
631 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
632 |
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
|
633 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
634 |
|
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 |
* 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
|
637 |
* 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
|
638 |
* 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
|
639 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
640 |
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
|
641 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
642 |
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
|
643 |
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
|
644 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
645 |
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
|
646 |
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
|
647 |
} |
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 |
// 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
|
650 |
// 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
|
651 |
// 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
|
652 |
// 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
|
653 |
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
|
654 |
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
|
655 |
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
|
656 |
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
|
657 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
658 |
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
|
659 |
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
|
660 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
661 |
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
|
662 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
663 |
|
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 |
* 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
|
666 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
667 |
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
|
668 |
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
|
669 |
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
|
670 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
671 |
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
|
672 |
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
|
673 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
674 |
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
|
675 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
676 |
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
|
677 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
678 |
|
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 |
* 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
|
681 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
682 |
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
|
683 |
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
|
684 |
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
|
685 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
686 |
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
|
687 |
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
|
688 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
689 |
// 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
|
690 |
// 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
|
691 |
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
|
692 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
693 |
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
|
694 |
|
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 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
697 |
}; // </ 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
|
698 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
699 |
/** |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
700 |
* 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
|
701 |
* 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
|
702 |
* 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
|
703 |
* 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
|
704 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
705 |
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
|
706 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
707 |
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
|
708 |
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
|
709 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
710 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
711 |
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
|
712 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
713 |
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
|
714 |
// 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
|
715 |
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
|
716 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
717 |
// 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
|
718 |
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
|
719 |
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
|
720 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
721 |
// 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
|
722 |
// 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
|
723 |
// 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
|
724 |
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
|
725 |
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
|
726 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
727 |
// 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
|
728 |
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
|
729 |
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
|
730 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
731 |
// 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
|
732 |
results = { |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
733 |
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
|
734 |
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
|
735 |
}; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
736 |
} |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
737 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
738 |
return results; |
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.btPosition() > |
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 |
|
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 |
* 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
|
744 |
* |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
745 |
* 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
|
746 |
* 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
|
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.width = 400; |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
749 |
* |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
750 |
* 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
|
751 |
* |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
752 |
* 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
|
753 |
* |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
754 |
* 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
|
755 |
* |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
756 |
*/ |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
757 |
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
|
758 |
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
|
759 |
// 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
|
760 |
// 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
|
761 |
// examples: |
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
762 |
// ['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
|
763 |
// '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
|
764 |
// ['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
|
765 |
// '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
|
766 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
767 |
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
|
768 |
// 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
|
769 |
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
|
770 |
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
|
771 |
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
|
772 |
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
|
773 |
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
|
774 |
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
|
775 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
776 |
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
|
777 |
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
|
778 |
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
|
779 |
// 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
|
780 |
// 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
|
781 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
782 |
// 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
|
783 |
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
|
784 |
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
|
785 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
786 |
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
|
787 |
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
|
788 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
789 |
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
|
790 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
791 |
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
|
792 |
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
|
793 |
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
|
794 |
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
|
795 |
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
|
796 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
797 |
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
|
798 |
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
|
799 |
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
|
800 |
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
|
801 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
802 |
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
|
803 |
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
|
804 |
// 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
|
805 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
806 |
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
|
807 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
808 |
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
|
809 |
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
|
810 |
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
|
811 |
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
|
812 |
|
3a60d5e5c14e
Third-party Javascript that should have been part of r891. Same license as
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
813 |
}; // </ jQuery.bt.defaults > |