r66256 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66255‎ | r66256 | r66257 >
Date:04:04, 12 May 2010
Author:neilk
Status:deferred
Tags:
Comment:
tooltips that can pop up even more information
Modified paths:
  • /trunk/extensions/UploadWizard/js/jquery/plugins/jquery.tipsy.js (modified) (history)
  • /trunk/extensions/UploadWizard/js/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/js/jquery/plugins/jquery.tipsy.js
@@ -23,10 +23,11 @@
2424 var title = this.getTitle();
2525 if (title && this.enabled) {
2626 var $tip = this.tip();
27 -
2827 $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title);
2928 $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);
 29+ // the remove strips events
 30+ //$tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
 31+ $tip.css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
3132
3233 var pos = $.extend({}, this.$element.offset(), {
3334 width: this.$element[0].offsetWidth,
@@ -71,12 +72,14 @@
7273 }
7374 }
7475 },
75 -
 76+
7677 hide: function() {
77 - if (this.options.fade) {
78 - this.tip().stop().fadeOut(function() { $(this).remove(); });
79 - } else {
80 - this.tip().remove();
 78+ if (!this.sticky) {
 79+ if (this.options.fade) {
 80+ this.tip().stop().fadeOut(function() { $(this).hide(); });
 81+ } else {
 82+ this.tip().hide();
 83+ }
8184 }
8285 },
8386
@@ -86,10 +89,10 @@
8790 var title, o = this.options;
8891 if (typeof o.title == 'string') {
8992 title = $e.attr(o.title == 'title' ? 'original-title' : o.title);
 93+ title = ('' + title).replace(/(^\s*|\s*$)/, "");
9094 } else if (typeof o.title == 'function') {
9195 title = o.title.call($e[0]);
9296 }
93 - title = ('' + title).replace(/(^\s*|\s*$)/, "");
9497 return title || o.fallback;
9598 },
9699
@@ -137,7 +140,7 @@
138141 setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn);
139142 }
140143 };
141 -
 144+
142145 function leave() {
143146 var tipsy = get(this);
144147 tipsy.hoverState = 'out';
Index: trunk/extensions/UploadWizard/js/mw.UploadWizard.js
@@ -94,7 +94,9 @@
9595 "mwe-upwiz-tooltip-sign": "You can use your wiki User name or your real name. In both cases, this will be linked to your wiki User page",
9696 "mwe-upwiz-tooltip-title": "A short title for the image. You may use plain language with spaces, but no line breaks. This title must be unlike all other titles in this wiki.",
9797 "mwe-upwiz-tooltip-description": "Briefly describe everything notable about the work. For a photo, mention the main things that are depicted, the occasion or the place.",
98 - "mwe-upwiz-tooltip-other": "Any other information you want to include about this work. You may use wikitext code."
 98+ "mwe-upwiz-tooltip-other": "Any other information you want to include about this work. You may use wikitext code.",
 99+
 100+ "mwe-upwiz-tooltip-more-info": "Learn more."
99101
100102 } );
101103
@@ -978,8 +980,8 @@
979981 $j(_this.languageMenu).addClass('mwe-upwiz-desc-lang-select');
980982 _this.description = $j('<textarea name="desc" rows="2" cols="36" class="mwe-upwiz-desc-lang-text"></textarea>')
981983 .attr( 'title', gM( 'mwe-upwiz-tooltip-description' ) )
982 - .tipsy( { gravity: 'w', trigger: 'focus' } )
983 - .growTextArea();
 984+ .growTextArea()
 985+ .tipsyPlus( { plus: 'even more stuff' } );
984986 _this.div = $j('<div class="mwe-upwiz-desc-lang-container"></div>')
985987 .append( _this.languageMenu )
986988 .append( _this.description );
@@ -3117,6 +3119,46 @@
31183120
31193121 ( function( $j ) {
31203122
 3123+ $j.fn.tipsyPlus = function( options ) {
 3124+ var titleOption = 'title';
 3125+ var htmlOption = false;
 3126+ var el = this;
 3127+
 3128+ if (options.plus) {
 3129+ htmlOption = true;
 3130+ titleOption = function() {
 3131+ return $j( '<span />' ).append(
 3132+ $j( this ).attr( 'original-title' ),
 3133+ $j( '<a class="mwe-upwiz-tooltip-link"/>' )
 3134+ .attr( 'href', '#' )
 3135+ .append( gM( 'mwe-upwiz-tooltip-more-info' ) )
 3136+ .mouseenter( function() {
 3137+ el.data('tipsy').sticky = true;
 3138+ } )
 3139+ .mouseleave( function() {
 3140+ el.data('tipsy').sticky = false;
 3141+ } )
 3142+ .click( function() {
 3143+ // show the wiki page with more
 3144+ alert( options.plus );
 3145+ // pass this in as a closure to be called on dismiss
 3146+ el.focus();
 3147+ el.data('tipsy').sticky = false;
 3148+ } )
 3149+ );
 3150+ };
 3151+ }
 3152+
 3153+ return this.tipsy( {
 3154+ gravity: 'w',
 3155+ trigger: 'focus',
 3156+ title: titleOption,
 3157+ html: htmlOption
 3158+ } );
 3159+
 3160+ }
 3161+
 3162+
31213163 /**
31223164 * Prevent the closing of a window with a confirm message (the onbeforeunload event seems to
31233165 * work in most browsers

Status & tagging log