Last modified: 2014-07-03 22:36:46 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T59146, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 57146 - tipsy can't use string for the title, if original element has non-empty title
tipsy can't use string for the title, if original element has non-empty title
Status: NEW
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.23.0
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks: tipsy
  Show dependency treegraph
 
Reported: 2013-11-17 02:46 UTC by kipod
Modified: 2014-07-03 22:36 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
patch for jquery.tipsy.js (1.45 KB, patch)
2013-11-17 03:00 UTC, kipod
Details

Description kipod 2013-11-17 02:46:29 UTC

    
Comment 1 kipod 2013-11-17 03:00:17 UTC
Created attachment 13817 [details]
patch for jquery.tipsy.js

remove duplicate declaration of variables, and correct usage of title when it's a string
Comment 2 kipod 2013-11-17 03:01:00 UTC
tipsy supposed to work with either a string or a function returning a string for "title". however, due to a small but, it doesn't work with a string: you can use "title" (in which case the original title will be used), but if you use anything else, instead of using it, tipsy will try to us an attribute whose name is that string, instead of using the string itself.

patch attached.

peace.
Comment 3 kipod 2013-11-17 03:03:19 UTC
/small but/small bug/
/try to us/try to use/
Comment 4 p858snake 2013-11-17 03:49:36 UTC
Can you please submit patches to our git (gerrit) development ecocycle?
Comment 5 This, that and the other (TTO) 2013-11-17 04:28:04 UTC
I think the behaviour you're seeing is expected: see the "Slightly Advanced Usage" section of [1]. The "title" property is meant to hold the name of the attribute whose value is used for the tooltip. If you want to use a custom string, use the "fallback" property, like Twinkle does [2].

