padding-left: 10px;
padding-right: 10px;
}
+#loading_message {
+ display: none;
+}
#directory {
height: 360px;
margin-left: 10px;
if( basepath.lastIndexOf('/') == basepath.length - 1 ) {
basepath = basepath.slice( 0, basepath.length - 1)
};
+ $('#textinfo_load_status').empty();
$('#stemma_graph').empty();
$('#textinfo_waitbox').show();
$('#textinfo_container').ajaxError(
var msg = "An error occurred: ";
var msghtml = $('<span>').attr('class', 'error').text(
msg + jqxhr.status + " " + jqxhr.statusText);
- $("#textinfo_container").append( msghtml ).show();
+ $("#textinfo_load_status").append( msghtml ).show();
}
}
);
$('#upload_button').button('enable');
}
+// Utility function to pull the JSON out of the <pre>-wrapped HTML that
+// plupload irritatingly returns.
+function parseResponse( resp ) {
+ return $.parseJSON($(resp).text() );
+}
+
function create_uploader(upload_url) {
uploader = new plupload.Uploader({
runtimes : 'html4',
uploader.bind('UploadProgress', function(up, file) {
$upl(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
});
+
+ uploader.bind('Error', function( up, args ) {
+ $('#upload_status').empty().append(
+ $('<span>').attr('class', 'error').append( 'A server error occurred' ) );
+ });
+
uploader.bind('FileUploaded', function(up, file, ret) {
- //token = ret.response;
- $('#upload-collation-dialog').dialog( 'option', 'buttons').cancel();
+ var result = parseResponse( ret.response );
+ if( result.id ) {
+ $('#upload-collation-dialog').dialog( 'option', 'buttons').cancel();
+ refreshDirectory();
+ loadTradition( result.id, result.name, 1 );
+ } else if( result.error ) {
+ file.status = plupload.FAILED;
+ $('#upload_status').empty().append(
+ $('<span>').attr('class', 'error').append( result.error ) );
+ }
});
uploader.init();
var stemmata = [];
function refreshDirectory () {
+ var lmesg = $('#loading_message').clone();
+ $('#directory').empty().append( lmesg.contents() );
$('#directory').load( "[% c.uri_for( 'directory' ) %]",
function(response, status, xhr) {
if (status == "error") {
</div>
<div id="directory_container">
<h2>Text directory</h2>
- <div id="directory">
- <h3>Loading texts, please wait...</h3>
- <img src="[% c.uri_for( 'images', 'ajax-loader.gif' ) %]" />
- </div>
+ <div id="directory"></div>
[% IF c.user_exists -%]
<div class="button" id="new_trad_button" onClick="start_upload_dialog();">
<span>Add a new text tradition</span>
<img src="[% c.uri_for( 'images', 'ajax-loader.gif' ) %]" alt="Loading tradition info..."/>
</div>
<div id="textinfo_container">
+ <div id="textinfo_load_status"></div>
<h2>Text <span class="texttitle"></span></h2>
<ul>
<li>has <span id="witness_num"></span> witnesses: <span id="witness_list"></span></li>
<div id="stemma_graph"></div>
</div>
+ <!-- Interim 'loading' message for directory box -->
+ <div id="loading_message">
+ <h3>Loading texts, please wait...</h3>
+ <img src="[% c.uri_for( 'images', 'ajax-loader.gif' ) %]" />
+ </div>
<!-- File upload dialog box -->
<div id="upload-collation-dialog" title="Upload a collation">