diff options
| author | Alon Levy <alon@pobox.com> | 2014-10-20 13:25:32 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-10-20 21:36:37 +0300 |
| commit | c919c4bfef4ad9e2dc25d040c0727dd29ad541ae (patch) | |
| tree | dd6394603680976c48801b53321e8085b0db1505 /scripts/drag_n_drop.js | |
| parent | f1f4e937932f52c630831d0d501f8f8756b37531 (diff) | |
introduce require.js and rewrite tests
Yes, I'm being lazy. The purpose of require.js is to allow writing
modules, i.e. individual smaller then the whole files with clear
dependencies. This is achieved by using a new api provided by
require.js:
define, require, requirejs
Read more at [requirejs] (http://requirejs.org)
Tests have been rewritten to work correctly with require.js; they still
use jsdom.
Test output is now stored in the repository, all tests are run via
run_tests.js; This is a hack - once a good harness (with assertions,
suites - unittest like) presents itself it will be used.
Hidden here is also using FileSaver for history saving, so history is
saved to history.json instead to a random name. Plus dropping some dead
code.
Diffstat (limited to 'scripts/drag_n_drop.js')
| -rw-r--r-- | scripts/drag_n_drop.js | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/scripts/drag_n_drop.js b/scripts/drag_n_drop.js index 57cd4f1d..6d1101ae 100644 --- a/scripts/drag_n_drop.js +++ b/scripts/drag_n_drop.js @@ -1,24 +1,31 @@ -$(function() { +define('drag_n_drop', ['jquery', 'jquery-ui', 'rhizicore'], function($, __unused_jqueryui, RZ) { + +function init() { +console.log('rhizi: init drag-n-drop'); $(document).on('drop', function(e) { - e.stopPropagation(); - e.preventDefault(); - var files = e.originalEvent.dataTransfer.files; - var file = files[files.length - 1]; - var fr = new FileReader(); - fr.onload = function() { - if (fr.readyState != 2) { - console.log('drop: error: reading from file failed'); - } else { - console.log(fr.result); - graph.load_from_json(fr.result); - } + e.stopPropagation(); + e.preventDefault(); + var files = e.originalEvent.dataTransfer.files; + var file = files[files.length - 1]; + var fr = new FileReader(); + fr.onload = function() { + if (fr.readyState != 2) { + console.log('drop: error: reading from file failed'); + } else { + console.log('loading dropped file'); + RZ.graph.load_from_json(fr.result); } - fr.readAsText(file); + } + fr.readAsText(file); + return false; }); $(document).on('dragover', function (e) { - e.stopPropagation(); - e.preventDefault(); -}); -document.bloated = true; + e.stopPropagation(); + e.preventDefault(); + return false; }); +}; +return {'init': init }; + +}); // define |
