-
Notifications
You must be signed in to change notification settings - Fork 5.3k
jquery-ui:Base text direction support #1715
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -697,6 +697,32 @@ $.Widget.prototype = { | |
return !( $.isFunction( callback ) && | ||
callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || | ||
event.isDefaultPrevented() ); | ||
}, | ||
|
||
_getTextDir: function( text ) { | ||
if ( this.options.textDir === "auto" ) { | ||
|
||
// Look for first strong (either English or Arabic/Hebrew) character. | ||
// Resolve text direction accordingly ("rtl" for Arabic/Hebrew, "ltr" otherwise). | ||
var matcher = /[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec( text ); | ||
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. Please add a comment about which set of characters this is searching for. 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. Done. |
||
return ( matcher && ( matcher[ 0 ] > "z" ) ) ? "rtl" : "ltr"; | ||
} | ||
return this.options.textDir; | ||
}, | ||
|
||
_applyTextDir: function( param ) { | ||
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. Blank line between methods. 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. Done. |
||
if ( typeof param === "string" ) { | ||
param = param.replace( /[\u202A\u202B\u202C]/g, "" ); | ||
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. Please add a comment about what these characters are. 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. Done. |
||
|
||
// Unicode directional characters: 202A and 202B used to enforce text direction. | ||
// 202C - POP formatter closing directional segment. | ||
return ( this._getTextDir( param ) === "rtl" ? "\u202B" : "\u202A" ) + param + "\u202C"; | ||
} else if ( param.jquery ) { | ||
var isField = param.is( "input" ) || param.is( "textarea" ); | ||
param.css( "direction", this._getTextDir( isField ? param.val() : param.text() ) ); | ||
} else if ( param.nodeType === 1 ) { | ||
param.style.direction = this._getTextDir( param.textContent ); | ||
} | ||
} | ||
}; | ||
|
||
|
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.
These options are alphabetized. All files will need to be updated for the correct order.
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.
Done.