Fix on autofocus of prefix field.

We don't want it to be focused on page load, but each time the archive is selected (either through DeviceStorage or manual file selection)
This commit is contained in:
mossroy 2013-07-27 12:14:41 +02:00
parent 21a97278b2
commit 86c2fe532d
2 changed files with 8 additions and 4 deletions

View File

@ -44,7 +44,7 @@
<br /> <br />
<form id="formTitleSearch" class="form-search"> <form id="formTitleSearch" class="form-search">
<div class="input-append"> <div class="input-append">
<input type="text" id="prefix" value="" placeholder="Find titles starting with..." class="input-medium search-query" autofocus/>&nbsp; <input type="text" id="prefix" value="" placeholder="Find titles starting with..." class="input-medium search-query" />&nbsp;
<a class="btn" id="searchTitles" href="#"><i class="icon-search"></i></a> <a class="btn" id="searchTitles" href="#"><i class="icon-search"></i></a>
</div> </div>
<img id="searchingForTitles" src="img/spinner.gif" style="display: none;"/> <img id="searchingForTitles" src="img/spinner.gif" style="display: none;"/>

View File

@ -55,9 +55,9 @@ define(function(require) {
else { else {
// If DeviceStorage is not available, we display the file select components // If DeviceStorage is not available, we display the file select components
displayFileSelect(); displayFileSelect();
setLocalArchiveFromFileSelect(); if (document.getElementById('archiveFiles').files && document.getElementById('archiveFiles').files.length>0) {
if (localArchive.dataFiles.length>0) { // Archive files are already selected,
// Hide the configuration elements if already set setLocalArchiveFromFileSelect();
$('#configuration').hide(); $('#configuration').hide();
} }
} }
@ -104,6 +104,8 @@ define(function(require) {
localArchive.readMathFilesFromStorage(storage, archiveDirectory); localArchive.readMathFilesFromStorage(storage, archiveDirectory);
localArchive.readMetadataFileFromStorage(storage, archiveDirectory); localArchive.readMetadataFileFromStorage(storage, archiveDirectory);
localArchive.readCoordinateFilesFromStorage(storage, archiveDirectory, 0); localArchive.readCoordinateFilesFromStorage(storage, archiveDirectory, 0);
// The archive is set : focus on the prefix field to start searching
document.getElementById("prefix").focus();
} }
/** /**
@ -120,6 +122,8 @@ define(function(require) {
function setLocalArchiveFromFileSelect() { function setLocalArchiveFromFileSelect() {
localArchive = new evopedia.LocalArchive(); localArchive = new evopedia.LocalArchive();
localArchive.initializeFromArchiveFiles(document.getElementById('archiveFiles').files); localArchive.initializeFromArchiveFiles(document.getElementById('archiveFiles').files);
// The archive is set : focus on the prefix field to start searching
document.getElementById("prefix").focus();
} }
/** /**