Replace profile options/editor switch buttons with Bootstrap tabs

This commit is contained in:
Norbert Renner 2019-11-11 19:22:38 +01:00
parent ef9cc7abe7
commit 21a8d8b5de
4 changed files with 94 additions and 68 deletions

View file

@ -191,8 +191,9 @@ input#trackname:focus:invalid {
cursor: auto;
}
#profile_editor {
display: none;
/* Override Bootstrap tabs that set `display` from `none` to `block` when activating */
.tab-content > #profile_editor.active {
display: flex;
}
#profile_buttons {
@ -440,7 +441,7 @@ table.dataTable.display tbody tr.even:hover {
min-height: 100%;
}
.leaflet-sidebar-pane#tab_profile .form-group {
#profile_params_container .form-group {
margin-bottom: 5px;
}

View file

@ -651,22 +651,55 @@
><span data-i18n="sidebar.customize-profile.title">Customize profile</span>
</h1>
<form class="flexcolumn flexgrow">
<div id="profile_params_container">
<ul class="nav nav-tabs " id="profileEditorTabs" role="tablist">
<li class="nav-item">
<a
class="nav-link active"
id="params-tab"
data-toggle="tab"
href="#profile_params_container"
role="tab"
aria-controls="profile_params_container"
aria-selected="true"
data-i18n="sidebar.profile.options"
>Options</a
>
</li>
<li class="nav-item">
<a
class="nav-link"
id="profile-editor-tab"
data-toggle="tab"
href="#profile_editor"
role="tab"
aria-controls="profile_editor"
aria-selected="false"
data-i18n="sidebar.profile.profile"
>Profile</a
>
</li>
</ul>
<div class="tab-content flexcolumn flexgrow" id="profileEditorTabsContent">
<div
id="profile_params_container"
class="tab-pane show active"
role="tabpanel"
aria-labelledby="params-tab"
>
<div id="profile_params"></div>
<div class="form-group" id="profile_buttons">
<button type="button" class="btn btn-info btn-sm" id="profile_advanced">
<span data-i18n="sidebar.profile.switch_advanced"
>Switch to advanced editor</span
>
</button>
<button id="save" type="button" class="btn btn-primary btn-sm pull-right">
<button id="save" type="button" class="btn btn-primary btn-sm">
<span class="fa fa-cloud-upload"></span>
<span data-i18n="sidebar.profile.save">Save</span>
</button>
</div>
</div>
<div id="profile_editor" class="flexcolumn flexgrow">
<div
id="profile_editor"
class="flexcolumn flexgrow tab-pane"
role="tabpanel"
aria-labelledby="profile-editor-tab"
>
<textarea
class="form-control flexgrow"
id="profile_upload"
@ -697,10 +730,7 @@
><span class="fa fa-question"></span>
<span data-i18n="sidebar.profile.help">Help</span></a
>
<button type="button" class="btn btn-info btn-sm" id="profile_basic">
<span data-i18n="sidebar.profile.switch_basic">Switch to basic editor</span>
</button>
</div>
</div>
</div>
</form>

View file

@ -7,13 +7,12 @@ BR.Profile = L.Evented.extend({
lineNumbers: true
});
var that = this;
L.DomUtil.get('profile_advanced').addEventListener('click', function() {
that._toggleAdvanced();
});
L.DomUtil.get('profile_basic').addEventListener('click', function() {
that._toggleAdvanced();
});
$('#profileEditorTabs a[data-toggle="tab"]').on(
'shown.bs.tab',
L.bind(function(e) {
this._activateSecondaryTab();
}, this)
);
L.DomUtil.get('save').onclick = L.bind(this._save, this);
L.DomUtil.get('upload').onclick = L.bind(this._upload, this);
@ -131,8 +130,8 @@ BR.Profile = L.Evented.extend({
});
},
_setValue: function(profileText) {
if (L.DomUtil.get('profile_editor').style.display == 'flex') {
_setValue: function(profileText, profileEditorActivated) {
if (L.DomUtil.get('profile_editor').classList.contains('active')) {
// Set value of the full editor and exit
this.editor.setValue(profileText);
this.editor.markClean();
@ -272,14 +271,10 @@ BR.Profile = L.Evented.extend({
});
},
_toggleAdvanced: function() {
if (L.DomUtil.get('profile_editor').style.display == 'flex') {
L.DomUtil.get('profile_params_container').style.display = 'initial';
L.DomUtil.get('profile_editor').style.display = 'none';
_activateSecondaryTab: function() {
if (L.DomUtil.get('profile_params_container').classList.contains('active')) {
this._setValue(this.editor.getValue());
} else {
L.DomUtil.get('profile_params_container').style.display = 'none';
L.DomUtil.get('profile_editor').style.display = 'flex';
this._setValue(this._buildCustomProfile());
}
}

View file

@ -203,13 +203,13 @@
"title": "Layers"
},
"profile": {
"profile": "Profile",
"options": "Options",
"clear": "Clear",
"help": "Help",
"no_easy_configuration_warning": "No easy configuration is available for this profile.",
"placeholder": "Write your custom profile here.",
"save": "Save",
"switch_advanced": "Switch to advanced editor",
"switch_basic": "Switch to basic editor",
"upload": "Upload"
}
},