Commit 16e89ce8 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Get rid of little edit window, and just show the editing modal. Less

confusing about what is going on. Add missing handler to copy back from
the XML after closing the editing modal. Add an onbeforeunload event
to catch unsaved modified profiles.
parent 7d391a91
......@@ -19,10 +19,11 @@ function (_, sup, filesize, ShowImagingModal,
'use strict';
var profile_uuid = null;
var version_uuid = null;
var snapping= 0;
var gotrspec = 0;
var ajaxurl = "";
var amlist = null;
var snapping = 0;
var gotrspec = 0;
var ajaxurl = "";
var amlist = null;
var modified = false;
var manageTemplate = _.template(manageString);
var waitwaitTemplate = _.template(waitwaitString);
var rendererTemplate = _.template(rendererString);
......@@ -50,6 +51,13 @@ function (_, sup, filesize, ShowImagingModal,
gotrspec = 1;
}
// Warn user if they have not saved changes.
window.onbeforeunload = function() {
if (! modified)
return null;
return "You have unsaved changes!";
}
// Generate the templates.
var manage_html = manageTemplate({
formfields: fields,
......@@ -107,6 +115,9 @@ function (_, sup, filesize, ShowImagingModal,
});
$('body').show();
//
// File upload handler.
//
$('#rspecfile').change(function() {
var reader = new FileReader();
reader.onload = function(event) {
......@@ -133,19 +144,12 @@ function (_, sup, filesize, ShowImagingModal,
reader.readAsText(this.files[0]);
});
$.fn.animateBackgroundHighlight = function(highlightColor, duration) {
var highlightBg = highlightColor || "#FFFF9C";
var animateMs = duration || 1500;
var originalBg = this.css("backgroundColor");
console.log(originalBg);
};
$('#showtopo_modal_button').click(function (event) {
event.preventDefault();
// The rspec is taken from the text area.
ShowRspecTopo($('#profile_rspec_textarea').val());
});
$('#expand_rspec_modal_button').click(function (event) {
$('#show_rspec_modal_button').click(function (event) {
$('#modal_profile_rspec_textarea').val(
$('#profile_rspec_textarea').val());
$('#rspec_modal').modal({'backdrop':'static','keyboard':false});
......@@ -157,9 +161,13 @@ function (_, sup, filesize, ShowImagingModal,
$('#profile_rspec_textarea').val(
$('#modal_profile_rspec_textarea').val());
$('#rspec_modal').modal('hide');
$('#modal_profile_rspec_textarea').val("");
$('#profile_rspec_textarea').css({"opacity":"0.2"});
$('#profile_rspec_textarea').animate({"opacity":"1.0"}, 1500);
$('#modal_profile_rspec_textarea').val("");
// Update the form.
var xmlDoc = $.parseXML($('#profile_rspec_textarea').val());
var xml = $(xmlDoc);
ExtractFromRspec(xml);
ProfileModified();
});
// Auto select the URL if the user clicks in the box.
$('#profile_url').click(function() {
......@@ -221,8 +229,6 @@ function (_, sup, filesize, ShowImagingModal,
$('#profile_who_public').change(function() { ProfileModified(); });
$('#profile_who_registered').change(function() { ProfileModified(); });
$('#profile_who_private').change(function() { ProfileModified(); });
$('#profile_rspec_textarea').change(function() { ProfileModified(); });
$('#modal_profile_rspec_textarea').change(function(){ProfileModified();});
/*
* A double click handler that will render the instructions
......@@ -725,6 +731,7 @@ function (_, sup, filesize, ShowImagingModal,
}
function ProfileModified()
{
modified = true;
EnableButton("profile_submit_button");
}
......
......@@ -189,31 +189,16 @@
<% if (! gotrspec) { %>invisible<% } %>'
type='button'
style='margin-right: 10px;'
id='show_rspec_textarea_button'
data-toggle='collapse' data-target='#rspec_textarea'>
id='show_rspec_modal_button'>
Edit</button>
</div>
</div>
<div class='collapse' id='rspec_textarea'
style='margin-top: 4px;'>
<div class='row'>
<div class='col-xs-12'>
<textarea name="formfields[profile_rspec]"
id='profile_rspec_textarea'
rows=5
class='form-control format-me'
type='textarea' data-key='profile_rspec'
><%- formfields.profile_rspec %></textarea>
</div>
</div>
<div class='row' style='margin-top: 4px;'>
<div class='col-xs-12'>
<button class='btn btn-primary btn-xs' type='button'
id='expand_rspec_modal_button'>
Expand</button>
</div>
</div>
</div>
<textarea name="formfields[profile_rspec]"
id='profile_rspec_textarea'
rows=5
class='form-control hidden'
type='textarea' data-key='profile_rspec'>
<%- formfields.profile_rspec %></textarea>
</div>
<textarea name=formfields[profile_description]
id='profile_description'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment