diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 846ffc7..12e2cbe 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,6 +1,6 @@ -Jimmy Yuen Ho Wong +Cloudflare, Inc Tim Walker -Jimmy Yuen Ho Wong +Cloudflare, Inc Gabriel Bédard Sicé pctj101 mdrapeau diff --git a/Gruntfile.js b/Gruntfile.js index 7a041d1..3ca526a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,7 +2,7 @@ backgrid-select-all http://github.com/wyuenho/backgrid-select-all - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present-present Cloudflare, Inc and contributors Licensed under the MIT license. */ diff --git a/LICENSE-MIT b/LICENSE-MIT index dc1cdcb..3bdf03d 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2012 Jimmy Yuen Ho Wong +Copyright (c) 2012 Cloudflare, Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/api/data-ba57a1d79a905d9e688108ce9a570e77.js b/api/data-ba1053d57bc7689f91ac9de2a13aeb41.js similarity index 96% rename from api/data-ba57a1d79a905d9e688108ce9a570e77.js rename to api/data-ba1053d57bc7689f91ac9de2a13aeb41.js index f9246bb..0b2a9fa 100644 --- a/api/data-ba57a1d79a905d9e688108ce9a570e77.js +++ b/api/data-ba1053d57bc7689f91ac9de2a13aeb41.js @@ -75,6 +75,15 @@ Docs = { }, "sort": 3 }, + { + "name": "checkbox", + "fullName": "Backgrid.Extension.SelectRowCell.checkbox", + "icon": "icon-method", + "url": "#!/api/Backgrid.Extension.SelectRowCell-method-checkbox", + "meta": { + }, + "sort": 3 + }, { "name": "enterEditMode", "fullName": "Backgrid.Extension.SelectRowCell.enterEditMode", diff --git a/api/index.html b/api/index.html index a8335f5..4463a7a 100644 --- a/api/index.html +++ b/api/index.html @@ -12,7 +12,7 @@ - + @@ -59,7 +59,7 @@

SelectAll

