diff --git a/src/dataset.js b/src/dataset.js deleted file mode 100644 index 842a6840..00000000 --- a/src/dataset.js +++ /dev/null @@ -1,43 +0,0 @@ -this.RECLINE = this.RECLINE || {}; - -RECLINE.Model = function ($, _, Backbone) { - var my = {}; - - // A Dataset model. - my.Dataset = Backbone.Model.extend({ - initialize: function(data, rawTabularData) { - this.tabularData = new my.TabularData(rawTabularData); - } - - // get TabularData object associated with this Dataset - // - // async (as may involve getting data from the server) implementing standard promise API - , getTabularData: function() { - var dfd = $.Deferred(); - dfd.resolve(this.tabularData); - return dfd.promise(); - } - }); - - // TabularData model - my.TabularData = Backbone.Model.extend({ - getLength: function() { - return this.get('rows').length; - } - , getRows: function(numRows, start) { - if (start === undefined) { - start = 0; - } - if (numRows === undefined) { - numRows = 10; - } - var dfd = $.Deferred(); - var results = this.get('rows').slice(start, start+numRows); - dfd.resolve(results); - return dfd.promise(); - } - }); - - return my; -}(this.jQuery, this._, this.Backbone); - diff --git a/src/model.js b/src/model.js new file mode 100644 index 00000000..85a93294 --- /dev/null +++ b/src/model.js @@ -0,0 +1,36 @@ +this.recline = this.recline || {}; + +// A Dataset model. +recline.Dataset = Backbone.Model.extend({ + initialize: function(data, rawTabularData) { + this.tabularData = new recline.TabularData(rawTabularData); + } + + // get TabularData object associated with this Dataset + // + // async (as may involve getting data from the server) implementing standard promise API + , getTabularData: function() { + var dfd = $.Deferred(); + dfd.resolve(this.tabularData); + return dfd.promise(); + } +}); + +// TabularData model +recline.TabularData = Backbone.Model.extend({ + getLength: function() { + return this.get('rows').length; + } + , getRows: function(numRows, start) { + if (start === undefined) { + start = 0; + } + if (numRows === undefined) { + numRows = 10; + } + var dfd = $.Deferred(); + var results = this.get('rows').slice(start, start+numRows); + dfd.resolve(results); + return dfd.promise(); + } +}); diff --git a/test/index.html b/test/index.html index ac334a85..7017acdb 100644 --- a/test/index.html +++ b/test/index.html @@ -8,8 +8,8 @@ - - + +

Qunit Tests

diff --git a/test/dataset.test.js b/test/model.test.js similarity index 93% rename from test/dataset.test.js rename to test/model.test.js index a2bd3d86..c8a33426 100644 --- a/test/dataset.test.js +++ b/test/model.test.js @@ -19,7 +19,7 @@ test('new Dataset', function () { , {x: 6, y: 12, z: 18} ] }; - var dataset = new RECLINE.Model.Dataset(metadata, indata); + var dataset = new recline.Dataset(metadata, indata); equal(dataset.get('name'), metadata.name); expect(6); setTimeout(2);