Comparing version 0.3.7 to 0.3.8
@@ -6,3 +6,3 @@ { | ||
"authors": [ | ||
"Jimmy Yuen Ho Wong <wyuenho@gmail.com>" | ||
"Cloudflare, Inc. <jwong@cloudflare.com>" | ||
], | ||
@@ -27,5 +27,5 @@ "keywords": [ | ||
"dependencies": { | ||
"backbone": "~1.2.3", | ||
"underscore": "^1.8.3" | ||
"backbone": "1.1.2 || 1.2.3 || ~1.3.2", | ||
"underscore": "^1.8.0" | ||
} | ||
} |
@@ -87,7 +87,8 @@ Bug Report | ||
Backbone.js uses [jasmine](http://pivotal.github.com/jasmine/) for testing. You | ||
can invoke the following Grunt task to run the tests inside a terminal: | ||
Backbone.js uses [karma](https://karma-runner.github.io/0.13/index.html) and | ||
[jasmine](http://jasmine.github.io/2.4/introduction.html) for testing. You can | ||
invoke the following Grunt task to run the tests inside a terminal: | ||
```shell | ||
$ grunt jasmine | ||
$ grunt karma | ||
``` | ||
@@ -94,0 +95,0 @@ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -53,5 +53,3 @@ */ | ||
' // CommonJS\n' + | ||
' var Backbone = require("backbone");\n' + | ||
' Backbone.$ = Backbone.$ || require("jquery");\n' + | ||
' module.exports = factory(require("underscore"), Backbone);\n' + | ||
' module.exports = factory(require("underscore"), require("backbone"));\n' + | ||
' } else {\n' + | ||
@@ -80,14 +78,5 @@ ' // Browser\n' + | ||
connect: { | ||
server: { | ||
options: { | ||
keepalive: true | ||
} | ||
} | ||
}, | ||
karma: { | ||
unit: { | ||
configFile: 'karma.conf.js', | ||
background: true, | ||
singleRun: true | ||
@@ -106,3 +95,2 @@ } | ||
"categories": "categories.json", | ||
"warnings": "-no_doc", | ||
"pretty-json": true, | ||
@@ -155,9 +143,2 @@ "body-html": '<script type="text/javascript">\n' + | ||
} | ||
}, | ||
watch: { | ||
default: { | ||
files: ["src/**/*.*"], | ||
tasks: ["dist"] | ||
} | ||
} | ||
@@ -169,6 +150,4 @@ }); | ||
grunt.loadNpmTasks("grunt-contrib-uglify"); | ||
grunt.loadNpmTasks("grunt-contrib-watch"); | ||
grunt.loadNpmTasks("grunt-recess"); | ||
grunt.loadNpmTasks("grunt-jsduck"); | ||
grunt.loadNpmTasks("grunt-contrib-connect"); | ||
grunt.loadNpmTasks("grunt-karma"); | ||
@@ -175,0 +154,0 @@ |
// Karma configuration | ||
// Generated on Wed Mar 09 2016 13:20:18 GMT+0000 (GMT) | ||
// Generated on Wed Mar 09 2016-present 13:20:18 GMT+0000 (GMT) | ||
@@ -42,10 +42,14 @@ module.exports = function(config) { | ||
preprocessors: { | ||
'lib/backgrid.js': ['coverage'] | ||
}, | ||
coverageReporter: { | ||
type: 'html', | ||
dir: 'test/coverage', | ||
}, | ||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress'], | ||
reporters: ['progress', 'kjhtml', 'coverage'], | ||
@@ -67,3 +71,3 @@ | ||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: false, | ||
autoWatch: true, | ||
@@ -70,0 +74,0 @@ |
{ | ||
"name": "backgrid", | ||
"version": "0.3.7", | ||
"author": "Jimmy Yuen Ho Wong and contributors <wyuenho@gmail.com>", | ||
"version": "0.3.8", | ||
"author": "Cloudflare, Inc. and contributors <jwong@cloudflare.com>", | ||
"description": "Backgrid.js is a set of components for building semantic and easily stylable data grid widgets with Backbone.", | ||
@@ -12,4 +12,5 @@ "homepage": "http://backgridjs.com/", | ||
"main": "./lib/backgrid.js", | ||
"style": "./lib/backgrid.css", | ||
"scripts": { | ||
"test": "karma start --single-run --browsers Chrome,Firefox", | ||
"test": "karma start --single-run", | ||
"prepublish": "grunt dist" | ||
@@ -19,33 +20,29 @@ }, | ||
"type": "git", | ||
"url": "http://github.com/wyuenho/backgrid" | ||
"url": "http://github.com/cloudflare/backgrid" | ||
}, | ||
"devDependencies": { | ||
"backbone.paginator": "^2.0.0", | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt": "^1.0.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^1.0.0", | ||
"grunt-contrib-concat": "^1.0.0", | ||
"grunt-contrib-connect": "^0.11.2", | ||
"grunt-contrib-jasmine": "^1.0.0", | ||
"grunt-contrib-uglify": "^1.0.0", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt-jsduck": "^1.0.1", | ||
"grunt-karma": "^0.12.1", | ||
"grunt-recess": "^1.0.1", | ||
"grunt-template-jasmine-istanbul": "^0.4.0", | ||
"jquery": "2.1.0", | ||
"karma": "^0.13.22", | ||
"karma-chrome-launcher": "^0.2.2", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.1.6", | ||
"karma-safari-launcher": "^0.1.1" | ||
"grunt-contrib-uglify": "^2.0.0", | ||
"grunt-jsduck": "^1.0.0", | ||
"grunt-karma": "^1.0.0", | ||
"grunt-recess": "^1.0.0", | ||
"jasmine-core": "^2.4.0", | ||
"jquery": "^2.1.0", | ||
"karma": "^1.0.0", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-coverage": "^1.0.0", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-jasmine": "^1.0.0", | ||
"karma-jasmine-textio-html-reporter": "^1.0.0", | ||
"karma-safari-launcher": "^1.0.0" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=0.10" | ||
}, | ||
"dependencies": { | ||
"backbone": "~1.2.3", | ||
"backbone": "1.1.2 || 1.2.3 || ~1.3.2", | ||
"underscore": "^1.8.0" | ||
} | ||
} |
# Backgrid.js | ||
[![Build Status](https://travis-ci.org/wyuenho/backgrid.png?branch=master)](https://travis-ci.org/wyuenho/backgrid) | ||
[![Build Status](https://travis-ci.org/cloudflare/backgrid.png?branch=master)](https://travis-ci.org/cloudflare/backgrid) | ||
@@ -25,3 +25,3 @@ Backgrid.js is a set of components for building semantic and easily stylable | ||
- Good documentation. | ||
- Well tested. Comes with [100s of test cases](http://wyuenho.github.io/backgrid/test/). | ||
- Well tested. Comes with [100s of test cases](http://cloudflare.github.io/backgrid/test/). | ||
@@ -108,9 +108,4 @@ ## Supported browsers [[1]](#note-1): | ||
## Commercial Support | ||
If there's a feature that you would like me to implement or a bug you'd like me | ||
to fix, you can contact me at this [email address](mailto:wyuenho@gmail.com). | ||
## License | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong | ||
Copyright (c) 2013-present Cloudflare, Inc. | ||
Licensed under the [MIT license](LICENSE-MIT "MIT License"). |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -309,5 +309,7 @@ */ | ||
collection.trigger("backgrid:sorted", column, direction, collection); | ||
column.set("direction", direction); | ||
} | ||
else collection.fetch({reset: true, success: function () { | ||
collection.trigger("backgrid:sorted", column, direction, collection); | ||
column.set("direction", direction); | ||
}}); | ||
@@ -319,6 +321,5 @@ } | ||
collection.trigger("backgrid:sorted", column, direction, collection); | ||
column.set("direction", direction); | ||
} | ||
column.set("direction", direction); | ||
return this; | ||
@@ -325,0 +326,0 @@ }, |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -58,3 +58,3 @@ */ | ||
column should be sortable. The method's signature must be `function | ||
(Backgrid.Column, Backbone.Model): boolean`. | ||
(Backbone.Model): boolean`. The function's context is the column instance. | ||
@@ -65,3 +65,3 @@ @cfg {boolean|string|function(): boolean} [defaults.editable=true] Whether | ||
column should be editable. The method's signature must be `function | ||
(Backgrid.Column, Backbone.Model): boolean`. | ||
(Backbone.Model): boolean`. The function's context is the column instance. | ||
@@ -72,3 +72,4 @@ @cfg {boolean|string|function(): boolean} [defaults.renderable=true] | ||
whether the column should be renderable. The method's signature must be | ||
`function (Backrid.Column, Backbone.Model): boolean`. | ||
`function (Backbone.Model): boolean`. The function's context is the column | ||
instance. | ||
@@ -179,20 +180,29 @@ @cfg {Backgrid.CellFormatter | Object | string} [defaults.formatter] The | ||
/** | ||
If you cannot always determine whether a column should be sortable before | ||
the grid get initialized, you can override this method. | ||
@member Backgrid.Column | ||
@protected | ||
@method sortable | ||
@return {function(Backgrid.Column, Backbone.Model): boolean | boolean} | ||
@return {function(Backbone.Model): boolean | boolean} | ||
*/ | ||
/** | ||
If you cannot always determine whether a column should be editable before | ||
the grid get initialized, you can override this method. | ||
@member Backgrid.Column | ||
@protected | ||
@method editable | ||
@return {function(Backgrid.Column, Backbone.Model): boolean | boolean} | ||
@return {function(Backbone.Model): boolean | boolean} | ||
*/ | ||
/** | ||
If you cannot always determine whether a column should be renderable before | ||
the grid get initialized, you can override this method. | ||
@member Backgrid.Column | ||
@protected | ||
@method renderable | ||
@return {function(Backgrid.Column, Backbone.Model): boolean | boolean} | ||
@return {function(Backbone.Model): boolean | boolean} | ||
*/ | ||
@@ -199,0 +209,0 @@ }); |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -79,2 +79,3 @@ */ | ||
@param {Backbone.Collection} options.collection The collection of tabular model data to display. | ||
@param {string} [options.caption=string] An optional caption to be added to the table. | ||
@param {Backgrid.Header} [options.header=Backgrid.Header] An optional Header class to override the default. | ||
@@ -92,2 +93,4 @@ @param {Backgrid.Body} [options.body=Backgrid.Body] An optional Body class to override the default. | ||
this.columns = options.columns; | ||
this.caption = options.caption; | ||
@@ -172,3 +175,3 @@ var filteredOptions = _.omit(options, ["el", "id", "attributes", | ||
/** | ||
Renders the grid's header, then footer, then finally the body. Triggers a | ||
Renders the grid's caption, then header, then footer, then finally the body. Triggers a | ||
Backbone `backgrid:rendered` event along with a reference to the grid when | ||
@@ -179,2 +182,6 @@ the it has successfully been rendered. | ||
this.$el.empty(); | ||
if (this.caption) { | ||
this.$el.append($("<caption>").text(this.caption)); | ||
} | ||
@@ -181,0 +188,0 @@ if (this.header) { |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -24,3 +24,3 @@ */ | ||
events: { | ||
"click a": "onClick" | ||
"click button": "onClick" | ||
}, | ||
@@ -60,8 +60,8 @@ | ||
this.listenTo(collection.fullCollection || collection, "sort", this.removeCellDirection); | ||
this.listenTo(collection.fullCollection || collection, "backgrid:sorted", this.removeCellDirection); | ||
}, | ||
/** | ||
Event handler for the collection's `sort` event. Removes all the CSS | ||
direction classes. | ||
Event handler for the collection's `backgrid:sorted` event. Removes | ||
all the CSS direction classes. | ||
*/ | ||
@@ -125,3 +125,3 @@ removeCellDirection: function () { | ||
if(sortable){ | ||
label = $("<a>").text(column.get("label")).append("<b class='sort-caret'></b>"); | ||
label = $("<button>").text(column.get("label")).append("<span class='sort-caret' aria-hidden='true'></span>"); | ||
} else { | ||
@@ -128,0 +128,0 @@ label = document.createTextNode(column.get("label")); |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -126,3 +126,3 @@ */ | ||
spyOn(CustomRow.prototype, "render").andCallThrough(); | ||
spyOn(CustomRow.prototype, "render").and.callThrough(); | ||
@@ -129,0 +129,0 @@ body = new Backgrid.Body({ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -76,11 +76,14 @@ */ | ||
this.addMatchers({ | ||
toBeAnInstanceOf: function (expected) { | ||
var actual = this.actual; | ||
var notText = this.isNot ? " not" : ""; | ||
this.message = function () { | ||
return "Expected " + actual + notText + " to be an instance of " + expected; | ||
jasmine.addMatchers({ | ||
toBeAnInstanceOf: function (util) { | ||
return { | ||
compare: function (actual, expected) { | ||
return { | ||
pass: actual instanceof expected | ||
}; | ||
}, | ||
negativeCompare: function (actual, expected) { | ||
return !this.compare(actual, expected) | ||
} | ||
}; | ||
return actual instanceof expected; | ||
} | ||
@@ -123,6 +126,6 @@ }); | ||
editor.formatter = { | ||
fromRaw: jasmine.createSpy("fromRaw").andCallFake(function (d) { | ||
fromRaw: jasmine.createSpy("fromRaw").and.callFake(function (d) { | ||
return d; | ||
}), | ||
toRaw: jasmine.createSpy("toRaw").andReturn(undefined) | ||
toRaw: jasmine.createSpy("toRaw").and.returnValue(undefined) | ||
}; | ||
@@ -133,3 +136,3 @@ editor.render(); | ||
editor.$el.trigger(enter); | ||
expect(editor.formatter.toRaw.calls.length).toBe(1); | ||
expect(editor.formatter.toRaw.calls.count()).toBe(1); | ||
expect(editor.formatter.toRaw).toHaveBeenCalledWith("invalid value", editor.model); | ||
@@ -141,3 +144,3 @@ expect(backgridErrorTriggerCount).toBe(1); | ||
editor.formatter.toRaw.reset(); | ||
editor.formatter.toRaw.calls.reset(); | ||
editor.$el.blur(); | ||
@@ -1330,7 +1333,7 @@ expect(backgridErrorTriggerCount).toBe(2); | ||
spyOn(editor.formatter, "toRaw").andCallThrough(); | ||
spyOn(editor.formatter, "toRaw").and.callThrough(); | ||
editor.$el.val(1).change(); | ||
expect(editor.formatter.toRaw).toHaveBeenCalledWith("1", editor.model); | ||
expect(editor.formatter.toRaw.calls.length).toBe(1); | ||
expect(editor.formatter.toRaw.calls.count()).toBe(1); | ||
expect(editor.model.get(editor.column.get("name"))).toBe("1"); | ||
@@ -1354,7 +1357,7 @@ | ||
spyOn(editor.formatter, "toRaw").andCallThrough(); | ||
spyOn(editor.formatter, "toRaw").and.callThrough(); | ||
editor.$el.val([1, 2]).change(); | ||
expect(editor.formatter.toRaw).toHaveBeenCalledWith(["1", "2"], editor.model); | ||
expect(editor.formatter.toRaw.calls.length).toBe(1); | ||
expect(editor.formatter.toRaw.calls.count()).toBe(1); | ||
expect(editor.model.get(editor.column.get("name"))).toEqual(["1", "2"]); | ||
@@ -1364,3 +1367,3 @@ | ||
expect(editor.formatter.toRaw).toHaveBeenCalledWith(null, editor.model); | ||
expect(editor.formatter.toRaw.calls.length).toBe(2); | ||
expect(editor.formatter.toRaw.calls.count()).toBe(2); | ||
expect(editor.model.get(editor.column.get("name"))).toBe(null); | ||
@@ -1367,0 +1370,0 @@ }); |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -41,5 +41,5 @@ */ | ||
spyOn(grid, "trigger"); | ||
spyOn(grid.header, "render").andCallThrough(); | ||
spyOn(grid.footer, "render").andCallThrough(); | ||
spyOn(grid.body, "render").andCallThrough(); | ||
spyOn(grid.header, "render").and.callThrough(); | ||
spyOn(grid.footer, "render").and.callThrough(); | ||
spyOn(grid.body, "render").and.callThrough(); | ||
@@ -49,6 +49,6 @@ grid.render(); | ||
expect(grid.el.tagName).toBe("TABLE"); | ||
expect(grid.header.render.calls.length).toBe(1); | ||
expect(grid.footer.render.calls.length).toBe(1); | ||
expect(grid.body.render.calls.length).toBe(1); | ||
expect(grid.trigger.calls.length).toBe(1); | ||
expect(grid.header.render.calls.count()).toBe(1); | ||
expect(grid.footer.render.calls.count()).toBe(1); | ||
expect(grid.body.render.calls.count()).toBe(1); | ||
expect(grid.trigger.calls.count()).toBe(1); | ||
expect(grid.trigger).toHaveBeenCalledWith("backgrid:rendered", grid); | ||
@@ -89,2 +89,19 @@ }); | ||
}); | ||
it("will render a table with a caption element", function () { | ||
var caption = "Table of data" | ||
grid = new Backgrid.Grid({ | ||
columns: [{ | ||
name: "title", | ||
cell: "string" | ||
}], | ||
collection: books, | ||
caption: caption, | ||
}); | ||
grid.render(); | ||
expect($(grid.el).find("caption")); | ||
expect($(grid.el).find("caption").text()).toBe(caption); | ||
}); | ||
@@ -96,5 +113,5 @@ it("will clean up all its decendant views when remove is called", function () { | ||
it("will delegate insertRow, removeRow and sort to the body", function () { | ||
spyOn(grid.body, "insertRow").andCallThrough(); | ||
spyOn(grid.body, "removeRow").andCallThrough(); | ||
spyOn(grid.body, "sort").andCallThrough(); | ||
spyOn(grid.body, "insertRow").and.callThrough(); | ||
spyOn(grid.body, "removeRow").and.callThrough(); | ||
spyOn(grid.body, "sort").and.callThrough(); | ||
grid.insertRow({}); | ||
@@ -110,4 +127,4 @@ expect(grid.body.insertRow).toHaveBeenCalledWith({}); | ||
it("will delegate to columns.add and columns.remove from insertColumn and removeColumn", function () { | ||
spyOn(grid.columns, "add").andCallThrough(); | ||
spyOn(grid.columns, "remove").andCallThrough(); | ||
spyOn(grid.columns, "add").and.callThrough(); | ||
spyOn(grid.columns, "remove").and.callThrough(); | ||
grid.insertColumn({name: "id", cell: "integer"}); | ||
@@ -130,4 +147,4 @@ expect(grid.columns.add).toHaveBeenCalledWith({name: "id", cell: "integer"}); | ||
expect($(thead).find("tr").length).toBe(1); | ||
expect($(thead).find("tr > th.editable.sortable.renderable.id > a > b.sort-caret").length).toBe(1); | ||
expect($(thead).find("tr > th.editable.sortable.renderable.id > a").text()).toBe("id"); | ||
expect($(thead).find("tr > th.editable.sortable.renderable.id > button > span.sort-caret").length).toBe(1); | ||
expect($(thead).find("tr > th.editable.sortable.renderable.id > button").text()).toBe("id"); | ||
@@ -134,0 +151,0 @@ var tfoot = grid.el.childNodes[1]; |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -28,4 +28,5 @@ */ | ||
expect(cell.el.tagName).toBe("TH"); | ||
expect(cell.$el.find("a").text()).toBe("id"); | ||
expect(cell.$el.find("button").text()).toBe("id"); | ||
expect(cell.$el.find(".sort-caret").length).toBe(1); | ||
expect(cell.$el.find(".sort-caret").attr("aria-hidden")).toEqual("true"); | ||
@@ -128,3 +129,3 @@ cell.column.set("sortable", false); | ||
it("will rerender with the column name and/or label changes", function () { | ||
expect(cell.$el.find("a").text(), "id"); | ||
expect(cell.$el.find("button").text(), "id"); | ||
expect(cell.$el.hasClass("id"), true); | ||
@@ -137,3 +138,3 @@ | ||
cell.column.set("label", "Name"); | ||
expect(cell.$el.find("a").text(), "Name"); | ||
expect(cell.$el.find("button").text(), "Name"); | ||
expect(cell.$el.hasClass("Name"), true); | ||
@@ -155,3 +156,3 @@ }); | ||
expect(cell.el.tagName).toBe("TH"); | ||
expect(cell.$el.find("a").text()).toBe("id"); | ||
expect(cell.$el.find("button").text()).toBe("id"); | ||
expect(cell.$el.find(".sort-caret").length).toBe(1); | ||
@@ -164,3 +165,3 @@ expect(cell.$el.hasClass("descending")).toBe(true); | ||
cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; }); | ||
cell.$el.find("a").click(); | ||
cell.$el.find("button").click(); | ||
expect(column).toBe(cell.column); | ||
@@ -174,3 +175,3 @@ expect(direction).toBe("ascending"); | ||
cell.column.set("direction", "ascending"); | ||
cell.$el.find("a").click(); | ||
cell.$el.find("button").click(); | ||
expect(column).toBe(cell.column); | ||
@@ -184,3 +185,3 @@ expect(direction).toBe("descending"); | ||
cell.column.set("direction", "descending"); | ||
cell.$el.find("a").click(); | ||
cell.$el.find("button").click(); | ||
expect(column).toBe(cell.column); | ||
@@ -200,6 +201,8 @@ expect(direction).toBeNull(); | ||
it("will remove its direction CSS class if `sort` is triggered from the collection or pageableCollection#fullCollection", function () { | ||
it("will remove its direction CSS class if `backgrid:sorted` is triggered from the collection or pageableCollection#fullCollection", function () { | ||
cell.column.set("direction", "ascending"); | ||
expect(cell.$el.hasClass("ascending")).toBe(true); | ||
cell.collection.comparator = "id"; | ||
cell.collection.sort(); | ||
cell.collection.trigger("backgrid:sorted"); | ||
expect(cell.$el.hasClass("ascending")).toBe(false); | ||
@@ -221,4 +224,6 @@ expect(cell.$el.hasClass("descending")).toBe(false); | ||
cell.column.set("direction", "ascending"); | ||
expect(cell.$el.hasClass("ascending")).toBe(true); | ||
cell.collection.fullCollection.comparator = "id"; | ||
cell.collection.fullCollection.sort(); | ||
cell.collection.fullCollection.trigger("backgrid:sorted"); | ||
expect(cell.$el.hasClass("ascending")).toBe(false); | ||
@@ -232,3 +237,3 @@ expect(cell.$el.hasClass("descending")).toBe(false); | ||
cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; }); | ||
cell.$el.find("a").click(); | ||
cell.$el.find("button").click(); | ||
expect(column).toBe(cell.column); | ||
@@ -243,3 +248,3 @@ expect(direction).toBe("ascending"); | ||
cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; }); | ||
cell.$el.find("a").click(); | ||
cell.$el.find("button").click(); | ||
expect(column).toBe(cell.column); | ||
@@ -254,3 +259,3 @@ expect(direction).toBe("descending"); | ||
cell.collection.on("backgrid:sort", function (col, dir) { column = col; direction = dir; }); | ||
cell.$el.find("a").click(); | ||
cell.$el.find("button").click(); | ||
expect(column).toBe(cell.column); | ||
@@ -307,4 +312,4 @@ expect(direction).toBe("ascending"); | ||
expect(th1.hasClass("name")).toBe(true); | ||
expect(th1.find("a").text()).toBe("name"); | ||
expect(th1.find("a").eq(1).is($("b", {className: "sort-caret"}))); | ||
expect(th1.find("button").text()).toBe("name"); | ||
expect(th1.find("button").eq(1).is($("b", {className: "sort-caret"}))); | ||
@@ -316,11 +321,11 @@ var th2 = $(row.el.childNodes[1]); | ||
expect(th2.hasClass("year")).toBe(true); | ||
expect(th2.find("a").text()).toBe("year"); | ||
expect(th2.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
expect(th2.find("button").text()).toBe("year"); | ||
expect(th2.find("button > span:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
}); | ||
it("resets the carets of the non-sorting columns", function () { | ||
row.$el.find("a").eq(0).click(); // ascending | ||
row.$el.find("a").eq(1).click(); // ascending, resets the previous | ||
expect(row.$el.find("a").eq(0).hasClass("ascending")).toBe(false); | ||
expect(row.$el.find("a").eq(1).hasClass("ascending")).toBe(false); | ||
row.$el.find("button").eq(0).click(); // ascending | ||
row.$el.find("button").eq(1).click(); // ascending, resets the previous | ||
expect(row.$el.find("button").eq(0).hasClass("ascending")).toBe(false); | ||
expect(row.$el.find("button").eq(1).hasClass("ascending")).toBe(false); | ||
}); | ||
@@ -336,8 +341,8 @@ | ||
expect(lastTh.hasClass("price")).toBe(true); | ||
expect(lastTh.find("a").text()).toBe("price"); | ||
expect(lastTh.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
expect(lastTh.find("button").text()).toBe("price"); | ||
expect(lastTh.find("button > span:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
row.columns.add({name: "publisher", cell: "string", renderable: false}); | ||
expect(row.$el.children().length).toBe(4); | ||
expect(row.$el.children().last().find("a").text()).toBe("publisher"); | ||
expect(row.$el.children().last().find("button").text()).toBe("publisher"); | ||
expect(row.$el.children().last().hasClass("renderable")).toBe(false); | ||
@@ -352,4 +357,4 @@ | ||
expect(firstTh.hasClass("year")).toBe(true); | ||
expect(firstTh.find("a").text()).toBe("year"); | ||
expect(firstTh.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
expect(firstTh.find("button").text()).toBe("year"); | ||
expect(firstTh.find("button > span:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
}); | ||
@@ -405,4 +410,4 @@ | ||
expect(th1.hasClass("name")).toBe(true); | ||
expect(th1.find("a").text()).toBe("name"); | ||
expect(th1.find("a").eq(1).is($("b", {className: "sort-caret"}))); | ||
expect(th1.find("button").text()).toBe("name"); | ||
expect(th1.find("button").eq(1).is($("b", {className: "sort-caret"}))); | ||
@@ -414,6 +419,6 @@ var th2 = $(head.row.el.childNodes[1]); | ||
expect(th2.hasClass("year")).toBe(true); | ||
expect(th2.find("a").text()).toBe("year"); | ||
expect(th2.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
expect(th2.find("button").text()).toBe("year"); | ||
expect(th2.find("button > span:last-child").eq(0).hasClass("sort-caret")).toBe(true); | ||
}); | ||
}); |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
/* | ||
backgrid | ||
http://github.com/wyuenho/backgrid | ||
http://github.com/cloudflare/backgrid | ||
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | ||
Copyright (c) 2013-present Cloudflare, Inc. and contributors | ||
Licensed under the MIT license. | ||
@@ -7,0 +7,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1237792
18
64
9644
2
110
- Removedbackbone@1.2.3(transitive)