Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

support target and popup attributes in pseudo-html text links #1726

Merged
merged 1 commit into from May 25, 2017

Conversation

alexcjohnson
Copy link
Contributor

Adds two new attributes for more flexibility to determine where links in our pseudo-html text will open:

  • target, which is preferred over xlink:show in modern browsers and has more functionality - but I still include xlink:show as a fallback: 'replace' if target is '_self', '_parent', or '_top' and 'new' for '_blank' or a named frame. Some xlink:show implementations seem to accept more values to partially bridge the gap with target but some don't, and I believe most that do will look at target anyway.
  • popup, which doesn't exist in html but we need a way to insert the "window features" string without accepting arbitrary javascript, so inventing a new attribute seemed like the easiest way. Note that target is sent as the second arg (name) to window.open, which lets you send subsequent requests to the same popup (or, uselessly, to not make a popup at all if you use '_self' etc)

So usage would look like:
'<a href="https://plot.ly" target="fred" popup="width=500,height=400,menubar=no">link</a>'

@etpinard look reasonable?
@scjody quick 馃悕 review? I poked at it for a while and couldn't find any problems but would love a second set of eyes. Note that both attribute values get encodeForHTML immediately on extraction.

* note that at least in Chrome, you need to give at least one property
* in this string or the page will open in a new tab anyway. We follow this
* convention and will not make a popup if this string is empty.
* per the spec, cannot contain whitespace.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be a point of browser inconsistency whether it still works with whitespace... alternatively I guess we could accept whitespace in the input but strip it from the output, but this was easier.

@@ -297,14 +322,14 @@ exports.plainText = function(_str) {
};

function replaceFromMapObject(_str, list) {
var out = _str || '';
if(!_str) return '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃悗 no need to loop over all these replacements on an empty string

@etpinard
Copy link
Contributor

@etpinard look reasonable?

Very reasonable. I'll leave it out to @scjody to review to 馃拑 over the 馃悕


Now, we should document these new pseudo-html features. We already have some info under the annotations text declaration, but really this extends to all text fields printed in SVG cc @cldougl

@alexcjohnson
Copy link
Contributor Author

Now, we should document these new pseudo-html features

Excellent point. Our pseudo-html applies to really anywhere we display text: annotations, plot and axis titles, trace names. Also tick labels (categories, ticktext, tickprefix, ticksuffix...) and trace text and hovertext though those are generally unclickable so this particular change doesn't matter there.

Seems like this format is too complex to include outright in all of these attribute, so we need some dedicated text formatting page that all of these attributes can somehow reference?

@etpinard
Copy link
Contributor

, so we need some dedicated text formatting page that all of these attributes can somehow reference?

馃憤

@etpinard
Copy link
Contributor

Maybe open up an issue on https://github.com/plotly/documentation/issues/new so we don't forget about it.

@scjody
Copy link
Contributor

scjody commented May 25, 2017

馃悕 looks good to me.

@alexcjohnson alexcjohnson merged commit 200a677 into master May 25, 2017
@alexcjohnson alexcjohnson deleted the popup-links branch May 25, 2017 20:05
@etpinard etpinard added this to the 1.28.0 milestone May 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants