publish_my_data 0.0.32 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. data/app/assets/images/publish_my_data/small-spinner.gif +0 -0
  2. data/app/assets/images/publish_my_data/sort-asc.gif +0 -0
  3. data/app/assets/images/publish_my_data/sort-desc.gif +0 -0
  4. data/app/assets/javascripts/bootstrap/affix.js +126 -0
  5. data/app/assets/javascripts/bootstrap/alert.js +98 -0
  6. data/app/assets/javascripts/bootstrap/button.js +109 -0
  7. data/app/assets/javascripts/bootstrap/carousel.js +217 -0
  8. data/app/assets/javascripts/bootstrap/collapse.js +179 -0
  9. data/app/assets/javascripts/bootstrap/dropdown.js +154 -0
  10. data/app/assets/javascripts/bootstrap/modal.js +246 -0
  11. data/app/assets/javascripts/bootstrap/popover.js +117 -0
  12. data/app/assets/javascripts/bootstrap/scrollspy.js +158 -0
  13. data/app/assets/javascripts/bootstrap/tab.js +135 -0
  14. data/app/assets/javascripts/bootstrap/tooltip.js +386 -0
  15. data/app/assets/javascripts/bootstrap/transition.js +56 -0
  16. data/app/assets/javascripts/publish_my_data/grid/10_data-loader.js +142 -0
  17. data/app/assets/javascripts/publish_my_data/grid/20_cube-grid.js +512 -0
  18. data/app/assets/javascripts/publish_my_data/grid/30_cube-dimension.js +77 -0
  19. data/app/assets/javascripts/publish_my_data/grid/40_cube-dimension-dropdown.js +87 -0
  20. data/app/assets/javascripts/publish_my_data/grid/45_cube-dimension-label.js +58 -0
  21. data/app/assets/javascripts/publish_my_data/grid/50_cube-dimensions-controls.js +336 -0
  22. data/app/assets/javascripts/publish_my_data/grid/60_dataset_cube_grid.js +187 -0
  23. data/app/assets/javascripts/publish_my_data/grid/70_sparql_results_grid.js +135 -0
  24. data/app/assets/javascripts/publish_my_data/select_text.js +27 -0
  25. data/app/assets/javascripts/publish_my_data.js +3 -0
  26. data/app/assets/javascripts/slick_grid/10_event-drag.js +402 -0
  27. data/app/assets/javascripts/slick_grid/20_slick-core.js +458 -0
  28. data/app/assets/javascripts/slick_grid/30_slick-grid.js +3295 -0
  29. data/app/assets/stylesheets/bootstrap/_alerts.scss +67 -0
  30. data/app/assets/stylesheets/bootstrap/_badges.scss +51 -0
  31. data/app/assets/stylesheets/bootstrap/_breadcrumbs.scss +23 -0
  32. data/app/assets/stylesheets/bootstrap/_button-groups.scss +248 -0
  33. data/app/assets/stylesheets/bootstrap/_buttons.scss +160 -0
  34. data/app/assets/stylesheets/bootstrap/_carousel.scss +209 -0
  35. data/app/assets/stylesheets/bootstrap/_close.scss +33 -0
  36. data/app/assets/stylesheets/bootstrap/_code.scss +56 -0
  37. data/app/assets/stylesheets/bootstrap/_component-animations.scss +29 -0
  38. data/app/assets/stylesheets/bootstrap/_dropdowns.scss +194 -0
  39. data/app/assets/stylesheets/bootstrap/_forms.scss +350 -0
  40. data/app/assets/stylesheets/bootstrap/_glyphicons.scss +232 -0
  41. data/app/assets/stylesheets/bootstrap/_grid.scss +346 -0
  42. data/app/assets/stylesheets/bootstrap/_input-groups.scss +127 -0
  43. data/app/assets/stylesheets/bootstrap/_jumbotron.scss +40 -0
  44. data/app/assets/stylesheets/bootstrap/_labels.scss +58 -0
  45. data/app/assets/stylesheets/bootstrap/_list-group.scss +88 -0
  46. data/app/assets/stylesheets/bootstrap/_media.scss +56 -0
  47. data/app/assets/stylesheets/bootstrap/_mixins.scss +728 -0
  48. data/app/assets/stylesheets/bootstrap/_modals.scss +145 -0
  49. data/app/assets/stylesheets/bootstrap/_navbar.scss +625 -0
  50. data/app/assets/stylesheets/bootstrap/_navs.scss +229 -0
  51. data/app/assets/stylesheets/bootstrap/_normalize.scss +396 -0
  52. data/app/assets/stylesheets/bootstrap/_pager.scss +55 -0
  53. data/app/assets/stylesheets/bootstrap/_pagination.scss +83 -0
  54. data/app/assets/stylesheets/bootstrap/_panels.scss +148 -0
  55. data/app/assets/stylesheets/bootstrap/_popovers.scss +133 -0
  56. data/app/assets/stylesheets/bootstrap/_print.scss +100 -0
  57. data/app/assets/stylesheets/bootstrap/_progress-bars.scss +95 -0
  58. data/app/assets/stylesheets/bootstrap/_responsive-utilities.scss +209 -0
  59. data/app/assets/stylesheets/bootstrap/_scaffolding.scss +130 -0
  60. data/app/assets/stylesheets/bootstrap/_tables.scss +236 -0
  61. data/app/assets/stylesheets/bootstrap/_theme.scss +232 -0
  62. data/app/assets/stylesheets/bootstrap/_thumbnails.scss +31 -0
  63. data/app/assets/stylesheets/bootstrap/_tooltip.scss +95 -0
  64. data/app/assets/stylesheets/bootstrap/_type.scss +238 -0
  65. data/app/assets/stylesheets/bootstrap/_utilities.scss +42 -0
  66. data/app/assets/stylesheets/bootstrap/_variables.scss +620 -0
  67. data/app/assets/stylesheets/bootstrap/_wells.scss +29 -0
  68. data/app/assets/stylesheets/bootstrap/bootstrap.scss +59 -0
  69. data/app/assets/stylesheets/publish_my_data/core.scss +244 -0
  70. data/app/assets/stylesheets/publish_my_data/data_grid.scss +103 -0
  71. data/app/assets/stylesheets/publish_my_data/variables.scss +1 -0
  72. data/app/assets/stylesheets/{publish_my_data.css → publish_my_data.scss} +13 -2
  73. data/app/assets/stylesheets/slick_grid/slick_grid.scss +155 -0
  74. data/app/assets/stylesheets/slick_grid/slick_grid_default_theme.scss +97 -0
  75. data/app/controllers/concerns/publish_my_data/data_cube.rb +42 -0
  76. data/app/controllers/publish_my_data/data_cube/dimensions_controller.rb +58 -0
  77. data/app/controllers/publish_my_data/data_cube/observations_controller.rb +54 -0
  78. data/app/controllers/publish_my_data/datasets_controller.rb +0 -11
  79. data/app/controllers/publish_my_data/example_resources_controller.rb +11 -0
  80. data/app/controllers/publish_my_data/home_controller.rb +4 -0
  81. data/app/controllers/publish_my_data/information_resources_controller.rb +0 -13
  82. data/app/helpers/publish_my_data/application_helper.rb +66 -0
  83. data/app/helpers/publish_my_data/crumb_helper.rb +61 -0
  84. data/app/helpers/publish_my_data/datasets_helper.rb +31 -0
  85. data/app/helpers/publish_my_data/resources_helper.rb +24 -0
  86. data/app/models/concerns/publish_my_data/cube_results.rb +51 -0
  87. data/app/models/concerns/publish_my_data/dataset_powers.rb +13 -0
  88. data/app/models/publish_my_data/data_cube/cube.rb +358 -0
  89. data/app/models/publish_my_data/data_cube/dimension.rb +58 -0
  90. data/app/models/publish_my_data/vocabulary.rb +0 -4
  91. data/app/views/layouts/publish_my_data/application.html.haml +18 -0
  92. data/app/views/layouts/publish_my_data/error.html.haml +21 -0
  93. data/app/views/publish_my_data/classes/show.html.haml +28 -0
  94. data/app/views/publish_my_data/concept_schemes/show.html.haml +79 -0
  95. data/app/views/publish_my_data/concepts/show.html.haml +28 -0
  96. data/app/views/publish_my_data/data_cube/_controls.html.haml +19 -0
  97. data/app/views/publish_my_data/data_cube/_grid.html.haml +37 -0
  98. data/app/views/publish_my_data/datasets/_example_resources.html.haml +47 -0
  99. data/app/views/publish_my_data/datasets/_types_table.html.erb +33 -0
  100. data/app/views/publish_my_data/datasets/index.html.haml +32 -0
  101. data/app/views/publish_my_data/datasets/show.html.haml +186 -0
  102. data/app/views/publish_my_data/errors/not_found.html.haml +18 -0
  103. data/app/views/publish_my_data/errors/response_too_large.html.haml +16 -0
  104. data/app/views/publish_my_data/errors/timeout.html.haml +16 -0
  105. data/app/views/publish_my_data/errors/uncaught.html.haml +16 -0
  106. data/app/views/publish_my_data/example_resources/index.js.erb +1 -0
  107. data/app/views/publish_my_data/home/accessibility.html.haml +1 -0
  108. data/app/views/publish_my_data/home/docs.html.haml +1 -0
  109. data/app/views/publish_my_data/home/home.html.haml +5 -0
  110. data/app/views/publish_my_data/home/privacy.html.haml +1 -0
  111. data/app/views/publish_my_data/ontologies/show.html.haml +100 -0
  112. data/app/views/publish_my_data/properties/show.html.haml +28 -0
  113. data/app/views/publish_my_data/resources/_resource_data.html.haml +16 -0
  114. data/app/views/publish_my_data/resources/_sparql_section.html.haml +22 -0
  115. data/app/views/publish_my_data/resources/index.html.haml +37 -0
  116. data/app/views/publish_my_data/resources/show.html.haml +36 -0
  117. data/app/views/publish_my_data/shared/_browser_warning.html.haml +4 -0
  118. data/app/views/publish_my_data/shared/_deprecation_notice.html.haml +8 -0
  119. data/app/views/publish_my_data/shared/_footer.html.haml +11 -0
  120. data/app/views/publish_my_data/shared/_google_analytics.html.haml +11 -0
  121. data/app/views/publish_my_data/shared/_logo.html.haml +1 -0
  122. data/app/views/publish_my_data/shared/_meta_title.html.haml +2 -0
  123. data/app/views/publish_my_data/sparql/_form.html.haml +28 -0
  124. data/app/views/publish_my_data/sparql/_formats_dropdown.html.haml +11 -0
  125. data/app/views/publish_my_data/sparql/endpoint.html.haml +125 -0
  126. data/app/views/publish_my_data/sparql/formats_dropdowns/_ask.html.haml +7 -0
  127. data/app/views/publish_my_data/sparql/formats_dropdowns/_construct.html.haml +7 -0
  128. data/app/views/publish_my_data/sparql/formats_dropdowns/_describe.html.haml +1 -0
  129. data/app/views/publish_my_data/sparql/formats_dropdowns/_select.html.haml +9 -0
  130. data/app/views/publish_my_data/themes/index.html.haml +30 -0
  131. data/app/views/publish_my_data/themes/show.html.haml +43 -0
  132. data/config/routes.rb +20 -5
  133. data/lib/publish_my_data/version.rb +1 -1
  134. data/lib/publish_my_data.rb +7 -12
  135. data/spec/controllers/publish_my_data/datasets_controller_spec.rb +0 -75
  136. data/spec/controllers/publish_my_data/information_resources_controller_spec.rb +2 -11
  137. data/spec/dummy/config/environments/development.rb +0 -4
  138. data/spec/dummy/config/environments/test.rb +0 -4
  139. data/spec/dummy/log/test.log +62962 -0
  140. data/spec/dummy/tmp/cache/sass/e509ccd4d793d2c162d70125e9f3656b6c28f357/(__TEMPLATE__)c +0 -0
  141. data/spec/features/running_a_sparql_query_spec.rb +1 -1
  142. data/spec/features/uri_dereferencing_spec.rb +1 -1
  143. metadata +200 -58
  144. data/app/controllers/concerns/publish_my_data/data_download.rb +0 -22
  145. data/app/controllers/publish_my_data/vocabularies_controller.rb +0 -18
  146. data/app/views/layouts/publish_my_data/application.html.erb +0 -13
  147. data/app/views/layouts/publish_my_data/error.html.erb +0 -13
  148. data/app/views/publish_my_data/classes/show.html.erb +0 -3
  149. data/app/views/publish_my_data/concept_schemes/_concepts.html.erb +0 -18
  150. data/app/views/publish_my_data/concept_schemes/show.html.erb +0 -11
  151. data/app/views/publish_my_data/concepts/show.html.erb +0 -3
  152. data/app/views/publish_my_data/datasets/index.html.erb +0 -20
  153. data/app/views/publish_my_data/datasets/show.html.erb +0 -18
  154. data/app/views/publish_my_data/errors/not_found.html.erb +0 -1
  155. data/app/views/publish_my_data/errors/response_too_large.html.erb +0 -1
  156. data/app/views/publish_my_data/errors/timeout.html.erb +0 -1
  157. data/app/views/publish_my_data/errors/uncaught.html.erb +0 -6
  158. data/app/views/publish_my_data/ontologies/show.html.erb +0 -17
  159. data/app/views/publish_my_data/properties/show.html.erb +0 -3
  160. data/app/views/publish_my_data/resources/_predicates_table.html.erb +0 -30
  161. data/app/views/publish_my_data/resources/_predicates_table_head.html.erb +0 -6
  162. data/app/views/publish_my_data/resources/_resource_formats.html.erb +0 -4
  163. data/app/views/publish_my_data/resources/_summaries.html.erb +0 -18
  164. data/app/views/publish_my_data/resources/_uri_and_label.html.erb +0 -3
  165. data/app/views/publish_my_data/resources/index.html.erb +0 -40
  166. data/app/views/publish_my_data/resources/show.html.erb +0 -3
  167. data/app/views/publish_my_data/sparql/_ask_formats.html.erb +0 -3
  168. data/app/views/publish_my_data/sparql/_construct_formats.html.erb +0 -3
  169. data/app/views/publish_my_data/sparql/_describe_formats.html.erb +0 -1
  170. data/app/views/publish_my_data/sparql/_error_message.html.erb +0 -3
  171. data/app/views/publish_my_data/sparql/_form.html.erb +0 -4
  172. data/app/views/publish_my_data/sparql/_formats.html.erb +0 -6
  173. data/app/views/publish_my_data/sparql/_pagination.html.erb +0 -6
  174. data/app/views/publish_my_data/sparql/_results.html.erb +0 -5
  175. data/app/views/publish_my_data/sparql/_results_data.html.erb +0 -4
  176. data/app/views/publish_my_data/sparql/_select_formats.html.erb +0 -3
  177. data/app/views/publish_my_data/sparql/endpoint.html.erb +0 -10
  178. data/app/views/publish_my_data/themes/index.html.erb +0 -13
  179. data/app/views/publish_my_data/themes/show.html.erb +0 -15
  180. data/config/initializers/20_s3_setup.rb +0 -4
  181. data/spec/controllers/publish_my_data/vocabularies_controller_spec.rb +0 -14
  182. data/spec/support/data_download.rb +0 -60
