Clear profile (creates new file on next upload)

This commit is contained in:
Norbert Renner 2014-05-24 13:09:25 +02:00
parent 3c0765547c
commit 858b68f91e
4 changed files with 16 additions and 3 deletions

View file

@ -60,6 +60,7 @@
</div>
<div id="profile_div" class="hidden">
<form id="profile_upload" name="profile_upload">
<button id="clear">Clear</button>
<input type="submit" value="Upload" />
<div id="textarea_container">
<textarea type="text" name="profile" spellcheck="false" wrap="off" maxlength="100000" placeholder="... paste your custom routing profile here ..."></textarea>

View file

@ -5,11 +5,20 @@ BR.Profile = BR.Control.extend({
},
onAdd: function (map) {
L.DomUtil.get('profile_upload').onsubmit = L.bind(this._submit, this)
L.DomUtil.get('profile_upload').onsubmit = L.bind(this._submit, this);
L.DomUtil.get('clear').onclick = L.bind(this.clear, this);
return BR.Control.prototype.onAdd.call(this, map);
},
clear: function(evt) {
evt.preventDefault();
document.profile_upload.profile.value = null;
this.fire('clear');
},
_submit: function(evt) {
var form = evt.target || evt.srcElement,
profile = document.profile_upload.profile.value;

View file

@ -44,8 +44,8 @@ BR.RoutingOptions = BR.Control.extend({
select = L.DomUtil.get('profile');
option = select.options[0]
option.value = profile;
select.value = profile;
option.disabled = false;
option.disabled = !profile;
option.selected = !!profile;
if (!noUpdate) {
this.fire('update', {options: this.getOptions()});

View file

@ -119,6 +119,9 @@
routingOptions.setCustomProfile(profile);
});
});
profile.on('clear', function(evt) {
routingOptions.setCustomProfile(null);
});
routing = new BR.Routing({routing: {
router: L.bind(router.getRouteSegment, router)