Fix additional breakage when bidi.browser.ui is true
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run
Broken by me in an edit to 181afb9
(#4534)
Follow-up to previous commit
This commit is contained in:
parent
ec50539e80
commit
531e8697be
2 changed files with 28 additions and 6 deletions
|
@ -424,8 +424,24 @@ Zotero.ItemFields = new function() {
|
||||||
* @returns {'auto' | 'ltr' | 'rtl'}
|
* @returns {'auto' | 'ltr' | 'rtl'}
|
||||||
*/
|
*/
|
||||||
this.getDirection = function (itemTypeID, field, itemLanguage) {
|
this.getDirection = function (itemTypeID, field, itemLanguage) {
|
||||||
field = this.getName(this.getBaseIDFromTypeAndField(itemTypeID, field) || field);
|
// Primary fields: follow app locale
|
||||||
switch (field) {
|
switch (field) {
|
||||||
|
case 'dateAdded':
|
||||||
|
case 'dateModified':
|
||||||
|
case 'accessDate':
|
||||||
|
return Zotero.dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fieldName = this.getName(fieldName);
|
||||||
|
if (!fieldName) {
|
||||||
|
return 'auto';
|
||||||
|
}
|
||||||
|
|
||||||
|
var baseField = this.getBaseIDFromTypeAndField(itemTypeID, fieldName);
|
||||||
|
if (baseField) {
|
||||||
|
fieldName = this.getName(baseField);
|
||||||
|
}
|
||||||
|
switch (fieldName) {
|
||||||
// Certain fields containing IDs, numbers, and data: always LTR
|
// Certain fields containing IDs, numbers, and data: always LTR
|
||||||
case 'ISBN':
|
case 'ISBN':
|
||||||
case 'ISSN':
|
case 'ISSN':
|
||||||
|
@ -449,11 +465,7 @@ Zotero.ItemFields = new function() {
|
||||||
case 'language':
|
case 'language':
|
||||||
case 'extra':
|
case 'extra':
|
||||||
return 'ltr';
|
return 'ltr';
|
||||||
// Primary fields: follow app locale
|
|
||||||
case 'dateAdded':
|
|
||||||
case 'dateModified':
|
|
||||||
case 'accessDate':
|
|
||||||
return Zotero.dir;
|
|
||||||
// Everything else: guess based on the language if we have one; otherwise auto
|
// Everything else: guess based on the language if we have one; otherwise auto
|
||||||
default:
|
default:
|
||||||
if (itemLanguage) {
|
if (itemLanguage) {
|
||||||
|
|
|
@ -44,4 +44,14 @@ describe("Zotero.ItemFields", function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#getDirection()", function () {
|
||||||
|
it("should return 'auto' for non-field", function () {
|
||||||
|
assert.equal(Zotero.ItemFields.getDirection('book', 'creator-0-lastName', ''), 'auto');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should follow app locale for primary field", function () {
|
||||||
|
assert.equal(Zotero.ItemFields.getDirection('book', 'dateAdded', ''), Zotero.dir)
|
||||||
|
});
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue