Index: trunk/phase3/resources/Resources.php |
— | — | @@ -76,6 +76,12 @@ |
77 | 77 | 'jquery.textSelection' => new ResourceLoaderFileModule( |
78 | 78 | array( 'scripts' => 'resources/jquery/jquery.textSelection.js' ) |
79 | 79 | ), |
| 80 | + 'jquery.tipsy' => new ResourceLoaderFileModule( |
| 81 | + array( |
| 82 | + 'scripts' => 'resources/jquery.tipsy/jquery.tipsy.js', |
| 83 | + 'styles' => 'resources/jquery.tipsy/jquery.tipsy.css', |
| 84 | + ) |
| 85 | + ), |
80 | 86 | |
81 | 87 | /* jQuery UI */ |
82 | 88 | |
Index: trunk/phase3/resources/jquery.tipsy/jquery.tipsy.js |
— | — | @@ -0,0 +1,198 @@ |
| 2 | +// tipsy, facebook style tooltips for jquery |
| 3 | +// version 1.0.0a |
| 4 | +// (c) 2008-2010 jason frame [jason@onehackoranother.com] |
| 5 | +// releated under the MIT license |
| 6 | + |
| 7 | +(function($) { |
| 8 | + |
| 9 | + function fixTitle($ele) { |
| 10 | + if ($ele.attr('title') || typeof($ele.attr('original-title')) != 'string') { |
| 11 | + $ele.attr('original-title', $ele.attr('title') || '').removeAttr('title'); |
| 12 | + } |
| 13 | + } |
| 14 | + |
| 15 | + function Tipsy(element, options) { |
| 16 | + this.$element = $(element); |
| 17 | + this.options = options; |
| 18 | + this.enabled = true; |
| 19 | + fixTitle(this.$element); |
| 20 | + } |
| 21 | + |
| 22 | + Tipsy.prototype = { |
| 23 | + show: function() { |
| 24 | + var title = this.getTitle(); |
| 25 | + if (title && this.enabled) { |
| 26 | + var $tip = this.tip(); |
| 27 | + |
| 28 | + $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title); |
| 29 | + $tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity |
| 30 | + $tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body); |
| 31 | + |
| 32 | + var pos = $.extend({}, this.$element.offset(), { |
| 33 | + width: this.$element[0].offsetWidth, |
| 34 | + height: this.$element[0].offsetHeight |
| 35 | + }); |
| 36 | + |
| 37 | + var actualWidth = $tip[0].offsetWidth, actualHeight = $tip[0].offsetHeight; |
| 38 | + var gravity = (typeof this.options.gravity == 'function') |
| 39 | + ? this.options.gravity.call(this.$element[0]) |
| 40 | + : this.options.gravity; |
| 41 | + |
| 42 | + var tp; |
| 43 | + switch (gravity.charAt(0)) { |
| 44 | + case 'n': |
| 45 | + tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; |
| 46 | + break; |
| 47 | + case 's': |
| 48 | + tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; |
| 49 | + break; |
| 50 | + case 'e': |
| 51 | + tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}; |
| 52 | + break; |
| 53 | + case 'w': |
| 54 | + tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}; |
| 55 | + break; |
| 56 | + } |
| 57 | + |
| 58 | + if (gravity.length == 2) { |
| 59 | + if (gravity.charAt(1) == 'w') { |
| 60 | + tp.left = pos.left + pos.width / 2 - 15; |
| 61 | + } else { |
| 62 | + tp.left = pos.left + pos.width / 2 - actualWidth + 15; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + $tip.css(tp).addClass('tipsy-' + gravity); |
| 67 | + |
| 68 | + if (this.options.fade) { |
| 69 | + $tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity}); |
| 70 | + } else { |
| 71 | + $tip.css({visibility: 'visible', opacity: this.options.opacity}); |
| 72 | + } |
| 73 | + } |
| 74 | + }, |
| 75 | + |
| 76 | + hide: function() { |
| 77 | + if (this.options.fade) { |
| 78 | + this.tip().stop().fadeOut(function() { $(this).remove(); }); |
| 79 | + } else { |
| 80 | + this.tip().remove(); |
| 81 | + } |
| 82 | + }, |
| 83 | + |
| 84 | + getTitle: function() { |
| 85 | + var title, $e = this.$element, o = this.options; |
| 86 | + fixTitle($e); |
| 87 | + var title, o = this.options; |
| 88 | + if (typeof o.title == 'string') { |
| 89 | + title = $e.attr(o.title == 'title' ? 'original-title' : o.title); |
| 90 | + } else if (typeof o.title == 'function') { |
| 91 | + title = o.title.call($e[0]); |
| 92 | + } |
| 93 | + title = ('' + title).replace(/(^\s*|\s*$)/, ""); |
| 94 | + return title || o.fallback; |
| 95 | + }, |
| 96 | + |
| 97 | + tip: function() { |
| 98 | + if (!this.$tip) { |
| 99 | + this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"/></div>'); |
| 100 | + } |
| 101 | + return this.$tip; |
| 102 | + }, |
| 103 | + |
| 104 | + validate: function() { |
| 105 | + if (!this.$element[0].parentNode) { |
| 106 | + this.hide(); |
| 107 | + this.$element = null; |
| 108 | + this.options = null; |
| 109 | + } |
| 110 | + }, |
| 111 | + |
| 112 | + enable: function() { this.enabled = true; }, |
| 113 | + disable: function() { this.enabled = false; }, |
| 114 | + toggleEnabled: function() { this.enabled = !this.enabled; } |
| 115 | + }; |
| 116 | + |
| 117 | + $.fn.tipsy = function(options) { |
| 118 | + |
| 119 | + if (options === true) { |
| 120 | + return this.data('tipsy'); |
| 121 | + } else if (typeof options == 'string') { |
| 122 | + return this.data('tipsy')[options](); |
| 123 | + } |
| 124 | + |
| 125 | + options = $.extend({}, $.fn.tipsy.defaults, options); |
| 126 | + |
| 127 | + function get(ele) { |
| 128 | + var tipsy = $.data(ele, 'tipsy'); |
| 129 | + if (!tipsy) { |
| 130 | + tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options)); |
| 131 | + $.data(ele, 'tipsy', tipsy); |
| 132 | + } |
| 133 | + return tipsy; |
| 134 | + } |
| 135 | + |
| 136 | + function enter() { |
| 137 | + var tipsy = get(this); |
| 138 | + tipsy.hoverState = 'in'; |
| 139 | + if (options.delayIn == 0) { |
| 140 | + tipsy.show(); |
| 141 | + } else { |
| 142 | + setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn); |
| 143 | + } |
| 144 | + }; |
| 145 | + |
| 146 | + function leave() { |
| 147 | + var tipsy = get(this); |
| 148 | + tipsy.hoverState = 'out'; |
| 149 | + if (options.delayOut == 0) { |
| 150 | + tipsy.hide(); |
| 151 | + } else { |
| 152 | + setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut); |
| 153 | + } |
| 154 | + }; |
| 155 | + |
| 156 | + if (!options.live) this.each(function() { get(this); }); |
| 157 | + |
| 158 | + if (options.trigger != 'manual') { |
| 159 | + var binder = options.live ? 'live' : 'bind', |
| 160 | + eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus', |
| 161 | + eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'; |
| 162 | + this[binder](eventIn, enter)[binder](eventOut, leave); |
| 163 | + } |
| 164 | + |
| 165 | + return this; |
| 166 | + |
| 167 | + }; |
| 168 | + |
| 169 | + $.fn.tipsy.defaults = { |
| 170 | + delayIn: 0, |
| 171 | + delayOut: 0, |
| 172 | + fade: false, |
| 173 | + fallback: '', |
| 174 | + gravity: 'n', |
| 175 | + html: false, |
| 176 | + live: false, |
| 177 | + offset: 0, |
| 178 | + opacity: 0.8, |
| 179 | + title: 'title', |
| 180 | + trigger: 'hover' |
| 181 | + }; |
| 182 | + |
| 183 | + // Overwrite this method to provide options on a per-element basis. |
| 184 | + // For example, you could store the gravity in a 'tipsy-gravity' attribute: |
| 185 | + // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' }); |
| 186 | + // (remember - do not modify 'options' in place!) |
| 187 | + $.fn.tipsy.elementOptions = function(ele, options) { |
| 188 | + return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; |
| 189 | + }; |
| 190 | + |
| 191 | + $.fn.tipsy.autoNS = function() { |
| 192 | + return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; |
| 193 | + }; |
| 194 | + |
| 195 | + $.fn.tipsy.autoWE = function() { |
| 196 | + return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; |
| 197 | + }; |
| 198 | + |
| 199 | +})(jQuery); |
Property changes on: trunk/phase3/resources/jquery.tipsy/jquery.tipsy.js |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 200 | + text/plain |
Added: svn:eol-style |
2 | 201 | + native |
Index: trunk/phase3/resources/jquery.tipsy/images/tipsy.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/phase3/resources/jquery.tipsy/images/tipsy.png |
___________________________________________________________________ |
Added: svn:mime-type |
3 | 202 | + application/octet-stream |
Index: trunk/phase3/resources/jquery.tipsy/jquery.tipsy.css |
— | — | @@ -0,0 +1,68 @@ |
| 2 | +.tipsy { |
| 3 | + padding: 5px; |
| 4 | + position: absolute; |
| 5 | + z-index: 100000; |
| 6 | +} |
| 7 | +.tipsy-inner { |
| 8 | + padding: 5px 8px 4px 8px; |
| 9 | + background-color: #e8f2f8; |
| 10 | + border: solid 1px #a7d7f9; |
| 11 | + color: black; |
| 12 | + max-width: 200px; |
| 13 | + text-align: center; |
| 14 | +} |
| 15 | +.tipsy-inner { |
| 16 | + border-radius: 3px; |
| 17 | + -moz-border-radius: 3px; |
| 18 | + -webkit-border-radius: 3px; |
| 19 | +} |
| 20 | +.tipsy-arrow { |
| 21 | + position: absolute; |
| 22 | + background: url('images/tipsy.png') no-repeat top left; |
| 23 | + width: 9px; |
| 24 | + height: 5px; |
| 25 | +} |
| 26 | +.tipsy-n .tipsy-arrow { |
| 27 | + top: 1px; |
| 28 | + left: 50%; |
| 29 | + margin-left: -4px; |
| 30 | +} |
| 31 | +.tipsy-nw .tipsy-arrow { |
| 32 | + top: 1px; |
| 33 | + left: 10px; |
| 34 | +} |
| 35 | +.tipsy-ne .tipsy-arrow { |
| 36 | + top: 1px; |
| 37 | + right: 10px; |
| 38 | +} |
| 39 | +.tipsy-s .tipsy-arrow { |
| 40 | + bottom: 1px; |
| 41 | + left: 50%; |
| 42 | + margin-left: -4px; |
| 43 | + background-position: bottom left; |
| 44 | +} |
| 45 | +.tipsy-sw .tipsy-arrow { |
| 46 | + bottom: 1px; |
| 47 | + left: 10px; |
| 48 | + background-position: bottom left; |
| 49 | +} |
| 50 | +.tipsy-se .tipsy-arrow { |
| 51 | + bottom: 1px; |
| 52 | + right: 10px; |
| 53 | + background-position: bottom left; |
| 54 | +} |
| 55 | +.tipsy-e .tipsy-arrow { |
| 56 | + top: 50%; |
| 57 | + margin-top: -4px; |
| 58 | + right: 1px; |
| 59 | + width: 5px; |
| 60 | + height: 9px; |
| 61 | + background-position: top right; |
| 62 | +} |
| 63 | +.tipsy-w .tipsy-arrow { |
| 64 | + top: 50%; |
| 65 | + margin-top: -4px; |
| 66 | + left: 1px; |
| 67 | + width: 5px; |
| 68 | + height: 9px; |
| 69 | +} |
\ No newline at end of file |
Property changes on: trunk/phase3/resources/jquery.tipsy/jquery.tipsy.css |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 70 | + text/plain |
Added: svn:eol-style |
2 | 71 | + native |