diff options
Diffstat (limited to 'site/app/webroot/js/addons.js')
-rw-r--r-- | site/app/webroot/js/addons.js | 132 |
1 files changed, 129 insertions, 3 deletions
diff --git a/site/app/webroot/js/addons.js b/site/app/webroot/js/addons.js index 6da858b..2f23003 100644 --- a/site/app/webroot/js/addons.js +++ b/site/app/webroot/js/addons.js @@ -260,10 +260,9 @@ function removeCompatibilityHint(versionID) { * This function is used on the addon version page to create an element * at the top of the page with the most recent compatible version of an addon */ -function createLatestVersionElement(get_latest_version_text) { +function createLatestVersionElement(get_latest_version_text, app) { var container = $("#latest-version-container"); - - container.wrapInner("<p>" + get_latest_version_text + " (" + gLatestApplicationVersion + ")" + "</p>"); + container.wrapInner("<p>" + sprintf(get_latest_version_text, app, gLatestApplicationVersion) + "</p>"); container.append(gLatestAddonVersion); var installButton = $("#install-"+ gLatestVersionID); var cloned = installButton.clone(); @@ -865,3 +864,130 @@ $.fn.collection = function(options) { /*# AVOID COLLISIONS #*/ })(jQuery); /*# AVOID COLLISIONS #*/ + +/** + * jQuery rollover reveal widget + * lorchard@mozilla.com + * + * Example markup: + * <div id="foo"> + * <a href="#" class="activator">Hover me</a> + * <div class="to-reveal">This content will appear</div> + * </div> + * <script> + * $('#foo').rolloverReveal({ + * reveal_delay: 1000, dismiss_delay: 2000 + * }) + * </script> + * + * Whenever the activator element is hovered, the to-reveal content will appear + * after a short delay. If the mouse leaves the activator or revealed content, + * the content will disappear after a short delay unless the mouse returns. + * + * Clicking on a link within the revealed content will dismiss the content. + */ +;if(jQuery) (function($){ + + $.fn.rolloverReveal = function(options) { + var $cls = arguments.callee.support; + $.each(this, function() { new $cls(this, options) }); + return this; + } + + $.fn.rolloverReveal.support = function(el, options) { + this.init(el, options); + }; + + $.fn.rolloverReveal.support.prototype = function() { + + var option_defaults = { + reveal_delay: 250, + dismiss_delay: 500 + }; + + return { + // Delayed execution timers. + timers: {}, + + /** Set up the object instance and event handlers for this widget. */ + init: function(el, options) { + var that = this; + this.options = $.extend({}, option_defaults, options); + + // Assign a unique ID to the element if none found. + if (!el.id) el.id = 'el-' + + (new Date()).getTime() + '-' + + parseInt(1000 * Math.random()); + + this.root = '#'+el.id; + this.to_reveal = $(this.root_id).find('.to-reveal'); + + // Wire up the event handlers for significant elements of + // the widget. + $(this.root) + .find('.activator') + .click(function() { that.toggle(); return false; }) + .mouseover(function() { that.schedule('reveal'); that.cancel('dismiss'); }) + .mouseout(function() { that.cancel('reveal'); that.schedule('dismiss'); }) + .end() + .find('.to-reveal') + .mouseover(function() { that.cancel('dismiss'); }) + .mouseout(function() { that.schedule('dismiss'); }) + .end() + .find('.to-reveal a') + .click(function() { that.dismiss(); return true; }) + .mouseover(function() { that.cancel('dismiss'); }) + .mouseout(function() { that.schedule('dismiss'); }) + .end(); + }, + + /** Reveal the hidden content */ + reveal: function() { + this.to_reveal.show().addClass('revealed'); + }, + + /** Determine whether the hidden content is revealed */ + revealStatus: function() { + return this.to_reveal.hasClass('revealed'); + }, + + /** Dismiss the hidden content */ + dismiss: function() { + this.to_reveal.hide().removeClass('revealed'); + }, + + /** Determine whether the hidden content is hidden */ + dismissStatus: function() { + return !this.to_reveal.hasClass('revealed'); + }, + + /** Toggle the hide/show of the content */ + toggle: function() { + return (this.revealStatus()) ? + this.dismiss() : this.reveal(); + }, + + /** Schedule delayed execution of the given action. */ + schedule: function(action) { + var that = this; + // Skip if the action is already in effect. + if (this[action+'Status']()) return; + // De-bounce any existing running timer. + this.cancel(action); + // Schedule a call to the given action. + this.timers[action] = setTimeout(function() { + that[action](); + }, this.options[action + '_delay']); + }, + + /** Cancel delayed execution of the given action. */ + cancel: function(action) { + if (this.timers[action]) + clearTimeout(this.timers[action]); + }, + + EOF:null + }; + }(); + +})(jQuery); |