From efee455a165c4e1839d2dd091eefd5eff160b281 Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Sun, 21 Jun 2015 02:19:34 +0300 Subject: fix mapping results loading --- .../static/new/javascript/create_lodchart.coffee | 4 +- .../static/new/javascript/create_lodchart.js | 139 +++++++++++---------- .../new/javascript/show_trait_mapping_tools.coffee | 17 ++- .../new/javascript/show_trait_mapping_tools.js | 17 ++- wqflask/wqflask/templates/base.html | 32 +---- wqflask/wqflask/templates/base_macro.html | 28 +++++ wqflask/wqflask/templates/marker_regression.html | 33 +---- wqflask/wqflask/templates/show_trait.html | 12 +- 8 files changed, 137 insertions(+), 145 deletions(-) create mode 100644 wqflask/wqflask/templates/base_macro.html diff --git a/wqflask/wqflask/static/new/javascript/create_lodchart.coffee b/wqflask/wqflask/static/new/javascript/create_lodchart.coffee index 76be5490..f1da65d7 100644 --- a/wqflask/wqflask/static/new/javascript/create_lodchart.coffee +++ b/wqflask/wqflask/static/new/javascript/create_lodchart.coffee @@ -44,8 +44,8 @@ create_manhattan_plot = -> d3.select(this) .transition().duration(500).attr("r", r*3) .transition().duration(500).attr("r", r) - -create_manhattan_plot() + +root.create_manhattan_plot = create_manhattan_plot $("#export").click => #Get d3 SVG element diff --git a/wqflask/wqflask/static/new/javascript/create_lodchart.js b/wqflask/wqflask/static/new/javascript/create_lodchart.js index f61f05bd..546d7c18 100644 --- a/wqflask/wqflask/static/new/javascript/create_lodchart.js +++ b/wqflask/wqflask/static/new/javascript/create_lodchart.js @@ -1,73 +1,76 @@ -// Generated by CoffeeScript 1.8.0 -var create_manhattan_plot; +// Generated by CoffeeScript 1.9.2 +(function() { + var create_manhattan_plot; -create_manhattan_plot = function() { - var additive, chrrect, data, h, halfh, margin, mychart, totalh, totalw, w; - h = 500; - w = 1200; - margin = { - left: 60, - top: 40, - right: 40, - bottom: 40, - inner: 5 - }; - halfh = h + margin.top + margin.bottom; - totalh = halfh * 2; - totalw = w + margin.left + margin.right; - if ('additive' in js_data) { - additive = js_data.additive; - } else { - additive = false; - } - console.log("js_data:", js_data); - mychart = lodchart().lodvarname("lod.hk").height(h).width(w).margin(margin).ylab("LOD score").manhattanPlot(js_data.manhattan_plot); - data = js_data.json_data; - d3.select("div#topchart").datum(data).call(mychart); - chrrect = mychart.chrSelect(); - chrrect.on("mouseover", function() { - return d3.select(this).attr("fill", "#E9CFEC"); - }).on("mouseout", function(d, i) { - return d3.select(this).attr("fill", function() { - if (i % 2) { - return "#F1F1F9"; - } - return "#FBFBFF"; + create_manhattan_plot = function() { + var additive, chrrect, data, h, halfh, margin, mychart, totalh, totalw, w; + h = 500; + w = 1200; + margin = { + left: 60, + top: 40, + right: 40, + bottom: 40, + inner: 5 + }; + halfh = h + margin.top + margin.bottom; + totalh = halfh * 2; + totalw = w + margin.left + margin.right; + if ('additive' in js_data) { + additive = js_data.additive; + } else { + additive = false; + } + console.log("js_data:", js_data); + mychart = lodchart().lodvarname("lod.hk").height(h).width(w).margin(margin).ylab("LOD score").manhattanPlot(js_data.manhattan_plot); + data = js_data.json_data; + d3.select("div#topchart").datum(data).call(mychart); + chrrect = mychart.chrSelect(); + chrrect.on("mouseover", function() { + return d3.select(this).attr("fill", "#E9CFEC"); + }).on("mouseout", function(d, i) { + return d3.select(this).attr("fill", function() { + if (i % 2) { + return "#F1F1F9"; + } + return "#FBFBFF"; + }); + }); + return mychart.markerSelect().on("click", function(d) { + var r; + r = d3.select(this).attr("r"); + return d3.select(this).transition().duration(500).attr("r", r * 3).transition().duration(500).attr("r", r); }); - }); - return mychart.markerSelect().on("click", function(d) { - var r; - r = d3.select(this).attr("r"); - return d3.select(this).transition().duration(500).attr("r", r * 3).transition().duration(500).attr("r", r); - }); -}; + }; -create_manhattan_plot(); + root.create_manhattan_plot = create_manhattan_plot; -$("#export").click((function(_this) { - return function() { - var filename, form, svg, svg_xml; - svg = $("#topchart").find("svg")[0]; - svg_xml = (new XMLSerializer).serializeToString(svg); - console.log("svg_xml:", svg_xml); - filename = "manhattan_plot_" + js_data.this_trait; - form = $("#exportform"); - form.find("#data").val(svg_xml); - form.find("#filename").val(filename); - return form.submit(); - }; -})(this)); + $("#export").click((function(_this) { + return function() { + var filename, form, svg, svg_xml; + svg = $("#topchart").find("svg")[0]; + svg_xml = (new XMLSerializer).serializeToString(svg); + console.log("svg_xml:", svg_xml); + filename = "manhattan_plot_" + js_data.this_trait; + form = $("#exportform"); + form.find("#data").val(svg_xml); + form.find("#filename").val(filename); + return form.submit(); + }; + })(this)); -$("#export_pdf").click((function(_this) { - return function() { - var filename, form, svg, svg_xml; - svg = $("#topchart").find("svg")[0]; - svg_xml = (new XMLSerializer).serializeToString(svg); - console.log("svg_xml:", svg_xml); - filename = "manhattan_plot_" + js_data.this_trait; - form = $("#exportpdfform"); - form.find("#data").val(svg_xml); - form.find("#filename").val(filename); - return form.submit(); - }; -})(this)); + $("#export_pdf").click((function(_this) { + return function() { + var filename, form, svg, svg_xml; + svg = $("#topchart").find("svg")[0]; + svg_xml = (new XMLSerializer).serializeToString(svg); + console.log("svg_xml:", svg_xml); + filename = "manhattan_plot_" + js_data.this_trait; + form = $("#exportpdfform"); + form.find("#data").val(svg_xml); + form.find("#filename").val(filename); + return form.submit(); + }; + })(this)); + +}).call(this); diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee index 9e070c97..29a637ee 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee @@ -76,14 +76,13 @@ do_ajax_post = (url, form_data) -> return false open_mapping_results = (data) -> - results_window = window.open() - $(results_window.document.body).html(data) - #$.colorbox( - # html: data - # href: "#mapping_results_holder" - # height: "90%" - # width: "90%" - #) + $.colorbox( + html: data + href: "#mapping_results_holder" + height: "90%" + width: "90%" + onComplete: => root.create_manhattan_plot() + ) showalert = (message,alerttype) -> $('#alert_placeholder').append('
×'+message+'
') @@ -119,7 +118,7 @@ $('input[name=display_all]').change(() => ) $("#pylmm_compute").on("click", => - #$("#progress_bar_container").modal() + $("#progress_bar_container").modal() url = "/marker_regression" $('input[name=method]').val("pylmm") $('input[name=num_perm]').val($('input[name=num_perm_pylmm]').val()) diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js index cc1ddf37..03862cf8 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.8.0 +// Generated by CoffeeScript 1.9.2 (function() { var block_outliers, composite_mapping_fields, do_ajax_post, get_progress, mapping_method_fields, open_mapping_results, showalert, submit_special, toggle_enable_disable, update_time_remaining; @@ -97,9 +97,17 @@ }; open_mapping_results = function(data) { - var results_window; - results_window = window.open(); - return $(results_window.document.body).html(data); + return $.colorbox({ + html: data, + href: "#mapping_results_holder", + height: "90%", + width: "90%", + onComplete: (function(_this) { + return function() { + return root.create_manhattan_plot(); + }; + })(this) + }); }; showalert = function(message, alerttype) { @@ -139,6 +147,7 @@ $("#pylmm_compute").on("click", (function(_this) { return function() { var form_data, url; + $("#progress_bar_container").modal(); url = "/marker_regression"; $('input[name=method]').val("pylmm"); $('input[name=num_perm]').val($('input[name=num_perm_pylmm]').val()); diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 30519e24..78682710 100755 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -1,3 +1,4 @@ +{% from "base_macro.html" import header, flash_me, timeago %} @@ -19,37 +20,6 @@ -{% macro header(main, second) %} -
-
-

