|
From: <tob...@us...> - 2014-06-10 20:59:51
|
Revision: 8459
http://sourceforge.net/p/bigdata/code/8459
Author: tobycraig
Date: 2014-06-10 20:59:43 +0000 (Tue, 10 Jun 2014)
Log Message:
-----------
Fixed file drag & drop on update pane
Modified Paths:
--------------
branches/WORKBENCH_QUERY_HISTORY/bigdata-war/src/html/js/workbench.js
Modified: branches/WORKBENCH_QUERY_HISTORY/bigdata-war/src/html/js/workbench.js
===================================================================
--- branches/WORKBENCH_QUERY_HISTORY/bigdata-war/src/html/js/workbench.js 2014-06-10 14:36:56 UTC (rev 8458)
+++ branches/WORKBENCH_QUERY_HISTORY/bigdata-war/src/html/js/workbench.js 2014-06-10 20:59:43 UTC (rev 8459)
@@ -322,22 +322,28 @@
/* Update */
-function handleDragOver(e) {
+function handleDragOver(cm, e) {
e.stopPropagation();
e.preventDefault();
- e.originalEvent.dataTransfer.dropEffect = 'copy';
+ e.dataTransfer.dropEffect = 'copy';
}
-function handleFile(e) {
+function handleDrop(cm, e) {
e.stopPropagation();
e.preventDefault();
+ var files = e.dataTransfer.files;
+ handleFile(files);
+}
- if(e.type == 'drop') {
- var files = e.originalEvent.dataTransfer.files;
- } else {
- var files = e.originalEvent.target.files;
- }
-
+function handleFileInput(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ var files = e.originalEvent.target.files;
+ handleFile(files);
+ $('#update-file').val('');
+}
+
+function handleFile(files) {
// only one file supported
if(files.length > 1) {
alert('Ignoring all but first file');
@@ -348,31 +354,29 @@
// if file is too large, tell user to supply local path
if(f.size > 1048576 * 100) {
alert('File too large, enter local path to file');
- $('#update-box').val('/path/to/' + f.name);
+ EDITORS.update.setValue('/path/to/' + f.name);
setType('path');
- $('#update-box').prop('disabled', false)
+ EDITORS.update.setOption('readOnly', false)
$('#large-file-message, #clear-file').hide();
} else {
var fr = new FileReader();
- fr.onload = function(e2) {
+ fr.onload = function(e) {
if(f.size > 10240) {
// do not use textarea
- $('#update-box').prop('disabled', true)
+ EDITORS.update.setOption('readOnly', true)
$('#filename').html(f.name);
$('#large-file-message, #clear-file').show()
- $('#update-box').val('');
- FILE_CONTENTS = e2.target.result;
+ EDITORS.update.setValue('');
+ FILE_CONTENTS = e.target.result;
} else {
// display file contents in the textarea
clearFile();
- $('#update-box').val(e2.target.result);
+ EDITORS.update.setValue(e.target.result);
}
- guessType(f.name.split('.').pop().toLowerCase(), e2.target.result);
+ guessType(f.name.split('.').pop().toLowerCase(), e.target.result);
};
fr.readAsText(f);
}
-
- $('#update-file').val('');
}
function clearFile(e) {
@@ -490,11 +494,11 @@
var sparql_update_commands = ['INSERT', 'DELETE', 'LOAD', 'CLEAR'];
-$('#update-file').change(handleFile);
-$('#update-box').on('dragover', handleDragOver)
- .on('drop', handleFile)
- .on('paste', handlePaste)
- .on('input propertychange', function() { $('#update-errors').hide(); });
+$('#update-file').change(handleFileInput);
+// $('#update-box').on('dragover', handleDragOver)
+// .on('drop', handleFile)
+// .on('paste', handlePaste)
+// .on('input propertychange', function() { $('#update-errors').hide(); });
$('#clear-file').click(clearFile);
$('#update-update').click(submitUpdate);
@@ -506,6 +510,9 @@
ERROR_CHARACTER_MARKERS.update.clear();
}
});
+EDITORS.update.on('dragover', handleDragOver);
+EDITORS.update.on('drop', handleDrop);
+EDITORS.update.on('paste', handlePaste);
EDITORS.update.addKeyMap({'Ctrl-Enter': submitUpdate});
function submitUpdate(e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|