[1] http://onehackoranother.com/projects/jquery/tipsy/
[2] https://github.com/azatoth/twinkle/blob/master/morebits.js#L592
Comment 6 kipod 2013-11-17 09:45:44 UTC
(In reply to comment #4)
> Can you please submit patches to our git (gerrit) development ecocycle?

unfortunately no - i did not go through all the steps required to install the "ecocycle" as you call it - i got stuck at some step (can't remember exactly where) and abandoned it. i might go back to it one day, but i doubt it will be soon.

(In reply to comment #5)
> I think the behaviour you're seeing is expected: see the "Slightly Advanced
> Usage" section of [1]. The "title" property is meant to hold the name of the
> attribute whose value is used for the tooltip. If you want to use a custom
> string, use the "fallback" property, like Twinkle does [2].
> 
> [1] http://onehackoranother.com/projects/jquery/tipsy/
> [2] https://github.com/azatoth/twinkle/blob/master/morebits.js#L592

the behavior might be "by design" that does not automatically preclude it from being a bug (designs can also contain bugs).

it is convoluted and does not make any sense. for the very rare case where you want to take the hint from some other attribute of the element (i can't think of a single case where such bizarre feature makes sense), one can always set

title: function(){return $(this).attr('foo'); }

(btw - it would make more sense to use "data" or "prop" than "attr" - strictly speaking only valid html attributes should be used with "attr")

otoh, the much more standard case is to feed the text when creating the tip. the current code uses an extra, completely superfluous field of "options" named "fallback" for that. 

making a very common case more difficult (or at least convoluted), in favor of some corner case which is not interesting (and can be easily implemented in the rare case someone will actually want it) is a bug, IMO.

however, i can concede that this behavior, though illogical,  should be preserved for backward compatibility.

i can not concede that removing the the extra variable declarations shouldn't be cleaned:

             var title, $e = this.$element, o = this.options;
             fixTitle($e);
             var title, o = this.options;

clearly, declaring "title" and "o" twice is just a sloppy bug - the line was copied and moved, but the original line was not removed.

peace.
Comment 7 kipod 2013-11-17 10:59:13 UTC
sorry for my previous long response.

the short and simple one is: "fallback" just doesn't work.
the twinkle example is nice, but as far as i could see, it points to dead code - there isn't a single callsite for this function, and once they'll create one, they'll have to fix this, because it doesn't do what the programmer thinks it does. 

the tipsy doc page does work (not really), but in order to do so, it creates an empty attribute named "original-title" on the element. this is completely  borked.

i could go into a long explanation why "fallback" doesn't work, but the simple fact is, it doesn't. either try it yourself or believe my - i tried it, and it doesn't (in order to make it work, you must create an empty attribute on the html element - this is completely perverted).

summary:
my patch fixes a real bug, and does not break any real backward compatibility. "fallback" never worked.
Comment 8 This, that and the other (TTO) 2013-11-17 11:02:47 UTC
I am a developer of Twinkle and I assure you that our tooltip code does work!

More to the point, patching MW's tipsy in this way would render it incompatible with other versions of tipsy, which is confusing. Hence I think it should not be done.
Comment 9 This, that and the other (TTO) 2013-11-17 11:10:23 UTC
(In reply to comment #7)
> there isn't a single callsite for this function,

Lines 254, 276, 571 of morebits call this function.
Comment 10 Bartosz Dziewoński 2013-11-17 11:27:21 UTC
(If you have any particular trouble setting up git-review or git, especially on Windows, then I'll be happy to help if you catch me on IRC or via e-mail. You can also try using http://tools.wmflabs.org/gerrit-patch-uploader/ to submit your patches via your MediaWiki.org account.)
Comment 11 Bartosz Dziewoński 2013-11-17 11:29:10 UTC
(The patch in attachment 13817 [details] here seems to be encoded in UTF-16, which apparently Bugzilla has problems with and won't show the diff, and I wouldn't be surprised if other tools refused to accept it too.)
Comment 12 kipod 2013-11-17 16:31:01 UTC
(In reply to comment #9)
> (In reply to comment #7)
> > there isn't a single callsite for this function,
> 
> Lines 254, 276, 571 of morebits call this function.

you are correct - i missed those in the search (my bad - i searched with a space).

however, this only works if the original "title" is empty. if you try to attach a tipsy tip to a node with existing hint (i.e., a non-empty "title" attribute), fallback is not usable. my patch does not break this case.


with current code, fallback only works if the node does not have a title, or if the node has some other empty attribute, and you pass to tipsy "title" with the name of this attribute.

my patch will not break the first case: if the original "title" is empty, fallback will still work.

with my patch, you could use "fallback" even when the original title is not empty, by passing

title: '',
fallback: yourstring

to tipsy. with current code, you just can't use fallback in this case.
(of course, with the patch, you can cut the detour and just pass
title: yourtring
)

of course, with my patch, you could bypass "fallback" altogether by passing the actual string as "title".


the only backward-compatibility case my patch *does* break is the case where you want a tip with the value of some attribute: for instance, you might want to see the ID of every node matching some selector, you could do
$(selector).tipsy({title: 'id'});
this is such an esoteric use, that it makes no sense to force everyone who wants to return a known string will be forced to use a function in order to save this esoteric case from the need to write
title: function(){return $(this).attr('id'); }




bottom line:
1) apologies for my long and winding comments
2) my patch will *not* break the twinkle use case, or any other case where the "title" attribute does not exist or is empty, which are the only cases where "fallback" works anyway.


peace.
Comment 13 kipod 2013-11-18 20:25:50 UTC
(In reply to comment #11)
> (The patch in attachment 13817 [details] here seems to be encoded in UTF-16,
> which
> apparently Bugzilla has problems with and won't show the diff, and I wouldn't
> be surprised if other tools refused to accept it too.)

strange.

i used 

git diff > tipsyPatch

on a linux box to create it, with a "mediawiki-core" that i cloned from github.

i do not think i explicitly changed the encoding of anything - neither the source file nor the patch. 
what is the encoding of the original file in the repo?

peace.
Comment 14 Bartosz Dziewoński 2013-11-18 22:19:37 UTC
All MediaWiki files should be encoded as UTF-8 or plain ASCII. This one seems to be properly ASCII on my machine.
Comment 15 Andre Klapper 2014-03-17 10:36:08 UTC
kipod: Any chance to put this into Gerrit by patching against https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/resources%2Fjquery.tipsy%2Fjquery.tipsy.js ? Could use http://tools.wmflabs.org/gerrit-patch-uploader/ for this...
Comment 16 kipod 2014-03-18 21:59:15 UTC
ooops - an oldie... i'll see what can i do - prolly not before the coming weekend.

there are other tipsy-related things i'm trying to push. if we decided to ignore upstream (as far as i can see, upstream is dead), i'd like to submit a couple more improvements:

-- add an option to instruct tipsy to stay alive when overing over the tip itself, not just the triggering element (this is very important with "rich" tips, which contain clickable elements like links etc.)

-- add an option to instruct tipsy to show the tip relative to the mouse, rather than the element (win WP this is important when the tip is attached to an internal link, because those can begin on one line and end on the next, which may cause the tip location to be surprising, thus violate the "least surprise" rule)


peace.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links