diff --git a/sourcing/static/js/sourcedoc.js b/sourcing/static/js/sourcedoc.js index 265cc31..d8a7bab 100644 --- a/sourcing/static/js/sourcedoc.js +++ b/sourcing/static/js/sourcedoc.js @@ -3,7 +3,10 @@ function add_message() { } function show_selection(event) { - var range = window.getSelection().getRangeAt(0); + var selection = window.getSelection(); + if(selection.type != 'Range') + return; + var range = selection.getRangeAt(0); var start_element = range.startContainer.parentElement; var end_element = range.endContainer.parentElement; @@ -41,9 +44,17 @@ $(function() { $("div#right").hide(); $("body").mouseup(show_selection); - - $("#show-span-selector").click(function(e) { - $("#span-selector").removeClass("hidden"); - $(this).hide(); - }); +}); + +$("#show-span-selector").click(function(e) { + e.preventDefault(); + $("#span-selector").removeClass("hidden"); + $(this).hide(); +}); + +$("#select-all").click(function(e) { + e.preventDefault(); + $("#span-selector").removeClass("hidden"); + $("#show-span-selector").hide(); + $("#span").text(doc_url + ",start=0,length=" + doc_length); }); diff --git a/sourcing/templates/view.html b/sourcing/templates/view.html index 3a94b6d..edc0955 100644 --- a/sourcing/templates/view.html +++ b/sourcing/templates/view.html @@ -43,7 +43,8 @@ div#text { font-family: Courier; } {% if doc.type == 'sourcedoc' and not span_length %} - show span selector + +
span:
{% endif %} @@ -52,6 +53,7 @@ div#text { font-family: Courier; } {% set scripts %} {% endset %}