From 71e83a00ec798b2fb2d053a136e13295ccbe3a9f Mon Sep 17 00:00:00 2001 From: mboudet Date: Fri, 8 Feb 2019 15:56:36 +0000 Subject: [PATCH] Fix link in analysis and gene page --- js/expression-fix.js | 748 ++++++++++++++++++++++++++++++++++++++++ tripal_bipaa_ui.install | 3 +- tripal_bipaa_ui.module | 3 +- 3 files changed, 752 insertions(+), 2 deletions(-) create mode 100644 js/expression-fix.js diff --git a/js/expression-fix.js b/js/expression-fix.js new file mode 100644 index 0000000..9697b0c --- /dev/null +++ b/js/expression-fix.js @@ -0,0 +1,748 @@ +(function ($) { + + Drupal.behaviors.expression = { + attach: function (context, settings) { + // Define variables + this.heatMapRaw = JSON.parse(settings.heatMapRaw); + this.selectedAnalysis = settings.selectedAnalysis; + this.feature_id = settings.feature_id; + this.heatMapTotal = ''; + this.heatMap = []; + this.currentSorting = $('#propertySortMenu').find(':selected').text(); + this.currentColor = $('#propertyColorMenu').find(':selected').text(); + this.downloadMessage = $(''); + this.downloadLink = $('#expressionDownloadLink'); + var link = '/analysis-expression/download?feature_ids=' + this.feature_id + '&analysis_id=' + this.selectedAnalysis; + $('#expressionDownloadLink').attr('href', link); + + //spacing variables + this.margin = {top: 50, bottom: 100, horizontal: 20}; + this.height = 500; + this.barwidth = 10 + this.scaleSize = this.barwidth * 4.5 //this is a thumbnail estimate, im not sure of a better way to do it + this.barSpacing = this.barwidth/2 + + + + // Activate plot + this.expNormal(); + this.attachEventListeners(); + }, + + /** + * Attach events to all of our elements here. + */ + attachEventListeners: function () { + $('#show-non-zero-only').on('click', this.nonZero.bind(this)); + $('#reset-expression-plot').on('click', this.expNormal.bind(this)); + $('#analyses-dropdown').on('change', this.analysisChanged.bind(this)); + $(window).on('resize', this.expNormal.bind(this)); + $(document).on('tripal_ds_pane_expanded', this.expNormal.bind(this)); + + // If the selector changes, rebuild the figure + $(document).on('change', '#propertySortMenu', function (e) { + this.currentSorting = e.target.value; + d3.selectAll('chart').remove(); + this.drawPlot(); + }.bind(this)); + + // If the selector changes, rebuild the figure + $(document).on('change', '#propertyColorMenu', function (e) { + this.currentColor = e.target.value; + d3.selectAll('chart').remove(); + this.drawPlot(); + }.bind(this)); + + var _that = this; + this.downloadLink.after(this.downloadMessage); + this.downloadLink.on('click', function (e) { + _that.initiateDownload.call(this, e, _that); + }); // Do not bind this here + }, + + /** + * Create an iframe to start the download. + * + * @param {Object} e event + * @param {Object} object this + */ + initiateDownload: function (e, object) { + e.preventDefault(); + var src = $(this).attr('href'); + var iframe = $('