- + diff --git a/api/output/Backgrid.Extension.SelectAllHeaderCell.js b/api/output/Backgrid.Extension.SelectAllHeaderCell.js index 64a59ed..0a9334e 100644 --- a/api/output/Backgrid.Extension.SelectAllHeaderCell.js +++ b/api/output/Backgrid.Extension.SelectAllHeaderCell.js @@ -56,6 +56,14 @@ Ext.data.JsonP.Backgrid_Extension_SelectAllHeaderCell({ } ], "method": [ + { + "name": "checkbox", + "tagname": "method", + "owner": "Backgrid.Extension.SelectRowCell", + "meta": { + }, + "id": "method-checkbox" + }, { "name": "enterEditMode", "tagname": "method", @@ -116,7 +124,7 @@ Ext.data.JsonP.Backgrid_Extension_SelectAllHeaderCell({ ] }, - "linenr": 123, + "linenr": 132, "files": [ { "filename": "backgrid-select-all.js", @@ -159,5 +167,5 @@ Ext.data.JsonP.Backgrid_Extension_SelectAllHeaderCell({ "parentMixins": [ ], - "html": "

Hierarchy

Backbone.View
Backgrid.Extension.SelectRowCell
Backgrid.Extension.SelectAllHeaderCell

Renders a checkbox to select all rows on the current page.

\n
Defined By

Properties

Backgrid.Extension.SelectAllHeaderCell
: String
...
\n

Defaults to: "select-all-header-cell"

Overrides: Backgrid.Extension.SelectRowCell.className

...
\n

Defaults to: {"keydown input[type=checkbox]": "onKeydown", "change input[type=checkbox]": "onChange", "click input[type=checkbox]": "enterEditMode"}

Backgrid.Extension.SelectAllHeaderCell
: String
...
\n

Defaults to: "th"

Overrides: Backgrid.Extension.SelectRowCell.tagName

Defined By

Methods

Focuses the checkbox. ...

Focuses the checkbox.

\n
Unfocuses the checkbox. ...

Unfocuses the checkbox.

\n
Backgrid.Extension.SelectAllHeaderCell
( options )
Initializer. ...

Initializer. When this cell's checkbox is checked, a Backbone\nbackgrid:select event will be triggered for each model for the current\npage in the underlying collection. If a SelectRowCell instance exists\nfor the rows representing the models, they will check themselves. If any\nof the SelectRowCell instances trigger a Backbone backgrid:selected\nevent with a false value, this cell will uncheck its checkbox. In the\nevent of a Backbone backgrid:refresh event, which is triggered when the\nbody refreshes its rows, which can happen under a number of conditions\nsuch as paging or the columns were reset, this cell will still remember\nthe previously selected models and trigger a Backbone backgrid:select\nevent on them such that the SelectRowCells can recheck themselves upon\nrefreshing.

\n

Parameters

  • options : Object
    \n
    • column : Backgrid.Column
    • collection : Backbone.Collection

Overrides: Backgrid.Extension.SelectRowCell.initialize

Backgrid.Extension.SelectAllHeaderCell
( )
Propagates the checked value of this checkbox to all the models of the\nunderlying collection by triggering a Backbone...

Propagates the checked value of this checkbox to all the models of the\nunderlying collection by triggering a Backbone backgrid:select event on\nthe models on the current page, passing each model and the current\nchecked value of the checkbox in each event.

\n\n

A backgrid:selected event will also be triggered with the current\nchecked value on all the models regardless of whether they are on the\ncurrent page.

\n\n

This method triggers a 'backgrid:select-all' event on the collection\nafterwards.

\n

Overrides: Backgrid.Extension.SelectRowCell.onChange

Process keyboard navigation. ...

Process keyboard navigation.

\n

Parameters

  • e : Object
    \n
Renders a checkbox in a table cell. ...

Renders a checkbox in a table cell.

\n

Returns

" + "html": "

Hierarchy

Backbone.View
Backgrid.Extension.SelectRowCell
Backgrid.Extension.SelectAllHeaderCell

Renders a checkbox to select all rows on the current page.

\n
Defined By

Properties

Backgrid.Extension.SelectAllHeaderCell
: String
...
\n

Defaults to: "select-all-header-cell"

Overrides: Backgrid.Extension.SelectRowCell.className

...
\n

Defaults to: {"keydown input[type=checkbox]": "onKeydown", "change input[type=checkbox]": "onChange", "click input[type=checkbox]": "enterEditMode"}

Backgrid.Extension.SelectAllHeaderCell
: String
...
\n

Defaults to: "th"

Overrides: Backgrid.Extension.SelectRowCell.tagName

Defined By

Methods

Returns the checkbox. ...

Returns the checkbox.

\n
Focuses the checkbox. ...

Focuses the checkbox.

\n
Unfocuses the checkbox. ...

Unfocuses the checkbox.

\n
Backgrid.Extension.SelectAllHeaderCell
( options )
Initializer. ...

Initializer. When this cell's checkbox is checked, a Backbone\nbackgrid:select event will be triggered for each model for the current\npage in the underlying collection. If a SelectRowCell instance exists\nfor the rows representing the models, they will check themselves. If any\nof the SelectRowCell instances trigger a Backbone backgrid:selected\nevent with a false value, this cell will uncheck its checkbox. In the\nevent of a Backbone backgrid:refresh event, which is triggered when the\nbody refreshes its rows, which can happen under a number of conditions\nsuch as paging or the columns were reset, this cell will still remember\nthe previously selected models and trigger a Backbone backgrid:select\nevent on them such that the SelectRowCells can recheck themselves upon\nrefreshing.

\n

Parameters

  • options : Object
    \n
    • column : Backgrid.Column
    • collection : Backbone.Collection

Overrides: Backgrid.Extension.SelectRowCell.initialize

Backgrid.Extension.SelectAllHeaderCell
( )
Propagates the checked value of this checkbox to all the models of the\nunderlying collection by triggering a Backbone...

Propagates the checked value of this checkbox to all the models of the\nunderlying collection by triggering a Backbone backgrid:select event on\nthe models on the current page, passing each model and the current\nchecked value of the checkbox in each event.

\n\n

A backgrid:selected event will also be triggered with the current\nchecked value on all the models regardless of whether they are on the\ncurrent page.

\n\n

This method triggers a 'backgrid:select-all' event on the collection\nafterwards.

\n

Overrides: Backgrid.Extension.SelectRowCell.onChange

Process keyboard navigation. ...

Process keyboard navigation.

\n

Parameters

  • e : Object
    \n
Renders a checkbox in a table cell. ...

Renders a checkbox in a table cell.

\n

Returns

" }); \ No newline at end of file diff --git a/api/output/Backgrid.Extension.SelectRowCell.js b/api/output/Backgrid.Extension.SelectRowCell.js index 0f0a3a1..8b521be 100644 --- a/api/output/Backgrid.Extension.SelectRowCell.js +++ b/api/output/Backgrid.Extension.SelectRowCell.js @@ -56,6 +56,14 @@ Ext.data.JsonP.Backgrid_Extension_SelectRowCell({ } ], "method": [ + { + "name": "checkbox", + "tagname": "method", + "owner": "Backgrid.Extension.SelectRowCell", + "meta": { + }, + "id": "method-checkbox" + }, { "name": "enterEditMode", "tagname": "method", @@ -116,7 +124,7 @@ Ext.data.JsonP.Backgrid_Extension_SelectRowCell({ ] }, - "linenr": 21, + "linenr": 23, "files": [ { "filename": "backgrid-select-all.js", @@ -158,5 +166,5 @@ Ext.data.JsonP.Backgrid_Extension_SelectRowCell({ "parentMixins": [ ], - "html": "

Hierarchy

Backbone.View
Backgrid.Extension.SelectRowCell

Subclasses

Renders a checkbox for row selection.

\n
Defined By

Properties

Backgrid.Extension.SelectRowCell
: String
...
\n

Defaults to: "select-row-cell"

Backgrid.Extension.SelectRowCell
: Object
...
\n

Defaults to: {"keydown input[type=checkbox]": "onKeydown", "change input[type=checkbox]": "onChange", "click input[type=checkbox]": "enterEditMode"}

Backgrid.Extension.SelectRowCell
: String
...
\n

Defaults to: "td"

Defined By

Methods

Backgrid.Extension.SelectRowCell
( )
Focuses the checkbox. ...

Focuses the checkbox.

\n
Backgrid.Extension.SelectRowCell
( )
Unfocuses the checkbox. ...

Unfocuses the checkbox.

\n
Backgrid.Extension.SelectRowCell
( options )
Initializer. ...

Initializer. If the underlying model triggers a select event, this cell\nwill change its checked value according to the event's selected value.

\n

Parameters

  • options : Object
    \n
    • column : Backgrid.Column
    • model : Backbone.Model
Backgrid.Extension.SelectRowCell
( )
When the checkbox's value changes, this method will trigger a Backbone\nbackgrid:selected event with a reference of th...

When the checkbox's value changes, this method will trigger a Backbone\nbackgrid:selected event with a reference of the model and the\ncheckbox's checked value.

\n
Backgrid.Extension.SelectRowCell
( e )
Process keyboard navigation. ...

Process keyboard navigation.

\n

Parameters

  • e : Object
    \n
Backgrid.Extension.SelectRowCell
( ) : Backgrid.Extension.SelectRowCellchainable
Renders a checkbox in a table cell. ...

Renders a checkbox in a table cell.

\n

Returns

" + "html": "

Hierarchy

Backbone.View
Backgrid.Extension.SelectRowCell

Subclasses

Renders a checkbox for row selection.

\n
Defined By

Properties

Backgrid.Extension.SelectRowCell
: String
...
\n

Defaults to: "select-row-cell"

Backgrid.Extension.SelectRowCell
: Object
...
\n

Defaults to: {"keydown input[type=checkbox]": "onKeydown", "change input[type=checkbox]": "onChange", "click input[type=checkbox]": "enterEditMode"}

Backgrid.Extension.SelectRowCell
: String
...
\n

Defaults to: "td"

Defined By

Methods

Backgrid.Extension.SelectRowCell
( )
Returns the checkbox. ...

Returns the checkbox.

\n
Backgrid.Extension.SelectRowCell
( )
Focuses the checkbox. ...

Focuses the checkbox.

\n
Backgrid.Extension.SelectRowCell
( )
Unfocuses the checkbox. ...

Unfocuses the checkbox.

\n
Backgrid.Extension.SelectRowCell
( options )
Initializer. ...

Initializer. If the underlying model triggers a select event, this cell\nwill change its checked value according to the event's selected value.

\n

Parameters

  • options : Object
    \n
    • column : Backgrid.Column
    • model : Backbone.Model
Backgrid.Extension.SelectRowCell
( )
When the checkbox's value changes, this method will trigger a Backbone\nbackgrid:selected event with a reference of th...

When the checkbox's value changes, this method will trigger a Backbone\nbackgrid:selected event with a reference of the model and the\ncheckbox's checked value.

\n
Backgrid.Extension.SelectRowCell
( e )
Process keyboard navigation. ...

Process keyboard navigation.

\n

Parameters

  • e : Object
    \n
Backgrid.Extension.SelectRowCell
( ) : Backgrid.Extension.SelectRowCellchainable
Renders a checkbox in a table cell. ...

Renders a checkbox in a table cell.

\n

Returns

" }); \ No newline at end of file diff --git a/backgrid-select-all.css b/backgrid-select-all.css index 17471c1..1427fe9 100644 --- a/backgrid-select-all.css +++ b/backgrid-select-all.css @@ -2,7 +2,7 @@ backgrid-select-all http://github.com/wyuenho/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc and contributors Licensed under the MIT @license. */ diff --git a/backgrid-select-all.js b/backgrid-select-all.js index bed1cfd..e2584e0 100644 --- a/backgrid-select-all.js +++ b/backgrid-select-all.js @@ -2,7 +2,7 @@ backgrid-select-all http://github.com/wyuenho/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc and contributors Licensed under the MIT @license. */ (function (root, factory) { diff --git a/backgrid-select-all.min.js b/backgrid-select-all.min.js index 1e49adf..ba8d996 100644 --- a/backgrid-select-all.min.js +++ b/backgrid-select-all.min.js @@ -2,7 +2,96 @@ backgrid-select-all http://github.com/wyuenho/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc and contributors Licensed under the MIT @license. */ -!function(a,b){"object"==typeof exports?module.exports=b(require("backbone"),require("backgrid")):b(a.Backbone,a.Backgrid)}(this,function(a,b){"use strict";var c=b.Extension.SelectRowCell=a.View.extend({className:"select-row-cell",tagName:"td",events:{"keydown input[type=checkbox]":"onKeydown","change input[type=checkbox]":"onChange","click input[type=checkbox]":"enterEditMode"},initialize:function(a){this.column=a.column,this.column instanceof b.Column||(this.column=new b.Column(this.column));var c=this.column,d=this.model,e=this.$el;this.listenTo(c,"change:renderable",function(a,b){e.toggleClass("renderable",b)}),b.callByNeed(c.renderable(),c,d)&&e.addClass("renderable"),this.listenTo(d,"backgrid:select",function(a,b){this.$el.find("input[type=checkbox]").prop("checked",b).change()})},enterEditMode:function(){this.$el.find("input[type=checkbox]").focus()},exitEditMode:function(){this.$el.find("input[type=checkbox]").blur()},onKeydown:function(a){var c=new b.Command(a);return c.passThru()?!0:(c.cancel()?(a.stopPropagation(),this.$el.find("input[type=checkbox]").blur()):(c.save()||c.moveLeft()||c.moveRight()||c.moveUp()||c.moveDown())&&(a.preventDefault(),a.stopPropagation(),this.model.trigger("backgrid:edited",this.model,this.column,c)),void 0)},onChange:function(){var a=this.$el.find("input[type=checkbox]").prop("checked");this.$el.parent().toggleClass("selected",a),this.model.trigger("backgrid:selected",this.model,a)},render:function(){return this.$el.empty().append(''),this.delegateEvents(),this}}),d=b.Extension.SelectAllHeaderCell=c.extend({className:"select-all-header-cell",tagName:"th",initialize:function(a){this.column=a.column,this.column instanceof b.Column||(this.column=new b.Column(this.column));var c=this.collection,d=this.selectedModels={};this.listenTo(c.fullCollection||c,"backgrid:selected",function(a,b){b?d[a.id||a.cid]=1:(delete d[a.id||a.cid],this.$el.find("input[type=checkbox]").prop("checked",!1))}),this.listenTo(c.fullCollection||c,"remove",function(a){delete d[a.id||a.cid]}),this.listenTo(c,"backgrid:refresh",function(){for(var a=this.$el.find("input[type=checkbox]").prop("checked"),b=0;bc;c++){var f=b[c];if(f instanceof d){a=f;break}}var g=[];if(a){var h=a.selectedModels,i=this.collection.fullCollection||this.collection;for(var j in h)g.push(i.get(j))}return g},b.Grid.prototype.clearSelectedModels=function(){for(var a=this.getSelectedModels(),b=0,c=a.length;c>b;b++){var d=a[b];d.trigger("backgrid:select",d,!1)}}}); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd? +// AMD. Register as an anonymous module. +define(["backbone","backgrid","underscore"],b):"object"==typeof exports? +// CommonJS +module.exports=b(require("backbone"),require("backgrid"),require("underscore")):b(a.Backbone,a.Backgrid,a._)}(this,function(a,b,c){"use strict";/** + Renders a checkbox for row selection. + + @class Backgrid.Extension.SelectRowCell + @extends Backbone.View + */ +var d=b.Extension.SelectRowCell=a.View.extend({/** @property */ +className:"select-row-cell",/** @property */ +tagName:"td",/** @property */ +events:{"keydown input[type=checkbox]":"onKeydown","change input[type=checkbox]":"onChange","click input[type=checkbox]":"enterEditMode"},/** + Initializer. If the underlying model triggers a `select` event, this cell + will change its checked value according to the event's `selected` value. + + @param {Object} options + @param {Backgrid.Column} options.column + @param {Backbone.Model} options.model + */ +initialize:function(a){this.column=a.column,this.column instanceof b.Column||(this.column=new b.Column(this.column));var c=this.column,d=this.model,e=this.$el;this.listenTo(c,"change:renderable",function(a,b){e.toggleClass("renderable",b)}),b.callByNeed(c.renderable(),c,d)&&e.addClass("renderable"),this.listenTo(d,"backgrid:select",function(a,b){this.checkbox().prop("checked",b).change()})},/** + Returns the checkbox. + */ +checkbox:function(){return this.$el.find("input[type=checkbox]")},/** + Focuses the checkbox. + */ +enterEditMode:function(){this.checkbox().focus()},/** + Unfocuses the checkbox. + */ +exitEditMode:function(){this.checkbox().blur()},/** + Process keyboard navigation. + */ +onKeydown:function(a){var c=new b.Command(a);// skip ahead to `change` +return!!c.passThru()||void(c.cancel()?(a.stopPropagation(),this.checkbox().blur()):(c.save()||c.moveLeft()||c.moveRight()||c.moveUp()||c.moveDown())&&(a.preventDefault(),a.stopPropagation(),this.model.trigger("backgrid:edited",this.model,this.column,c)))},/** + When the checkbox's value changes, this method will trigger a Backbone + `backgrid:selected` event with a reference of the model and the + checkbox's `checked` value. + */ +onChange:function(){var a=this.checkbox().prop("checked");this.$el.parent().toggleClass("selected",a),this.model.trigger("backgrid:selected",this.model,a)},/** + Renders a checkbox in a table cell. + */ +render:function(){return this.$el.empty().append(''),this.delegateEvents(),this}}),e=b.Extension.SelectAllHeaderCell=d.extend({/** @property */ +className:"select-all-header-cell",/** @property */ +tagName:"th",/** + Initializer. When this cell's checkbox is checked, a Backbone + `backgrid:select` event will be triggered for each model for the current + page in the underlying collection. If a `SelectRowCell` instance exists + for the rows representing the models, they will check themselves. If any + of the SelectRowCell instances trigger a Backbone `backgrid:selected` + event with a `false` value, this cell will uncheck its checkbox. In the + event of a Backbone `backgrid:refresh` event, which is triggered when the + body refreshes its rows, which can happen under a number of conditions + such as paging or the columns were reset, this cell will still remember + the previously selected models and trigger a Backbone `backgrid:select` + event on them such that the SelectRowCells can recheck themselves upon + refreshing. + + @param {Object} options + @param {Backgrid.Column} options.column + @param {Backbone.Collection} options.collection + */ +initialize:function(a){this.column=a.column,this.column instanceof b.Column||(this.column=new b.Column(this.column));var d=this.collection,e=this.selectedModels={};this.listenTo(d.fullCollection||d,"backgrid:selected",function(a,b){b?e[a.id||a.cid]=1:(delete e[a.id||a.cid],this.checkbox().prop("checked",!1)),c.keys(e).length===(d.fullCollection||d).length&&this.checkbox().prop("checked",!0)}),this.listenTo(d.fullCollection||d,"remove",function(a){delete e[a.id||a.cid],0===(d.fullCollection||d).length&&this.checkbox().prop("checked",!1)}),this.listenTo(d,"backgrid:refresh",function(){if(0===(d.fullCollection||d).length)this.checkbox().prop("checked",!1);else for(var a=this.checkbox().prop("checked"),b=0;b} + */ +b.Grid.prototype.getSelectedModels=function(){for(var a,b=this.header.row.cells,c=0,d=b.length;c" + "Cloudflare, Inc " ], "keywords": [ "backbone", diff --git a/package.json b/package.json index 607f31e..3445f5a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "backbone", "backgrid" ], - "author": "Jimmy Yuen Ho Wong ", + "author": "Cloudflare, Inc ", "license": "MIT", "readmeFilename": "README.md", "bugs": { diff --git a/test/select-all.js b/test/select-all.js index 74ceafa..a75f9e4 100644 --- a/test/select-all.js +++ b/test/select-all.js @@ -2,7 +2,7 @@ backgrid http://github.com/wyuenho/backgrid - Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors + Copyright (c) 2013-present Cloudflare, Inc and contributors Licensed under the MIT @license. */ describe("A SelectRowCell", function () {