@@ -0,0 +1,187 @@
1
+ // object to setup a cube grid for a pmd dataset, and wire everything together.
2
+ (function ($) {
3
+
4
+ function DatasetCubeGrid(siteDomain, datasetSlug, datasetTitle, elementSelector) {
5
+
6
+ var pageSize = 25
7
+ , cubeDimensions = null
8
+ , cubeDimensionsControls = null
9
+ ;
10
+
11
+ function setGridStatus(status, busy) {
12
+ $(".grid-status .status-value").empty();
13
+ $(".grid-status .status-value").append(status);
14
+
15
+ if (busy) {
16
+ $(".grid-status img.busy").show();
17
+ } else {
18
+ $(".grid-status img.busy").hide();
19
+ }
20
+ }
21
+
22
+ function setGridError(httpStatusCode) {
23
+ $(".grid-status img.busy").hide();
24
+ $(".grid-status .status-value").empty();
25
+ if (httpStatusCode == 500 || httpStatusCode == 400) {
26
+ $(".grid-status .status-value").append('<i class="icon-warning"></i> Error fetching data');
27
+ } else if (httpStatusCode == 503) {
28
+ $(".grid-status .status-value").append('<i class="icon-warning"></i> Query timed out');
29
+ }
30
+ }
31
+
32
+ function setDimensionsStatus(status, busy){
33
+ $(".dimensions-status .status-value").empty();
34
+ $(".dimensions-status .status-value").append(status);
35
+
36
+ if (busy) {
37
+ $(".dimensions-status").show();
38
+ $(".dimensions-status img.busy").show();
39
+ } else {
40
+ $(".dimensions-status").hide();
41
+ $(".dimensions-status img.busy").hide();
42
+ }
43
+ }
44
+
45
+ function showDimensionsControls() {
46
+ $("#dimensions-controls form").show();
47
+ }
48
+
49
+ function showOptionsToggler() {
50
+ $("#options-toggler").show();
51
+ }
52
+
53
+ function setTitle(title) {
54
+ $("#cube-grid-title").empty();
55
+ $("#cube-grid-title").append(title);
56
+ }
57
+
58
+ function calculateGridTitle() {
59
+ var title = datasetTitle;
60
+ var lockedDimensionLabels = cubeDimensionsControls.getLockedDimensionValueLabels();
61
+ if ( lockedDimensionLabels.length > 0 ) {
62
+ title += ' (';
63
+ $.each(lockedDimensionLabels, function(i, label) {
64
+ title += label;
65
+ if ( lockedDimensionLabels.length-1 != i ){
66
+ title += ", ";
67
+ }
68
+ });
69
+ title += ')';
70
+ }
71
+ return title;
72
+ }
73
+
74
+ function wireUpCubeDimensionsEvents() {
75
+
76
+ cubeDimensionsControls.onInitialized.subscribe(function (e,args) {
77
+
78
+ showDimensionsControls();
79
+ showOptionsToggler();
80
+ setDimensionsStatus('', false);
81
+
82
+ // once the controls are initialized...
83
+ setTitle(calculateGridTitle()); // set initial title
84
+
85
+ // wire up the ready/busy events
86
+ cubeDimensionsControls.onReady.subscribe(function (e, args) {
87
+ cubeDimensionsControls.enable();
88
+ setDimensionsStatus('', false);
89
+
90
+ // re-init grid
91
+ cubeGrid.clear();
92
+ cubeGrid.initGridWhenReady();
93
+
94
+ // set locked dims
95
+ $.each(cubeDimensionsControls.getLockedDimensionUris(), function(i, lockedDimUri) {
96
+ var value = cubeDimensionsControls.getLockedDimensionValues()[i];
97
+ cubeGrid.setLockedDimensionValue(lockedDimUri, value);
98
+ });
99
+
100
+ // set rows and cols
101
+ cubeGrid.setRowsDimension(cubeDimensionsControls.getRowsDimension());
102
+ cubeGrid.setColumnsDimension(cubeDimensionsControls.getColumnsDimension());
103
+
104
+ cubeGrid.showCSVDownloadLink();
105
+ setTitle(calculateGridTitle());
106
+ });
107
+
108
+ cubeDimensionsControls.onBusy.subscribe(function (e, args) {
109
+ setTitle('&nbsp;');
110
+ cubeGrid.hideCSVDownloadLink();
111
+ setDimensionsStatus('Re-calculating options...', true);
112
+ setGridStatus('Re-initializing grid...', true);
113
+ cubeDimensionsControls.disable(); // disable the controls while they're busy.
114
+ });
115
+
116
+ // and enable the controls
117
+ cubeDimensionsControls.enable();
118
+ });
119
+
120
+ }
121
+
122
+ function setInitialGridStatus() {
123
+ // unsubscribe
124
+ cubeGrid.onCubeDimensionsReady.unsubscribe(setInitialGridStatus);
125
+
126
+ $.ajax({
127
+ url: "http://" + siteDomain + "/data/" + datasetSlug + "/cube/recommended_dimensions.json",
128
+ dataType: 'json',
129
+ success: function(recommendedDimensions){
130
+
131
+ // for locked dims, just set the uris
132
+ for ( var dim in recommendedDimensions.locked_dimensions ) {
133
+ cubeGrid.setLockedDimensionValue( dim, recommendedDimensions.locked_dimensions[dim] )
134
+ }
135
+
136
+ // for the other dimensions, find the appropriate object
137
+ var columnsDimension = cubeGrid.getDimensionWithUri(recommendedDimensions.columns_dimension);
138
+ var rowsDimension = cubeGrid.getDimensionWithUri(recommendedDimensions.rows_dimension);
139
+
140
+ cubeGrid.setColumnsDimension(columnsDimension);
141
+ cubeGrid.setRowsDimension(rowsDimension);
142
+ cubeGrid.showCSVDownloadLink();
143
+ },
144
+ error: function(jqXHR, _, _) {
145
+ setGridError(jqXHR.status);
146
+ }
147
+ });
148
+
149
+ }
150
+
151
+ // set initial status
152
+ setTitle('&nbsp;');
153
+ setGridStatus('Initializing grid...', true);
154
+
155
+ var cubeGrid = new Swirrl.CubeGrid(elementSelector, siteDomain, datasetSlug, pageSize);
156
+
157
+ cubeGrid.onAjaxError.subscribe(function (e, args) {
158
+ setGridError(args.status);
159
+ });
160
+
161
+ // subscribe to grid events.
162
+ cubeGrid.onGridReady.subscribe(function (e, args) {
163
+ setGridStatus("Grid ready.", false);
164
+ });
165
+
166
+ var gridInitializedHandler = function (e, args) {
167
+ cubeDimensionsControls = new Swirrl.CubeDimensionsControls(cubeGrid, "#dimensions-controls");
168
+ wireUpCubeDimensionsEvents();
169
+ cubeDimensionsControls.init();
170
+ cubeGrid.onGridInitialized.unsubscribe(gridInitializedHandler);// only do 1st time round.
171
+ }
172
+
173
+ cubeGrid.onGridInitialized.subscribe(gridInitializedHandler);
174
+
175
+ cubeGrid.onGridGettingData.subscribe(function (e, args) {
176
+ setGridStatus("Getting data...", true)
177
+ });
178
+
179
+ // tell the grid to get all it's dimensions (and set up init grid status when they're ready).
180
+ cubeGrid.onCubeDimensionsReady.subscribe(setInitialGridStatus);
181
+ cubeGrid.getAllDimensionsAsync();
182
+
183
+ }
184
+
185
+
186
+ $.extend(true, window, { Swirrl: { DatasetCubeGrid: DatasetCubeGrid }});
187
+ })(jQuery);
@@ -0,0 +1,135 @@
1
+ // object to setup a grid for sparql results
2
+ (function ($) {
3
+
4
+ // ctor
5
+ function SparqlResultsGrid(encodedQuery) {
6
+
7
+ var SLICKGRIDOPTIONS = {
8
+ enableCellNavigation: false
9
+ , enableColumnReorder: false
10
+ , syncColumnCellResize: true
11
+ , rowHeight: 24
12
+ , enableTextSelectionOnCells: true
13
+ }
14
+ , ROWNUMBERSCOLUMNWIDTH = 55
15
+ , COLUMNWIDTH = 270
16
+ , PAGESIZE = 20
17
+ , INITIALTOTALCOUNT = 500
18
+ , TOTALCOUNTMARGIN = 200
19
+ , TOTALCOUNTEXTENDAMOUNT = 200
20
+
21
+ var totalCount = INITIALTOTALCOUNT;
22
+ var columns = null;
23
+ var loader = new Swirrl.DataLoader(totalCount, PAGESIZE);
24
+ var slickGrid = new Slick.Grid('#results-grid.data-grid', loader.data, [], SLICKGRIDOPTIONS);
25
+
26
+ $(document).on("click", ".slick-cell", function() {
27
+ $(this).selectText();
28
+ });
29
+
30
+ // These are thte same methods as in the cube grid. Refactor??
31
+ function setGridStatus(status, busy) {
32
+ $(".grid-status .status-value").empty();
33
+ $(".grid-status .status-value").append(status);
34
+
35
+ if (busy) {
36
+ $(".grid-status img.busy").show();
37
+ } else {
38
+ $(".grid-status img.busy").hide();
39
+ }
40
+ }
41
+
42
+ function setGridError(httpStatusCode) {
43
+ $(".grid-status img.busy").hide();
44
+ $(".grid-status .status-value").empty();
45
+ if (httpStatusCode == 500 || httpStatusCode == 400) {
46
+ $(".grid-status .status-value").append('<i class="icon-warning"></i> Error fetching data');
47
+ } else if (httpStatusCode == 503) {
48
+ $(".grid-status .status-value").append('<i class="icon-warning"></i> Query timed out');
49
+ }
50
+ }
51
+
52
+ function setColumns(responseData) {
53
+ var vars = responseData["head"]["vars"];
54
+ columns = [{id: '__row_num', field: '__row_num', name: '#', width: ROWNUMBERSCOLUMNWIDTH, cssClass: 'row-num' }];
55
+ $.each(vars, function(i, col) {
56
+ columns.push({id: col, name: col, field: col, width: COLUMNWIDTH});
57
+ });
58
+ slickGrid.setColumns(columns);
59
+ }
60
+
61
+ function loaderFunction(pageIndex) {
62
+
63
+ function processResponseData(responseData) {
64
+ // set the columns onto the grid if we haven't already
65
+ if(!columns) { setColumns(responseData); }
66
+
67
+ var rowsData = [];
68
+ var results = responseData["results"]["bindings"];
69
+
70
+ // go through the results, and make rows data.
71
+ for (var i = 0; i < results.length; i++) {
72
+ var resultsRow = null;
73
+ resultsRow = {};
74
+ for (var col in results[i]) {
75
+ resultsRow[col] = results[i][col]["value"];
76
+ }
77
+ rowsData.push(resultsRow);
78
+ }
79
+ return rowsData;
80
+ };
81
+
82
+ var theUrl = "/sparql.json?query=" + encodedQuery +
83
+ "&page=" + (pageIndex+1).toString() + // we use one-based pagination on the server.
84
+ "&per_page=" + PAGESIZE.toString();
85
+
86
+ setGridStatus('Getting data...', true);
87
+ req = $.ajax({
88
+ url: theUrl,
89
+ dataType: 'json',
90
+ success: function(responseData, _, jqXHR) {
91
+ loader.setPageOfData(jqXHR.page, processResponseData(responseData));
92
+ setGridStatus('Grid Ready.');
93
+ },
94
+ error: function( jqXHR, _, _ ) {
95
+ setGridError(jqXHR.status);
96
+ }
97
+ });
98
+ req.page = pageIndex; // add a page property onto the jqXHR obj
99
+ }
100
+
101
+ // initialisation...
102
+
103
+ // when a bunch of rows are loaded,
104
+ // re-render them.
105
+ loader.onDataLoaded.subscribe(function (e, args) {
106
+ for (var i = args.from; i <= args.to; i++) {
107
+ slickGrid.invalidateRow(i); // causes the appropriate rows to redraw.
108
+ }
109
+ slickGrid.updateRowCount(); // uses data.length
110
+ slickGrid.render();
111
+ });
112
+
113
+ // When the viewport changes, ensure the loader has the relevent data.
114
+ // (when scrolling stops for 200ms)
115
+ var viewportChangedTimer;
116
+
117
+ slickGrid.onViewportChanged.subscribe(function (e, args) {
118
+ clearTimeout(viewportChangedTimer);
119
+ viewportChangedTimer = setTimeout( function() {
120
+
121
+ // extend the grid if near the bottom
122
+ if( slickGrid.getViewport().bottom > (totalCount - TOTALCOUNTMARGIN) ) {
123
+ totalCount = totalCount + TOTALCOUNTEXTENDAMOUNT;
124
+ loader.updateTotalCount( totalCount );
125
+ }
126
+
127
+ loader.ensureData(slickGrid.getViewport().top, slickGrid.getViewport().bottom, loaderFunction);
128
+ }, 200); // 200ms delay.
129
+ });
130
+
131
+ loader.ensureData(slickGrid.getViewport().top, slickGrid.getViewport().bottom, loaderFunction);
132
+ }
133
+
134
+ $.extend(true, window, { Swirrl: { SparqlResultsGrid: SparqlResultsGrid }});
135
+ })(jQuery);
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * Highlight areas of text
3
+ * Copyright 2012, Swirrl IT Limited
4
+ * All rights reserved
5
+ */
6
+
7
+ jQuery.fn.selectText = function(){
8
+ var doc = document;
9
+ var element = this[0];
10
+ if (doc.body.createTextRange) {
11
+ var range = document.body.createTextRange();
12
+ range.moveToElementText(element);
13
+ range.select();
14
+ } else if (window.getSelection) {
15
+ var selection = window.getSelection();
16
+ var range = document.createRange();
17
+ range.selectNodeContents(element);
18
+ selection.removeAllRanges();
19
+ selection.addRange(range);
20
+ }
21
+ };
22
+
23
+ $(function(){
24
+ $('.click-to-select').click(function(){
25
+ $(this).selectText();
26
+ });
27
+ });
@@ -10,4 +10,7 @@
10
10
  // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
11
  // GO AFTER THE REQUIRES BELOW.
12
12
  //
13
+ //= require jquery
14
+ //= require_tree ./slick_grid
13
15
  //= require_tree ./publish_my_data
16
+ //= require bootstrap/tab