Merge pull request #76 from bagage/feature/profile-sidebar

Move custom profile in sidebar
This commit is contained in:
Norbert Renner 2017-05-20 21:18:54 +02:00 committed by GitHub
commit 74a76ef4ef
4 changed files with 22 additions and 31 deletions

View file

@ -25,7 +25,8 @@
"leaflet.locatecontrol": "^0.60.0",
"font-awesome": "^4.7.0",
"bootstrap-select": "hugdx/bootstrap-select#patch-1",
"leaflet-sidebar": "^0.1.9"
"leaflet-sidebar": "^0.1.9",
"autosize": "^3.0.20"
},
"overrides": {
"leaflet": {
@ -96,6 +97,9 @@
"css/font-awesome.css",
"fonts/*"
]
},
"autosize": {
"main": "dist/autosize.js"
}
}
}

View file

@ -105,7 +105,7 @@ footer {
}
/* track messages (data tab) */
#tab_data {
#tab_data, #profile_upload {
font-size: x-small;
}

View file

@ -19,8 +19,6 @@
</div>
<div class="collapse navbar-toggleable-sm" id="collapsingNavbar">
<div class="nav navbar-nav">
<a class="nav-item nav-link" href="" data-toggle="modal" data-target="#options">
<span class="fa fa-lg fa-cog"></span>&nbsp;Options</a>
<div class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-lg fa-cloud-download"></span>&nbsp;Download</a>
@ -95,32 +93,6 @@
</div>
</div>
<!-- Options modal window -->
<div class="modal fade" id="options" tabindex="-1" role="dialog" aria-labelledby="Help window" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Options</h4>
</div>
<div class="modal-body">
<form>
<label for="profile_upload">Custom routing profile:</label>
<textarea class="form-control" type="text" id="profile_upload" spellcheck="false" wrap="off" rows="5"></textarea>
<div id="profile_message"></div>
<div class="form-group" id="profile_buttons">
<button id="clear" type="button" class="btn btn-sm"><span class="fa fa-eraser"></span> Clear</button>
<button id="upload" type="button" class="btn btn-sm" data-uploading-text="Uploading…"><span class="fa fa-cloud-upload"></span> Upload</button>
<a href="http://brouter.de/brouter/costfunctions.html" target="_blank" class="btn btn-sm btn-info pull-right"><span class="fa fa-question"></span> Help</a>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Layers modal window -->
<div class="modal fade" id="custom_layers" tabindex="-1" role="dialog" aria-labelledby="Layers window" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
@ -195,6 +167,17 @@
<div id="sidebar">
<form>
<label for="profile_upload">Custom routing profile</label>
<textarea class="form-control" type="text" id="profile_upload" spellcheck="false" wrap="off" placeholder="Write your custom profile here."></textarea>
<div id="profile_message"></div>
<div class="form-group" id="profile_buttons">
<button id="clear" type="button" class="btn btn-sm"><span class="fa fa-eraser"></span> Clear</button>
<button id="upload" type="button" class="btn btn-sm" data-uploading-text="Uploading…"><span class="fa fa-cloud-upload"></span> Upload</button>
<a href="http://brouter.de/brouter/costfunctions.html" target="_blank" class="btn btn-sm btn-info pull-right"><span class="fa fa-question"></span> Help</a>
</div>
</form>
<ul id="tab" class="nav nav-tabs" role="tablist">
</ul>
<div class="tab-content">

View file

@ -5,6 +5,7 @@ BR.Profile = L.Class.extend({
L.DomUtil.get('upload').onclick = L.bind(this._upload, this);
L.DomUtil.get('clear').onclick = L.bind(this.clear, this);
this.ele = L.DomUtil.get('profile_upload');
autosize(this.ele);
this.message = new BR.Message('profile_message', {
alert: true
});
@ -15,7 +16,8 @@ BR.Profile = L.Class.extend({
evt.preventDefault();
this.ele.value = null;
this.ele.defaultValue = this.ele.value;
this.ele.defaultValue = null;
autosize.update(this.ele);
this.fire('clear');
button.blur();
@ -43,11 +45,13 @@ BR.Profile = L.Class.extend({
if (!this.profileName || this.profileName === profileName) {
ele.value = profileText;
ele.defaultValue = ele.value;
autosize.update(this.ele);
}
}, this));
} else {
ele.value = this.cache[profileName];
ele.defaultValue = ele.value;
autosize.update(this.ele);
}
}
},