Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/Styling.js @ 9062

Last change on this file since 9062 was 9062, checked in by fschoepp, 11 years ago

#1888:
Backend changes:

  • Simplified job state detection (only one hive call will be made to detect all states now, instead of one additional call per job)
  • Reorganized classes (moved model classes into Model folder)

Website changes:

  • Website now heavily uses JavaScript to achieve better user experience
  • JavaScript degrades gracefully, except for plots
  • Tables: Added jquery-datatable-plugin to extend tables (pagination + search functionality)
  • OaaS-Website now uses the design of the HL websites (found in WebApplication branch)
  • Added jqplot to render zoomable line plots for HL-Datatables
  • Styling.js: Plots will be generated by using an ajax call; additional jquery-styling occurs within this file.
  • Added jquery-ui-1.9.2 which is capable of handling/rendering tabs, accordions and resizers.
File size: 4.7 KB
Line 
1/*!
2Styling for heuristiclab via jQuery
3*/
4
5function retrieveMatrix(id) {
6    var indexRegEx = /matrix-graph-(\d*)-(\d*)/g
7    var array = indexRegEx.exec(id)
8    if (array != null && array.length == 3) {
9        return { runId: array[1], parameterOffset: array[2] }
10    }
11    return null;
12}
13
14function generatePlot(plotId, plotData) {
15    var seriesData = plotData.Series;
16    var showMarker = plotData.ShowMarker;
17    var labels = new Array(seriesData.length);
18    var series = new Array(seriesData.length);
19
20    for (var i = 0; i < seriesData.length; i++) {
21        labels[i] = { label: seriesData[i].Label, showMarker : showMarker };
22        series[i] = seriesData[i].Values;
23    }
24
25    return $.jqplot(plotId, series, {
26        cursor: {
27            show: true,
28            zoom: true,
29            showTooltip: false
30        },
31        series: labels,
32        legend: {
33            show: true,
34            placement: 'outsideGrid'
35        }
36    });
37}
38
39$(document).ready(
40
41function () {
42
43    /*
44    $('input:submit, input:reset').each(function () {
45    $(this).replaceWith('<button class="' + $(this).attr('class') + '" name="' + $(this).attr('name') + '" type="' + $(this).attr('type') + '">' + $(this).val() + '</button>');
46    });
47
48
49    $('.hl-dataTable').dataTable(
50    {
51    "bJQueryUI": true,
52    "sScrollX": "100%",
53
54    }
55
56    );
57
58
59
60    $(".hl-dataTable").addClass("display");
61
62    $(".hl-button-text-plus").button({ icons: { primary: 'ui-icon-plus'} });
63    $(".hl-button-text-signon").button({ icons: { primary: 'ui-icon-key'} });
64    $(".hl-button-text-back").button({ icons: { primary: 'ui-icon-triangle-1-w'} });
65    $(".hl-icon-delete").button({ icons: { primary: 'ui-icon-close' }, text: false });
66    $(".hl-icon-edit").button({ icons: { primary: 'ui-icon-pencil' }, text: false });
67    $(".hl-icon-view").button({ icons: { primary: ' ui-icon-arrowthick-1-e' }, text: false });
68    $(".hl-icon-refresh").button({ icons: { primary: ' ui-icon-refresh' }, text: false });
69 
70    // Standard Table
71    $(".hl-table th").each(function () {
72
73    $(this).addClass("ui-state-default hl-formHeader");
74
75    });
76    $(".hl-table td").each(function () {
77
78    $(this).addClass("ui-widget-content");
79
80    });
81
82    $(".hl-table td:odd").addClass("odd");
83    $(".hl-table td:even").addClass("even");
84    */
85    try {
86        $(".viewableTable").dataTable()
87    } catch (e) {
88    }
89
90    try {
91        $(".editableTable").dataTable(
92      {
93          "bSort": false,
94          "bFilter": false
95      }
96    )
97    } catch (e) {
98    }
99
100    try {
101        $(".tabable").tabs({
102            collapsible: true,
103            active: false
104        }
105        );
106    } catch (e) {
107    }
108
109    try {
110        $(".collapsible").accordion("resize",
111        {
112            collapsible: true,
113            active: false
114        });
115    } catch (e) {
116    }
117
118    try {
119        $(".delete-row").click(function () {
120            var row = $(this).closest("tr").get(0);
121            var dt = $(this).closest(".editableTable");
122            dt = dt.dataTable()
123            dt.fnDeleteRow(dt.fnGetPosition(row));
124            // TODO: Update the Ids of the next rows!!
125        });
126    } catch (e) {
127    }
128
129    try {
130        $(".resizable").each(function (i) {
131            $(this).resizable();
132        });
133
134        $(".matrix-graph").each(function (i) {
135            var tabable = $(this).closest(".tabable");
136            var id = this.id;
137            var resizerId = $(this).parent().get(0).id;
138            var indices = retrieveMatrix(id);
139
140            $.ajax({
141                url: '/Chart/GetMatrixContentForGraph?run=' + indices.runId + '&parameterOffset=' + indices.parameterOffset + "&showMarker=false",
142
143                success: function (result) {
144                    var plot = generatePlot(id, result);
145                    tabable.bind('tabsshow', function (event, ui) {
146                        if (ui.index == 1 && plot._drawCount == 0) {
147                            plot.replot();
148                        }
149                    });
150                    var resizer = $("#"+id).closest('.resizable');
151                    $(resizer).bind('resizestop', function (event, ui) {
152                        var id = $(this).children('div').get(0).id;
153                        $("#"+id).height($(this).height() * 0.96);
154                        $("#" + id).width($(this).width() * 0.96);
155                        plot.replot({ resetAxes: true });
156                    });
157                },
158                error: function (jqXHR, textStatus, errorThrown) {
159                    alert(textStatus);
160                    alert(errorThrown);
161                }
162            });
163        });
164    } catch (e) {
165    }
166}
167);
168
Note: See TracBrowser for help on using the repository browser.