mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +08:00
Move locale dropdown to right side of header
This commit is contained in:
parent
47730cffeb
commit
ed234db09d
|
@ -23,33 +23,6 @@ export default class HeaderPrimary extends Component {
|
|||
* @return {ItemList}
|
||||
*/
|
||||
items() {
|
||||
const items = new ItemList();
|
||||
|
||||
if (Object.keys(app.locales).length > 1) {
|
||||
const locales = [];
|
||||
|
||||
for (const locale in app.locales) {
|
||||
locales.push(Button.component({
|
||||
active: app.locale === locale,
|
||||
children: app.locales[locale],
|
||||
icon: app.locale === locale ? 'check' : true,
|
||||
onclick: () => {
|
||||
if (app.session.user) {
|
||||
app.session.user.savePreferences({locale}).then(() => window.location.reload());
|
||||
} else {
|
||||
document.cookie = `locale=${locale}; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT`;
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
items.add('locale', SelectDropdown.component({
|
||||
children: locales,
|
||||
buttonClassName: 'Button Button--link'
|
||||
}));
|
||||
}
|
||||
|
||||
return items;
|
||||
return new ItemList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import Button from 'flarum/components/Button';
|
|||
import LogInModal from 'flarum/components/LogInModal';
|
||||
import SignUpModal from 'flarum/components/SignUpModal';
|
||||
import SessionDropdown from 'flarum/components/SessionDropdown';
|
||||
import SelectDropdown from 'flarum/components/SelectDropdown';
|
||||
import NotificationsDropdown from 'flarum/components/NotificationsDropdown';
|
||||
import ItemList from 'flarum/utils/ItemList';
|
||||
import listItems from 'flarum/helpers/listItems';
|
||||
|
@ -31,6 +32,31 @@ export default class HeaderSecondary extends Component {
|
|||
|
||||
items.add('search', app.search.render());
|
||||
|
||||
if (Object.keys(app.locales).length > 1) {
|
||||
const locales = [];
|
||||
|
||||
for (const locale in app.locales) {
|
||||
locales.push(Button.component({
|
||||
active: app.locale === locale,
|
||||
children: app.locales[locale],
|
||||
icon: app.locale === locale ? 'check' : true,
|
||||
onclick: () => {
|
||||
if (app.session.user) {
|
||||
app.session.user.savePreferences({locale}).then(() => window.location.reload());
|
||||
} else {
|
||||
document.cookie = `locale=${locale}; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT`;
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
items.add('locale', SelectDropdown.component({
|
||||
children: locales,
|
||||
buttonClassName: 'Button Button--link'
|
||||
}));
|
||||
}
|
||||
|
||||
if (app.session.user) {
|
||||
items.add('notifications', NotificationsDropdown.component());
|
||||
items.add('session', SessionDropdown.component());
|
||||
|
|
Loading…
Reference in New Issue
Block a user