Skip to content

Commit

Permalink
Fix direction icons for Firefox (and possibly Mac).
Browse files Browse the repository at this point in the history
Fixes #540
  • Loading branch information
kabalin committed Nov 27, 2023
1 parent ed0aa29 commit 20a1aa9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
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

0 comments on commit 20a1aa9

Please sign in to comment.