{{ main }}

-

- {{ second }} -

-
-
- - {{ flash_me() }} -{% endmacro %} - - -{% macro flash_me() -%} - {% with messages = get_flashed_messages(with_categories=true) %} - {% if messages %} -
- {% for category, message in messages %} -
{{ message }}
- {% endfor %} -
- {% endif %} - {% endwith %} -{% endmacro %} - -{% macro timeago(timestamp) %} - -{% endmacro %} - - diff --git a/wqflask/wqflask/templates/base_macro.html b/wqflask/wqflask/templates/base_macro.html new file mode 100644 index 00000000..c2905ebe --- /dev/null +++ b/wqflask/wqflask/templates/base_macro.html @@ -0,0 +1,28 @@ +{% macro flash_me() -%} + {% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} +
+ {% for category, message in messages %} +
{{ message }}
+ {% endfor %} +
+ {% endif %} + {% endwith %} +{% endmacro %} + +{% macro header(main, second) %} +
+
+

{{ main }}

+

+ {{ second }} +

+
+
+ + {{ flash_me() }} +{% endmacro %} + +{% macro timeago(timestamp) %} + +{% endmacro %} diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html index 62146662..0cd004cd 100755 --- a/wqflask/wqflask/templates/marker_regression.html +++ b/wqflask/wqflask/templates/marker_regression.html @@ -1,16 +1,5 @@ -{% extends "base.html" %} -{% block title %}Interval Mapping{% endblock %} -{% block css %} - - - - - - - -{% endblock %} -{% block content %} - +{% from "base_macro.html" import header %} +{% block content %} {{ header("Mapping", '{}: {}'.format(this_trait.name, this_trait.description_fmt)) }} @@ -76,22 +65,6 @@ js_data = {{ js_data | safe }} - - - - - - - - - - - - - - - - -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index ca530162..cdde5d9d 100755 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -12,6 +12,8 @@ + + {% endblock %} {% block content %} @@ -133,8 +135,16 @@ - + + + + + + + + + -- cgit v1.2.3