-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Widgets: Add RTL support #1682
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Widgets: Add RTL support #1682
Changes from 1 commit
2c9539a
34004ae
8f86527
8ba1210
1946111
1a47821
6a00fb0
23cc693
543aaea
e3581d0
fc01eb6
43b3c2f
d1f0301
10deed0
6999e35
0a71279
c92c299
1a1f8b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>jQuery UI Accordion - Default functionality</title> | ||
<link rel="stylesheet" href="../../themes/base/all.css"> | ||
<link rel="stylesheet" href="../demos.css"> | ||
<script src="../../external/requirejs/require.js"></script> | ||
<script src="../bootstrap.js"> | ||
$( "#accordion" ).accordion(); | ||
</script> | ||
</head> | ||
<body dir="rtl"> | ||
|
||
<div id="accordion"> | ||
<h3>Section 1</h3> | ||
<div> | ||
<p> | ||
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer | ||
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit | ||
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut | ||
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. | ||
</p> | ||
</div> | ||
<h3>Section 2</h3> | ||
<div> | ||
<p> | ||
Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet | ||
purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor | ||
velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In | ||
suscipit faucibus urna. | ||
</p> | ||
</div> | ||
<h3>Section 3</h3> | ||
<div> | ||
<p> | ||
Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. | ||
Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero | ||
ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis | ||
lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. | ||
</p> | ||
<ul> | ||
<li>List item one</li> | ||
<li>List item two</li> | ||
<li>List item three</li> | ||
</ul> | ||
</div> | ||
<h3>Section 4</h3> | ||
<div> | ||
<p> | ||
Cras dictum. Pellentesque habitant morbi tristique senectus et netus | ||
et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in | ||
faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia | ||
mauris vel est. | ||
</p> | ||
<p> | ||
Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. | ||
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per | ||
inceptos himenaeos. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="demo-description"> | ||
<p> | ||
Click headers to expand/collapse content that is broken into logical sections, much like tabs. | ||
Optionally, toggle sections open/closed on mouseover. | ||
</p> | ||
<p> | ||
The underlying HTML markup is a series of headers (H3 tags) and content divs so the content is | ||
usable without JavaScript. | ||
</p> | ||
</div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,14 @@ | |
border-top: 0; | ||
overflow: auto; | ||
} | ||
|
||
/* RTL support */ | ||
.ui-accordion-rtl { | ||
direction: rtl; | ||
} | ||
.ui-accordion-rtl .ui-accordion .ui-accordion-header { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is overly specific (and actually wrong). I'd personally prefer just changing the rule to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
+1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
padding: .5em .7em .5em .5em; | ||
} | ||
.ui-accordion-header-iconRtl.ui-icon { | ||
transform: scaleX(-1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems wrong. The user has full control over what icons are used via the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The support aims to make the changes required to mirror the app as minimal as possible (just set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I very much disagree with this. This penalizes every user who uses RTL and a proper non-symmetrical icon. The documentation would have to tell users to intentionally build their icons backward or override our CSS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also many icons should not be mirrored for example play icons fastforward rewind etc all should never be mirrored mirroring is specific to the icon chosen. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that makes sense |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing new line at end of file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,9 @@ return $.widget( "ui.accordion", { | |
var options = this.options; | ||
|
||
this.prevShow = this.prevHide = $(); | ||
if ( this.isRtl() ) { | ||
this._addClass( ".ui-accordion-rtl" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't have a leading dot. I'm also not sure it should be a keyed class. |
||
} | ||
this._addClass( "ui-accordion", "ui-widget ui-helper-reset" ); | ||
this.element.attr( "role", "tablist" ); | ||
|
||
|
@@ -108,6 +111,9 @@ return $.widget( "ui.accordion", { | |
|
||
if ( icons ) { | ||
icon = $( "<span>" ); | ||
if ( this.isRtl() ) { | ||
this._addClass( icon, "ui-accordion-header-iconRtl" ); | ||
} | ||
this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header ); | ||
icon.prependTo( this.headers ); | ||
children = this.active.children( ".ui-accordion-header-icon" ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to exist? The direction is already set or we wouldn't be adding this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct for the current case. But it would be required if there is a parent widget with
dir ='rtl'
& its child widget exists somewhere in the DOM with nodir
attribute (e.g. autocomplete & menu).I know it doesn't make any sense her, but I added it in case we need it at some point & for the mirroring support to be consistent across all the widgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would never need this for accordion, so it doesn't make sense to add it.