From c4bdca79adb23e6e9f5d44f92afc591a337401b2 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 15 Apr 2013 17:10:41 +0200 Subject: [PATCH 1/9] [#340] Value of 30 in comment contradicts actual value in code (15) --- src/view.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view.flot.js b/src/view.flot.js index 018a2963..10bab4eb 100644 --- a/src/view.flot.js +++ b/src/view.flot.js @@ -208,7 +208,7 @@ my.Flot = Backbone.View.extend({ // for labels case we only want ticks at the label intervals // HACK: however we also get this case with Date fields. In that case we - // could have a lot of values and so we limit to max 30 (we assume) + // could have a lot of values and so we limit to max 15 (we assume) if (this.xvaluesAreIndex) { var numTicks = Math.min(this.model.records.length, 15); var increment = this.model.records.length / numTicks; From bada4a877b7cbded8eaf147a491460ec586a981d Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 15 Apr 2013 17:11:54 +0200 Subject: [PATCH 2/9] [#340] jshint cleanup of view.flot.js --- src/view.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view.flot.js b/src/view.flot.js index 10bab4eb..b50c6000 100644 --- a/src/view.flot.js +++ b/src/view.flot.js @@ -214,7 +214,7 @@ my.Flot = Backbone.View.extend({ var increment = this.model.records.length / numTicks; var ticks = []; for (i=0; i Date: Mon, 15 Apr 2013 17:15:08 +0200 Subject: [PATCH 3/9] [#340] jshint cleanup of backend.ckan.js --- src/backend.ckan.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/backend.ckan.js b/src/backend.ckan.js index 893067a1..19998cab 100644 --- a/src/backend.ckan.js +++ b/src/backend.ckan.js @@ -37,12 +37,13 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {}; // ### fetch my.fetch = function(dataset) { + var wrapper; if (dataset.endpoint) { - var wrapper = my.DataStore(dataset.endpoint); + wrapper = my.DataStore(dataset.endpoint); } else { var out = my._parseCkanResourceUrl(dataset.url); dataset.id = out.resource_id; - var wrapper = my.DataStore(out.endpoint); + wrapper = my.DataStore(out.endpoint); } var dfd = new Deferred(); var jqxhr = wrapper.search({resource_id: dataset.id, limit: 0}); @@ -89,12 +90,13 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {}; }; my.query = function(queryObj, dataset) { + var wrapper; if (dataset.endpoint) { - var wrapper = my.DataStore(dataset.endpoint); + wrapper = my.DataStore(dataset.endpoint); } else { var out = my._parseCkanResourceUrl(dataset.url); dataset.id = out.resource_id; - var wrapper = my.DataStore(out.endpoint); + wrapper = my.DataStore(out.endpoint); } var actualQuery = my._normalizeQuery(queryObj, dataset); var dfd = new Deferred(); From 6073c4837f57da00c5ce552792a22ff548a212a4 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 15 Apr 2013 17:17:01 +0200 Subject: [PATCH 4/9] [#340] jshint cleanup of backend.dataproxy.js --- src/backend.dataproxy.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backend.dataproxy.js b/src/backend.dataproxy.js index 44db50cf..d16e6553 100644 --- a/src/backend.dataproxy.js +++ b/src/backend.dataproxy.js @@ -42,8 +42,8 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {}; useMemoryStore: true }); }) - .fail(function(arguments) { - dfd.reject(arguments); + .fail(function(args) { + dfd.reject(args); }); return dfd.promise(); }; @@ -60,16 +60,16 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {}; message: 'Request Error: Backend did not respond after ' + (my.timeout / 1000) + ' seconds' }); }, my.timeout); - ourFunction.done(function(arguments) { + ourFunction.done(function(args) { clearTimeout(timer); - dfd.resolve(arguments); + dfd.resolve(args); }) - .fail(function(arguments) { + .fail(function(args) { clearTimeout(timer); - dfd.reject(arguments); + dfd.reject(args); }) ; return dfd.promise(); - } + }; }(this.recline.Backend.DataProxy)); From 9e47ea3ad9f6cde9d37de2578a670ea977489f02 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 15 Apr 2013 17:35:59 +0200 Subject: [PATCH 5/9] [#340] jshint cleanup of model.js --- src/model.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/model.js b/src/model.js index b76986e4..1e8b0bd9 100644 --- a/src/model.js +++ b/src/model.js @@ -55,8 +55,8 @@ my.Dataset = Backbone.Model.extend({ if (this.backend !== recline.Backend.Memory) { this.backend.fetch(this.toJSON()) .done(handleResults) - .fail(function(arguments) { - dfd.reject(arguments); + .fail(function(args) { + dfd.reject(args); }); } else { // special case where we have been given data directly @@ -79,8 +79,8 @@ my.Dataset = Backbone.Model.extend({ .done(function() { dfd.resolve(self); }) - .fail(function(arguments) { - dfd.reject(arguments); + .fail(function(args) { + dfd.reject(args); }); } @@ -198,9 +198,9 @@ my.Dataset = Backbone.Model.extend({ self.trigger('query:done'); dfd.resolve(self.records); }) - .fail(function(arguments) { - self.trigger('query:fail', arguments); - dfd.reject(arguments); + .fail(function(args) { + self.trigger('query:fail', args); + dfd.reject(args); }); return dfd.promise(); }, @@ -450,7 +450,7 @@ my.Field = Backbone.Model.extend({ if (val && typeof val === 'string') { val = val.replace(/(https?:\/\/[^ ]+)/g, '$1'); } - return val + return val; } } } From c77b35d9f21f09a780c1e5a16635d47b7c7f6843 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 15 Apr 2013 17:36:09 +0200 Subject: [PATCH 6/9] [#340] jshint cleanup of view.grid.js --- src/view.grid.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/view.grid.js b/src/view.grid.js index c13a8c21..2a6a2b55 100644 --- a/src/view.grid.js +++ b/src/view.grid.js @@ -103,12 +103,12 @@ my.Grid = Backbone.View.extend({ var numFields = this.fields.length; // compute field widths (-20 for first menu col + 10px for padding on each col and finally 16px for the scrollbar) var fullWidth = self.el.width() - 20 - 10 * numFields - this.scrollbarDimensions.width; - var width = parseInt(Math.max(50, fullWidth / numFields)); + var width = parseInt(Math.max(50, fullWidth / numFields), 10); // if columns extend outside viewport then remainder is 0 var remainder = Math.max(fullWidth - numFields * width,0); _.each(this.fields, function(field, idx) { // add the remainder to the first field width so we make up full col - if (idx == 0) { + if (idx === 0) { field.set({width: width+remainder}); } else { field.set({width: width}); From 522e88fe415eb448db4fa3c442ad8f7d40b15e71 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 15 Apr 2013 17:36:22 +0200 Subject: [PATCH 7/9] [#340] jshint cleanup of view.multiview.js --- src/view.multiview.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/view.multiview.js b/src/view.multiview.js index c69612b6..d0640ff7 100644 --- a/src/view.multiview.js +++ b/src/view.multiview.js @@ -464,13 +464,14 @@ my.MultiView = Backbone.View.extend({ // This inverts the state serialization process in Multiview my.MultiView.restore = function(state) { // hack-y - restoring a memory dataset does not mean much ... (but useful for testing!) + var datasetInfo; if (state.backend === 'memory') { - var datasetInfo = { + datasetInfo = { backend: 'memory', records: [{stub: 'this is a stub dataset because we do not restore memory datasets'}] }; } else { - var datasetInfo = _.extend({ + datasetInfo = _.extend({ url: state.url, backend: state.backend }, @@ -483,7 +484,7 @@ my.MultiView.restore = function(state) { state: state }); return explorer; -} +}; // ## Miscellaneous Utilities var urlPathRegex = /^([^?]+)(\?.*)?/; From 5839ab8fa6f6f248e5b1268c2eae99c9e4ec4b31 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 15 Apr 2013 17:58:28 +0200 Subject: [PATCH 8/9] [#340] jshint cleanup of view.slickgrid.js --- src/view.slickgrid.js | 56 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/view.slickgrid.js b/src/view.slickgrid.js index d9f61deb..88d20319 100644 --- a/src/view.slickgrid.js +++ b/src/view.slickgrid.js @@ -39,7 +39,7 @@ my.SlickGrid = Backbone.View.extend({ this.model.records.bind('add', this.render); this.model.records.bind('reset', this.render); this.model.records.bind('remove', this.render); - this.model.records.bind('change', this.onRecordChanged, this) + this.model.records.bind('change', this.onRecordChanged, this); var state = _.extend({ hiddenColumns: [], @@ -52,7 +52,6 @@ my.SlickGrid = Backbone.View.extend({ }, modelEtc.state ); -// this.grid_options = modelEtc.options; this.state = new recline.Model.ObjectState(state); }, @@ -95,25 +94,25 @@ my.SlickGrid = Backbone.View.extend({ } else { return value; } - } + }; _.each(this.model.fields.toJSON(),function(field){ var column = { - id:field['id'], - name:field['label'], - field:field['id'], + id:field.id, + name:field.label, + field:field.id, sortable: true, minWidth: 80, formatter: formatter }; - var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column == field.id}); + var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column == field.id;}); if (widthInfo){ - column['width'] = widthInfo.width; + column.width = widthInfo.width; } - var editInfo = _.find(self.state.get('columnsEditor'),function(c){return c.column == field.id}); + var editInfo = _.find(self.state.get('columnsEditor'),function(c){return c.column == field.id;}); if (editInfo){ - column['editor'] = editInfo.editor; + column.editor = editInfo.editor; } columns.push(column); }); @@ -159,18 +158,18 @@ my.SlickGrid = Backbone.View.extend({ this.push = function(model, row) { models.push(model); rows.push(row); - } - - this.getLength = function() { return rows.length; } - this.getItem = function(index) { return rows[index];} - this.getItemMetadata= function(index) { return {};} - this.getModel= function(index) { return models[index]; } - this.getModelRow = function(m) { return models.indexOf(m);} - this.updateItem = function(m,i) { - rows[i] = toRow(m); - models[i] = m }; - }; + + this.getLength = function() {return rows.length; }; + this.getItem = function(index) {return rows[index];}; + this.getItemMetadata= function(index) {return {};}; + this.getModel= function(index) {return models[index];}; + this.getModelRow = function(m) {return models.indexOf(m);}; + this.updateItem = function(m,i) { + rows[i] = toRow(m); + models[i] = m; + }; + } var data = new RowSet(); @@ -184,7 +183,7 @@ my.SlickGrid = Backbone.View.extend({ var sortInfo = this.model.queryState.get('sort'); if (sortInfo){ var column = sortInfo[0].field; - var sortAsc = !(sortInfo[0].order == 'desc'); + var sortAsc = sortInfo[0].order !== 'desc'; this.grid.setSortColumn(column, sortAsc); } @@ -218,7 +217,7 @@ my.SlickGrid = Backbone.View.extend({ // var grid = args.grid; var model = data.getModel(args.row); - var field = grid.getColumns()[args.cell]['id']; + var field = grid.getColumns()[args.cell].id; var v = {}; v[field] = args.item[field]; model.set(v); @@ -279,7 +278,7 @@ my.SlickGrid = Backbone.View.extend({ $menu = $('