From 4d15287fee5610bcf4d0b1a5f94af6cca92e01d2 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Thu, 18 Nov 2010 00:27:32 +0000 Subject: [PATCH] Updated jquery.tipsy and added it to the Resources manifest. --- resources/Resources.php | 6 + resources/jquery.tipsy/images/tipsy.png | Bin 0 -> 173 bytes resources/jquery.tipsy/jquery.tipsy.css | 68 ++++++++ resources/jquery.tipsy/jquery.tipsy.js | 198 ++++++++++++++++++++++++ 4 files changed, 272 insertions(+) create mode 100644 resources/jquery.tipsy/images/tipsy.png create mode 100644 resources/jquery.tipsy/jquery.tipsy.css create mode 100644 resources/jquery.tipsy/jquery.tipsy.js diff --git a/resources/Resources.php b/resources/Resources.php index 836bbb23f5..7728e4a1ed 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -76,6 +76,12 @@ return array( 'jquery.textSelection' => new ResourceLoaderFileModule( array( 'scripts' => 'resources/jquery/jquery.textSelection.js' ) ), + 'jquery.tipsy' => new ResourceLoaderFileModule( + array( + 'scripts' => 'resources/jquery.tipsy/jquery.tipsy.js', + 'styles' => 'resources/jquery.tipsy/jquery.tipsy.css', + ) + ), /* jQuery UI */ diff --git a/resources/jquery.tipsy/images/tipsy.png b/resources/jquery.tipsy/images/tipsy.png new file mode 100644 index 0000000000000000000000000000000000000000..945319b2568956f93ede262220c4e3cfcd94a5f3 GIT binary patch literal 173 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>3?#4ne^UZdk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*A&x0(?STmtX(+;?s}+|NobYwV5*cQCBze4=@WqL').html('
'); + } + return this.$tip; + }, + + validate: function() { + if (!this.$element[0].parentNode) { + this.hide(); + this.$element = null; + this.options = null; + } + }, + + enable: function() { this.enabled = true; }, + disable: function() { this.enabled = false; }, + toggleEnabled: function() { this.enabled = !this.enabled; } + }; + + $.fn.tipsy = function(options) { + + if (options === true) { + return this.data('tipsy'); + } else if (typeof options == 'string') { + return this.data('tipsy')[options](); + } + + options = $.extend({}, $.fn.tipsy.defaults, options); + + function get(ele) { + var tipsy = $.data(ele, 'tipsy'); + if (!tipsy) { + tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options)); + $.data(ele, 'tipsy', tipsy); + } + return tipsy; + } + + function enter() { + var tipsy = get(this); + tipsy.hoverState = 'in'; + if (options.delayIn == 0) { + tipsy.show(); + } else { + setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn); + } + }; + + function leave() { + var tipsy = get(this); + tipsy.hoverState = 'out'; + if (options.delayOut == 0) { + tipsy.hide(); + } else { + setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut); + } + }; + + if (!options.live) this.each(function() { get(this); }); + + if (options.trigger != 'manual') { + var binder = options.live ? 'live' : 'bind', + eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus', + eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'; + this[binder](eventIn, enter)[binder](eventOut, leave); + } + + return this; + + }; + + $.fn.tipsy.defaults = { + delayIn: 0, + delayOut: 0, + fade: false, + fallback: '', + gravity: 'n', + html: false, + live: false, + offset: 0, + opacity: 0.8, + title: 'title', + trigger: 'hover' + }; + + // Overwrite this method to provide options on a per-element basis. + // For example, you could store the gravity in a 'tipsy-gravity' attribute: + // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' }); + // (remember - do not modify 'options' in place!) + $.fn.tipsy.elementOptions = function(ele, options) { + return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; + }; + + $.fn.tipsy.autoNS = function() { + return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; + }; + + $.fn.tipsy.autoWE = function() { + return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; + }; + +})(jQuery); -- 2.20.1