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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix direction icons for Firefox (and possibly Mac). #637

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/js/lib/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ define([], function () {
}()),
cssAnimation: true,
chromeframe: false,
selectOptionFont: !(uA.indexOf('FIREFOX') >= 0 || navigator.platform.toUpperCase().indexOf('MAC') >= 0),
},
};

Expand Down
18 changes: 9 additions & 9 deletions public/js/module/photo/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ define(['m/photo/status'], function () {
aero: 'Аэро/Спутник',
},
dirIcons: {
n: '',
ne: '',
e: '',
se: '',
s: '',
sw: '',
w: '',
nw: '',
aero: '',
n: ['', '🡡'],
ne: ['', '🡥'],
e: ['', '🡢'],
se: ['', '🡦'],
s: ['', '🡣'],
sw: ['', '🡧'],
w: ['', '🡠'],
nw: ['', '🡤'],
aero: ['', '◎'],
},
dirValsArr: ['w', 'nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'aero'],
watersign: {
Expand Down
11 changes: 9 additions & 2 deletions public/js/module/photo/photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Модель страницы фотографии
*/
define(['underscore', 'Utils', 'socket!', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'noties', 'model/Photo', 'model/Region', 'model/storage', 'm/photo/fields', 'm/photo/status', 'text!tpl/photo/photo.pug', 'css!style/photo/photo', 'bs/ext/multiselect', 'jquery-plugins/imgareaselect'], function (_, Utils, socket, P, ko, koMapping, Cliche, globalVM, renderer, moment, noties, Photo, Region, storage, fields, statuses, pug) {
define(['underscore', 'Utils', 'Browser', 'socket!', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche', 'globalVM', 'renderer', 'moment', 'noties', 'model/Photo', 'model/Region', 'model/storage', 'm/photo/fields', 'm/photo/status', 'text!tpl/photo/photo.pug', 'css!style/photo/photo', 'bs/ext/multiselect', 'jquery-plugins/imgareaselect'], function (_, Utils, Browser, socket, P, ko, koMapping, Cliche, globalVM, renderer, moment, noties, Photo, Region, storage, fields, statuses, pug) {
const $window = $(window);
const imgFailTpl = _.template('<div class="imgFail"><div class="failContent" style="${ style }">${ txt }</div></div>');
const statusKeys = statuses.keys;
Expand Down Expand Up @@ -2230,10 +2230,17 @@ define(['underscore', 'Utils', 'socket!', 'Params', 'knockout', 'knockout.mappin
setDirOptionHTML: function (option, item) {
// Render option content as html to decode entitites.
if (item !== undefined) {
const iconIndex = Browser.support.selectOptionFont ? 0 : 1;

ko.applyBindingsToNode(option, {
html: fields.dirIcons[item] + '&nbsp;' + fields.dirVals[item],
html: fields.dirIcons[item][iconIndex] + '&nbsp;' + fields.dirVals[item],
});
}
},
getDirIcon: function (dir) {
const iconIndex = Browser.support.selectOptionFont ? 0 : 1;

return fields.dirIcons[dir][iconIndex];
},
});
});
2 changes: 1 addition & 1 deletion views/module/photo/photo.pug
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
//ko if: p.dir && p.dir() && p.dir().length
.info
span.infoName(data-bind="html: fields.dir+':'")
span.direction-icon(data-bind="html: fields.dirIcons[p.dir()]")
span.direction-icon(data-bind="html: getDirIcon(p.dir())")
| &nbsp;
span(data-bind="text: fields.dirVals[p.dir()]", style="text-transform: lowercase;")
// /ko
Expand Down